@@ -12,28 +12,44 @@ import '../models/counter.dart';
1212import '../utils/utils.dart' ;
1313
1414/// Screen that displays inspiration ideas for counting with a specific counter color.
15- class InspirationScreen extends StatelessWidget {
15+ class InspirationScreen extends StatefulWidget {
1616 const InspirationScreen ({required this .counter, super .key});
1717
1818 /// The counter for which to show inspiration ideas.
1919 final Counter counter;
2020
21+ @override
22+ State <InspirationScreen > createState () => _InspirationScreenState ();
23+ }
24+
25+ /// The logic and internal state for the inspiration screen widget.
26+ class _InspirationScreenState extends State <InspirationScreen > {
27+ /// The shuffled list of ideas to display.
28+ late List <String > _shuffledIdeas;
29+
30+ @override
31+ void initState () {
32+ super .initState ();
33+ // Shuffle ideas once when the screen is created
34+ _shuffledIdeas = List .from (counterIdeas[widget.counter.type] ?? [])..shuffle ();
35+ }
36+
2137 @override
2238 Widget build (BuildContext context) {
23- final List <String > ideas = counterIdeas[counter.type] ?? [];
24- final Color counterColor = counter.color;
39+ final Color counterColor = widget.counter.color;
2540 final Color textColor = counterColor.contrastOf ();
26- final String colorName = counter.type.name[0 ].toUpperCase () + counter.type.name.substring (1 );
41+ final String colorName =
42+ widget.counter.type.name[0 ].toUpperCase () + widget.counter.type.name.substring (1 );
2743
2844 return Scaffold (
2945 appBar: AppBar (
3046 backgroundColor: counterColor,
3147 foregroundColor: textColor,
3248 title: Text (strings.inspirationScreenTitle (colorName)),
3349 ),
34- body: ideas .isEmpty
50+ body: _shuffledIdeas .isEmpty
3551 ? _EmptyStateWidget (colorName: colorName)
36- : _IdeasListWidget (ideas: ideas , dotColor: counterColor),
52+ : _IdeasListWidget (ideas: _shuffledIdeas , dotColor: counterColor),
3753 );
3854 }
3955}
0 commit comments