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],
)
const copy = useCallback(() => {
const plan: Plan = {...item}
delete plan.id
setShow(false)
navigation.navigate('EditPlan', {plan})
}, [navigation, item])
return (
<>
<List.Item
onPress={start}
title={title}
description={description}
onLongPress={longPress}
right={() => (
<Menu anchor={anchor} visible={show} onDismiss={() => setShow(false)}>
<Menu.Item icon="edit" onPress={edit} title="Edit" />
<Divider />
<Menu.Item icon="delete" onPress={remove} title="Delete" />
</Menu>
)}
/>
</>
<List.Item
onPress={start}
title={title}
description={description}
onLongPress={longPress}
right={() => (
<Menu anchor={anchor} visible={show} onDismiss={() => setShow(false)}>
<Menu.Item icon="edit" onPress={edit} title="Edit" />
<Menu.Item icon="content-copy" onPress={copy} title="Copy" />
<Divider />
<Menu.Item icon="delete" onPress={remove} title="Delete" />
</Menu>
)}
/>
)
}