diff --git a/example/app/src/screens/advanced/ScrollableDynamicHeightExample.tsx b/example/app/src/screens/advanced/ScrollableDynamicHeightExample.tsx new file mode 100644 index 000000000..dfdc5ecfc --- /dev/null +++ b/example/app/src/screens/advanced/ScrollableDynamicHeightExample.tsx @@ -0,0 +1,165 @@ +import React, { useCallback, useRef, useState } from 'react'; +import { View, StyleSheet, Text } from 'react-native'; +import BottomSheet, { + BottomSheetScrollView, + useMaxHeightScrollableBottomSheet, +} from '@gorhom/bottom-sheet'; +import { Button } from '../../components/button'; +type CSSHeight = `${number}%` | number; + +const DynamicSnapPointExample = () => { + // state + const [count, setCount] = useState(3); + const [maxHeight, setMaxHeight] = useState(); + // hooks + const bottomSheetRef = useRef(null); + const { + animatedHandleHeight, + animatedSnapPoints, + animatedContentHeight, + handleContentLayout, + innerScrollViewAnimatedStyles, + } = useMaxHeightScrollableBottomSheet(maxHeight); + // callbacks + + const handleExpandPress = useCallback(() => { + bottomSheetRef.current?.expand(); + }, []); + const handleClosePress = useCallback(() => { + bottomSheetRef.current?.close(); + }, []); + + const changeItemsCount = useCallback((direction: 1 | -1) => { + setCount(state => state + direction); + }, []); + + // styles + + // renders + return ( + +