@composable-os/pack-programs 0.1.0-beta.10 → 0.1.0-beta.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/authoring.d.ts +4 -1
- package/dist/authoring.js +65 -5
- package/dist/blocks/programs-builder/program-builder.d.ts +12 -3
- package/dist/blocks/programs-builder/program-builder.js +16 -3
- package/dist/blocks/programs-class-today/class-today.d.ts +1 -1
- package/dist/blocks/programs-coach-client/coach-client.d.ts +1 -1
- package/dist/blocks/programs-history/history.d.ts +11 -0
- package/dist/blocks/programs-history/history.js +84 -0
- package/dist/blocks/programs-native-class-today/class-today-screen.js +3 -2
- package/dist/blocks/programs-native-coach-client/coach-client-screen.js +2 -2
- package/dist/blocks/programs-native-history/history-screen.d.ts +11 -0
- package/dist/blocks/programs-native-history/history-screen.js +98 -0
- package/dist/blocks/programs-native-progress/progress-screen.js +4 -4
- package/dist/blocks/programs-native-session/session-screen.d.ts +6 -2
- package/dist/blocks/programs-native-session/session-screen.js +214 -88
- package/dist/blocks/programs-native-today/today-screen.d.ts +1 -1
- package/dist/blocks/programs-native-today/today-screen.js +22 -3
- package/dist/blocks/programs-session/session-view.d.ts +7 -3
- package/dist/blocks/programs-session/session-view.js +139 -81
- package/dist/blocks/programs-today/today.d.ts +1 -1
- package/dist/client/index.d.ts +367 -12
- package/dist/client/index.js +393 -12
- package/dist/client/logging.d.ts +289 -0
- package/dist/client/logging.js +558 -0
- package/dist/index.d.ts +152 -6
- package/dist/index.js +141 -6
- package/dist/layout.d.ts +3 -1
- package/dist/layout.js +10 -2
- package/dist/tools.d.ts +25 -2
- package/dist/tools.js +269 -37
- package/package.json +3 -3
|
@@ -1,108 +1,169 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
// One session to do, for the mobile app (stage 41):
|
|
3
|
-
//
|
|
2
|
+
// One session to do, for the mobile app (stage 41): the workout logger. Each set is a row with its
|
|
3
|
+
// numbers and a tick; one tap logs it with the numbers shown (a suggestion, greyed, until the
|
|
4
|
+
// person types), even with the keyboard open and a number half typed. A tick of a done set takes
|
|
5
|
+
// it back; typing over a done set's numbers changes it. Effort (RPE) is an optional tap. Ticking
|
|
6
|
+
// a set starts the rest timer (the set's rest time, else `defaultRest`); a timed set has a
|
|
7
|
+
// start/stop timer that fills its seconds and ticks it; an exercise folds away when its last set
|
|
8
|
+
// is ticked; the sets done show at the top; finishing says what was not ticked. A member's own
|
|
4
9
|
// session, a class's (choose the level you take), or a coach logging for a client (`personId`).
|
|
5
|
-
//
|
|
6
|
-
//
|
|
7
|
-
//
|
|
8
|
-
|
|
10
|
+
//
|
|
11
|
+
// Every change shows at once and goes to the host through the pack's one queue
|
|
12
|
+
// (`useSessionLog`): in order, retried when it fails, flushed when the app goes to the background
|
|
13
|
+
// and when the screen is left, and it says when something could not be saved. The app gives the
|
|
14
|
+
// buzz at the end of a rest (`onRestDone`, for example `expo-haptics`), so this block needs no
|
|
15
|
+
// device package. It holds no rules: targets, whose session it is and what may be logged are the
|
|
16
|
+
// host's, and a set it refuses is shown with its reason.
|
|
17
|
+
import { describeSet, describeSets, EFFORTS, exerciseDone, exerciseKey, levelExercises, levelLabel, levelOf, notTickedText, progressOf, restAfter, secondsBetween, setKey, setRow, timed, unsaved, weighed, } from "@composable-os/pack-programs/client";
|
|
9
18
|
import { useEffect, useState } from "react";
|
|
10
|
-
import { StyleSheet,
|
|
19
|
+
import { AppState, Pressable, StyleSheet, TextInput, View } from "react-native";
|
|
11
20
|
import { Button } from "../native-base/button.js";
|
|
12
|
-
import { Field } from "../native-base/field.js";
|
|
13
21
|
import { Screen } from "../native-base/screen.js";
|
|
22
|
+
import { Text } from "../native-base/text.js";
|
|
14
23
|
import { theme } from "../native-base/theme.js";
|
|
15
|
-
export function SessionScreen({ programs, sessionId, personId, onRestDone, }) {
|
|
16
|
-
const
|
|
24
|
+
export function SessionScreen({ programs, sessionId, personId, onRestDone, defaultRest = 90, }) {
|
|
25
|
+
const { detail, log, state } = programs.useSessionLog({
|
|
26
|
+
sessionId,
|
|
27
|
+
...(personId ? { personId } : {}),
|
|
28
|
+
});
|
|
17
29
|
const mark = programs.useMarkSession();
|
|
18
|
-
const [
|
|
30
|
+
const [now, setNow] = useState(Date.now());
|
|
31
|
+
const [restUntil, setRestUntil] = useState(null);
|
|
32
|
+
const [clock, setClock] = useState(null);
|
|
33
|
+
const [finishing, setFinishing] = useState(null);
|
|
34
|
+
const [said, setSaid] = useState(null);
|
|
35
|
+
// Nothing waits when the app goes to the background or the screen is left: what is queued is
|
|
36
|
+
// sent now (and, if it cannot be, it stays queued and the screen says so when it is back).
|
|
19
37
|
useEffect(() => {
|
|
20
|
-
|
|
38
|
+
const sub = AppState.addEventListener("change", (next) => {
|
|
39
|
+
if (next !== "active")
|
|
40
|
+
void log.flush();
|
|
41
|
+
});
|
|
42
|
+
return () => {
|
|
43
|
+
sub.remove();
|
|
44
|
+
void log.flush();
|
|
45
|
+
};
|
|
46
|
+
}, [log]);
|
|
47
|
+
// One clock for the rest and a timed set, from timestamps, so a pause in the background
|
|
48
|
+
// does not drift.
|
|
49
|
+
const ticking = restUntil !== null || clock !== null;
|
|
50
|
+
useEffect(() => {
|
|
51
|
+
if (!ticking)
|
|
21
52
|
return undefined;
|
|
22
|
-
|
|
23
|
-
|
|
53
|
+
const timer = setInterval(() => setNow(Date.now()), 250);
|
|
54
|
+
return () => clearInterval(timer);
|
|
55
|
+
}, [ticking]);
|
|
56
|
+
const restFor = restUntil === null ? null : secondsBetween(now, restUntil);
|
|
57
|
+
useEffect(() => {
|
|
58
|
+
if (restUntil !== null && now >= restUntil) {
|
|
59
|
+
setRestUntil(null);
|
|
24
60
|
onRestDone?.();
|
|
25
|
-
return undefined;
|
|
26
61
|
}
|
|
27
|
-
|
|
28
|
-
return () => clearTimeout(timer);
|
|
29
|
-
}, [rest, onRestDone]);
|
|
62
|
+
}, [now, restUntil, onRestDone]);
|
|
30
63
|
if (detail.isPending)
|
|
31
|
-
return (_jsx(Screen, { title: "Session", children: _jsx(Text, { children: "Loading\u2026" }) }));
|
|
64
|
+
return (_jsx(Screen, { title: "Session", children: _jsx(Text, { tone: "muted", accessibilityRole: "progressbar", children: "Loading\u2026" }) }));
|
|
32
65
|
if (!detail.data)
|
|
33
|
-
return (_jsx(Screen, { title: "Session", children: _jsx(Text, { children: "We could not load this session." }) }));
|
|
34
|
-
const { session, exercises
|
|
66
|
+
return (_jsx(Screen, { title: "Session", children: _jsx(Text, { tone: "danger", accessibilityRole: "alert", children: "We could not load this session. Check the connection and try again." }) }));
|
|
67
|
+
const { session, exercises } = detail.data;
|
|
35
68
|
const plan = session.plan;
|
|
36
69
|
const names = new Map(exercises.map((e) => [e.id, e]));
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
70
|
+
const progress = progressOf(state);
|
|
71
|
+
const waiting = unsaved(state);
|
|
72
|
+
const startRest = (target) => {
|
|
73
|
+
setRestUntil(Date.now() + restAfter(target, defaultRest) * 1000);
|
|
74
|
+
setNow(Date.now());
|
|
75
|
+
};
|
|
76
|
+
const finish = async (anyway) => {
|
|
77
|
+
setSaid(null);
|
|
78
|
+
const missing = notTickedText(state, (id) => names.get(id)?.name);
|
|
79
|
+
if (missing && !anyway) {
|
|
80
|
+
setFinishing(missing);
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
setFinishing(null);
|
|
84
|
+
if (!(await log.flush())) {
|
|
85
|
+
setSaid("Some sets are not saved yet. They stay on this phone and are sent when the connection is back: try finishing again then.");
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
if (session.kind !== "personal") {
|
|
89
|
+
setSaid("All your sets are saved.");
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
try {
|
|
93
|
+
await mark.mutateAsync({ sessionId, state: "done" });
|
|
94
|
+
detail.refetch?.();
|
|
95
|
+
}
|
|
96
|
+
catch (e) {
|
|
97
|
+
setSaid(e.message ?? "We could not mark the session done.");
|
|
98
|
+
}
|
|
99
|
+
};
|
|
100
|
+
return (_jsxs(Screen, { title: session.name ?? "Session", children: [_jsx(Text, { style: styles.muted, children: [session.programTitle, session.classTypeName, session.date].filter(Boolean).join(" · ") }), _jsxs(View, { accessibilityRole: "progressbar", style: styles.progress, children: [_jsxs(Text, { style: styles.heading, children: [progress.done, " of ", progress.planned, " sets"] }), _jsx(View, { style: styles.track, children: _jsx(View, { style: [
|
|
101
|
+
styles.fill,
|
|
102
|
+
{
|
|
103
|
+
width: `${progress.planned ? Math.round((progress.done / progress.planned) * 100) : 0}%`,
|
|
104
|
+
},
|
|
105
|
+
] }) })] }), waiting && state.failure ? (_jsxs(View, { style: styles.warning, accessibilityLiveRegion: "polite", children: [_jsxs(Text, { style: styles.warningText, children: [waiting === 1 ? "1 set is" : `${waiting} sets are`, " not saved yet. ", state.failure] }), _jsx(Button, { quiet: true, label: "Try now", onPress: () => void log.flush() })] })) : null, restFor !== null ? (_jsxs(View, { style: styles.timer, accessibilityRole: "timer", accessibilityLiveRegion: "polite", children: [_jsxs(Text, { style: styles.timerText, children: [restFor, "s rest"] }), _jsx(Button, { quiet: true, label: "+30s", onPress: () => setRestUntil((t) => (t ?? Date.now()) + 30_000) }), _jsx(Button, { quiet: true, label: "Skip", onPress: () => setRestUntil(null) })] })) : null, plan?.warmup?.text ? _jsx(Text, { children: plan.warmup.text }) : null, (plan?.blocks ?? []).map((block) => (_jsxs(View, { style: styles.block, children: [_jsxs(Text, { style: styles.heading, children: ["Block ", block.label, block.rounds ? ` · ${block.rounds} rounds` : ""] }), (block.notes ?? []).map((n) => (_jsx(Text, { style: styles.muted, children: n.text }, n.text))), block.items.map((item) => (_jsx(NativeItem, { item: item, names: names, log: log, state: state, now: now, clock: clock, onClock: (next) => {
|
|
106
|
+
setClock(next);
|
|
107
|
+
setNow(Date.now());
|
|
108
|
+
}, onTicked: startRest }, item.label)))] }, block.label))), finishing ? (_jsxs(View, { style: styles.warning, children: [_jsxs(Text, { style: styles.warningText, children: ["Not ticked: ", finishing, "."] }), _jsxs(View, { style: styles.row, children: [_jsx(Button, { label: "Finish anyway", onPress: () => void finish(true) }), _jsx(Button, { quiet: true, label: "Keep going", onPress: () => setFinishing(null) })] })] })) : null, said ? _jsx(Text, { accessibilityLiveRegion: "polite", children: said }) : null, session.state === "done" ? (_jsx(Text, { style: styles.heading, children: "Done" })) : (_jsx(Button, { label: "Finish session", busy: mark.isPending, onPress: () => void finish(false) }))] }));
|
|
45
109
|
}
|
|
46
|
-
function NativeItem({
|
|
47
|
-
const taken = logged.find((l) => l.item === item.label)?.level ?? null;
|
|
48
|
-
const [chosen, setChosen] = useState(taken);
|
|
110
|
+
function NativeItem({ item, names, log, state, now, clock, onClock, onTicked, }) {
|
|
49
111
|
const levels = item.kind === "levels" ? item.levels : [];
|
|
50
|
-
const
|
|
51
|
-
const
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
s.seconds !== null ? `${s.seconds}s` : null,
|
|
58
|
-
s.load !== null ? `${s.load}kg` : null,
|
|
59
|
-
]
|
|
60
|
-
.filter((x) => x !== null)
|
|
61
|
-
.join(" "))
|
|
62
|
-
.join(", ")] })) : null, p.sets.map((set, i) => (_jsx(NativeSet
|
|
63
|
-
// biome-ignore lint/suspicious/noArrayIndexKey: sets are positions.
|
|
64
|
-
, { programs: programs, sessionId: sessionId, personId: personId, itemLabel: item.label, level: item.kind === "levels" ? level?.level : undefined, exerciseId: p.exercise, setNumber: i + 1, target: set, done: loggedFor(logged, item.label, p.exercise, i + 1), onLogged: onLogged }, i)))] }, p.exercise));
|
|
65
|
-
})] }));
|
|
112
|
+
const chosen = levelOf(state, item.label);
|
|
113
|
+
const level = levels.find((l) => l.level === chosen);
|
|
114
|
+
// Everyone's exercises (beside the levels, if any), then the level's.
|
|
115
|
+
const list = item.kind === "all"
|
|
116
|
+
? item.exercises
|
|
117
|
+
: [...(item.exercises ?? []), ...(level ? levelExercises(level) : [])];
|
|
118
|
+
return (_jsxs(View, { style: styles.item, children: [_jsx(Text, { style: styles.heading, children: item.label }), (item.notes ?? []).map((n) => (_jsx(Text, { style: styles.muted, children: n.text }, n.text))), levels.length > 1 ? (_jsx(View, { style: styles.row, children: levels.map((l) => (_jsx(Button, { quiet: l.level !== level?.level, label: levelLabel(l), onPress: () => log.dispatch({ type: "level", item: item.label, level: l.level }) }, l.level))) })) : null, item.kind === "levels" && !level ? (_jsx(Text, { style: styles.muted, children: "Choose the level you take to log it." })) : null, list.map((p) => (_jsx(NativeExercise, { itemLabel: item.label, exerciseId: p.exercise, targets: p.sets, note: p.note, exercise: names.get(p.exercise), log: log, state: state, now: now, clock: clock, onClock: onClock, onTicked: onTicked }, p.exercise)))] }));
|
|
66
119
|
}
|
|
67
|
-
function
|
|
68
|
-
const
|
|
69
|
-
const
|
|
70
|
-
const
|
|
71
|
-
const
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
120
|
+
function NativeExercise({ itemLabel, exerciseId, targets, note, exercise, log, state, now, clock, onClock, onTicked, }) {
|
|
121
|
+
const folded = exerciseDone(state, itemLabel, exerciseId);
|
|
122
|
+
const [open, setOpen] = useState(false);
|
|
123
|
+
const name = exercise?.name ?? "Exercise";
|
|
124
|
+
const withLoad = weighed(state.exercises[exerciseKey(itemLabel, exerciseId)], exercise?.measure ?? null);
|
|
125
|
+
if (folded && !open) {
|
|
126
|
+
return (_jsxs(Pressable, { accessibilityRole: "button", accessibilityLabel: `${name}, all sets done. Show the sets`, onPress: () => setOpen(true), style: styles.folded, children: [_jsxs(Text, { style: styles.name, children: ["\u2713 ", name] }), _jsxs(Text, { style: styles.muted, children: [targets.length, " sets done"] })] }));
|
|
127
|
+
}
|
|
128
|
+
return (_jsxs(View, { style: styles.exercise, children: [_jsx(Pressable, { accessibilityRole: "button", disabled: !folded, onPress: () => setOpen(false), children: _jsx(Text, { style: styles.name, children: name }) }), _jsx(Text, { style: styles.muted, children: describeSets(targets) }), note ? _jsx(Text, { children: note }) : null, exercise?.last.length ? (_jsxs(Text, { style: styles.muted, children: ["Last time:", " ", exercise.last
|
|
129
|
+
.map((s) => [
|
|
130
|
+
s.reps,
|
|
131
|
+
s.seconds !== null ? `${s.seconds}s` : null,
|
|
132
|
+
s.load !== null ? `${s.load}kg` : null,
|
|
133
|
+
]
|
|
134
|
+
.filter((x) => x !== null)
|
|
135
|
+
.join(" "))
|
|
136
|
+
.join(", ")] })) : null, targets.map((target, i) => (_jsx(NativeSet
|
|
137
|
+
// biome-ignore lint/suspicious/noArrayIndexKey: sets are positions.
|
|
138
|
+
, { itemLabel: itemLabel, exerciseId: exerciseId, setNumber: i + 1, target: target, withLoad: withLoad, log: log, state: state, now: now, clock: clock, onClock: onClock, onTicked: onTicked }, i)))] }));
|
|
139
|
+
}
|
|
140
|
+
function NativeSet({ itemLabel, exerciseId, setNumber, target, withLoad, log, state, now, clock, onClock, onTicked, }) {
|
|
141
|
+
const at = { item: itemLabel, exercise: exerciseId, setNumber };
|
|
142
|
+
const row = setRow(state, itemLabel, exerciseId, setNumber);
|
|
143
|
+
const [effortOpen, setEffortOpen] = useState(false);
|
|
144
|
+
const count = timed(target) ? "seconds" : "reps";
|
|
145
|
+
const key = setKey(itemLabel, exerciseId, setNumber);
|
|
146
|
+
const running = clock?.key === key;
|
|
147
|
+
const field = (name, label, keyboard) => (_jsx(TextInput, { accessibilityLabel: `Set ${setNumber} ${label}`, keyboardType: keyboard,
|
|
148
|
+
// A suggestion is greyed (the placeholder); what the person typed or ticked is the value.
|
|
149
|
+
placeholder: row.suggested ? (row.values[name] ?? label) : label, placeholderTextColor: theme.color.muted, value: row.suggested ? "" : (row.values[name] ?? ""), onChangeText: (text) => log.dispatch({ type: "edit", ...at, field: name, text }), selectTextOnFocus: true, style: [styles.input, row.done ? styles.inputDone : null] }));
|
|
150
|
+
return (_jsxs(View, { style: styles.set, children: [_jsxs(View, { style: styles.setRow, children: [_jsx(Text, { style: styles.setNumber, children: setNumber }), field(count, count === "reps" ? "reps" : "s", "number-pad"), withLoad ? field("load", "kg", "decimal-pad") : null, _jsx(Pressable, { accessibilityRole: "button", accessibilityLabel: row.rpe !== null ? `Set ${setNumber} effort ${row.rpe}` : `Set ${setNumber} effort`, onPress: () => setEffortOpen((o) => !o), style: styles.effort, children: _jsx(Text, { style: row.rpe !== null ? styles.effortSet : styles.muted, children: row.rpe !== null ? `@${row.rpe}` : "RPE" }) }), timed(target) && !row.done ? (_jsx(Pressable, { accessibilityRole: "button", accessibilityLabel: running ? `Stop set ${setNumber}` : `Start set ${setNumber}`, onPress: () => {
|
|
151
|
+
if (!running) {
|
|
152
|
+
onClock({ key, from: Date.now() });
|
|
153
|
+
return;
|
|
154
|
+
}
|
|
155
|
+
onClock(null);
|
|
156
|
+
const seconds = String(secondsBetween(clock?.from ?? Date.now(), Date.now()));
|
|
157
|
+
log.dispatch({ type: "tick", ...at, values: { seconds } });
|
|
158
|
+
onTicked(target);
|
|
159
|
+
}, style: [styles.clock, running ? styles.clockRunning : null], children: _jsx(Text, { style: running ? styles.tickMarkDone : styles.heading, children: running ? `${secondsBetween(clock?.from ?? now, now)}s ■` : "▶" }) })) : null, _jsx(Pressable, { accessibilityRole: "checkbox", accessibilityLabel: `Set ${setNumber} done`, accessibilityState: { checked: row.done }, hitSlop: 8, onPress: () => {
|
|
160
|
+
if (!row.done)
|
|
161
|
+
onTicked(target);
|
|
162
|
+
log.dispatch({ type: "toggle", ...at });
|
|
163
|
+
}, style: [styles.tick, row.done ? styles.tickDone : null], children: _jsx(Text, { style: row.done ? styles.tickMarkDone : styles.tickMark, children: "\u2713" }) })] }), _jsx(Text, { style: styles.muted, children: describeSet(target) }), effortOpen ? (_jsx(View, { style: styles.row, children: EFFORTS.map((e) => (_jsx(Pressable, { accessibilityRole: "button", accessibilityLabel: `Effort ${e}`, accessibilityState: { selected: row.rpe === e }, onPress: () => {
|
|
164
|
+
log.dispatch({ type: "rpe", ...at, rpe: row.rpe === e ? null : e });
|
|
165
|
+
setEffortOpen(false);
|
|
166
|
+
}, style: [styles.chip, row.rpe === e ? styles.chipOn : null], children: _jsx(Text, { style: row.rpe === e ? styles.tickMarkDone : styles.heading, children: e }) }, e))) })) : null, row.error ? _jsx(Text, { style: styles.error, children: row.error }) : null] }));
|
|
106
167
|
}
|
|
107
168
|
const styles = StyleSheet.create({
|
|
108
169
|
muted: { color: theme.color.muted, fontSize: theme.font.small },
|
|
@@ -116,8 +177,73 @@ const styles = StyleSheet.create({
|
|
|
116
177
|
borderRadius: theme.radius,
|
|
117
178
|
},
|
|
118
179
|
exercise: { gap: theme.space.xs },
|
|
119
|
-
|
|
180
|
+
folded: {
|
|
181
|
+
flexDirection: "row",
|
|
182
|
+
justifyContent: "space-between",
|
|
183
|
+
paddingVertical: theme.space.sm,
|
|
184
|
+
},
|
|
185
|
+
set: { gap: 2, paddingVertical: theme.space.xs },
|
|
186
|
+
setRow: { flexDirection: "row", alignItems: "center", gap: theme.space.sm },
|
|
187
|
+
setNumber: { width: 20, color: theme.color.muted, fontWeight: "600" },
|
|
188
|
+
input: {
|
|
189
|
+
flex: 1,
|
|
190
|
+
minHeight: 44,
|
|
191
|
+
borderWidth: 1,
|
|
192
|
+
borderColor: theme.color.border,
|
|
193
|
+
borderRadius: theme.radius,
|
|
194
|
+
paddingHorizontal: theme.space.sm,
|
|
195
|
+
fontSize: theme.font.body,
|
|
196
|
+
color: theme.color.text,
|
|
197
|
+
backgroundColor: theme.color.background,
|
|
198
|
+
textAlign: "center",
|
|
199
|
+
},
|
|
200
|
+
inputDone: { borderColor: theme.color.primary },
|
|
201
|
+
effort: { minWidth: 44, minHeight: 44, alignItems: "center", justifyContent: "center" },
|
|
202
|
+
effortSet: { fontWeight: "600", color: theme.color.text },
|
|
203
|
+
clock: {
|
|
204
|
+
minWidth: 56,
|
|
205
|
+
minHeight: 44,
|
|
206
|
+
borderRadius: theme.radius,
|
|
207
|
+
alignItems: "center",
|
|
208
|
+
justifyContent: "center",
|
|
209
|
+
backgroundColor: theme.color.background,
|
|
210
|
+
},
|
|
211
|
+
clockRunning: { backgroundColor: theme.color.primary },
|
|
212
|
+
tick: {
|
|
213
|
+
width: 44,
|
|
214
|
+
height: 44,
|
|
215
|
+
borderRadius: theme.radius,
|
|
216
|
+
borderWidth: 2,
|
|
217
|
+
borderColor: theme.color.border,
|
|
218
|
+
alignItems: "center",
|
|
219
|
+
justifyContent: "center",
|
|
220
|
+
backgroundColor: theme.color.background,
|
|
221
|
+
},
|
|
222
|
+
tickDone: { backgroundColor: theme.color.primary, borderColor: theme.color.primary },
|
|
223
|
+
tickMark: { fontSize: 20, color: theme.color.muted },
|
|
224
|
+
tickMarkDone: { fontSize: 18, fontWeight: "700", color: theme.color.onPrimary },
|
|
225
|
+
chip: {
|
|
226
|
+
minWidth: 44,
|
|
227
|
+
minHeight: 40,
|
|
228
|
+
borderRadius: theme.radius,
|
|
229
|
+
alignItems: "center",
|
|
230
|
+
justifyContent: "center",
|
|
231
|
+
backgroundColor: theme.color.background,
|
|
232
|
+
},
|
|
233
|
+
chipOn: { backgroundColor: theme.color.primary },
|
|
120
234
|
row: { flexDirection: "row", flexWrap: "wrap", gap: theme.space.sm },
|
|
235
|
+
progress: { gap: theme.space.xs },
|
|
236
|
+
track: { height: 6, borderRadius: 3, backgroundColor: theme.color.surface, overflow: "hidden" },
|
|
237
|
+
fill: { height: 6, backgroundColor: theme.color.primary },
|
|
238
|
+
warning: {
|
|
239
|
+
gap: theme.space.sm,
|
|
240
|
+
padding: theme.space.sm,
|
|
241
|
+
borderRadius: theme.radius,
|
|
242
|
+
borderWidth: 1,
|
|
243
|
+
borderColor: theme.color.danger,
|
|
244
|
+
},
|
|
245
|
+
warningText: { color: theme.color.text },
|
|
246
|
+
error: { color: theme.color.danger, fontSize: theme.font.small },
|
|
121
247
|
timer: {
|
|
122
248
|
flexDirection: "row",
|
|
123
249
|
alignItems: "center",
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { PlannedSession, ProgramsHooks } from "@composable-os/pack-programs/client";
|
|
2
2
|
export declare function TodayScreen({ programs, date, onOpen, }: {
|
|
3
|
-
programs: Pick<ProgramsHooks, "useToday">;
|
|
3
|
+
programs: Pick<ProgramsHooks, "useToday" | "useUnsavedSets">;
|
|
4
4
|
/** The member's local date (YYYY-MM-DD). */
|
|
5
5
|
date?: string;
|
|
6
6
|
onOpen: (session: PlannedSession) => void;
|
|
@@ -1,11 +1,30 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useEffect } from "react";
|
|
3
|
+
import { AppState, StyleSheet, View } from "react-native";
|
|
4
|
+
import { Button } from "../native-base/button.js";
|
|
3
5
|
import { List } from "../native-base/list.js";
|
|
4
6
|
import { Row } from "../native-base/row.js";
|
|
5
7
|
import { Screen } from "../native-base/screen.js";
|
|
8
|
+
import { Text } from "../native-base/text.js";
|
|
9
|
+
import { theme } from "../native-base/theme.js";
|
|
6
10
|
export function TodayScreen({ programs, date, onOpen, }) {
|
|
7
11
|
const today = programs.useToday(date ? { date } : {});
|
|
8
|
-
|
|
12
|
+
const unsaved = programs.useUnsavedSets();
|
|
13
|
+
const { flush } = unsaved;
|
|
14
|
+
useEffect(() => {
|
|
15
|
+
const sub = AppState.addEventListener("change", () => void flush());
|
|
16
|
+
return () => sub.remove();
|
|
17
|
+
}, [flush]);
|
|
18
|
+
return (_jsxs(Screen, { title: "Today", children: [unsaved.count ? (_jsxs(View, { style: styles.warning, accessibilityLiveRegion: "polite", children: [_jsxs(Text, { children: [unsaved.count === 1 ? "1 set is" : `${unsaved.count} sets are`, " not saved yet.", " ", unsaved.failure ?? "Sending…"] }), _jsx(Button, { quiet: true, label: "Try now", onPress: () => void flush() })] })) : null, today.isPending ? (_jsx(Text, { tone: "muted", accessibilityRole: "progressbar", children: "Loading\u2026" })) : null, today.error ? (_jsx(Text, { tone: "danger", accessibilityRole: "alert", children: "We could not load today's sessions. Check the connection and try again." })) : null, today.data ? (_jsx(List, { empty: "Nothing planned today.", children: today.data.sessions.map((s) => (_jsx(Row, { title: s.name ?? "Session", detail: [s.programTitle, s.state === "done" ? "Done" : null]
|
|
9
19
|
.filter(Boolean)
|
|
10
20
|
.join(" · "), onPress: () => onOpen(s) }, s.id))) })) : null] }));
|
|
11
21
|
}
|
|
22
|
+
const styles = StyleSheet.create({
|
|
23
|
+
warning: {
|
|
24
|
+
gap: theme.space.sm,
|
|
25
|
+
padding: theme.space.sm,
|
|
26
|
+
borderRadius: theme.radius,
|
|
27
|
+
borderWidth: 1,
|
|
28
|
+
borderColor: theme.color.danger,
|
|
29
|
+
},
|
|
30
|
+
});
|
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
import { type ProgramsHooks } from "@composable-os/pack-programs/client";
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
type Programs = Pick<ProgramsHooks, "useMarkSession" | "useSessionLog">;
|
|
3
|
+
export declare function SessionView({ programs, sessionId, personId, onRestDone, defaultRest, }: {
|
|
4
|
+
programs: Programs;
|
|
4
5
|
sessionId: string;
|
|
5
|
-
/** A coach logging for a client names them
|
|
6
|
+
/** A coach logging for a client names them. */
|
|
6
7
|
personId?: string;
|
|
7
8
|
/** Called when a rest ends (a sound, a buzz): the app's. */
|
|
8
9
|
onRestDone?: () => void;
|
|
10
|
+
/** Seconds of rest after a set whose plan names none. */
|
|
11
|
+
defaultRest?: number;
|
|
9
12
|
}): import("react").JSX.Element;
|
|
13
|
+
export {};
|