Self-hosted fitness tracker. Log workouts, track nutrition, and monitor progress. Docker deployment, mobile-friendly.
Dock the rest timer below the buttons on every Gym Mode screen (#193) (#198)
Carter769c890bd155
diff --git a/mobile/src/components/workouts/GymModeWorkout.tsx b/mobile/src/components/workouts/GymModeWorkout.tsxindex eb125d7..fa556fb 100644--- a/mobile/src/components/workouts/GymModeWorkout.tsx+++ b/mobile/src/components/workouts/GymModeWorkout.tsx@@ -157,6 +157,9 @@ export function GymModeWorkout() {<Animated.View exiting={FadeOut.duration(160)} style={{ position: 'absolute', top: 0, left: 0, right: 0, bottom: 0, zIndex: 60 }}><SafeAreaView edges={['top', 'left', 'right']} style={{ flex: 1 }} className="bg-surface-base">{children}+ {/* Docked in-flow below every phase's bottom actions so it never covers them; owns+ the bottom safe-area inset while shown. */}+ <RestTimerBanner /><ConfirmSheetopen={confirmFinish}icon={Flag}@@ -182,9 +185,6 @@ export function GymModeWorkout() {onClose={() => setShowPicker(false)}/>) : null}- {/* Floating rest banner on the non-logging phases (the logging phase docks its- own). Mirrors web Layout's `gymOpen && gymPhase !== 'exercise'` render. */}- {phase !== 'exercise' ? <RestTimerBanner /> : null}{/* iOS Done bar above the numeric keyboard (the reps/weight NumberFields link it). */}<NumericKeyboardAccessory /></SafeAreaView>@@ -295,7 +295,7 @@ export function GymModeWorkout() {)}</ScrollView>- <View className="gap-2 border-t border-surface-border px-5 pt-4" style={{ paddingBottom: insets.bottom + 16 }}>+ <View className="gap-2 border-t border-surface-border px-5 pt-4" style={{ paddingBottom: restShown ? 16 : insets.bottom + 16 }}><Pressable onPress={() => setShowPicker(true)} className="flex-row items-center justify-center gap-2 rounded-2xl border border-surface-border bg-surface-muted py-3 active:scale-95"><Plus size={16} color={colors.txSecondary} /><Text className="font-sans-semibold text-sm text-tx-secondary">Add Exercise</Text>@@ -406,7 +406,7 @@ export function GymModeWorkout() {) : null}</View></ScrollView>- <View className="border-t border-surface-border px-5 pt-4" style={{ paddingBottom: insets.bottom + 16 }}>+ <View className="border-t border-surface-border px-5 pt-4" style={{ paddingBottom: restShown ? 16 : insets.bottom + 16 }}><Pressable onPress={() => setPhase('exercise')} className="flex-row items-center justify-center gap-2 rounded-2xl bg-brand-500 py-4 active:scale-95"><Play size={20} color="#ffffff" /><Text className="font-sans-bold text-base text-white">Begin Exercise</Text>@@ -584,9 +584,6 @@ export function GymModeWorkout() {)}</View></View>-- {/* docked rest banner */}- <RestTimerBanner docked /></>,)}diff --git a/mobile/src/components/workouts/RestTimerBanner.tsx b/mobile/src/components/workouts/RestTimerBanner.tsxindex 839dae9..b0cfda6 100644--- a/mobile/src/components/workouts/RestTimerBanner.tsx+++ b/mobile/src/components/workouts/RestTimerBanner.tsx@@ -15,10 +15,10 @@ import { useTheme } from '../../theme/useTheme'// (matches the ConfirmSheet/ActionSheet visual language: rounded-top, grabber,// elevated surface — but NOT the Sheet modal, since a rest timer must stay persistent// and non-dimming). A draining line, a big optically-centred countdown with pause/-// resume, and full-width −15/+15/Skip actions (Done when finished). DOCKED in-flow at-// the bottom of the gym set screen; FLOATING (bottom-anchored) over the overview/info-// screens. When minimized the countdown moves to the session-pill chip instead.-export function RestTimerBanner({ docked = false }: { docked?: boolean }) {+// resume, and full-width −15/+15/Skip actions (Done when finished). Docked in-flow as+// the last child of every gym phase, below its bottom actions, so it never covers a+// control. When minimized the countdown is the session-pill chip instead.+export function RestTimerBanner() {const { colors, brand } = useTheme()const insets = useSafeAreaInsets()const restDurationSec = useWorkoutSession((s) => s.restDurationSec)@@ -168,8 +168,5 @@ export function RestTimerBanner({ docked = false }: { docked?: boolean }) {</View>)- // Docked: in-flow last child of the set screen (pushes content up). Floating: anchored- // to the very bottom over the overview/info screens. Both span the full width.- if (docked) return <View className="flex-shrink-0">{panel}</View>- return <View className="absolute bottom-0 left-0 right-0 z-50">{panel}</View>+ return panel}diff --git a/web/e2e/workouts.spec.ts b/web/e2e/workouts.spec.tsindex 55b44ef..339349e 100644--- a/web/e2e/workouts.spec.ts+++ b/web/e2e/workouts.spec.ts@@ -446,6 +446,49 @@ test.describe('Gym Mode', { tag: '@mobile' }, () => {await expect(page.getByRole('button', { name: /completed/i })).toBeVisible({ timeout: 2000 })})+ // #193: the rest panel used to float over Begin Exercise / Start Workout. It is docked+ // in-flow below each phase's CTA now, so it must sit under the button, not over it.+ test('gym mode rest panel sits below Begin Exercise and Start Workout', async ({ page }) => {+ await seedGymSession(page, 'E2E Rest Dock Test', 'Bench Press', [+ { set_number: 1, target_reps: 5, target_weight: 100, actual_reps: 5, actual_weight: 100, completed: false },+ { set_number: 2, target_reps: 5, target_weight: 100, actual_reps: 5, actual_weight: 100, completed: false },+ ])++ await page.goto('/workout/active')+ await page.getByRole('button', { name: /start workout/i }).click()+ await page.getByRole('button', { name: /begin exercise/i }).click()+ await page.getByRole('button', { name: /complete set/i }).click()++ const skip = page.getByRole('button', { name: /^skip$/i })+ await expect(skip).toBeVisible({ timeout: 3000 })+ await expect(skip).toHaveCount(1)++ const expectBelow = async (cta: RegExp) => {+ const ctaBox = await page.getByRole('button', { name: cta }).boundingBox()+ const skipBox = await skip.boundingBox()+ expect(ctaBox).not.toBeNull()+ expect(skipBox).not.toBeNull()+ expect(skipBox!.y).toBeGreaterThanOrEqual(ctaBox!.y + ctaBox!.height)+ }++ // Set screen → exercise info+ await page.getByRole('button', { name: /^info$/i }).click()+ await expect(page.getByRole('button', { name: /begin exercise/i })).toBeVisible({ timeout: 3000 })+ await expect(skip).toHaveCount(1)+ await expectBelow(/begin exercise/i)++ // Exercise info → overview+ await page.getByRole('dialog', { name: 'Workout' }).getByRole('button').first().click()+ await expect(page.getByRole('button', { name: /start workout/i })).toBeVisible({ timeout: 3000 })+ await expect(skip).toHaveCount(1)+ await expectBelow(/start workout/i)++ // Both CTAs stay reachable while resting+ await page.getByRole('button', { name: /start workout/i }).click()+ await page.getByRole('button', { name: /begin exercise/i }).click()+ await expect(skip).toBeVisible({ timeout: 3000 })+ })+test('gym mode restores phase after minimize and reopen', async ({ page }) => {const exId = gymExerciseIdawait page.addInitScript(({ sk, lk, id }: { sk: string; lk: string; id: number }) => {diff --git a/web/src/components/Layout.tsx b/web/src/components/Layout.tsxindex d1e80ff..1c12d68 100644--- a/web/src/components/Layout.tsx+++ b/web/src/components/Layout.tsx@@ -13,7 +13,6 @@ import { fmtClock, formatElapsed, useElapsedSeconds, nameInitial } from '@lyftr/import { useDisplayName } from '../lib/lyftr'import { useSettingsStore, weightShort } from '../stores/settings'import GymModeWorkout from '../pages/GymModeWorkout'-import RestTimerBanner from './RestTimerBanner'import Logo from './Logo'import ErrorBoundary from './ErrorBoundary'@@ -159,7 +158,7 @@ function UserMenu() {export default function Layout() {const { pathname } = useLocation()- const { session, gymOpen, gymPhase } = useWorkoutSession()+ const { session, gymOpen } = useWorkoutSession()const { settings } = useSettingsStore()const wUnit = weightShort(settings.weight_unit)// The one condition that decides whether the gym overlay is covering the app.@@ -198,12 +197,6 @@ export default function Layout() {{/* Gym mode overlay — rendered at root so it persists across routes */}{gymOverlayUp && <GymModeWorkout wUnit={wUnit} />}- {/* Rest timer floating panel — only INSIDE the workout, on the gym overview /- exercise-info screens. The set screen docks its own copy (pushes content up),- and when the workout is minimized the countdown shows as a chip in the session- pill (ActiveSessionBar) rather than a panel following you around the app. */}- {gymOpen && gymPhase !== 'exercise' && <RestTimerBanner />}-{/* Active session pill floats above bottom nav */}<div className="sticky bottom-0 z-50 relative"><ActiveSessionBar />diff --git a/web/src/components/RestTimerBanner.tsx b/web/src/components/RestTimerBanner.tsxindex 89353e2..ed9eeae 100644--- a/web/src/components/RestTimerBanner.tsx+++ b/web/src/components/RestTimerBanner.tsx@@ -7,12 +7,12 @@ import { IconButton } from './ui'// Hevy/Strong-style rest panel: a thin draining progress line, a big centred// countdown with a pause/resume toggle, and full-width −15/+15/Skip actions.-// Shown only INSIDE the workout — DOCKED in-flow at the bottom of the gym set screen-// (pushes the set content up instead of covering it) and FLOATING above the gym-// overview/exercise-info screens. When the workout is minimized the countdown moves-// to a compact chip in the session pill (see Layout's ActiveSessionBar) instead of-// following you around the app. Haptics/sound are left to a future native app.-export default function RestTimerBanner({ docked = false }: { docked?: boolean }) {+// Shown only INSIDE the workout — docked in-flow as the last child of every gym phase,+// below that phase's bottom actions, so it pushes content up and never covers a control.+// When the workout is minimized the countdown moves to a compact chip in the session+// pill (see Layout's ActiveSessionBar) instead of following you around the app.+// Haptics/sound are left to a future native app.+export default function RestTimerBanner() {const {restEndsAt, restDurationSec, restPausedRemainingMs, restExIdx, restSetIdx,session, adjustRest, clearRest, pauseRest, resumeRest,@@ -121,19 +121,11 @@ export default function RestTimerBanner({ docked = false }: { docked?: boolean }</>)- // Docked: an in-flow block at the bottom of the gym set column, so the flex- // layout pushes the set content up above it (nothing is covered).- if (docked) {- return (- <div className="flex-shrink-0 bg-surface-raised border-t border-surface-border animate-slide-up">- <div className="max-w-md mx-auto">{body}</div>- </div>- )- }- // Floating: above the tab bar on every other screen (e.g. gym minimized).+ // In-flow block at the bottom of the gym phase column, so the flex layout pushes+ // the content up above it (nothing is covered).return (- <div className="fixed bottom-24 inset-x-3 z-[70] mx-auto max-w-md animate-slide-up">- <div className="rounded-2xl border border-surface-border bg-surface-raised overflow-hidden shadow-lg">{body}</div>+ <div className="flex-shrink-0 bg-surface-raised border-t border-surface-border animate-slide-up">+ <div className="max-w-md mx-auto">{body}</div></div>)}diff --git a/web/src/components/ui/Toast.tsx b/web/src/components/ui/Toast.tsxindex 3899f12..d567368 100644--- a/web/src/components/ui/Toast.tsx+++ b/web/src/components/ui/Toast.tsx@@ -27,9 +27,9 @@ const VARIANTS: Record<ToastVariant, { border: string; chip: string; icon: strinerror: { border: 'border-error-500/20', chip: 'bg-error-500/10 border-error-500/20', icon: 'text-error-400' },}-// A dismissible floating toast — the app's shared transient notification. Docks in-// the same bottom slot as the floating RestTimerBanner (bottom-24 clears the nav);-// callers that fire it after a session ends don't collide with session-gated UI.+// A dismissible floating toast — the app's shared transient notification. Sits at+// bottom-24 to clear the nav; callers that fire it after a session ends don't+// collide with session-gated UI.export default function Toast({ title, description, icon: Icon, variant = 'default', onClick, onDismiss, autoDismissMs = 4000 }: Props) {// Armed once on mount — parent re-renders must not extend the window (0 disables).useEffect(() => {diff --git a/web/src/pages/GymModeWorkout.tsx b/web/src/pages/GymModeWorkout.tsxindex e30fbf1..5f2892e 100644--- a/web/src/pages/GymModeWorkout.tsx+++ b/web/src/pages/GymModeWorkout.tsx@@ -179,11 +179,12 @@ export default function GymModeWorkout({ wUnit }: GymModeWorkoutProps) {)}- // The two confirms, declared once. Each phase below returns its own tree, and all- // three ended with a byte-identical copy of this pair — nothing in it varies by- // phase, so it was three places to forget the same change.- const confirms = (+ // Closes every phase: the docked rest panel (in-flow, below the phase's bottom+ // actions, null when no rest is active) plus the two portalled confirms. Each phase+ // below returns its own tree, and nothing here varies by phase.+ const trailing = (<>+ <RestTimerBanner /><ConfirmSheetopen={confirmFinish}icon={Flag}@@ -311,7 +312,7 @@ export default function GymModeWorkout({ wUnit }: GymModeWorkoutProps) {)}</div>- {confirms}+ {trailing}</div>)}@@ -468,7 +469,7 @@ export default function GymModeWorkout({ wUnit }: GymModeWorkoutProps) {</button></div>- {confirms}+ {trailing}</div>)}@@ -730,11 +731,7 @@ export default function GymModeWorkout({ wUnit }: GymModeWorkoutProps) {</div></div>- {/* Rest timer — docked here (in-flow, last child) so it pushes the set- content up instead of covering it. Renders null when no rest is active. */}- <RestTimerBanner docked />-- {confirms}+ {trailing}</div>)}