diff --git a/lib/widgets/workouts/gym_mode.dart b/lib/widgets/workouts/gym_mode.dart index 6b3743fa..266512e0 100644 --- a/lib/widgets/workouts/gym_mode.dart +++ b/lib/widgets/workouts/gym_mode.dart @@ -560,9 +560,11 @@ class _SessionPageState extends State { final timeStartController = TextEditingController(); final timeEndController = TextEditingController(); - int impressionValue = 2; var _session = WorkoutSession(); + /// Selected impression: bad, neutral, good + var selectedImpression = [false, true, false]; + @override void initState() { super.initState(); @@ -593,25 +595,35 @@ class _SessionPageState extends State { child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ - DropdownButtonFormField( - value: impressionValue, - decoration: InputDecoration( - labelText: AppLocalizations.of(context)!.impression, - ), - items: IMPRESSION_MAP.keys.map>((int key) { - return DropdownMenuItem( - value: key, - child: Text(IMPRESSION_MAP[key]!), - ); - }).toList(), - onSaved: (int? newValue) { - _session.impression = newValue!; - }, - onChanged: (int? newValue) { + ToggleButtons( + children: [ + Icon( + Icons.sentiment_very_dissatisfied, + ), + Icon( + Icons.sentiment_neutral, + ), + Icon( + Icons.sentiment_very_satisfied, + ), + ], + renderBorder: false, + onPressed: (int index) { setState(() { - impressionValue = newValue!; + for (int buttonIndex = 0; + buttonIndex < selectedImpression.length; + buttonIndex++) { + _session.impression = index + 1; + + if (buttonIndex == index) { + selectedImpression[buttonIndex] = true; + } else { + selectedImpression[buttonIndex] = false; + } + } }); }, + isSelected: selectedImpression, ), TextFormField( decoration: InputDecoration( @@ -650,6 +662,7 @@ class _SessionPageState extends State { }, ), ), + SizedBox(width: 10), Flexible( child: TextFormField( decoration: diff --git a/test/gym_mode_screen_test.dart b/test/gym_mode_screen_test.dart index 2369073b..d3d552bf 100644 --- a/test/gym_mode_screen_test.dart +++ b/test/gym_mode_screen_test.dart @@ -165,6 +165,9 @@ void main() { expect(find.text('Workout session'), findsOneWidget); expect(find.byType(SessionPage), findsOneWidget); expect(find.byType(Form), findsOneWidget); + expect(find.byIcon(Icons.sentiment_dissatisfied), findsOneWidget); + expect(find.byIcon(Icons.sentiment_neutral), findsOneWidget); + expect(find.byIcon(Icons.sentiment_satisfied), findsOneWidget); expect(find.byIcon(Icons.chevron_left), findsOneWidget); expect(find.byIcon(Icons.close), findsOneWidget); expect(find.byIcon(Icons.chevron_right), findsNothing);