Compare commits
2
Commits
7f2fe0c300
...
522337d332
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
522337d332 | ||
|
|
070429627b |
@@ -13,9 +13,11 @@ const STROKES: StrokeType[] = ["Freestyle", "Backstroke", "Breaststroke", "Butte
|
|||||||
export function BuilderScreen() {
|
export function BuilderScreen() {
|
||||||
const { t } = useTranslation("workout");
|
const { t } = useTranslation("workout");
|
||||||
const { t: tc } = useTranslation("common");
|
const { t: tc } = useTranslation("common");
|
||||||
|
const { t: tb } = useTranslation("navigation");
|
||||||
const navigation = useNavigation<NativeStackNavigationProp<RootStackParamList>>();
|
const navigation = useNavigation<NativeStackNavigationProp<RootStackParamList>>();
|
||||||
const { poolLength: defaultPoolLength } = useSettings();
|
const { poolLength: defaultPoolLength } = useSettings();
|
||||||
const [poolLength, setPoolLength] = useState(defaultPoolLength);
|
const [poolLength, setPoolLength] = useState(defaultPoolLength);
|
||||||
|
const [fieldValues, setFieldValues] = useState<Record<string, string>>({});
|
||||||
const {
|
const {
|
||||||
sets,
|
sets,
|
||||||
workoutName,
|
workoutName,
|
||||||
@@ -46,7 +48,7 @@ export function BuilderScreen() {
|
|||||||
>
|
>
|
||||||
<ScrollView className="flex-1 bg-white" contentContainerStyle={{ paddingBottom: 40 }}>
|
<ScrollView className="flex-1 bg-white" contentContainerStyle={{ paddingBottom: 40 }}>
|
||||||
<View className="p-4">
|
<View className="p-4">
|
||||||
<Text className="text-2xl font-bold text-slate-900 mb-1">{t("buildWorkout")}</Text>
|
<Text className="text-2xl font-bold text-slate-900 mb-1">{tb("buildWorkout")}</Text>
|
||||||
<Text className="text-slate-500 mb-4">
|
<Text className="text-slate-500 mb-4">
|
||||||
{totalDistance}m total · {tc("pool", { length: poolLength })}
|
{totalDistance}m total · {tc("pool", { length: poolLength })}
|
||||||
</Text>
|
</Text>
|
||||||
@@ -124,8 +126,19 @@ export function BuilderScreen() {
|
|||||||
<Text className="text-xs font-medium text-slate-500 mb-1">{t("distanceM")}</Text>
|
<Text className="text-xs font-medium text-slate-500 mb-1">{t("distanceM")}</Text>
|
||||||
<TextInput
|
<TextInput
|
||||||
keyboardType="numeric"
|
keyboardType="numeric"
|
||||||
value={String(set.distancePerRep)}
|
value={fieldValues[`${index}-distance`] ?? String(set.distancePerRep)}
|
||||||
onChangeText={(val) => updateSet(index, { distancePerRep: Number(val) || 0 })}
|
onChangeText={(val) => setFieldValues((prev) => ({ ...prev, [`${index}-distance`]: val }))}
|
||||||
|
onBlur={() => {
|
||||||
|
const num = Number(fieldValues[`${index}-distance`] ?? set.distancePerRep);
|
||||||
|
updateSet(index, { distancePerRep: isNaN(num) || num < poolLength ? poolLength : num });
|
||||||
|
setFieldValues((prev) => {
|
||||||
|
const next = { ...prev };
|
||||||
|
delete next[`${index}-distance`];
|
||||||
|
return next;
|
||||||
|
});
|
||||||
|
}}
|
||||||
|
placeholder={String(poolLength)}
|
||||||
|
placeholderTextColor="#94a3b8"
|
||||||
className="bg-white border border-slate-300 rounded-lg px-3 py-2 text-slate-900"
|
className="bg-white border border-slate-300 rounded-lg px-3 py-2 text-slate-900"
|
||||||
/>
|
/>
|
||||||
</View>
|
</View>
|
||||||
@@ -133,8 +146,19 @@ export function BuilderScreen() {
|
|||||||
<Text className="text-xs font-medium text-slate-500 mb-1">{t("reps")}</Text>
|
<Text className="text-xs font-medium text-slate-500 mb-1">{t("reps")}</Text>
|
||||||
<TextInput
|
<TextInput
|
||||||
keyboardType="numeric"
|
keyboardType="numeric"
|
||||||
value={String(set.repCount)}
|
value={fieldValues[`${index}-rep`] ?? String(set.repCount)}
|
||||||
onChangeText={(val) => updateSet(index, { repCount: Number(val) || 1 })}
|
onChangeText={(val) => setFieldValues((prev) => ({ ...prev, [`${index}-rep`]: val }))}
|
||||||
|
onBlur={() => {
|
||||||
|
const num = Number(fieldValues[`${index}-rep`] ?? set.repCount);
|
||||||
|
updateSet(index, { repCount: isNaN(num) || num < 1 ? 1 : num });
|
||||||
|
setFieldValues((prev) => {
|
||||||
|
const next = { ...prev };
|
||||||
|
delete next[`${index}-rep`];
|
||||||
|
return next;
|
||||||
|
});
|
||||||
|
}}
|
||||||
|
placeholder="1"
|
||||||
|
placeholderTextColor="#94a3b8"
|
||||||
className="bg-white border border-slate-300 rounded-lg px-3 py-2 text-slate-900"
|
className="bg-white border border-slate-300 rounded-lg px-3 py-2 text-slate-900"
|
||||||
/>
|
/>
|
||||||
</View>
|
</View>
|
||||||
@@ -142,8 +166,19 @@ export function BuilderScreen() {
|
|||||||
<Text className="text-xs font-medium text-slate-500 mb-1">{t("restS")}</Text>
|
<Text className="text-xs font-medium text-slate-500 mb-1">{t("restS")}</Text>
|
||||||
<TextInput
|
<TextInput
|
||||||
keyboardType="numeric"
|
keyboardType="numeric"
|
||||||
value={String(set.restDuration)}
|
value={fieldValues[`${index}-rest`] ?? String(set.restDuration)}
|
||||||
onChangeText={(val) => updateSet(index, { restDuration: Number(val) || 0 })}
|
onChangeText={(val) => setFieldValues((prev) => ({ ...prev, [`${index}-rest`]: val }))}
|
||||||
|
onBlur={() => {
|
||||||
|
const num = Number(fieldValues[`${index}-rest`] ?? set.restDuration);
|
||||||
|
updateSet(index, { restDuration: isNaN(num) || num < 0 ? 0 : num });
|
||||||
|
setFieldValues((prev) => {
|
||||||
|
const next = { ...prev };
|
||||||
|
delete next[`${index}-rest`];
|
||||||
|
return next;
|
||||||
|
});
|
||||||
|
}}
|
||||||
|
placeholder="0"
|
||||||
|
placeholderTextColor="#94a3b8"
|
||||||
className="bg-white border border-slate-300 rounded-lg px-3 py-2 text-slate-900"
|
className="bg-white border border-slate-300 rounded-lg px-3 py-2 text-slate-900"
|
||||||
/>
|
/>
|
||||||
</View>
|
</View>
|
||||||
|
|||||||
Reference in New Issue
Block a user