Skip to content

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

Show the rep range goal under the reps in the live session

InlitX73b2786acda9
diff --git a/lib/models/live_session.dart b/lib/models/live_session.dart
index a3c45ed..7077267 100644
--- a/lib/models/live_session.dart
+++ b/lib/models/live_session.dart
@@ -2,9 +2,10 @@ import 'workout.dart';
class SessionSet {
SessionSet(this.reps, this.weight, this.done,
- {this.kind = SetKind.normal, this.rpe, this.sec, this.km, this.rest, this.note = '', this.repsR});
+ {this.kind = SetKind.normal, this.rpe, this.sec, this.km, this.rest, this.note = '', this.repsR, this.goal});
int reps;
int? repsR;
+ String? goal;
String note;
int? rest;
double weight;
@@ -25,11 +26,12 @@ class SessionSet {
kind: kind, rpe: rpe, sec: sec, km: km, note: note.trim(), left: repsR == null ? null : reps, right: repsR);
SessionSet copy({bool done = false}) =>
- SessionSet(reps, weight, done, kind: kind, rpe: rpe, sec: sec, km: km, repsR: repsR);
+ SessionSet(reps, weight, done, kind: kind, rpe: rpe, sec: sec, km: km, repsR: repsR, goal: goal);
Map<String, dynamic> toJson() => {
'r': reps,
if (repsR != null) 'rr': repsR,
+ if (goal != null) 'g': goal,
'w': weight,
'd': done,
if (kind != SetKind.normal) 'k': kind.index,
@@ -50,6 +52,7 @@ class SessionSet {
rest: (j['rs'] as num?)?.toInt().clamp(0, 3600),
note: j['n'] as String? ?? '',
repsR: (j['rr'] as num?)?.toInt(),
+ goal: j['g'] as String?,
);
}
diff --git a/lib/screens/session_screen.dart b/lib/screens/session_screen.dart
index 85d4aa6..3bb8f2a 100644
--- a/lib/screens/session_screen.dart
+++ b/lib/screens/session_screen.dart
@@ -1373,7 +1373,7 @@ class SessionScreen extends StatelessWidget {
double minW, {
required void Function(BuildContext) onEdit,
}) step = list ? _pillCell : _miniStepper;
- Widget reps() => step(
+ Widget repsStep() => step(
gc,
'${st.reps}',
() => fit.bumpSessionReps(exIdx, j, -1),
@@ -1389,6 +1389,15 @@ class SessionScreen extends StatelessWidget {
onSave: (v) => fit.setSessionReps(exIdx, j, v.round()),
),
);
+ Widget reps() {
+ final goal = st.goal;
+ if (goal == null || st.done) return repsStep();
+ return Column(mainAxisSize: MainAxisSize.min, children: [
+ repsStep(),
+ Text(goal, style: AppTheme.f(10.5, weight: FontWeight.w700, color: gc.textTertiary)),
+ ]);
+ }
+
final exId = fit.session!.exercises[exIdx].id;
final sided = fit.isSidedReps(exId);
Widget repsLeft() => step(
diff --git a/lib/state/workout_state.dart b/lib/state/workout_state.dart
index d6938dc..8b96a69 100644
--- a/lib/state/workout_state.dart
+++ b/lib/state/workout_state.dart
@@ -240,6 +240,7 @@ mixin WorkoutState on FitCore, SettingsState, LibraryState, PlacesState, StatsSt
kind: p.kind,
sec: p.sec ?? b.sec,
km: p.km ?? b.km,
+ goal: own || warm || p.repsMax == null ? null : p.repsLabel,
));
}
return out;
diff --git a/test/continue_session_test.dart b/test/continue_session_test.dart
index e04bb3b..ae41476 100644
--- a/test/continue_session_test.dart
+++ b/test/continue_session_test.dart
@@ -1,4 +1,5 @@
import 'package:flutter_test/flutter_test.dart';
+import 'package:gymmane/models/live_session.dart';
import 'package:gymmane/models/workout.dart';
import 'package:gymmane/services/local_store.dart';
import 'package:gymmane/state/fit_state.dart';
@@ -27,6 +28,22 @@ void main() {
return fit.routines.firstWhere((r) => r.id == id);
}
+ test('a rep range from the routine shows as the goal in the live session and survives a restart', () {
+ final r = routine(['Barbell Bench Press']);
+ final bench = fit.matchExerciseByName('Barbell Bench Press')!.id;
+ fit.setPlannedSets(r.id, bench, const [
+ PlannedSet(reps: 10, weightKg: 20, kind: SetKind.warmup),
+ PlannedSet(reps: 8, repsMax: 12, weightKg: 60),
+ PlannedSet(reps: 8, weightKg: 60),
+ ]);
+ fit.startRoutine(fit.routines.firstWhere((x) => x.id == r.id));
+ final sets = fit.session!.exercises.first.sets;
+ expect(sets.map((s) => s.goal), [null, '8-12', null]);
+ final back = SessionSet.fromJson(sets[1].toJson());
+ expect(back.goal, '8-12');
+ expect(sets[1].copy().goal, '8-12');
+ });
+
test('finishing by mistake can be undone and nothing is lost', () {
fit.startRoutine(routine(['Barbell Bench Press', 'Barbell Squat']));
fit.endCountdown();