Add copy feature for plans

Long tap an existing plan, then press copy.
This will bring up a new plan to add with all
the same workouts/days as the one you have
copied.
This commit is contained in:
Brandon Presley 2022-11-02 13:02:02 +13:00
parent ffbefe7a4f
commit f91d529f39
1 changed files with 21 additions and 15 deletions

View File

@ -78,21 +78,27 @@ export default function PlanItem({
[item.workouts], [item.workouts],
) )
const copy = useCallback(() => {
const plan: Plan = {...item}
delete plan.id
setShow(false)
navigation.navigate('EditPlan', {plan})
}, [navigation, item])
return ( return (
<> <List.Item
<List.Item onPress={start}
onPress={start} title={title}
title={title} description={description}
description={description} onLongPress={longPress}
onLongPress={longPress} right={() => (
right={() => ( <Menu anchor={anchor} visible={show} onDismiss={() => setShow(false)}>
<Menu anchor={anchor} visible={show} onDismiss={() => setShow(false)}> <Menu.Item icon="edit" onPress={edit} title="Edit" />
<Menu.Item icon="edit" onPress={edit} title="Edit" /> <Menu.Item icon="content-copy" onPress={copy} title="Copy" />
<Divider /> <Divider />
<Menu.Item icon="delete" onPress={remove} title="Delete" /> <Menu.Item icon="delete" onPress={remove} title="Delete" />
</Menu> </Menu>
)} )}
/> />
</>
) )
} }