From 2c7ffd46177c714c194b1268988dd354a4d9d70d Mon Sep 17 00:00:00 2001 From: Brett Morgan Date: Fri, 13 Jan 2023 14:47:23 +1000 Subject: [PATCH] Fixup `varfont_shader_puzzle`, attempt #2 (#1563) --- .../analysis_options.yaml | 2 +- .../lib/components/components.dart | 8 ++-- .../lib/components/fragment_shaded.dart | 2 +- .../lib/components/lightboxed_panel.dart | 4 +- .../lib/components/rotator_puzzle.dart | 16 +++---- .../lib/components/wonky_char.dart | 42 ++++++++++--------- .../page_content/page_ascender_descender.dart | 12 +++--- .../lib/page_content/page_narrative_post.dart | 4 +- .../lib/page_content/page_narrative_pre.dart | 4 +- .../lib/page_content/page_optical_size.dart | 10 +++-- .../lib/page_content/page_weight.dart | 10 +++-- .../lib/page_content/page_width.dart | 12 +++--- .../lib/page_content/pages.dart | 8 ++-- .../lib/page_content/pages_flow.dart | 14 ++++--- .../varfont_shader_puzzle/lib/styles.dart | 9 ++-- 15 files changed, 83 insertions(+), 74 deletions(-) diff --git a/experimental/varfont_shader_puzzle/analysis_options.yaml b/experimental/varfont_shader_puzzle/analysis_options.yaml index f9b303465..f04c6cf0f 100644 --- a/experimental/varfont_shader_puzzle/analysis_options.yaml +++ b/experimental/varfont_shader_puzzle/analysis_options.yaml @@ -1 +1 @@ -include: package:flutter_lints/flutter.yaml +include: ../../analysis_options.yaml diff --git a/experimental/varfont_shader_puzzle/lib/components/components.dart b/experimental/varfont_shader_puzzle/lib/components/components.dart index 185380723..f6974e9d9 100644 --- a/experimental/varfont_shader_puzzle/lib/components/components.dart +++ b/experimental/varfont_shader_puzzle/lib/components/components.dart @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -export 'wonky_char.dart'; -export 'wonky_anim_palette.dart'; -export 'rotator_puzzle.dart'; -export 'lightboxed_panel.dart'; export 'fragment_shaded.dart'; +export 'lightboxed_panel.dart'; +export 'rotator_puzzle.dart'; +export 'wonky_anim_palette.dart'; +export 'wonky_char.dart'; diff --git a/experimental/varfont_shader_puzzle/lib/components/fragment_shaded.dart b/experimental/varfont_shader_puzzle/lib/components/fragment_shaded.dart index c376e001f..7f19f60fc 100644 --- a/experimental/varfont_shader_puzzle/lib/components/fragment_shaded.dart +++ b/experimental/varfont_shader_puzzle/lib/components/fragment_shaded.dart @@ -62,7 +62,7 @@ class FragmentShadedState extends State initializeFragmentProgramsAndBuilder(); } - void initializeFragmentProgramsAndBuilder() async { + Future initializeFragmentProgramsAndBuilder() async { if (FragmentShaded.fragmentPrograms.isEmpty) { for (String s in FragmentShaded.fragmentProgramNames) { FragmentShaded.fragmentPrograms[s] = diff --git a/experimental/varfont_shader_puzzle/lib/components/lightboxed_panel.dart b/experimental/varfont_shader_puzzle/lib/components/lightboxed_panel.dart index d16ccb11d..f02b5845d 100644 --- a/experimental/varfont_shader_puzzle/lib/components/lightboxed_panel.dart +++ b/experimental/varfont_shader_puzzle/lib/components/lightboxed_panel.dart @@ -18,7 +18,7 @@ class LightboxedPanel extends StatefulWidget { final Color cardBgColor; const LightboxedPanel({ - Key? key, + super.key, required this.pageConfig, required this.content, this.onDismiss, @@ -27,7 +27,7 @@ class LightboxedPanel extends StatefulWidget { this.buildButton = true, this.lightBoxBgColor = const Color.fromARGB(200, 255, 255, 255), this.cardBgColor = Colors.white, - }) : super(key: key); + }); @override State createState() => _LightboxedPanelState(); diff --git a/experimental/varfont_shader_puzzle/lib/components/rotator_puzzle.dart b/experimental/varfont_shader_puzzle/lib/components/rotator_puzzle.dart index 3cc2baf17..0a8fc0e4b 100644 --- a/experimental/varfont_shader_puzzle/lib/components/rotator_puzzle.dart +++ b/experimental/varfont_shader_puzzle/lib/components/rotator_puzzle.dart @@ -3,12 +3,14 @@ // found in the LICENSE file. import 'dart:math'; -import 'package:flutter/rendering.dart'; -import 'components.dart'; -import 'package:flutter/material.dart'; import 'dart:ui' as ui; + +import 'package:flutter/material.dart'; +import 'package:flutter/rendering.dart'; + import '../model/puzzle_model.dart'; import '../page_content/pages_flow.dart'; +import 'components.dart'; class RotatorPuzzle extends StatefulWidget { final PageConfig pageConfig; @@ -25,7 +27,7 @@ class RotatorPuzzle extends StatefulWidget { final double tileScaleModifier; const RotatorPuzzle({ - Key? key, + super.key, required this.pageConfig, required this.numTiles, required this.puzzleNum, @@ -37,7 +39,7 @@ class RotatorPuzzle extends StatefulWidget { required this.tileShadedStringAnimDuration, this.tileShadedStringAnimSettings = const [], this.tileScaleModifier = 1.0, - }) : super(key: key); + }); @override State createState() => RotatorPuzzleState(); @@ -258,7 +260,7 @@ class RotatorPuzzleTile extends StatefulWidget { final int col; RotatorPuzzleTile({ - Key? key, + super.key, required this.tileID, required this.row, required this.col, @@ -271,7 +273,7 @@ class RotatorPuzzleTile extends StatefulWidget { required this.animationSettings, required this.tileShadedStringAnimDuration, required this.tileScaleModifier, - }) : super(key: key); + }); final State tileState = RotatorPuzzleTileState(); diff --git a/experimental/varfont_shader_puzzle/lib/components/wonky_char.dart b/experimental/varfont_shader_puzzle/lib/components/wonky_char.dart index efdc64fb4..71a7bba2f 100644 --- a/experimental/varfont_shader_puzzle/lib/components/wonky_char.dart +++ b/experimental/varfont_shader_puzzle/lib/components/wonky_char.dart @@ -2,9 +2,10 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -import 'package:flutter/material.dart'; import 'dart:ui'; + import 'package:flutter/foundation.dart' show kDebugMode; +import 'package:flutter/material.dart'; class WonkyChar extends StatefulWidget { final String text; @@ -13,13 +14,13 @@ class WonkyChar extends StatefulWidget { final int animDurationMillis; final List animationSettings; const WonkyChar({ - Key? key, + super.key, required this.text, required this.size, this.baseRotation = 0, this.animDurationMillis = 1000, this.animationSettings = const [], - }) : super(key: key); + }); @override State createState() => WonkyCharState(); @@ -79,20 +80,21 @@ class WonkyCharState extends State Widget build(BuildContext context) { List fontVariations = []; for (int i = 0; i < _fvAxes.length; i++) { - fontVariations.add(FontVariation(_fvAxes[i], _fvAnimations[i].value)); + fontVariations + .add(FontVariation(_fvAxes[i], _fvAnimations[i].value as double)); } return Transform( alignment: Alignment.center, - transform: Matrix4.translationValues( - _offsetXAnimation.value, _offsetYAnimation.value, 0) + transform: Matrix4.translationValues(_offsetXAnimation.value as double, + _offsetYAnimation.value as double, 0) ..scale(_scaleAnimation.value) - ..rotateZ(widget.baseRotation + _rotationAnimation.value), + ..rotateZ(widget.baseRotation + (_rotationAnimation.value as double)), child: IgnorePointer( child: Text( widget.text, textAlign: TextAlign.center, style: TextStyle( - color: _colorAnimation.value, + color: _colorAnimation.value as Color?, fontFamily: 'Amstelvar', fontSize: widget.size, fontVariations: fontVariations, @@ -114,13 +116,15 @@ class WonkyCharState extends State ); late Animation animation; if (s.property == 'color') { - animation = - ColorTween(begin: s.fromTo.fromValue(), end: s.fromTo.toValue()) - .animate(curve); + animation = ColorTween( + begin: s.fromTo.fromValue() as Color?, + end: s.fromTo.toValue() as Color?) + .animate(curve); } else { - animation = - Tween(begin: s.fromTo.fromValue(), end: s.fromTo.toValue()) - .animate(curve); + animation = Tween( + begin: s.fromTo.fromValue() as double, + end: s.fromTo.toValue() as double) + .animate(curve); } if (s.type == 'fv') { _fvAxes.add(s.property); @@ -168,13 +172,13 @@ class WonkyCharState extends State } } -abstract class WCRange { +abstract class WCRange { WCRange(); - fromValue() {} - toValue() {} + T fromValue(); + T toValue(); } -class RangeColor implements WCRange { +class RangeColor implements WCRange { Color from; Color to; RangeColor({required this.from, required this.to}); @@ -189,7 +193,7 @@ class RangeColor implements WCRange { } } -class RangeDbl implements WCRange { +class RangeDbl implements WCRange { double from; double to; diff --git a/experimental/varfont_shader_puzzle/lib/page_content/page_ascender_descender.dart b/experimental/varfont_shader_puzzle/lib/page_content/page_ascender_descender.dart index fb239c941..741710ec8 100644 --- a/experimental/varfont_shader_puzzle/lib/page_content/page_ascender_descender.dart +++ b/experimental/varfont_shader_puzzle/lib/page_content/page_ascender_descender.dart @@ -2,19 +2,19 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +import 'dart:math'; + +import 'package:flutter/material.dart'; + import '../components/components.dart'; import '../page_content/pages_flow.dart'; -import 'package:flutter/material.dart'; -import 'dart:math'; import '../styles.dart'; class PageAscenderDescender extends SinglePage { const PageAscenderDescender({ - Key? key, + super.key, required super.pageConfig, - }) : super( - key: key, - ); + }); @override State createState() => _PageAscenderDescenderState(); } diff --git a/experimental/varfont_shader_puzzle/lib/page_content/page_narrative_post.dart b/experimental/varfont_shader_puzzle/lib/page_content/page_narrative_post.dart index 57c60f126..7df89ed84 100644 --- a/experimental/varfont_shader_puzzle/lib/page_content/page_narrative_post.dart +++ b/experimental/varfont_shader_puzzle/lib/page_content/page_narrative_post.dart @@ -8,9 +8,9 @@ import '../styles.dart'; class PageNarrativePost extends NarrativePage { const PageNarrativePost({ - Key? key, + super.key, required super.pageConfig, - }) : super(key: key); + }); @override State createState() => _PageNarrativePostState(); diff --git a/experimental/varfont_shader_puzzle/lib/page_content/page_narrative_pre.dart b/experimental/varfont_shader_puzzle/lib/page_content/page_narrative_pre.dart index 6ea8fa427..e465bdacf 100644 --- a/experimental/varfont_shader_puzzle/lib/page_content/page_narrative_pre.dart +++ b/experimental/varfont_shader_puzzle/lib/page_content/page_narrative_pre.dart @@ -8,9 +8,9 @@ import '../styles.dart'; class PageNarrativePre extends NarrativePage { const PageNarrativePre({ - Key? key, + super.key, required super.pageConfig, - }) : super(key: key); + }); @override State createState() => _PageNarrativePreState(); diff --git a/experimental/varfont_shader_puzzle/lib/page_content/page_optical_size.dart b/experimental/varfont_shader_puzzle/lib/page_content/page_optical_size.dart index 713ccbd2c..1be4f6413 100644 --- a/experimental/varfont_shader_puzzle/lib/page_content/page_optical_size.dart +++ b/experimental/varfont_shader_puzzle/lib/page_content/page_optical_size.dart @@ -1,17 +1,19 @@ // Copyright 2023 The Flutter team. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -import '../components/components.dart'; +import 'dart:math'; + import 'package:flutter/material.dart'; + +import '../components/components.dart'; import '../page_content/pages_flow.dart'; -import 'dart:math'; import '../styles.dart'; class PageOpticalSize extends SinglePage { const PageOpticalSize({ - Key? key, + super.key, required super.pageConfig, - }) : super(key: key); + }); @override State createState() => _PageOpticalSizeState(); diff --git a/experimental/varfont_shader_puzzle/lib/page_content/page_weight.dart b/experimental/varfont_shader_puzzle/lib/page_content/page_weight.dart index 0826f3701..56727bf44 100644 --- a/experimental/varfont_shader_puzzle/lib/page_content/page_weight.dart +++ b/experimental/varfont_shader_puzzle/lib/page_content/page_weight.dart @@ -1,17 +1,19 @@ // Copyright 2023 The Flutter team. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -import '../components/components.dart'; -import 'package:flutter/material.dart'; import 'dart:math'; + +import 'package:flutter/material.dart'; + +import '../components/components.dart'; import '../page_content/pages_flow.dart'; import '../styles.dart'; class PageWeight extends SinglePage { const PageWeight({ - Key? key, + super.key, required super.pageConfig, - }) : super(key: key); + }); @override State createState() => _PageWeightState(); diff --git a/experimental/varfont_shader_puzzle/lib/page_content/page_width.dart b/experimental/varfont_shader_puzzle/lib/page_content/page_width.dart index 802c608f1..ece52b1ef 100644 --- a/experimental/varfont_shader_puzzle/lib/page_content/page_width.dart +++ b/experimental/varfont_shader_puzzle/lib/page_content/page_width.dart @@ -1,19 +1,19 @@ // Copyright 2023 The Flutter team. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -import '../components/components.dart'; -import 'package:flutter/material.dart'; import 'dart:math'; + +import 'package:flutter/material.dart'; + +import '../components/components.dart'; import '../page_content/pages_flow.dart'; import '../styles.dart'; class PageWidth extends SinglePage { const PageWidth({ - Key? key, + super.key, required super.pageConfig, - }) : super( - key: key, - ); + }); @override State createState() => _PageWidthState(); } diff --git a/experimental/varfont_shader_puzzle/lib/page_content/pages.dart b/experimental/varfont_shader_puzzle/lib/page_content/pages.dart index a01c3f431..df882ac83 100644 --- a/experimental/varfont_shader_puzzle/lib/page_content/pages.dart +++ b/experimental/varfont_shader_puzzle/lib/page_content/pages.dart @@ -1,9 +1,9 @@ // Copyright 2023 The Flutter team. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -export 'page_weight.dart'; -export 'page_width.dart'; export 'page_ascender_descender.dart'; -export 'page_optical_size.dart'; -export 'page_narrative_pre.dart'; export 'page_narrative_post.dart'; +export 'page_narrative_pre.dart'; +export 'page_optical_size.dart'; +export 'page_weight.dart'; +export 'page_width.dart'; diff --git a/experimental/varfont_shader_puzzle/lib/page_content/pages_flow.dart b/experimental/varfont_shader_puzzle/lib/page_content/pages_flow.dart index 5f39c4747..101fb21a8 100644 --- a/experimental/varfont_shader_puzzle/lib/page_content/pages_flow.dart +++ b/experimental/varfont_shader_puzzle/lib/page_content/pages_flow.dart @@ -2,13 +2,15 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. import 'dart:math'; + import 'package:flutter/material.dart'; -import '../page_content/wallpapers_flow.dart'; + import '../components/components.dart'; +import '../page_content/wallpapers_flow.dart'; import 'pages.dart'; class PagesFlow extends StatefulWidget { - const PagesFlow({Key? key}) : super(key: key); + const PagesFlow({super.key}); static const pageScrollDuration = 400; @@ -92,9 +94,9 @@ class PageConfig { class SinglePage extends StatefulWidget { final PageConfig pageConfig; const SinglePage({ - Key? key, + super.key, required this.pageConfig, - }) : super(key: key); + }); @override State createState() => SinglePageState(); @@ -133,9 +135,9 @@ class SinglePageState extends State with TickerProviderStateMixin { class NarrativePage extends StatefulWidget { final PageConfig pageConfig; const NarrativePage({ - Key? key, + super.key, required this.pageConfig, - }) : super(key: key); + }); @override State createState() => NarrativePageState(); diff --git a/experimental/varfont_shader_puzzle/lib/styles.dart b/experimental/varfont_shader_puzzle/lib/styles.dart index ce9886bf9..170b9ca9c 100644 --- a/experimental/varfont_shader_puzzle/lib/styles.dart +++ b/experimental/varfont_shader_puzzle/lib/styles.dart @@ -30,18 +30,15 @@ class TextStyles { class ButtonStyles { static ButtonStyle style() { return ButtonStyle( - fixedSize: - MaterialStateProperty.resolveWith((Set states) { + fixedSize: MaterialStateProperty.resolveWith((states) { return const Size(100, 36); }), - shape: MaterialStateProperty.resolveWith( - (Set states) { + shape: MaterialStateProperty.resolveWith((states) { return const RoundedRectangleBorder( borderRadius: BorderRadius.all(Radius.circular(18))); }), overlayColor: null, - backgroundColor: MaterialStateProperty.resolveWith( - (Set states) { + backgroundColor: MaterialStateProperty.resolveWith((states) { if (states.contains(MaterialState.hovered)) { return Colors.black; // Hovered bg (for desktop with mouse) }