@@ -2,7 +2,7 @@ import { useEffect, useRef, useState } from 'react'
22import { ActivityIndicator , Platform , Pressable , ScrollView , Text , View } from 'react-native'
33import { router , useLocalSearchParams } from 'expo-router'
44import {
5- AlertCircle , ArrowLeft , CalendarDays , Clock , Dumbbell , FileText , Plus , Zap ,
5+ AlertCircle , ArrowLeft , CalendarDays , Clock , Dumbbell , FileText , Plus , Timer , Zap ,
66} from 'lucide-react-native'
77import type { LucideIcon } from 'lucide-react-native'
88import {
@@ -11,15 +11,15 @@ import {
1111import { AppText , Button , DateInput , EmptyState , Field , IconButton , Label , Screen } from '../../../../src/components/ui'
1212import { ExerciseFormCard } from '../../../../src/components/workouts/ExerciseFormCard'
1313import { DurationField } from '../../../../src/components/workouts/DurationField'
14+ import { RestPicker } from '../../../../src/components/workouts/RestPicker'
1415import { ExercisePicker } from '../../../../src/components/workouts/ExercisePicker'
1516import { KeyboardDoneBar } from '../../../../src/components/workouts/KeyboardDoneBar'
1617import { client , useSettingsStore } from '../../../../src/lib/lyftr'
1718import { useTheme } from '../../../../src/theme/useTheme'
1819
19- // Edit-form shape. Unlike web (which leaves the date immutable) mobile lets you
20- // correct the workout's date here too — so `date` (local YYYY-MM-DD) joins the form.
21- // NO rest_seconds (the edit screen doesn't touch rest). Weights/duration in DISPLAY
22- // units; converted on submit.
20+ // Edit-form shape. Mobile is a superset of web's edit form: it lets you correct the
21+ // workout's `date` (local YYYY-MM-DD) and per-exercise `rest_seconds` too. Weights/
22+ // duration in DISPLAY units; converted on submit.
2323interface WorkoutFormData {
2424 name : string
2525 notes : string
@@ -28,6 +28,7 @@ interface WorkoutFormData {
2828 exercises : {
2929 exercise_id : number
3030 notes : string
31+ rest_seconds : number
3132 sets : { set_number : number ; reps : number ; weight : number } [ ]
3233 } [ ]
3334}
@@ -109,6 +110,7 @@ export default function EditWorkout() {
109110 exercises : ( workout . exercises || [ ] ) . map ( ( ex ) => ( {
110111 exercise_id : ex . exercise_id ,
111112 notes : ex . notes || '' ,
113+ rest_seconds : ex . rest_seconds ?? ( settings . rest_seconds_default ?? 90 ) ,
112114 // Web parity: unrounded lbsToDisplay prefill (kg users see long decimals).
113115 sets : ( ex . sets || [ ] ) . map ( ( s ) => ( {
114116 set_number : s . set_number ,
@@ -132,7 +134,12 @@ export default function EditWorkout() {
132134 ...prev ,
133135 exercises : [
134136 ...prev . exercises ,
135- { exercise_id : exercise . id , notes : '' , sets : [ { set_number : 1 , reps : 0 , weight : 0 } ] } ,
137+ {
138+ exercise_id : exercise . id ,
139+ notes : '' ,
140+ rest_seconds : settings . rest_seconds_default ?? 90 ,
141+ sets : [ { set_number : 1 , reps : 0 , weight : 0 } ] ,
142+ } ,
136143 ] ,
137144 } ) )
138145 setShowPicker ( false )
@@ -166,6 +173,14 @@ export default function EditWorkout() {
166173 } )
167174 }
168175
176+ const setExRest = ( exIdx : number , secs : number ) => {
177+ setFormData ( ( prev ) => {
178+ const exercises = [ ...prev . exercises ]
179+ exercises [ exIdx ] = { ...exercises [ exIdx ] , rest_seconds : secs }
180+ return { ...prev , exercises }
181+ } )
182+ }
183+
169184 const updateExNotes = ( exIdx : number , text : string ) => {
170185 setFormData ( ( prev ) => {
171186 const exercises = [ ...prev . exercises ]
@@ -316,7 +331,6 @@ export default function EditWorkout() {
316331 ) }
317332
318333 < View className = "gap-4" >
319- { /* No RestPicker footer here — web's edit form doesn't touch rest_seconds. */ }
320334 { formData . exercises . map ( ( workoutEx , exIdx ) => (
321335 < ExerciseFormCard
322336 key = { exIdx }
@@ -331,6 +345,15 @@ export default function EditWorkout() {
331345 onRemoveSet = { ( setIdx ) => removeSet ( exIdx , setIdx ) }
332346 onUpdateSet = { ( setIdx , field , v ) => updateSet ( exIdx , setIdx , field , v ) }
333347 inputAccessoryViewID = { KEYPAD_DONE_ID }
348+ footer = {
349+ < View >
350+ < View className = "mb-1 flex-row items-center gap-1.5" >
351+ < Timer size = { 13 } color = { accent } />
352+ < Label > Rest between sets</ Label >
353+ </ View >
354+ < RestPicker value = { workoutEx . rest_seconds ?? 90 } onChange = { ( secs ) => setExRest ( exIdx , secs ) } />
355+ </ View >
356+ }
334357 />
335358 ) ) }
336359 { /* Thumb-zone duplicate of Add Exercise: the header button scrolls away
0 commit comments