2022-10-31 04:22:08 +00:00
|
|
|
import {Button, Dialog, Portal, Text} from 'react-native-paper'
|
2022-07-10 23:26:45 +00:00
|
|
|
|
|
|
|
export default function ConfirmDialog({
|
|
|
|
title,
|
|
|
|
children,
|
|
|
|
onOk,
|
|
|
|
show,
|
|
|
|
setShow,
|
2022-12-13 09:54:37 +00:00
|
|
|
onCancel,
|
2022-07-10 23:26:45 +00:00
|
|
|
}: {
|
2022-10-31 04:22:08 +00:00
|
|
|
title: string
|
|
|
|
children: JSX.Element | JSX.Element[] | string
|
|
|
|
onOk: () => void
|
|
|
|
show: boolean
|
|
|
|
setShow: (show: boolean) => void
|
2022-12-13 09:54:37 +00:00
|
|
|
onCancel?: () => void
|
2022-07-10 23:26:45 +00:00
|
|
|
}) {
|
2022-12-13 09:54:37 +00:00
|
|
|
const cancel = () => {
|
|
|
|
setShow(false)
|
|
|
|
onCancel && onCancel()
|
|
|
|
}
|
|
|
|
|
2022-07-10 23:26:45 +00:00
|
|
|
return (
|
|
|
|
<Portal>
|
|
|
|
<Dialog visible={show} onDismiss={() => setShow(false)}>
|
|
|
|
<Dialog.Title>{title}</Dialog.Title>
|
|
|
|
<Dialog.Content>
|
|
|
|
<Text>{children}</Text>
|
|
|
|
</Dialog.Content>
|
|
|
|
<Dialog.Actions>
|
|
|
|
<Button onPress={onOk}>OK</Button>
|
2022-12-13 09:54:37 +00:00
|
|
|
<Button onPress={cancel}>Cancel</Button>
|
2022-07-10 23:26:45 +00:00
|
|
|
</Dialog.Actions>
|
|
|
|
</Dialog>
|
|
|
|
</Portal>
|
2022-10-31 04:22:08 +00:00
|
|
|
)
|
2022-07-10 23:26:45 +00:00
|
|
|
}
|