MCPcopy
hub / github.com/obytes/react-native-template-obytes / Modal

Function Modal

src/components/ui/modal.tsx:66–101  ·  view source on GitHub ↗
({ ref, snapPoints: _snapPoints = ['60%'] as (string | number)[], title, detached = false, ...props }: ModalProps & { ref?: ModalRef })

Source from the content-addressed store, hash-verified

64}
65
66export function Modal({ ref, snapPoints: _snapPoints = ['60%'] as (string | number)[], title, detached = false, ...props }: ModalProps & { ref?: ModalRef }) {
67 const detachedProps = React.useMemo(
68 () => getDetachedProps(detached),
69 [detached],
70 );
71 const modal = useModal();
72 const snapPoints = React.useMemo(() => _snapPoints, [_snapPoints]);
73
74 React.useImperativeHandle(
75 ref,
76 () => (modal.ref.current as BottomSheetModal) || null,
77 );
78
79 const renderHandleComponent = React.useCallback(
80 () => (
81 <>
82 <View className="mt-2 mb-8 h-1 w-12 self-center rounded-lg bg-gray-400 dark:bg-gray-700" />
83 <ModalHeader title={title} dismiss={modal.dismiss} />
84 </>
85 ),
86 [title, modal.dismiss],
87 );
88
89 return (
90 <BottomSheetModal
91 {...props}
92 {...detachedProps}
93 ref={modal.ref}
94 index={0}
95 snapPoints={snapPoints}
96 backdropComponent={props.backdropComponent || renderBackdrop}
97 enableDynamicSizing={false}
98 handleComponent={renderHandleComponent}
99 />
100 );
101}
102
103/**
104 * Custom Backdrop

Callers

nothing calls this directly

Calls 2

getDetachedPropsFunction · 0.85
useModalFunction · 0.85

Tested by

no test coverage detected