Skip to content

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

Add a light session switch and left and right reps for one-sided exercises

InlitX129349d23c15
diff --git a/lib/l10n/app_en.arb b/lib/l10n/app_en.arb
index 6d7666f..60df476 100644
--- a/lib/l10n/app_en.arb
+++ b/lib/l10n/app_en.arb
@@ -2497,5 +2497,39 @@
"@voiceMinutes": { "placeholders": { "count": { "type": "int" } } },
"voiceSeconds": "{count, plural, =1{1 second} other{{count} seconds}}",
"@voiceSeconds": { "placeholders": { "count": { "type": "int" } } },
- "voiceAnd": "and"
+ "voiceAnd": "and",
+
+ "repRecordsTitle": "Best weight by reps",
+
+ "suppUnitCapsule": "{n, plural, one{capsule} other{capsules}}",
+ "@suppUnitCapsule": {"placeholders": {"n": {"type": "int"}}},
+ "suppUnitPill": "{n, plural, one{pill} other{pills}}",
+ "@suppUnitPill": {"placeholders": {"n": {"type": "int"}}},
+ "suppUnitScoop": "{n, plural, one{scoop} other{scoops}}",
+ "@suppUnitScoop": {"placeholders": {"n": {"type": "int"}}},
+ "suppUnitDrop": "{n, plural, one{drop} other{drops}}",
+ "@suppUnitDrop": {"placeholders": {"n": {"type": "int"}}},
+ "suppUnitServing": "{n, plural, one{serving} other{servings}}",
+ "@suppUnitServing": {"placeholders": {"n": {"type": "int"}}},
+ "suppUnitIu": "IU",
+ "suppLeft": "Left",
+ "suppLeftHint": "Optional",
+ "suppLeftFor": "{n, plural, one{Left for 1 day} other{Left for {n} days}}",
+ "@suppLeftFor": {"placeholders": {"n": {"type": "int"}}},
+ "suppForDays": "{n, plural, one{1 day} other{{n} days}}",
+ "@suppForDays": {"placeholders": {"n": {"type": "int"}}},
+ "suppRanOut": "Ran out",
+
+ "lightSession": "Light session",
+ "lightSessionHint": "Saved in your history and stats, but it won't change your next targets.",
+ "lightSessionNote": "Doesn't count for progression",
+ "lightSessionOff": "Turn off",
+
+ "eachSideRepsHint": "Log the left and right reps separately. Progression follows the weaker side.",
+ "repsLeftCol": "REPS L",
+ "repsRightCol": "REPS R",
+ "repsLeftTitle": "LEFT REPS",
+ "repsRightTitle": "RIGHT REPS",
+ "sidesReps": "L{l} R{r}",
+ "@sidesReps": {"placeholders": {"l": {"type": "int"}, "r": {"type": "int"}}}
}
diff --git a/lib/l10n/app_es.arb b/lib/l10n/app_es.arb
index 93a7221..c1c6bfe 100644
--- a/lib/l10n/app_es.arb
+++ b/lib/l10n/app_es.arb
@@ -2170,5 +2170,32 @@
"voiceMinutes": "{count, plural, =1{1 minuto} other{{count} minutos}}",
"voiceSeconds": "{count, plural, =1{1 segundo} other{{count} segundos}}",
- "voiceAnd": "y"
+ "voiceAnd": "y",
+
+ "repRecordsTitle": "Mejor peso por reps",
+
+ "suppUnitCapsule": "{n, plural, =1{cápsula} other{cápsulas}}",
+ "suppUnitPill": "{n, plural, =1{pastilla} other{pastillas}}",
+ "suppUnitScoop": "{n, plural, =1{cazo} other{cazos}}",
+ "suppUnitDrop": "{n, plural, =1{gota} other{gotas}}",
+ "suppUnitServing": "{n, plural, =1{ración} other{raciones}}",
+ "suppUnitIu": "UI",
+ "suppLeft": "Quedan",
+ "suppLeftHint": "Opcional",
+ "suppLeftFor": "{n, plural, =1{Queda para 1 día} other{Quedan para {n} días}}",
+ "suppForDays": "{n, plural, =1{1 día} other{{n} días}}",
+ "suppRanOut": "Se ha acabado",
+
+ "lightSession": "Sesión ligera",
+ "lightSessionHint": "Se guarda en tu historial y estadísticas, pero no cambia tus próximos objetivos.",
+ "lightSessionNote": "No cuenta para la progresión",
+ "lightSessionOff": "Quitar",
+
+ "eachSideRepsHint": "Apunta las reps de la izquierda y la derecha por separado. La progresión sigue al lado más flojo.",
+ "repsLeftCol": "REPS I",
+ "repsRightCol": "REPS D",
+ "repsLeftTitle": "REPS IZQUIERDA",
+ "repsRightTitle": "REPS DERECHA",
+ "sidesReps": "I{l} D{r}",
+ "@sidesReps": {"placeholders": {"l": {"type": "int"}, "r": {"type": "int"}}}
}
diff --git a/lib/l10n/app_localizations.dart b/lib/l10n/app_localizations.dart
index 84feaaa..e1acb15 100644
--- a/lib/l10n/app_localizations.dart
+++ b/lib/l10n/app_localizations.dart
@@ -12675,6 +12675,138 @@ abstract class AppLocalizations {
/// In en, this message translates to:
/// **'and'**
String get voiceAnd;
+
+ /// No description provided for @repRecordsTitle.
+ ///
+ /// In en, this message translates to:
+ /// **'Best weight by reps'**
+ String get repRecordsTitle;
+
+ /// No description provided for @suppUnitCapsule.
+ ///
+ /// In en, this message translates to:
+ /// **'{n, plural, one{capsule} other{capsules}}'**
+ String suppUnitCapsule(int n);
+
+ /// No description provided for @suppUnitPill.
+ ///
+ /// In en, this message translates to:
+ /// **'{n, plural, one{pill} other{pills}}'**
+ String suppUnitPill(int n);
+
+ /// No description provided for @suppUnitScoop.
+ ///
+ /// In en, this message translates to:
+ /// **'{n, plural, one{scoop} other{scoops}}'**
+ String suppUnitScoop(int n);
+
+ /// No description provided for @suppUnitDrop.
+ ///
+ /// In en, this message translates to:
+ /// **'{n, plural, one{drop} other{drops}}'**
+ String suppUnitDrop(int n);
+
+ /// No description provided for @suppUnitServing.
+ ///
+ /// In en, this message translates to:
+ /// **'{n, plural, one{serving} other{servings}}'**
+ String suppUnitServing(int n);
+
+ /// No description provided for @suppUnitIu.
+ ///
+ /// In en, this message translates to:
+ /// **'IU'**
+ String get suppUnitIu;
+
+ /// No description provided for @suppLeft.
+ ///
+ /// In en, this message translates to:
+ /// **'Left'**
+ String get suppLeft;
+
+ /// No description provided for @suppLeftHint.
+ ///
+ /// In en, this message translates to:
+ /// **'Optional'**
+ String get suppLeftHint;
+
+ /// No description provided for @suppLeftFor.
+ ///
+ /// In en, this message translates to:
+ /// **'{n, plural, one{Left for 1 day} other{Left for {n} days}}'**
+ String suppLeftFor(int n);
+
+ /// No description provided for @suppForDays.
+ ///
+ /// In en, this message translates to:
+ /// **'{n, plural, one{1 day} other{{n} days}}'**
+ String suppForDays(int n);
+
+ /// No description provided for @suppRanOut.
+ ///
+ /// In en, this message translates to:
+ /// **'Ran out'**
+ String get suppRanOut;
+
+ /// No description provided for @lightSession.
+ ///
+ /// In en, this message translates to:
+ /// **'Light session'**
+ String get lightSession;
+
+ /// No description provided for @lightSessionHint.
+ ///
+ /// In en, this message translates to:
+ /// **'Saved in your history and stats, but it won\'t change your next targets.'**
+ String get lightSessionHint;
+
+ /// No description provided for @lightSessionNote.
+ ///
+ /// In en, this message translates to:
+ /// **'Doesn\'t count for progression'**
+ String get lightSessionNote;
+
+ /// No description provided for @lightSessionOff.
+ ///
+ /// In en, this message translates to:
+ /// **'Turn off'**
+ String get lightSessionOff;
+
+ /// No description provided for @eachSideRepsHint.
+ ///
+ /// In en, this message translates to:
+ /// **'Log the left and right reps separately. Progression follows the weaker side.'**
+ String get eachSideRepsHint;
+
+ /// No description provided for @repsLeftCol.
+ ///
+ /// In en, this message translates to:
+ /// **'REPS L'**
+ String get repsLeftCol;
+
+ /// No description provided for @repsRightCol.
+ ///
+ /// In en, this message translates to:
+ /// **'REPS R'**
+ String get repsRightCol;
+
+ /// No description provided for @repsLeftTitle.
+ ///
+ /// In en, this message translates to:
+ /// **'LEFT REPS'**
+ String get repsLeftTitle;
+
+ /// No description provided for @repsRightTitle.
+ ///
+ /// In en, this message translates to:
+ /// **'RIGHT REPS'**
+ String get repsRightTitle;
+
+ /// No description provided for @sidesReps.
+ ///
+ /// In en, this message translates to:
+ /// **'L{l} R{r}'**
+ String sidesReps(int l, int r);
}
class _AppLocalizationsDelegate extends LocalizationsDelegate<AppLocalizations> {
diff --git a/lib/l10n/app_localizations_en.dart b/lib/l10n/app_localizations_en.dart
index 334ed0c..3cf74b5 100644
--- a/lib/l10n/app_localizations_en.dart
+++ b/lib/l10n/app_localizations_en.dart
@@ -7228,4 +7228,99 @@ class AppLocalizationsEn extends AppLocalizations {
@override
String get voiceAnd => 'and';
+
+ @override
+ String get repRecordsTitle => 'Best weight by reps';
+
+ @override
+ String suppUnitCapsule(int n) {
+ String _temp0 = intl.Intl.pluralLogic(n, locale: localeName, other: 'capsules', one: 'capsule');
+ return '$_temp0';
+ }
+
+ @override
+ String suppUnitPill(int n) {
+ String _temp0 = intl.Intl.pluralLogic(n, locale: localeName, other: 'pills', one: 'pill');
+ return '$_temp0';
+ }
+
+ @override
+ String suppUnitScoop(int n) {
+ String _temp0 = intl.Intl.pluralLogic(n, locale: localeName, other: 'scoops', one: 'scoop');
+ return '$_temp0';
+ }
+
+ @override
+ String suppUnitDrop(int n) {
+ String _temp0 = intl.Intl.pluralLogic(n, locale: localeName, other: 'drops', one: 'drop');
+ return '$_temp0';
+ }
+
+ @override
+ String suppUnitServing(int n) {
+ String _temp0 = intl.Intl.pluralLogic(n, locale: localeName, other: 'servings', one: 'serving');
+ return '$_temp0';
+ }
+
+ @override
+ String get suppUnitIu => 'IU';
+
+ @override
+ String get suppLeft => 'Left';
+
+ @override
+ String get suppLeftHint => 'Optional';
+
+ @override
+ String suppLeftFor(int n) {
+ String _temp0 = intl.Intl.pluralLogic(
+ n,
+ locale: localeName,
+ other: 'Left for $n days',
+ one: 'Left for 1 day',
+ );
+ return '$_temp0';
+ }
+
+ @override
+ String suppForDays(int n) {
+ String _temp0 = intl.Intl.pluralLogic(n, locale: localeName, other: '$n days', one: '1 day');
+ return '$_temp0';
+ }
+
+ @override
+ String get suppRanOut => 'Ran out';
+
+ @override
+ String get lightSession => 'Light session';
+
+ @override
+ String get lightSessionHint => 'Saved in your history and stats, but it won\'t change your next targets.';
+
+ @override
+ String get lightSessionNote => 'Doesn\'t count for progression';
+
+ @override
+ String get lightSessionOff => 'Turn off';
+
+ @override
+ String get eachSideRepsHint =>
+ 'Log the left and right reps separately. Progression follows the weaker side.';
+
+ @override
+ String get repsLeftCol => 'REPS L';
+
+ @override
+ String get repsRightCol => 'REPS R';
+
+ @override
+ String get repsLeftTitle => 'LEFT REPS';
+
+ @override
+ String get repsRightTitle => 'RIGHT REPS';
+
+ @override
+ String sidesReps(int l, int r) {
+ return 'L$l R$r';
+ }
}
diff --git a/lib/l10n/app_localizations_es.dart b/lib/l10n/app_localizations_es.dart
index 19b918b..6f64428 100644
--- a/lib/l10n/app_localizations_es.dart
+++ b/lib/l10n/app_localizations_es.dart
@@ -7274,4 +7274,100 @@ class AppLocalizationsEs extends AppLocalizations {
@override
String get voiceAnd => 'y';
+
+ @override
+ String get repRecordsTitle => 'Mejor peso por reps';
+
+ @override
+ String suppUnitCapsule(int n) {
+ String _temp0 = intl.Intl.pluralLogic(n, locale: localeName, other: 'cápsulas', one: 'cápsula');
+ return '$_temp0';
+ }
+
+ @override
+ String suppUnitPill(int n) {
+ String _temp0 = intl.Intl.pluralLogic(n, locale: localeName, other: 'pastillas', one: 'pastilla');
+ return '$_temp0';
+ }
+
+ @override
+ String suppUnitScoop(int n) {
+ String _temp0 = intl.Intl.pluralLogic(n, locale: localeName, other: 'cazos', one: 'cazo');
+ return '$_temp0';
+ }
+
+ @override
+ String suppUnitDrop(int n) {
+ String _temp0 = intl.Intl.pluralLogic(n, locale: localeName, other: 'gotas', one: 'gota');
+ return '$_temp0';
+ }
+
+ @override
+ String suppUnitServing(int n) {
+ String _temp0 = intl.Intl.pluralLogic(n, locale: localeName, other: 'raciones', one: 'ración');
+ return '$_temp0';
+ }
+
+ @override
+ String get suppUnitIu => 'UI';
+
+ @override
+ String get suppLeft => 'Quedan';
+
+ @override
+ String get suppLeftHint => 'Opcional';
+
+ @override
+ String suppLeftFor(int n) {
+ String _temp0 = intl.Intl.pluralLogic(
+ n,
+ locale: localeName,
+ other: 'Quedan para $n días',
+ one: 'Queda para 1 día',
+ );
+ return '$_temp0';
+ }
+
+ @override
+ String suppForDays(int n) {
+ String _temp0 = intl.Intl.pluralLogic(n, locale: localeName, other: '$n días', one: '1 día');
+ return '$_temp0';
+ }
+
+ @override
+ String get suppRanOut => 'Se ha acabado';
+
+ @override
+ String get lightSession => 'Sesión ligera';
+
+ @override
+ String get lightSessionHint =>
+ 'Se guarda en tu historial y estadísticas, pero no cambia tus próximos objetivos.';
+
+ @override
+ String get lightSessionNote => 'No cuenta para la progresión';
+
+ @override
+ String get lightSessionOff => 'Quitar';
+
+ @override
+ String get eachSideRepsHint =>
+ 'Apunta las reps de la izquierda y la derecha por separado. La progresión sigue al lado más flojo.';
+
+ @override
+ String get repsLeftCol => 'REPS I';
+
+ @override
+ String get repsRightCol => 'REPS D';
+
+ @override
+ String get repsLeftTitle => 'REPS IZQUIERDA';
+
+ @override
+ String get repsRightTitle => 'REPS DERECHA';
+
+ @override
+ String sidesReps(int l, int r) {
+ return 'I$l D$r';
+ }
}
diff --git a/lib/models/live_session.dart b/lib/models/live_session.dart
index 9e47eff..a3c45ed 100644
--- a/lib/models/live_session.dart
+++ b/lib/models/live_session.dart
@@ -2,8 +2,9 @@ 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.kind = SetKind.normal, this.rpe, this.sec, this.km, this.rest, this.note = '', this.repsR});
int reps;
+ int? repsR;
String note;
int? rest;
double weight;
@@ -15,13 +16,20 @@ class SessionSet {
bool get counts => kind != SetKind.warmup;
- LoggedSet get logged => LoggedSet(reps, weight, kind: kind, rpe: rpe, sec: sec, km: km, note: note.trim());
+ int get weakReps {
+ final right = repsR;
+ return right == null || right > reps ? reps : right;
+ }
+
+ LoggedSet get logged => LoggedSet(weakReps, weight,
+ 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);
+ SessionSet(reps, weight, done, kind: kind, rpe: rpe, sec: sec, km: km, repsR: repsR);
Map<String, dynamic> toJson() => {
'r': reps,
+ if (repsR != null) 'rr': repsR,
'w': weight,
'd': done,
if (kind != SetKind.normal) 'k': kind.index,
@@ -41,6 +49,7 @@ class SessionSet {
km: (j['km'] as num?)?.toDouble(),
rest: (j['rs'] as num?)?.toInt().clamp(0, 3600),
note: j['n'] as String? ?? '',
+ repsR: (j['rr'] as num?)?.toInt(),
);
}
@@ -81,6 +90,7 @@ class WorkoutSession {
bool complete = false;
bool manual = false;
bool deload = false;
+ bool lightened = false;
String? routineId;
String? name;
DateTime? loggedAt;
@@ -110,6 +120,7 @@ class WorkoutSession {
'c': complete,
if (manual) 'm': true,
if (deload) 'dl': true,
+ if (lightened) 'lt': true,
if (routineId != null) 'r': routineId,
if (name != null) 'n': name,
'at': loggedAt?.toIso8601String(),
@@ -127,6 +138,7 @@ class WorkoutSession {
..complete = j['c'] as bool? ?? false
..manual = j['m'] as bool? ?? false
..deload = j['dl'] as bool? ?? false
+ ..lightened = j['lt'] as bool? ?? false
..routineId = j['r'] as String?
..name = j['n'] as String?
..loggedAt = DateTime.tryParse((j['at'] as String?) ?? '')
diff --git a/lib/models/workout.dart b/lib/models/workout.dart
index 5c28d0c..99fb914 100644
--- a/lib/models/workout.dart
+++ b/lib/models/workout.dart
@@ -17,8 +17,11 @@ double? rpePercent(int reps, double? rpe) {
}
class LoggedSet {
- LoggedSet(this.reps, this.weight, {this.kind = SetKind.normal, this.rpe, this.sec, this.km, this.note = ''});
+ LoggedSet(this.reps, this.weight,
+ {this.kind = SetKind.normal, this.rpe, this.sec, this.km, this.note = '', this.left, this.right});
final int reps;
+ final int? left;
+ final int? right;
final String note;
final double weight;
final SetKind kind;
@@ -27,6 +30,7 @@ class LoggedSet {
final double? km;
bool get counts => kind != SetKind.warmup;
+ bool get sided => left != null && right != null;
double get volume => reps * weight;
double get oneRm {
@@ -38,6 +42,8 @@ class LoggedSet {
Map<String, dynamic> toJson() => {
'r': reps,
'w': weight,
+ if (sided) 'rl': left,
+ if (sided) 'rr': right,
if (kind != SetKind.normal) 'k': kind.index,
if (rpe != null) 'e': rpe,
if (sec != null) 't': sec,
@@ -52,6 +58,8 @@ class LoggedSet {
sec: (j['t'] as num?)?.toInt(),
km: (j['km'] as num?)?.toDouble(),
note: j['n'] as String? ?? '',
+ left: (j['rl'] as num?)?.toInt(),
+ right: (j['rr'] as num?)?.toInt(),
);
}
diff --git a/lib/screens/exercise_detail_screen.dart b/lib/screens/exercise_detail_screen.dart
index 8367510..cbdf27b 100644
--- a/lib/screens/exercise_detail_screen.dart
+++ b/lib/screens/exercise_detail_screen.dart
@@ -321,7 +321,15 @@ class _ExerciseDetailScreenState extends State<ExerciseDetailScreen> {
() => fit.toggleEachSide(ex.id),
),
_holdProgressRow(gc, ex.id),
- ],
+ ] else if (mode.isEmpty)
+ _switchRow(
+ gc,
+ PhosphorIconsRegular.arrowsLeftRight,
+ t.eachSide,
+ t.eachSideRepsHint,
+ fit.isSidedReps(ex.id),
+ () => fit.toggleSidedReps(ex.id),
+ ),
_restRow(gc, ex.id),
if (ex.equipment == 'Barbell' || ex.equipment == 'Machine') _barRow(gc, ex),
if ((ex.equipment == 'Machine' || ex.equipment == 'Cable') && mode.isEmpty && !repsOnly)
diff --git a/lib/screens/progress_screen.dart b/lib/screens/progress_screen.dart
index 6e3fd6a..c84975b 100644
--- a/lib/screens/progress_screen.dart
+++ b/lib/screens/progress_screen.dart
@@ -2816,7 +2816,14 @@ Widget _editSetRow(GymColors gc, LoggedSession s, LoggedExercise e, int i, bool
] else ...[
if (timed)
time
- else
+ else if (set.sided) ...[
+ cell(t.repsLeftCol, '${set.left}', () => fit.bumpLoggedSide(e, i, true, -1),
+ () => fit.bumpLoggedSide(e, i, true, 1),
+ minWidth: 22),
+ cell(t.repsRightCol, '${set.right}', () => fit.bumpLoggedSide(e, i, false, -1),
+ () => fit.bumpLoggedSide(e, i, false, 1),
+ minWidth: 22),
+ ] else
cell(t.repsCol, '${set.reps}', () => fit.bumpLoggedReps(e, i, -1), () => fit.bumpLoggedReps(e, i, 1)),
if (!repsOnly && (!timed || set.weight > 0))
cell(t.weightCol(fit.units.toUpperCase()), fit.weightValue(set.weight), () => fit.bumpLoggedWeight(e, i, -1),
diff --git a/lib/screens/session_screen.dart b/lib/screens/session_screen.dart
index c29a419..1ddec1d 100644
--- a/lib/screens/session_screen.dart
+++ b/lib/screens/session_screen.dart
@@ -50,7 +50,9 @@ class SessionScreen extends StatelessWidget {
);
}
- Widget _deloadNote(GymColors gc) => Container(
+ Widget _deloadNote(GymColors gc) {
+ final auto = fit.session?.lightened ?? false;
+ return Container(
padding: const EdgeInsets.fromLTRB(14, 10, 8, 10),
decoration: BoxDecoration(color: gc.bgRaised, borderRadius: BorderRadius.circular(16)),
child: Row(children: [
@@ -58,24 +60,26 @@ class SessionScreen extends StatelessWidget {
const SizedBox(width: 10),
Expanded(
child: Column(crossAxisAlignment: CrossAxisAlignment.start, children: [
- Text(t.deloadNow,
+ Text(auto ? t.deloadNow : t.lightSession,
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: AppTheme.f(13.5, weight: FontWeight.w800, color: gc.text)),
const SizedBox(height: 2),
- Text(t.deloadNowHint,
+ Text(auto ? t.deloadNowHint : t.lightSessionNote,
maxLines: 2,
overflow: TextOverflow.ellipsis,
style: AppTheme.f(12, weight: FontWeight.w500, color: gc.textSecondary, height: 1.3)),
]),
),
- if (fit.canSkipDeload)
+ if (fit.canSkipDeload || !auto)
TextButton(
- onPressed: fit.skipDeload,
- child: Text(t.deloadSkip, style: AppTheme.f(12.5, weight: FontWeight.w700, color: gc.accent)),
+ onPressed: fit.toggleLightSession,
+ child: Text(auto ? t.deloadSkip : t.lightSessionOff,
+ style: AppTheme.f(12.5, weight: FontWeight.w700, color: gc.accent)),
),
]),
);
+ }
Widget _active(BuildContext context, GymColors gc) {
final s = fit.session!;
@@ -163,7 +167,7 @@ class SessionScreen extends StatelessWidget {
children: [
Padding(
padding: const EdgeInsets.fromLTRB(_rowPad, 0, _rowPad, 10),
- child: _setsHeader(gc, mode, repsOnly, ex != null && fit.isEachSide(ex.id), exId: ex?.id),
+ child: _setsHeader(gc, mode, repsOnly, ex != null && (fit.isEachSide(ex.id) || fit.isSidedReps(ex.id)), exId: ex?.id),
),
for (int j = 0; j < (ex?.sets.length ?? 0); j++) ...[
_swipeSet(context, gc, exIdx, j, ex!.sets[j], locked,
@@ -305,6 +309,10 @@ class SessionScreen extends StatelessWidget {
children: [
_listStats(gc, s),
const SizedBox(height: 16),
+ if (s.deload) ...[
+ _deloadNote(gc),
+ const SizedBox(height: 12),
+ ],
for (var i = 0; i < s.exercises.length; i++) ...[
_listExercise(context, gc, s, i, locked),
SizedBox(height: s.exercises[i].linkedNext && i < s.exercises.length - 1 ? 4 : 12),
@@ -436,7 +444,7 @@ class SessionScreen extends StatelessWidget {
const SizedBox(height: 12),
Padding(
padding: const EdgeInsets.fromLTRB(8, 0, 8, 6),
- child: _setsHeader(gc, mode, repsOnly, fit.isEachSide(ex.id), list: true, exId: ex.id),
+ child: _setsHeader(gc, mode, repsOnly, fit.isEachSide(ex.id) || fit.isSidedReps(ex.id), list: true, exId: ex.id),
),
for (var j = 0; j < ex.sets.length; j++)
_swipeSet(context, gc, i, j, ex.sets[j], locked,
@@ -552,6 +560,13 @@ class SessionScreen extends StatelessWidget {
showNotchToast(context, t.superset,
subtitle: t.supersetHint, icon: PhosphorIconsFill.link, accent: gc.brass);
}),
+ OptionItem(t.lightSession,
+ icon: PhosphorIconsRegular.feather,
+ selected: s.deload,
+ onTap: () {
+ Navigator.pop(sheet);
+ fit.toggleLightSession();
+ }),
if (s.exercises.length > 1)
OptionItem(t.dropExerciseAction, icon: PhosphorIconsRegular.trash, danger: true, onTap: () {
Navigator.pop(sheet);
@@ -598,7 +613,7 @@ class SessionScreen extends StatelessWidget {
String _prevLabel(LoggedSet p, int exIdx) {
final id = fit.session?.exercises[exIdx].id;
if ((p.km ?? 0) > 0 || p.sec != null) return fit.loggedSetLabel(p, id: id);
- return p.weight > 0 ? fit.loggedSetLabel(p, id: id) : '×${p.reps}';
+ return p.weight > 0 ? fit.loggedSetLabel(p, id: id) : (p.sided ? '×${t.sidesReps(p.left!, p.right!)}' : '×${p.reps}');
}
Widget _prevCell(GymColors gc, int exIdx, int j, LoggedSet? prev, bool locked) {
@@ -1375,6 +1390,39 @@ class SessionScreen extends StatelessWidget {
),
);
final exId = fit.session!.exercises[exIdx].id;
+ final sided = fit.isSidedReps(exId);
+ Widget repsLeft() => step(
+ gc,
+ '${st.reps}',
+ () => fit.bumpSessionReps(exIdx, j, -1),
+ () => fit.bumpSessionReps(exIdx, j, 1),
+ 18,
+ onEdit: (context) => _ruler(
+ context,
+ title: t.repsLeftTitle,
+ value: st.reps.toDouble(),
+ max: 100,
+ step: 1,
+ majorEvery: 5,
+ onSave: (v) => fit.setSessionReps(exIdx, j, v.round()),
+ ),
+ );
+ Widget repsRight() => step(
+ gc,
+ '${st.repsR ?? st.reps}',
+ () => fit.bumpSessionRepsRight(exIdx, j, -1),
+ () => fit.bumpSessionRepsRight(exIdx, j, 1),
+ 18,
+ onEdit: (context) => _ruler(
+ context,
+ title: t.repsRightTitle,
+ value: (st.repsR ?? st.reps).toDouble(),
+ max: 100,
+ step: 1,
+ majorEvery: 5,
+ onSave: (v) => fit.setSessionRepsRight(exIdx, j, v.round()),
+ ),
+ );
Widget weight() => step(
gc,
fit.weightValueFor(exId, st.weight),
@@ -1440,14 +1488,17 @@ class SessionScreen extends StatelessWidget {
return switch (mode) {
'cardio' => [distance(), time()],
'time' => [time(), if (!repsOnly) weight()],
- _ => [reps(), if (!repsOnly) weight()],
+ _ => sided ? [repsLeft(), repsRight(), if (!repsOnly) weight()] : [reps(), if (!repsOnly) weight()],
};
}
List<String> _headers(String mode, bool repsOnly, bool sided, String unit) => switch (mode) {
'cardio' => [t.distanceCol(fit.distanceUnit.toUpperCase()), t.timeCol],
'time' => [sided ? t.timePerSideCol : t.timeCol, if (!repsOnly) t.weightCol(unit.toUpperCase())],
- _ => [t.repsCol, if (!repsOnly) t.weightCol(unit.toUpperCase())],
+ _ => [
+ if (sided) ...[t.repsLeftCol, t.repsRightCol] else t.repsCol,
+ if (!repsOnly) t.weightCol(unit.toUpperCase()),
+ ],
};
Widget _setRow(GymColors gc, int exIdx, int j, SessionSet st, bool repsOnly, bool locked,
@@ -2908,7 +2959,15 @@ void showSessionOverview(BuildContext context) {
itemBuilder: (context, i) => _overviewRow(sheet, gc, s, i),
),
),
- const SizedBox(height: 6),
+ const SizedBox(height: 10),
+ OptionGroup([
+ OptionItem(t.lightSession,
+ icon: PhosphorIconsRegular.feather,
+ detail: t.lightSessionHint,
+ trailing: TinySwitch(on: s.deload),
+ onTap: fit.toggleLightSession),
+ ]),
+ const SizedBox(height: 10),
Text(t.dragToReorder,
textAlign: TextAlign.center,
style: AppTheme.f(11, weight: FontWeight.w500, color: gc.textTertiary)),
diff --git a/lib/services/live_workout.dart b/lib/services/live_workout.dart
index ebe6455..5a74eb6 100644
--- a/lib/services/live_workout.dart
+++ b/lib/services/live_workout.dart
@@ -70,7 +70,7 @@ class LiveWorkout {
detail = t.liveAllDone;
} else {
final st = ex.sets[pending];
- final load = st.sec != null || st.km != null
+ final load = st.sec != null || st.km != null || st.repsR != null
? fit.loggedSetLabel(st.logged)
: fit.isRepsOnly(ex.id)
? '${st.reps} ${t.repsCol.toLowerCase()}'
diff --git a/lib/state/library_state.dart b/lib/state/library_state.dart
index bfe2847..660cb89 100644
--- a/lib/state/library_state.dart
+++ b/lib/state/library_state.dart
@@ -442,6 +442,8 @@ mixin LibraryState on FitCore {
return _sidedByDefault.contains(id);
}
+ bool isSidedReps(String id) => !isTimed(id) && modeOf(id) != 'cardio' && eachSide.contains(id);
+
void toggleEachSide(String id) {
final on = !isEachSide(id);
eachSide.remove(id);
diff --git a/lib/state/stats_state.dart b/lib/state/stats_state.dart
index c9ee144..41a20d2 100644
--- a/lib/state/stats_state.dart
+++ b/lib/state/stats_state.dart
@@ -380,6 +380,10 @@ mixin StatsState on FitCore, ToolsState, LibraryState, SettingsState, TimelineSt
String line(LoggedSet x) {
if (x.km != null) return '${distanceLabel(x.km!)} · ${durationLabel(x.sec ?? 0)}';
if (x.sec != null && x.reps == 0) return durationLabel(x.sec!);
+ if (x.sided) {
+ final both = t.sidesReps(x.left!, x.right!);
+ return x.weight > 0 ? '${weightLabel(x.weight)} × $both' : both;
+ }
return x.weight > 0 ? '${weightLabel(x.weight)} × ${x.reps}' : t.repCount(x.reps);
}
@@ -434,9 +438,21 @@ mixin StatsState on FitCore, ToolsState, LibraryState, SettingsState, TimelineSt
notifyListeners();
}
- void _replaceLoggedSet(LoggedExercise e, int i, {int? reps, double? weight, int? sec, double? km}) {
+ void _replaceLoggedSet(LoggedExercise e, int i,
+ {int? reps, int? left, int? right, double? weight, int? sec, double? km}) {
if (i < 0 || i >= e.sets.length) return;
final old = e.sets[i];
+ var l = old.left;
+ var r = old.right;
+ if (old.sided) {
+ if (reps != null) {
+ l = reps;
+ r = reps;
+ }
+ l = left ?? l;
+ r = right ?? r;
+ reps = l! < r! ? l : r;
+ }
e.sets[i] = LoggedSet(
reps ?? old.reps,
weight ?? old.weight,
@@ -445,6 +461,8 @@ mixin StatsState on FitCore, ToolsState, LibraryState, SettingsState, TimelineSt
sec: sec ?? old.sec,
km: km ?? old.km,
note: old.note,
+ left: l,
+ right: r,
);
persistNow();
_refreshWidgets();
@@ -543,6 +561,13 @@ mixin StatsState on FitCore, ToolsState, LibraryState, SettingsState, TimelineSt
void bumpLoggedReps(LoggedExercise e, int i, int d) =>
setLoggedReps(e, i, e.sets[i].reps + d);
+ void bumpLoggedSide(LoggedExercise e, int i, bool leftSide, int d) {
+ final s = e.sets[i];
+ if (!s.sided) return;
+ final v = ((leftSide ? s.left! : s.right!) + d).clamp(0, 999);
+ _replaceLoggedSet(e, i, left: leftSide ? v : null, right: leftSide ? null : v);
+ }
+
void bumpLoggedWeight(LoggedExercise e, int i, int dir) {
final next = _roundTo(toDisplayWeight(e.sets[i].weight), weightStep) + dir * weightStep;
setLoggedWeight(e, i, fromDisplayWeight(math.max(0, next)));
@@ -550,7 +575,7 @@ mixin StatsState on FitCore, ToolsState, LibraryState, SettingsState, TimelineSt
void addLoggedSet(LoggedExercise e) {
final last = e.sets.isNotEmpty ? e.sets.last : LoggedSet(10, isRepsOnly(e.id) ? 0 : 20);
- e.sets.add(LoggedSet(last.reps, last.weight, sec: last.sec, km: last.km));
+ e.sets.add(LoggedSet(last.reps, last.weight, sec: last.sec, km: last.km, left: last.left, right: last.right));
persistNow();
_refreshWidgets();
notifyListeners();
@@ -812,6 +837,31 @@ mixin StatsState on FitCore, ToolsState, LibraryState, SettingsState, TimelineSt
return best;
}
+ List<({int reps, double kg, DateTime date})> repRecords(String id) {
+ if (modeOf(id).isNotEmpty || isRepsOnly(id) || isAssisted(id)) return const [];
+ final best = <int, ({double kg, DateTime date})>{};
+ for (final h in exerciseHistory(id)) {
+ for (final st in h.ex.workingSets) {
+ if (st.reps <= 0 || st.weight <= 0) continue;
+ final had = best[st.reps];
+ if (had == null || st.weight > had.kg || (st.weight == had.kg && h.date.isBefore(had.date))) {
+ best[st.reps] = (kg: st.weight, date: h.date);
+ }
+ }
+ }
+ final out = <({int reps, double kg, DateTime date})>[];
+ var floor = 0.0;
+ for (final r in best.keys.toList()..sort((a, b) => b.compareTo(a))) {
+ final b = best[r]!;
+ if (b.kg <= floor) continue;
+ out.add((reps: r, kg: b.kg, date: b.date));
+ floor = b.kg;
+ }
+ final ladder = out.reversed.toList();
+ if (ladder.length <= 5) return ladder;
+ return [for (var i = 0; i < 5; i++) ladder[(i * (ladder.length - 1) / 4).round()]];
+ }
+
String bestWorkoutLabel(double score, PrKind kind) => kind == PrKind.weight
? '${fmt(toDisplayWeight(score).roundToDouble())} $units'
: t.repCount(score.round());
@@ -1128,11 +1178,18 @@ mixin StatsState on FitCore, ToolsState, LibraryState, SettingsState, TimelineSt
return out;
}
+ Set<LoggedExercise> get _lightExercises => _remember('lightEx', () => Set<LoggedExercise>.identity()
+ ..addAll([for (final s in sessions) if (s.deload) ...s.exercises]));
+
+ List<({DateTime date, LoggedExercise ex})> progressHistory(String id) {
+ final light = _lightExercises;
+ return [for (final h in exerciseHistory(id)) if (!light.contains(h.ex)) h];
+ }
+
List<LoggedSet> lastSetsFor(String id) {
final h = exerciseHistory(id);
if (h.isEmpty) return const [];
- final light = _remember('lightEx', () => Set<LoggedExercise>.identity()
- ..addAll([for (final s in sessions) if (s.deload) ...s.exercises]));
+ final light = _lightExercises;
for (final e in h) {
if (!light.contains(e.ex)) return e.ex.sets;
}
@@ -1156,7 +1213,7 @@ mixin StatsState on FitCore, ToolsState, LibraryState, SettingsState, TimelineSt
if (sec != null && s.reps <= 0) {
return s.weight > 0 ? '$w × ${durationLabel(sec)}' : durationLabel(sec);
}
- return '$w×${s.reps}';
+ return s.sided ? '$w×${t.sidesReps(s.left!, s.right!)}' : '$w×${s.reps}';
}
String? strengthExerciseId;
diff --git a/lib/state/workout_state.dart b/lib/state/workout_state.dart
index ce54f62..421022d 100644
--- a/lib/state/workout_state.dart
+++ b/lib/state/workout_state.dart
@@ -245,13 +245,53 @@ mixin WorkoutState on FitCore, SettingsState, LibraryState, PlacesState, StatsSt
return out;
}
- List<SessionSet> _openingSets(String id, {int? count, List<PlannedSet>? planned}) {
+ List<SessionSet> _openingSets(String id, {int? count, List<PlannedSet>? planned}) =>
+ _withSides(id, _openingSetsRaw(id, count: count, planned: planned));
+
+ List<SessionSet> _openingSetsRaw(String id, {int? count, List<PlannedSet>? planned}) {
if (planned != null && planned.isNotEmpty) return _fromPlan(id, planned);
final sets = _workingOpeners(id, count: count);
if (!warmsUp(id) || isRepsOnly(id) || modeOf(id).isNotEmpty) return sets;
return [..._warmupFor(sets, id), ...sets];
}
+ List<SessionSet> _withSides(String id, List<SessionSet> sets) {
+ if (isSidedReps(id)) {
+ for (final st in sets) {
+ st.repsR ??= st.reps;
+ }
+ }
+ return sets;
+ }
+
+ void syncSides(SessionExercise e) {
+ final sided = isSidedReps(e.id);
+ for (final st in e.sets) {
+ if (sided) {
+ st.repsR ??= st.reps;
+ } else if (st.repsR != null) {
+ st.reps = st.weakReps;
+ st.repsR = null;
+ }
+ }
+ }
+
+ void toggleSidedReps(String id) {
+ if (isSidedReps(id)) {
+ eachSide.remove(id);
+ } else {
+ eachSide.add(id);
+ }
+ final s = session;
+ if (s != null && !s.complete) {
+ for (final e in s.exercises) {
+ if (e.id == id) syncSides(e);
+ }
+ }
+ _persist();
+ notifyListeners();
+ }
+
int? nextHoldSeconds(String id) {
if (modeOf(id) != 'time') return null;
final step = holdStepFor(id);
@@ -315,7 +355,7 @@ mixin WorkoutState on FitCore, SettingsState, LibraryState, PlacesState, StatsSt
static const deloadAfter = 3;
int stallStreak(String id) {
- final h = exerciseHistory(id);
+ final h = progressHistory(id);
if (h.isEmpty) return 0;
final rule = progressRule(id);
final load = headlineWeight(h.first.ex);
@@ -520,6 +560,7 @@ mixin WorkoutState on FitCore, SettingsState, LibraryState, PlacesState, StatsSt
void _lighten(WorkoutSession s) {
s.deload = true;
+ s.lightened = true;
for (final e in s.exercises) {
final working = e.sets.where((st) => st.kind != SetKind.warmup).toList();
if (working.isEmpty) continue;
@@ -550,6 +591,24 @@ mixin WorkoutState on FitCore, SettingsState, LibraryState, PlacesState, StatsSt
..addAll(fresh);
}
s.deload = false;
+ s.lightened = false;
+ persistNow();
+ notifyListeners();
+ }
+
+ void toggleLightSession() {
+ final s = session;
+ if (s == null || s.complete) return;
+ if (s.deload) {
+ if (s.lightened && canSkipDeload) {
+ skipDeload();
+ return;
+ }
+ s.deload = false;
+ s.lightened = false;
+ } else {
+ s.deload = true;
+ }
persistNow();
notifyListeners();
}
@@ -762,7 +821,12 @@ mixin WorkoutState on FitCore, SettingsState, LibraryState, PlacesState, StatsSt
final prev = previousSet(s.exercises[exIdx].id, setIdx);
if (prev == null || setIdx >= sets.length) return;
final st = sets[setIdx];
- st.reps = prev.reps;
+ if (st.repsR != null) {
+ st.reps = prev.left ?? prev.reps;
+ st.repsR = prev.right ?? prev.reps;
+ } else {
+ st.reps = prev.reps;
+ }
st.weight = prev.weight;
if (prev.sec != null) st.sec = prev.sec;
if (prev.km != null) st.km = prev.km;
@@ -809,7 +873,7 @@ mixin WorkoutState on FitCore, SettingsState, LibraryState, PlacesState, StatsSt
var kg = 0.0;
for (final e in session?.exercises ?? const <SessionExercise>[]) {
for (final st in e.sets) {
- if (st.done && st.counts) kg += st.reps * st.weight;
+ if (st.done && st.counts) kg += st.weakReps * st.weight;
}
}
return kg;
@@ -1123,8 +1187,10 @@ mixin WorkoutState on FitCore, SettingsState, LibraryState, PlacesState, StatsSt
: _modeOpeners(mode, const []).first);
} else {
final last = sets.last;
- sets.add(SessionSet(last.reps, last.weight, false, kind: last.kind, sec: last.sec, km: last.km));
+ sets.add(SessionSet(last.reps, last.weight, false,
+ kind: last.kind, sec: last.sec, km: last.km, repsR: last.repsR));
}
+ syncSides(ex);
_persist();
notifyListeners();
}
@@ -1398,6 +1464,11 @@ mixin WorkoutState on FitCore, SettingsState, LibraryState, PlacesState, StatsSt
void bumpSessionReps(int exIdx, int setIdx, int d) =>
setSessionReps(exIdx, setIdx, session!.exercises[exIdx].sets[setIdx].reps + d);
+ void bumpSessionRepsRight(int exIdx, int setIdx, int d) {
+ final st = session!.exercises[exIdx].sets[setIdx];
+ setSessionRepsRight(exIdx, setIdx, (st.repsR ?? st.reps) + d);
+ }
+
void bumpSessionWeight(int exIdx, int setIdx, int dir) {
final id = session!.exercises[exIdx].id;
if (stackFor(id) != null) {
@@ -1447,6 +1518,7 @@ mixin WorkoutState on FitCore, SettingsState, LibraryState, PlacesState, StatsSt
final warm = _warmupFor(sets, s.exercises[exIdx].id);
if (warm.isEmpty) return;
sets.insertAll(0, warm);
+ syncSides(s.exercises[exIdx]);
_persist();
notifyListeners();
}
@@ -1500,6 +1572,12 @@ mixin WorkoutState on FitCore, SettingsState, LibraryState, PlacesState, StatsSt
notifyListeners();
}
+ void setSessionRepsRight(int exIdx, int setIdx, int reps) {
+ _carry(exIdx, setIdx, (st) => st.repsR ?? st.reps, (st, v) => st.repsR = v, reps.clamp(0, 999));
+ _persist();
+ notifyListeners();
+ }
+
void setSessionWeight(int exIdx, int setIdx, double kg) {
_carry(exIdx, setIdx, (st) => st.weight, (st, v) => st.weight = v, _round3(kg.clamp(0, 1000)));
_persist();
@@ -1594,7 +1672,7 @@ mixin WorkoutState on FitCore, SettingsState, LibraryState, PlacesState, StatsSt
final started = from.sets.any((st) => st.done);
final count = left > 0 ? left : null;
final next = SessionExercise(to.id, to.name, to.primary,
- started ? _workingOpeners(toId, count: count) : _openingSets(toId, count: count),
+ started ? _withSides(toId, _workingOpeners(toId, count: count)) : _openingSets(toId, count: count),
linkedNext: from.linkedNext,
swappedFrom: from.swappedFrom ?? from.id);
if (started) {
@@ -1670,7 +1748,7 @@ mixin WorkoutState on FitCore, SettingsState, LibraryState, PlacesState, StatsSt
if (st.counts) working.add(st);
}
}
- s.summaryVolume = working.fold<double>(0, (sum, st) => sum + st.reps * st.weight).round();
+ s.summaryVolume = working.fold<double>(0, (sum, st) => sum + st.weakReps * st.weight).round();
s.summarySets = working.length;
s.summaryDuration = s.manual ? _elapsedBefore : sessionElapsed;
s.complete = true;
@@ -1746,7 +1824,7 @@ mixin WorkoutState on FitCore, SettingsState, LibraryState, PlacesState, StatsSt
setPlannedSets(routineId, ex.id, [
for (final st in ex.sets)
PlannedSet(
- reps: modeOf(ex.id).isEmpty ? st.reps : null,
+ reps: modeOf(ex.id).isEmpty ? st.weakReps : null,
weightKg: st.weight > 0 ? st.weight : null,
kind: st.kind,
sec: st.sec,
@@ -1872,7 +1950,7 @@ mixin WorkoutState on FitCore, SettingsState, LibraryState, PlacesState, StatsSt
setPlannedSets(r.id, exId, [
for (final st in done)
PlannedSet(
- reps: timed ? null : st.reps,
+ reps: timed ? null : st.weakReps,
weightKg: st.weight > 0 ? st.weight : null,
kind: st.kind,
sec: st.sec,
@@ -2143,8 +2221,8 @@ mixin WorkoutState on FitCore, SettingsState, LibraryState, PlacesState, StatsSt
e.name,
e.primary,
e.sets
- .map((x) => SessionSet(x.reps, x.weight, true,
- kind: x.kind, rpe: x.rpe, sec: x.sec, km: x.km, note: x.note))
+ .map((x) => SessionSet(x.sided ? x.left! : x.reps, x.weight, true,
+ kind: x.kind, rpe: x.rpe, sec: x.sec, km: x.km, note: x.note, repsR: x.right))
.toList()))
.toList();
_restTimer?.cancel();
diff --git a/test/progression_test.dart b/test/progression_test.dart
index 2d3a6f6..4671174 100644
--- a/test/progression_test.dart
+++ b/test/progression_test.dart
@@ -1,5 +1,6 @@
import 'package:flutter_test/flutter_test.dart';
import 'package:gymmane/l10n/l10n.dart';
+import 'package:gymmane/models/live_session.dart';
import 'package:gymmane/models/progression.dart';
import 'package:gymmane/models/workout.dart';
import 'package:gymmane/services/local_store.dart';
@@ -36,6 +37,19 @@ void main() {
expect(fit.needsDeload(id), isFalse);
});
+ test('una sesión ligera no corta la racha ni cambia el objetivo', () {
+ final id = bench();
+ for (final d in [9, 6, 3]) {
+ logged(id, d, [LoggedSet(8, 80), LoggedSet(6, 80)]);
+ }
+ fit.sessions.add(LoggedSession(ago(1), 900, [
+ LoggedExercise(id, id, 'back', [LoggedSet(8, 72)])
+ ], deload: true));
+ expect(fit.stallStreak(id), 3);
+ expect(fit.lastSetsFor(id).first.weight, 80);
+ expect(fit.exerciseHistory(id).length, 4);
+ });
+
test('tres entrenos al mismo peso sin cumplir bajan al 90 %', () {
final id = bench();
fit.progressStep[id] = 2.5;
@@ -480,6 +494,23 @@ void main() {
expect(fit.weeksToDeload, 3);
});
+ test('cualquier sesión se puede marcar como ligera sin tocar las series', () {
+ final id = fit.createRoutine('Ligera');
+ fit.toggleRoutineExercise(id, 'EIeI8Vf');
+ final r = fit.routines.firstWhere((x) => x.id == id);
+ fit.startRoutine(r);
+ final s = fit.session!;
+ final before = s.exercises.first.sets.length;
+ expect(s.deload, isFalse);
+ fit.toggleLightSession();
+ expect(s.deload, isTrue);
+ expect(s.lightened, isFalse);
+ expect(s.exercises.first.sets.length, before);
+ expect(WorkoutSession.fromJson(s.toJson()).deload, isTrue);
+ fit.toggleLightSession();
+ expect(s.deload, isFalse);
+ });
+
test('en descarga la sesión lleva la mitad de series, y entrenar normal las devuelve', () {
final id = fit.createRoutine('Descarga');
fit.toggleRoutineExercise(id, 'EIeI8Vf');
@@ -499,4 +530,54 @@ void main() {
expect(s.exercises.first.sets.where((x) => x.kind != SetKind.warmup).length, normal);
});
});
+
+ group('cada lado', () {
+ setUp(() async {
+ SharedPreferences.setMockInitialValues({});
+ await Store.instance.init();
+ fit.resetAllData();
+ fit.onboarded = true;
+ });
+
+ tearDown(() => fit.saveAndExit());
+
+ test('una serie con dos lados guarda el más flojo y los dos números', () {
+ final st = SessionSet(10, 40, true, repsR: 8);
+ expect(st.weakReps, 8);
+ final logged = st.logged;
+ expect(logged.reps, 8);
+ expect(logged.left, 10);
+ expect(logged.right, 8);
+ expect(logged.sided, isTrue);
+ final back = LoggedSet.fromJson(logged.toJson());
+ expect(back.left, 10);
+ expect(back.right, 8);
+ expect(back.reps, 8);
+ expect(SessionSet.fromJson(st.toJson()).repsR, 8);
+ });
+
+ test('una serie antigua sin lados se lee igual', () {
+ final old = LoggedSet.fromJson({'r': 9, 'w': 30.0});
+ expect(old.sided, isFalse);
+ expect(old.reps, 9);
+ expect(old.toJson().containsKey('rl'), isFalse);
+ });
+
+ test('al activar «cada lado» las series abren con los dos lados y siguen al lado flojo', () {
+ final id = fit.createRoutine('Lados');
+ fit.toggleRoutineExercise(id, 'EIeI8Vf');
+ final r = fit.routines.firstWhere((x) => x.id == id);
+ fit.toggleSidedReps('EIeI8Vf');
+ expect(fit.isSidedReps('EIeI8Vf'), isTrue);
+ fit.startRoutine(r);
+ final sets = fit.session!.exercises.first.sets;
+ expect(sets.every((st) => st.repsR == st.reps), isTrue);
+ fit.setSessionRepsRight(0, 0, 6);
+ expect(sets.first.repsR, 6);
+ expect(sets.first.weakReps, 6);
+ expect(sets.first.logged.reps, 6);
+ fit.toggleSidedReps('EIeI8Vf');
+ expect(sets.every((st) => st.repsR == null), isTrue);
+ });
+ });
}