Skip to content

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

Back from a routine returns to where you opened it

InlitXb7084238dac2
diff --git a/lib/state/routines_state.dart b/lib/state/routines_state.dart
index b01f269..f783f8c 100644
--- a/lib/state/routines_state.dart
+++ b/lib/state/routines_state.dart
@@ -5,7 +5,6 @@ const int kDefaultRoutineSets = 3;
mixin RoutinesState on FitCore, LibraryState {
String? activeRoutineId;
int _routineSeq = 0;
- bool _editFromExercise = false;
void goRoutines() => pushRoute('routines');
@@ -385,17 +384,14 @@ mixin RoutinesState on FitCore, LibraryState {
}
void openRoutine(String id) {
- if (route != 'routine-edit') _editFromExercise = false;
activeRoutineId = id;
- route = 'routine-edit';
- notifyListeners();
+ pushRoute('routine-edit');
}
void addToRoutineAndEdit(String? routineId, String exId) {
final id = routineId ?? createRoutine();
if (!routineHas(id, exId)) toggleRoutineExercise(id, exId);
activeRoutineId = id;
- _editFromExercise = true;
pushRoute('routine-edit');
}
@@ -403,12 +399,5 @@ mixin RoutinesState on FitCore, LibraryState {
String routineTitle(Routine r) => r.name.isEmpty ? t.newRoutineName : r.name;
- void closeRoutineEdit() {
- if (_editFromExercise) {
- _editFromExercise = false;
- return popRoute(fallback: 'routines');
- }
- route = 'routines';
- notifyListeners();
- }
+ void closeRoutineEdit() => popRoute(fallback: 'routines');
}
diff --git a/test/route_stack_test.dart b/test/route_stack_test.dart
index 5a4e201..46d2fe4 100644
--- a/test/route_stack_test.dart
+++ b/test/route_stack_test.dart
@@ -45,6 +45,25 @@ void main() {
expect(fit.route, 'home');
});
+ test('a routine opened from home goes back home', () {
+ fit.goHome();
+ fit.openRoutine(fit.createRoutine());
+ fit.handleBack();
+ expect(fit.route, 'home');
+ });
+
+ test('a routine opened from the routines list goes back to the list', () {
+ fit.goHome();
+ fit.goRoutines();
+ final id = fit.createRoutine();
+ fit.openRoutine(id);
+ fit.openRoutine(fit.duplicateRoutine(id));
+ fit.closeRoutineEdit();
+ expect(fit.route, 'routines');
+ fit.handleBack();
+ expect(fit.route, 'home');
+ });
+
test('a route never comes back to itself', () {
fit.goSettings();
fit.goPlaces();