diff --git a/native/bottom-sheets/bottom-sheet.react.js b/native/bottom-sheets/bottom-sheet.react.js index 84d1e62ed..f86c2af49 100644 --- a/native/bottom-sheets/bottom-sheet.react.js +++ b/native/bottom-sheets/bottom-sheet.react.js @@ -1,56 +1,67 @@ // @flow import { BottomSheetModal } from '@gorhom/bottom-sheet'; import * as React from 'react'; import BottomSheetBackdrop from './bottom-sheet-backdrop.react.js'; import BottomSheetHandle from './bottom-sheet-handle.react.js'; import { useStyles } from '../themes/colors.js'; type Props = { +children: React.Node, + +onClosed: () => mixed, }; function ForwardedBottomSheet( props: Props, ref: React.Ref, ): React.Node { - const { children } = props; + const { children, onClosed } = props; const styles = useStyles(unboundStyles); const snapPoints = React.useMemo(() => ['25%', '50%'], []); + const onChange = React.useCallback( + (index: number) => { + if (index === -1) { + onClosed(); + } + }, + [onClosed], + ); + return ( {children} ); } const unboundStyles = { background: { backgroundColor: 'modalForeground', }, }; const BottomSheet: React.AbstractComponent< Props, React.ElementRef, > = React.forwardRef>( ForwardedBottomSheet, ); BottomSheet.displayName = 'BottomSheet'; const MemoizedBottomSheet: typeof BottomSheet = React.memo< Props, React.ElementRef, >(BottomSheet); export default MemoizedBottomSheet;