diff --git a/EditWorkout.tsx b/EditWorkout.tsx index 7271bcf..c1bd5f1 100644 --- a/EditWorkout.tsx +++ b/EditWorkout.tsx @@ -138,14 +138,16 @@ export default function EditWorkout() { onSubmitEditing={() => setsRef.current?.focus()} /> )} - minutesRef.current?.focus()} - /> + {!!settings.showSets && ( + minutesRef.current?.focus()} + /> + )} {!!settings.alarm && ( <> { + setShowSets(enabled); + if (enabled) toast('Show maximum sets for workouts.', 4000); + else toast('Stopped showing maximum sets for workouts.', 4000); + }, + [toast], + ); + const switches: Input[] = [ {name: 'Rest timers', value: alarm, onChange: changeAlarmEnabled}, {name: 'Vibrate', value: vibrate, onChange: changeVibrate}, @@ -151,6 +163,7 @@ export default function SettingsPage() { {name: 'Show unit', value: showUnit, onChange: changeUnit}, {name: 'Show steps', value: steps, onChange: changeSteps}, {name: 'Show date', value: showDate, onChange: changeShowDate}, + {name: 'Show sets', value: showSets, onChange: changeShowSets}, ]; return ( diff --git a/StartPlan.tsx b/StartPlan.tsx index 9189e18..26d3f89 100644 --- a/StartPlan.tsx +++ b/StartPlan.tsx @@ -125,11 +125,14 @@ export default function StartPlan() { const getDescription = useCallback( (countName: string) => { const count = counts?.find(c => c.name === countName); + console.log(`${StartPlan.name}:`, {count, countName}); if (!distinctSets) return; const distinct = distinctSets.find(d => d.name === countName); - return `${count?.total || 0} / ${distinct?.sets}`; + console.log(`${StartPlan.name}:`, {distinct}); + if (settings.showSets) return `${count?.total || 0} / ${distinct?.sets}`; + return count?.total || '0'; }, - [counts, distinctSets], + [counts, distinctSets, settings.showSets], ); return ( diff --git a/WorkoutItem.tsx b/WorkoutItem.tsx index 814140f..ad001e6 100644 --- a/WorkoutItem.tsx +++ b/WorkoutItem.tsx @@ -37,9 +37,12 @@ export default function WorkoutItem({ const description = useMemo(() => { const seconds = item.seconds?.toString().padStart(2, '0'); - if (settings.alarm) return `${item.sets} x ${item.minutes || 0}:${seconds}`; + if (settings.alarm && settings.showSets) + return `${item.sets} x ${item.minutes || 0}:${seconds}`; + else if (settings.alarm && !settings.showSets) + return `${item.minutes || 0}:${seconds}`; return `${item.sets}`; - }, [item, settings.alarm]); + }, [item, settings]); return ( <> diff --git a/db.ts b/db.ts index b339be5..fa195b2 100644 --- a/db.ts +++ b/db.ts @@ -28,9 +28,9 @@ const migrations = [ CREATE TABLE IF NOT EXISTS settings ( minutes INTEGER NOT NULL DEFAULT 3, seconds INTEGER NOT NULL DEFAULT 30, - alarm BOOLEAN NOT NULL DEFAULT false, - vibrate BOOLEAN NOT NULL DEFAULT true, - predict BOOLEAN NOT NULL DEFAULT true, + alarm BOOLEAN NOT NULL DEFAULT 0, + vibrate BOOLEAN NOT NULL DEFAULT 1, + predict BOOLEAN NOT NULL DEFAULT 1, sets INTEGER NOT NULL DEFAULT 3 ) `, @@ -42,16 +42,16 @@ const migrations = [ ) `, ` - ALTER TABLE sets ADD COLUMN hidden DEFAULT false + ALTER TABLE sets ADD COLUMN hidden DEFAULT 0 `, ` - ALTER TABLE settings ADD COLUMN notify DEFAULT false + ALTER TABLE settings ADD COLUMN notify DEFAULT 0 `, ` ALTER TABLE sets ADD COLUMN image TEXT NULL `, ` - ALTER TABLE settings ADD COLUMN images BOOLEAN DEFAULT false + ALTER TABLE settings ADD COLUMN images BOOLEAN DEFAULT 0 `, ` SELECT * FROM settings LIMIT 1 @@ -75,7 +75,7 @@ const migrations = [ ALTER TABLE sets ADD COLUMN seconds INTEGER NOT NULL DEFAULT 30 `, ` - ALTER TABLE settings ADD COLUMN showUnit BOOLEAN DEFAULT true + ALTER TABLE settings ADD COLUMN showUnit BOOLEAN DEFAULT 1 `, ` ALTER TABLE sets ADD COLUMN steps TEXT NULL @@ -115,6 +115,9 @@ const migrations = [ ` ALTER TABLE settings ADD COLUMN theme TEXT `, + ` + ALTER TABLE settings ADD COLUMN showSets BOOLEAN DEFAULT 1 + `, ]; export let db: SQLiteDatabase; diff --git a/settings.ts b/settings.ts index 5f81959..596d2c1 100644 --- a/settings.ts +++ b/settings.ts @@ -11,4 +11,5 @@ export default interface Settings { date?: string; showDate: number; theme?: 'system' | 'dark' | 'light'; + showSets?: number; }