-
Notifications
You must be signed in to change notification settings - Fork 0
/
App.tsx
48 lines (42 loc) · 1.2 KB
/
App.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
import { StatusBar } from "expo-status-bar"
import { useCallback, useRef } from "react"
import { StyleSheet, TouchableOpacity, View } from "react-native"
import { GestureHandlerRootView } from "react-native-gesture-handler"
import { BottomSheet, BottomSheetRefProps } from "./components/BottomSheet"
export default function App() {
const ref = useRef<BottomSheetRefProps>(null)
const onPress = useCallback(() => {
const isActive = ref?.current?.isActive()
if (isActive) {
ref?.current?.scrollTo(0)
} else {
ref?.current?.scrollTo(-200)
}
}, [])
return (
<GestureHandlerRootView style={{ flex: 1 }}>
<View style={styles.container}>
<StatusBar style="light" />
<TouchableOpacity style={styles.button} onPress={onPress} />
<BottomSheet ref={ref}>
<View style={{flex: 1, backgroundColor: "orange"}}/>
</BottomSheet>
</View>
</GestureHandlerRootView>
)
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: "#111",
alignItems: "center",
justifyContent: "center",
},
button: {
height: 50,
borderRadius: 25,
aspectRatio: 1,
backgroundColor: "#fff",
opacity: 0.6,
}
})