Show count when adding a new set
This commit is contained in:
parent
3abc4da861
commit
4aa91253a1
20
EditSet.tsx
20
EditSet.tsx
|
@ -21,14 +21,20 @@ export default function EditSet() {
|
|||
|
||||
useFocusEffect(
|
||||
useCallback(() => {
|
||||
navigation.getParent()?.setOptions({
|
||||
headerLeft: () => (
|
||||
<IconButton icon="arrow-back" onPress={() => navigation.goBack()} />
|
||||
),
|
||||
headerRight: null,
|
||||
title: params.set.id ? 'Edit set' : 'Create set',
|
||||
getSettings().then(settings => {
|
||||
let title = 'Edit set';
|
||||
if (!params.set.id && params.set.name)
|
||||
title = `Add set (${params.count} / ${settings.sets})`;
|
||||
if (!params.set.id && !params.set.name) title = 'Add set';
|
||||
navigation.getParent()?.setOptions({
|
||||
headerLeft: () => (
|
||||
<IconButton icon="arrow-back" onPress={() => navigation.goBack()} />
|
||||
),
|
||||
headerRight: null,
|
||||
title,
|
||||
});
|
||||
});
|
||||
}, [navigation, params.set.id]),
|
||||
}, [navigation, params]),
|
||||
);
|
||||
|
||||
const startTimer = useCallback(async () => {
|
||||
|
|
|
@ -13,6 +13,7 @@ export type HomePageParams = {
|
|||
Sets: {};
|
||||
EditSet: {
|
||||
set: Set;
|
||||
count: number;
|
||||
workouts?: string[];
|
||||
};
|
||||
};
|
||||
|
|
|
@ -21,6 +21,7 @@ const limit = 15;
|
|||
export default function SetList() {
|
||||
const [sets, setSets] = useState<Set[]>();
|
||||
const [set, setSet] = useState<Set>();
|
||||
const [count, setCount] = useState(1);
|
||||
const [workouts, setWorkouts] = useState<string[]>([]);
|
||||
const [offset, setOffset] = useState(0);
|
||||
const [search, setSearch] = useState('');
|
||||
|
@ -52,11 +53,12 @@ export default function SetList() {
|
|||
let workout = todaysWorkouts[0];
|
||||
console.log(`${SetList.name}.predict:`, {todaysSets, todaysWorkouts});
|
||||
if (todaysWorkouts.includes(todaysSets[0]?.name) && todaysSets.length > 0) {
|
||||
const count = todaysSets.filter(
|
||||
const _count = todaysSets.filter(
|
||||
s => s.name === todaysSets[0].name,
|
||||
).length;
|
||||
setCount(_count);
|
||||
workout = todaysSets[0].name;
|
||||
if (count >= Number(settings.sets))
|
||||
if (_count >= Number(settings.sets))
|
||||
workout =
|
||||
todaysWorkouts[todaysWorkouts.indexOf(todaysSets[0].name!) + 1];
|
||||
}
|
||||
|
@ -117,9 +119,10 @@ export default function SetList() {
|
|||
const onAdd = useCallback(async () => {
|
||||
navigation.navigate('EditSet', {
|
||||
set: set || {...defaultSet},
|
||||
count,
|
||||
workouts,
|
||||
});
|
||||
}, [navigation, set, workouts]);
|
||||
}, [navigation, set, workouts, count]);
|
||||
|
||||
return (
|
||||
<View style={styles.container}>
|
||||
|
|
Loading…
Reference in New Issue
Block a user