From 3428daeb5472fb23ba4e17c852aa03738a78406f Mon Sep 17 00:00:00 2001 From: Duarte Santos Date: Mon, 20 Jul 2026 20:21:46 +0200 Subject: [PATCH] =?UTF-8?q?Workout-Ende:=20Finish/Continue-Popup=20nach=20?= =?UTF-8?q?letztem=20Satz,=20dezenter=20Finish-Button=20mit=20x/y-Z=C3=A4h?= =?UTF-8?q?ler?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Beim Abhaken des letzten Satzes der letzten Übung erscheint ein Popup 'That's the whole workout!' mit 'Finish workout' und 'Continue workout' (weitermachen + neue Übung hinzufügen). Der Finish-Button während des Trainings ist jetzt dezent ('Finish workout early · x/y exercises') und wird erst prominent, wenn alle Übungen erledigt sind. --- frontend/src/sheets.jsx | 17 +++++++++++++++-- frontend/src/views/Workout.jsx | 17 ++++++++++++++--- 2 files changed, 29 insertions(+), 5 deletions(-) diff --git a/frontend/src/sheets.jsx b/frontend/src/sheets.jsx index 9ffbf58..42ce56a 100644 --- a/frontend/src/sheets.jsx +++ b/frontend/src/sheets.jsx @@ -411,7 +411,7 @@ function TopWeight({ entryIdx, close }) { }) close() if (advance && unitDone) { - if (isLastUnit) finishWorkout() + if (isLastUnit) workoutCompleteSheet() // whole workout done → finish/continue prompt else update(s => { s.active.cur = units[unitIdx + 1][0] }) } else toast('Tracked — next time starts at ' + fmtNum(S().exWeights[entry.id].w) + ' ' + st.unit + ' 📈') } @@ -421,13 +421,26 @@ function TopWeight({ entryIdx, close }) {
setV(e.target.value)} />{st.unit}
{prevBest > 0 ?
Previous best: {fmtNum(prevBest)} {st.unit}{maxSet > prevBest && — new record! 🏆}
:
} {unitDone ? <> - +
: } } export const topWeightSheet = entryIdx => ui().openSheet(close => ) +// Shown when the last exercise's last set is checked — finish, or keep going. +function WorkoutComplete({ close }) { + return
+
🎉
+

That's the whole workout!

+
Every exercise done — great work. Finish up, or keep going and add another exercise.
+ +
+ +
+} +export const workoutCompleteSheet = () => ui().openSheet(close => , { kind: 'center' }) + function FinishSummary({ w, prs, close }) { const st = useStore(s => s.S) return
diff --git a/frontend/src/views/Workout.jsx b/frontend/src/views/Workout.jsx index 80623e2..9ca2565 100644 --- a/frontend/src/views/Workout.jsx +++ b/frontend/src/views/Workout.jsx @@ -7,7 +7,7 @@ import { effectiveRoutine, lastEntryFor, bestWeightFor, buildSets, setsDoneActiv import { fmtNum, fmtDate, todayISO, DAYN } from '../lib/format.js' import { beep, vibrate } from '../lib/sound.js' import Media from '../components/Media.jsx' -import { startFlow, exercisePicker, exConfigSheet, exerciseDetailSheet, topWeightSheet, finishWorkout } from '../sheets.jsx' +import { startFlow, exercisePicker, exConfigSheet, exerciseDetailSheet, topWeightSheet, finishWorkout, workoutCompleteSheet } from '../sheets.jsx' /* ---------- start chooser (no active workout) ---------- */ function StartChooser() { @@ -121,7 +121,8 @@ function ActiveWorkout() { const toggle = (idx, i) => { const cardioEntry = isCardio(A.entries[idx].id) - let askTop = false, exJustDone = false + const isLastUnit = unitIdx >= units.length - 1 + let askTop = false, exJustDone = false, workoutDone = false mutEntry(idx, e => { e.sets[i].done = !e.sets[i].done if (e.sets[i].done) { @@ -130,10 +131,14 @@ function ActiveWorkout() { const unitDone = unit.every(ui => (ui === idx ? e : A.entries[ui]).sets.every(x => x.done)) if (isLastExInUnit && !unitDone) startRest(S.restSec) else if (unitDone) stopRest() + if (unitDone && isLastUnit) workoutDone = true // last exercise's last set → done if (e.sets.every(x => x.done)) { exJustDone = true; if (!cardioEntry && !e.asked) { e.asked = true; askTop = true } } } }) + // non-cardio: topWeight first (it chains into the finish/continue prompt on the last unit). + // cardio or already-confirmed: go straight to the prompt. if (askTop) topWeightSheet(idx) + else if (workoutDone) workoutCompleteSheet() else if (exJustDone && cardioEntry) useUI.getState().toast('Cardio logged 🏃') } @@ -172,7 +177,13 @@ function ActiveWorkout() { s.active.cur = s.active.entries.length - 1 })))}>+ Add exercise
- + {(() => { + const exDone = A.entries.filter(e => e.sets.length && e.sets.every(s => s.done)).length + const allDone = A.entries.length > 0 && exDone === A.entries.length + return + })()}
}