-
Notifications
You must be signed in to change notification settings - Fork 0
/
BottomSheet.tsx
51 lines (45 loc) · 1.29 KB
/
BottomSheet.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import { useCallback, useMemo, useRef } from 'react'
import { Button, StyleSheet, Text } from 'react-native'
import { GestureHandlerRootView } from 'react-native-gesture-handler'
import BottomSheet, { BottomSheetBackdrop, BottomSheetScrollView } from '@gorhom/bottom-sheet'
export const BottomSheetView = () => {
const ref = useRef<BottomSheet>(null)
const snapPoints = useMemo(() => ['25%', '50%'], [])
const handleSheetChanges = useCallback((index: number) => {
console.log('handleSheetChanges', index)
}, [])
return (
<GestureHandlerRootView style={css.container}>
<Button title="Open" onPress={() => ref.current?.snapToIndex(1)} />
<BottomSheet
ref={ref}
index={1}
snapPoints={snapPoints}
onChange={handleSheetChanges}
backdropComponent={(props) => {
return <BottomSheetBackdrop {...props} onPress={() => ref.current?.close()} />
}}
>
<BottomSheetScrollView style={css.sheetContainer}>
<Text>Awesome2 2🎉</Text>
</BottomSheetScrollView>
</BottomSheet>
</GestureHandlerRootView>
)
}
const css = StyleSheet.create({
container: {
flex: 1,
height: '100%',
justifyContent: 'center',
},
sheetContainer: {
flex: 1,
},
input: {
backgroundColor: 'rgba(151, 151, 151, 0.25)',
borderRadius: 10,
padding: 12,
width: '80%',
},
})