Pass event through click handlers
This commit is contained in:
@@ -1,10 +1,10 @@
|
|||||||
import React from 'react'
|
import React from 'react'
|
||||||
import {View} from 'react-native'
|
import {GestureResponderEvent, View} from 'react-native'
|
||||||
import {msg} from '@lingui/macro'
|
import {msg} from '@lingui/macro'
|
||||||
import {useLingui} from '@lingui/react'
|
import {useLingui} from '@lingui/react'
|
||||||
|
|
||||||
import {atoms as a, useBreakpoints, useTheme} from '#/alf'
|
import {atoms as a, useBreakpoints, useTheme} from '#/alf'
|
||||||
import {Button, ButtonColor, ButtonText} from '#/components/Button'
|
import {Button, ButtonColor, ButtonProps, ButtonText} from '#/components/Button'
|
||||||
import * as Dialog from '#/components/Dialog'
|
import * as Dialog from '#/components/Dialog'
|
||||||
import {Text} from '#/components/Typography'
|
import {Text} from '#/components/Typography'
|
||||||
|
|
||||||
@@ -136,7 +136,7 @@ export function Action({
|
|||||||
* Note: The dialog will close automatically when the action is pressed, you
|
* Note: The dialog will close automatically when the action is pressed, you
|
||||||
* should NOT close the dialog as a side effect of this method.
|
* should NOT close the dialog as a side effect of this method.
|
||||||
*/
|
*/
|
||||||
onPress: () => void
|
onPress: ButtonProps['onPress']
|
||||||
color?: ButtonColor
|
color?: ButtonColor
|
||||||
/**
|
/**
|
||||||
* Optional i18n string. If undefined, it will default to "Confirm".
|
* Optional i18n string. If undefined, it will default to "Confirm".
|
||||||
@@ -147,9 +147,12 @@ export function Action({
|
|||||||
const {_} = useLingui()
|
const {_} = useLingui()
|
||||||
const {gtMobile} = useBreakpoints()
|
const {gtMobile} = useBreakpoints()
|
||||||
const {close} = Dialog.useDialogContext()
|
const {close} = Dialog.useDialogContext()
|
||||||
const handleOnPress = React.useCallback(() => {
|
const handleOnPress = React.useCallback(
|
||||||
close(onPress)
|
(e: GestureResponderEvent) => {
|
||||||
}, [close, onPress])
|
close(() => onPress?.(e))
|
||||||
|
},
|
||||||
|
[close, onPress],
|
||||||
|
)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Button
|
<Button
|
||||||
@@ -186,7 +189,7 @@ export function Basic({
|
|||||||
* Note: The dialog will close automatically when the action is pressed, you
|
* Note: The dialog will close automatically when the action is pressed, you
|
||||||
* should NOT close the dialog as a side effect of this method.
|
* should NOT close the dialog as a side effect of this method.
|
||||||
*/
|
*/
|
||||||
onConfirm: () => void
|
onConfirm: ButtonProps['onPress']
|
||||||
confirmButtonColor?: ButtonColor
|
confirmButtonColor?: ButtonColor
|
||||||
showCancel?: boolean
|
showCancel?: boolean
|
||||||
}>) {
|
}>) {
|
||||||
|
|||||||
Reference in New Issue
Block a user