Skip to content

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

Track assisted machines and suggest a deload after stalling

InlitX8d717023e0c7
diff --git a/lib/screens/exercise_detail_screen.dart b/lib/screens/exercise_detail_screen.dart
index 1151efd..e278cdd 100644
--- a/lib/screens/exercise_detail_screen.dart
+++ b/lib/screens/exercise_detail_screen.dart
@@ -315,6 +315,14 @@ class _ExerciseDetailScreenState extends State<ExerciseDetailScreen> {
() => fit.toggleSuggest(ex.id),
),
if (!repsOnly && mode.isEmpty) ...[
+ _switchRow(
+ gc,
+ PhosphorIconsRegular.arrowFatLinesDown,
+ t.assistedSetting,
+ t.assistedSettingHint,
+ fit.isAssisted(ex.id),
+ () => fit.toggleAssisted(ex.id),
+ ),
_progressRow(gc, ex.id),
_switchRow(
gc,
@@ -457,7 +465,7 @@ class _ExerciseDetailScreenState extends State<ExerciseDetailScreen> {
Column(
crossAxisAlignment: CrossAxisAlignment.end,
children: [
- Text(fit.weightLabel(e.topWeight),
+ Text(fit.weightLabel(fit.headlineWeight(e)),
style: AppTheme.f(17, weight: FontWeight.w700, color: gc.text)),
const SizedBox(height: 3),
Text(t.volumeSuffix(fit.volumeLabel(e.volume)),
@@ -811,8 +819,9 @@ class _ExerciseDetailScreenState extends State<ExerciseDetailScreen> {
]),
);
- Widget _bests(GymColors gc, String id, PrKind kind) {
- final set = kind == PrKind.weight ? fit.bestSet(id) : null;
+ Widget _bests(GymColors gc, String id, PrKind record) {
+ final set = record == PrKind.weight ? fit.bestSet(id) : null;
+ final kind = record == PrKind.weight && fit.isAssisted(id) ? PrKind.reps : record;
final work = fit.bestWorkout(id, kind);
if (work == null) return const SizedBox.shrink();
Widget cell(String label, String value, DateTime date) => Expanded(
@@ -1215,7 +1224,8 @@ class _ExerciseDetailScreenState extends State<ExerciseDetailScreen> {
style: AppTheme.f(10.5, weight: FontWeight.w700, color: gc.textTertiary, letterSpacing: 1.3)),
if (!target.up) ...[
const SizedBox(height: 2),
- Text(t.nextHold, style: AppTheme.f(11.5, weight: FontWeight.w500, color: gc.textTertiary)),
+ Text(target.deload ? t.nextDeload(fit.stallStreak(id)) : t.nextHold,
+ style: AppTheme.f(11.5, weight: FontWeight.w500, color: gc.textTertiary)),
],
],
),
diff --git a/lib/state/fit_core.dart b/lib/state/fit_core.dart
index dd4ff25..e643d46 100644
--- a/lib/state/fit_core.dart
+++ b/lib/state/fit_core.dart
@@ -70,6 +70,8 @@ abstract class FitCore extends ChangeNotifier {
final Set<String> eachSide = {};
final Set<String> eachSideOff = {};
+ final Set<String> assistedOn = {};
+ final Set<String> assistedOff = {};
final Set<String> noSuggest = {};
diff --git a/lib/state/library_state.dart b/lib/state/library_state.dart
index 69d97d9..ea6afb2 100644
--- a/lib/state/library_state.dart
+++ b/lib/state/library_state.dart
@@ -412,6 +412,36 @@ mixin LibraryState on FitCore {
notifyListeners();
}
+ static const _assistedByDefault = {'kiJ4Z2K', '7OeHptV', 'PAgTVaK'};
+
+ bool _assistedName(String id) {
+ for (final e in customExercises) {
+ if (e.id == id) {
+ final n = e.name.toLowerCase();
+ return n.contains('assist') || n.contains('asistid');
+ }
+ }
+ return false;
+ }
+
+ bool _assistedDefault(String id) => _assistedByDefault.contains(id) || _assistedName(id);
+
+ bool isAssisted(String id) {
+ if (modeOf(id).isNotEmpty || isRepsOnly(id)) return false;
+ if (assistedOn.contains(id)) return true;
+ if (assistedOff.contains(id)) return false;
+ return _assistedDefault(id);
+ }
+
+ void toggleAssisted(String id) {
+ final on = !isAssisted(id);
+ assistedOn.remove(id);
+ assistedOff.remove(id);
+ if (on != _assistedDefault(id)) (on ? assistedOn : assistedOff).add(id);
+ _persist();
+ notifyListeners();
+ }
+
void toggleRepsOnly(String id) {
if (isRepsOnly(id)) {
repsOnly.remove(id);
diff --git a/lib/state/workout_state.dart b/lib/state/workout_state.dart
index 6ac3b64..6099e63 100644
--- a/lib/state/workout_state.dart
+++ b/lib/state/workout_state.dart
@@ -265,8 +265,12 @@ mixin WorkoutState on FitCore, SettingsState, LibraryState, PlacesState, StatsSt
if (mode.isNotEmpty) {
base = _modeOpeners(mode, last);
} else if (last.isNotEmpty) {
- final bump = _progressBump(id, last);
- base = last.map((l) => SessionSet(l.reps, l.weight + bump, false)).toList();
+ if (needsDeload(id)) {
+ base = last.map((l) => SessionSet(l.reps, deloadWeight(id, l.weight), false)).toList();
+ } else {
+ final bump = _progressBump(id, last) * (isAssisted(id) ? -1 : 1);
+ base = last.map((l) => SessionSet(l.reps, math.max(0.0, l.weight + bump), false)).toList();
+ }
} else {
final w = isRepsOnly(id) ? 0.0 : 20.0;
base = [for (var i = 0; i < kDefaultRoutineSets; i++) SessionSet(10, w, false)];
@@ -280,17 +284,50 @@ mixin WorkoutState on FitCore, SettingsState, LibraryState, PlacesState, StatsSt
];
}
- ({double weightKg, int reps, bool up})? nextTarget(String id) {
+ static const deloadAfter = 3;
+
+ int stallStreak(String id) {
+ final h = exerciseHistory(id);
+ if (h.isEmpty) return 0;
+ final load = headlineWeight(h.first.ex);
+ var n = 0;
+ for (final r in h) {
+ final sets = r.ex.workingSets;
+ if (sets.isEmpty || (headlineWeight(r.ex) - load).abs() > 0.01) break;
+ final target = sets.first.reps;
+ if (target <= 0 || sets.every((s) => s.reps >= target)) break;
+ n++;
+ }
+ return n;
+ }
+
+ bool needsDeload(String id) =>
+ hasProgress(id) && modeOf(id).isEmpty && !isRepsOnly(id) && stallStreak(id) >= deloadAfter;
+
+ double deloadWeight(String id, double from) {
+ final step = progressStep[id] ?? fromDisplayWeight(weightStep);
+ if (isAssisted(id)) return from + step;
+ final grid = weightStep;
+ final shown = toDisplayWeight(from);
+ var next = (shown * 0.9 / grid).round() * grid;
+ if (next >= shown) next = shown - grid;
+ return _round3(fromDisplayWeight(math.max(0.0, next)));
+ }
+
+ ({double weightKg, int reps, bool up, bool deload})? nextTarget(String id) {
if (modeOf(id).isNotEmpty) return null;
final last = lastSetsFor(id).where((l) => l.counts).toList();
if (last.isEmpty) return null;
final reps = last.first.reps;
if (reps <= 0) return null;
final hit = last.every((l) => l.reps >= reps);
- if (isRepsOnly(id)) return (weightKg: 0, reps: hit ? reps + 1 : reps, up: hit);
- final top = last.map((l) => l.weight).reduce(math.max);
+ if (isRepsOnly(id)) return (weightKg: 0, reps: hit ? reps + 1 : reps, up: hit, deload: false);
final step = progressStep[id] ?? fromDisplayWeight(weightStep);
- return (weightKg: hit ? top + step : top, reps: reps, up: hit);
+ final assisted = isAssisted(id);
+ final load = assisted ? last.map((l) => l.weight).reduce(math.min) : last.map((l) => l.weight).reduce(math.max);
+ if (!hit && needsDeload(id)) return (weightKg: deloadWeight(id, load), reps: reps, up: false, deload: true);
+ if (assisted) return (weightKg: hit ? math.max(0.0, load - step) : load, reps: reps, up: hit, deload: false);
+ return (weightKg: hit ? load + step : load, reps: reps, up: hit, deload: false);
}
String? nextTargetLabel(String id) {