-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
aef9b48
commit 33eab2f
Showing
4 changed files
with
53 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 39 additions & 17 deletions
56
examples/vk-mini-apps-router-example/src/popouts/OffencePersikPopout.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,45 @@ | ||
import { useCallback, useRef } from 'react'; | ||
import { useRouteNavigator } from '@vkontakte/vk-mini-apps-router'; | ||
import { Alert } from '@vkontakte/vkui'; | ||
|
||
export function OffencePersikPopout() { | ||
const routeNavigator = useRouteNavigator(); | ||
return <Alert | ||
actions={[ | ||
{ | ||
title: 'Отмена', | ||
mode: 'cancel', | ||
}, | ||
{ | ||
title: 'Забрать', | ||
mode: 'destructive', | ||
action: () => setTimeout(() => routeNavigator.replace('/persik/sad/persik_modal/sad', { keepSearchParams: true }), 100), | ||
}, | ||
]} | ||
actionsLayout="horizontal" | ||
onClose={() => routeNavigator.hidePopout()} | ||
title="Еда персика" | ||
description="Вы уверены, что хотите забрать у персика еду?" | ||
/>; | ||
const closeWithAction = useRef(false); | ||
|
||
const handleTakeFood = useCallback(() => { | ||
closeWithAction.current = true; | ||
|
||
routeNavigator.runSync([ | ||
() => routeNavigator.hidePopout(), | ||
() => routeNavigator.replace('/persik/sad/persik_modal/sad', { keepSearchParams: true }), | ||
]); | ||
}, [routeNavigator]); | ||
|
||
const handleClose = useCallback(() => { | ||
if (!closeWithAction.current) { | ||
routeNavigator.hidePopout(); | ||
} | ||
|
||
closeWithAction.current = false; | ||
}, [closeWithAction, routeNavigator]); | ||
|
||
return ( | ||
<Alert | ||
actions={[ | ||
{ | ||
title: 'Отмена', | ||
mode: 'cancel', | ||
}, | ||
{ | ||
title: 'Забрать', | ||
mode: 'destructive', | ||
action: handleTakeFood, | ||
}, | ||
]} | ||
actionsLayout="horizontal" | ||
onClose={handleClose} | ||
title="Еда персика" | ||
description="Вы уверены, что хотите забрать у персика еду?" | ||
/> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters