Skip to content

Offline gym log for Android. No account, no ads, no internet.

feat(train): make reset picks button dynamically reflect hasPicks state

ddd1f4b5e3efba7
diff --git a/lib/screens/train_screen.dart b/lib/screens/train_screen.dart
index ceecc99..e6bac0d 100644
--- a/lib/screens/train_screen.dart
+++ b/lib/screens/train_screen.dart
@@ -229,16 +229,22 @@ class _TrainScreenState extends State<TrainScreen> {
),
const SizedBox(width: 10),
GestureDetector(
- onTap: fit.toggleResetPicks,
+ onTap: () => setState(() => fit.toggleResetPicks()),
child: Container(
width: 48,
height: 48,
decoration: BoxDecoration(
- color: gc.bgRaised,
+ color: fit.sessionPicks.isNotEmpty ? gc.emberSoft : gc.bgRaised,
borderRadius: BorderRadius.circular(14),
- border: Border.all(color: gc.border),
+ border: Border.all(
+ color: fit.sessionPicks.isNotEmpty ? gc.ember.withValues(alpha: 0.3) : gc.border,
+ ),
+ ),
+ child: Icon(
+ PhosphorIconsRegular.arrowCounterClockwise,
+ size: 20,
+ color: fit.sessionPicks.isNotEmpty ? gc.ember : gc.textTertiary,
),
- child: Icon(PhosphorIconsRegular.arrowCounterClockwise, size: 20, color: gc.textSecondary),
),
),
const SizedBox(width: 10),
diff --git a/test/train_step2_test.dart b/test/train_step2_test.dart
index 938bc3a..b53eba0 100644
--- a/test/train_step2_test.dart
+++ b/test/train_step2_test.dart
@@ -1,3 +1,4 @@
+import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:gymmane/app/gymmane_app.dart';
import 'package:gymmane/state/fit_state.dart';
@@ -14,8 +15,9 @@ void main() {
await tester.pumpWidget(const GymManeApp());
await tester.pumpAndSettle();
- // Verify Reset button icon is present
- expect(find.byIcon(PhosphorIconsRegular.arrowCounterClockwise), findsOneWidget);
+ final iconFinder = find.byIcon(PhosphorIconsRegular.arrowCounterClockwise);
+ expect(iconFinder, findsOneWidget);
+ final initialIcon = tester.widget<Icon>(iconFinder);
// Verify Plus button icon is present
expect(find.byIcon(PhosphorIconsRegular.plus), findsOneWidget);
@@ -23,15 +25,19 @@ void main() {
// Verify picks initially non-empty
expect(fit.sessionPicks.isNotEmpty, true);
- // Tap reset button -> clears picks
- await tester.tap(find.byIcon(PhosphorIconsRegular.arrowCounterClockwise));
+ // Tap reset button -> clears picks, button becomes dimmed
+ await tester.tap(iconFinder);
await tester.pumpAndSettle();
expect(fit.sessionPicks.isEmpty, true);
+ final clearedIcon = tester.widget<Icon>(iconFinder);
+ expect(clearedIcon.color != initialIcon.color, true);
- // Tap reset button again -> restores default picks
- await tester.tap(find.byIcon(PhosphorIconsRegular.arrowCounterClockwise));
+ // Tap reset button again -> restores default picks, button lights up again
+ await tester.tap(iconFinder);
await tester.pumpAndSettle();
expect(fit.sessionPicks.isNotEmpty, true);
+ final restoredIcon = tester.widget<Icon>(iconFinder);
+ expect(restoredIcon.color == initialIcon.color, true);
fit.route = 'home';
});