Skip to content

Commit b0f7e0a

Browse files
committed
fix: scroll draggable modal with isScrollable prop
1 parent 5df5039 commit b0f7e0a

File tree

2 files changed

+33
-10
lines changed

2 files changed

+33
-10
lines changed

apps/docs/pages/docs/Components/draggable-modal.en-US.mdx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,13 @@ Extends every `Box` props and `BottomSheetModalProps` from `@gorhom/bottom-sheet
7272
prop={{ type: "() => void", required: false }}
7373
/>
7474

75+
### `isScrollable`
76+
77+
<PropsTable
78+
description="Boolean to indicate if the modal should be scrollable."
79+
prop={{ type: "boolean", required: false }}
80+
/>
81+
7582
### `scrollViewProps`
7683

7784
<PropsTable

packages/react-native-ficus-ui/src/components/draggable-modal/index.tsx

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import { mergeRefs } from '../utils/merge-refs';
1818
interface DraggableModalOptions {
1919
isOpen?: boolean;
2020
onClose?: () => void;
21+
isScrollable?: boolean;
2122
scrollViewProps?: BottomSheetScrollViewProps;
2223
}
2324

@@ -35,7 +36,15 @@ export const DraggableModal = forwardRef<
3536
const { colorMode } = useColorMode();
3637

3738
const bottomSheetModalRef = mergeRefs(_ref, ref);
38-
const { children, isOpen, onClose, h, scrollViewProps, ...rest } = props;
39+
const {
40+
children,
41+
isOpen,
42+
onClose,
43+
h,
44+
isScrollable,
45+
scrollViewProps,
46+
...rest
47+
} = props;
3948

4049
useEffect(() => {
4150
if (isOpen) {
@@ -86,6 +95,15 @@ export const DraggableModal = forwardRef<
8695
const safeAreaViewStyle = {
8796
flex: 1,
8897
};
98+
99+
const modalContent = (
100+
<Box h={h ?? '100%'}>
101+
<SafeAreaView style={safeAreaViewStyle}>
102+
{children as ReactNode}
103+
</SafeAreaView>
104+
</Box>
105+
);
106+
89107
return (
90108
<ficus.BottomSheetModal
91109
ref={bottomSheetModalRef}
@@ -95,15 +113,13 @@ export const DraggableModal = forwardRef<
95113
backgroundStyle={bottomSheetBackgroundStyleObject as ViewStyle}
96114
handleIndicatorStyle={handleStyleObject}
97115
>
98-
<BottomSheetScrollView {...scrollViewProps}>
99-
<ficus.BottomSheetView {...rest}>
100-
<Box h={h ?? '100%'}>
101-
<SafeAreaView style={safeAreaViewStyle}>
102-
{children as ReactNode}
103-
</SafeAreaView>
104-
</Box>
105-
</ficus.BottomSheetView>
106-
</BottomSheetScrollView>
116+
{isScrollable ? (
117+
<BottomSheetScrollView {...scrollViewProps}>
118+
{modalContent}
119+
</BottomSheetScrollView>
120+
) : (
121+
<ficus.BottomSheetView {...rest}>{modalContent}</ficus.BottomSheetView>
122+
)}
107123
</ficus.BottomSheetModal>
108124
);
109125
});

0 commit comments

Comments
 (0)