diff --git a/example/index.ts b/example/index.ts index d3c277a28..fc6f4f5e8 100644 --- a/example/index.ts +++ b/example/index.ts @@ -3,6 +3,10 @@ import 'react-native-gesture-handler'; import { enableScreens } from 'react-native-screens'; enableScreens(true); +// @ts-ignore +import { enableLogging } from '@gorhom/bottom-sheet'; +enableLogging(); + import { AppRegistry, LogBox } from 'react-native'; import App from './src/App'; import { name as appName } from './app.json'; diff --git a/example/src/Dev.tsx b/example/src/Dev.tsx index 635b18760..84c10f684 100644 --- a/example/src/Dev.tsx +++ b/example/src/Dev.tsx @@ -4,28 +4,34 @@ import React, { useCallback, useMemo, useRef, useState } from 'react'; import { View, StyleSheet, Dimensions, StatusBar } from 'react-native'; import { createStackNavigator } from '@react-navigation/stack'; import { useAnimatedStyle, useSharedValue } from 'react-native-reanimated'; -import { useSafeAreaInsets } from 'react-native-safe-area-context'; +import { + SafeAreaProvider, + useSafeAreaInsets, +} from 'react-native-safe-area-context'; import BottomSheet from '@gorhom/bottom-sheet'; import SearchHandle from './components/searchHandle'; import Button from './components/button'; import ContactList from './components/contactList'; -import { NavigationContainer } from '@react-navigation/native'; +import { NavigationContainer, useNavigation } from '@react-navigation/native'; const { height: windowHeight } = Dimensions.get('window'); const BasicExample = () => { //#region state + const shownHeader = useRef(true); const [dynamicSnapPoint, setDynamicSnapPoint] = useState(300); //#endregion //#region hooks + const { setOptions } = useNavigation(); const bottomSheetRef = useRef(null); const { top: topSafeArea, bottom: bottomSafeArea } = useSafeAreaInsets(); //#endregion //#region variables - const snapPoints = useMemo(() => [150, dynamicSnapPoint], [dynamicSnapPoint]); + const snapPoints = useMemo(() => [150, 400, '100%'], []); const animatedPosition = useSharedValue(0); + const animatedContainerHeight = useSharedValue(800); //#endregion //#region styles @@ -83,12 +89,21 @@ const BasicExample = () => { const handleSnapPress = useCallback(index => { bottomSheetRef.current?.snapTo(index); }, []); + const handleSnapPosition = useCallback(position => { + bottomSheetRef.current?.snapTo(position); + }, []); const handleClosePress = useCallback(() => { bottomSheetRef.current?.close(); }, []); const handleIncreaseDynamicSnapPoint = useCallback(() => { setDynamicSnapPoint(state => state + 50); }, []); + const handleHideHeaderPress = useCallback(() => { + shownHeader.current = !shownHeader.current; + setOptions({ + headerShown: shownHeader.current, + }); + }, []); //#endregion // renders @@ -98,36 +113,45 @@ const BasicExample = () => { label="Increase Dynamic Snap Point" style={styles.buttonContainer} onPress={handleIncreaseDynamicSnapPoint} - /> + /> */}