1- import React , { useCallback , useMemo , useRef , useState } from 'react' ;
2- import { View , StyleSheet , Text } from 'react-native' ;
3- import BottomSheet , { BottomSheetFooter } from '@gorhom/bottom-sheet' ;
4- import { useSafeAreaInsets } from 'react-native-safe-area-context' ;
5- import SearchHandle from '../../components/searchHandle' ;
1+ import React , { useCallback , useMemo , useRef } from 'react' ;
2+ import { View , StyleSheet } from 'react-native' ;
3+ import BottomSheet from '@gorhom/bottom-sheet' ;
64import Button from '../../components/button' ;
75import ContactList from '../../components/contactList' ;
6+ import customFooter from '../../components/customFooter' ;
7+ import searchHandle from '../../components/searchHandle' ;
88
99const FooterExample = ( ) => {
10- // state
11- const [ fadeBehavior , setFadeBehavior ] = useState < 'none' | 'fade' > ( 'none' ) ;
12- const [ slideBehavior , setSlideBehavior ] = useState < 'none' | 'slide' > ( 'none' ) ;
13- const [ scaleBehavior , setScaleBehavior ] = useState < 'none' | 'scale' > ( 'none' ) ;
14-
1510 // hooks
1611 const bottomSheetRef = useRef < BottomSheet > ( null ) ;
17- const { bottom : bottomSafeArea } = useSafeAreaInsets ( ) ;
1812
1913 // variables
20- const snapPoints = useMemo ( ( ) => [ 80 , 250 ] , [ ] ) ;
21- const appearanceBehavior = useMemo (
22- ( ) => [ fadeBehavior , slideBehavior , scaleBehavior ] ,
23- [ fadeBehavior , slideBehavior , scaleBehavior ]
24- ) ;
14+ const snapPoints = useMemo ( ( ) => [ '25%' , '50%' ] , [ ] ) ;
2515
2616 // callbacks
27- const handleFadeBehavior = useCallback ( ( ) => {
28- setFadeBehavior ( state => ( state === 'none' ? 'fade' : 'none' ) ) ;
29- } , [ ] ) ;
30- const handleScaleBehavior = useCallback ( ( ) => {
31- setScaleBehavior ( state => ( state === 'none' ? 'scale' : 'none' ) ) ;
32- } , [ ] ) ;
33- const handleSlideBehavior = useCallback ( ( ) => {
34- setSlideBehavior ( state => ( state === 'none' ? 'slide' : 'none' ) ) ;
35- } , [ ] ) ;
3617 const handleExpandPress = useCallback ( ( ) => {
3718 bottomSheetRef . current ?. expand ( ) ;
3819 } , [ ] ) ;
@@ -46,18 +27,6 @@ const FooterExample = () => {
4627 // renders
4728 return (
4829 < View style = { styles . container } >
49- < Button
50- label = { `Toggle Fade Behavior: ${ fadeBehavior } ` }
51- onPress = { handleFadeBehavior }
52- />
53- < Button
54- label = { `Toggle Scale Behavior: ${ scaleBehavior } ` }
55- onPress = { handleScaleBehavior }
56- />
57- < Button
58- label = { `Toggle Slide Behavior: ${ slideBehavior } ` }
59- onPress = { handleSlideBehavior }
60- />
6130 < Button label = "Expand" onPress = { handleExpandPress } />
6231 < Button label = "Collapse" onPress = { handleCollapsePress } />
6332 < Button label = "Close" onPress = { handleClosePress } />
@@ -66,17 +35,15 @@ const FooterExample = () => {
6635 snapPoints = { snapPoints }
6736 keyboardBehavior = "interactive"
6837 keyboardBlurBehavior = "restore"
69- handleComponent = { SearchHandle }
38+ enablePanDownToClose = { true }
39+ handleComponent = { searchHandle }
40+ footerComponent = { customFooter }
7041 >
71- < ContactList count = { 10 } type = "FlatList" />
72- < BottomSheetFooter
73- bottomInset = { bottomSafeArea }
74- appearanceBehavior = { appearanceBehavior }
75- >
76- < View style = { styles . footer } >
77- < Text style = { styles . footerText } > this is a footer!</ Text >
78- </ View >
79- </ BottomSheetFooter >
42+ < ContactList
43+ count = { 10 }
44+ type = "FlatList"
45+ enableFooterMarginAdjustment = { false }
46+ />
8047 </ BottomSheet >
8148 </ View >
8249 ) ;
@@ -88,13 +55,22 @@ const styles = StyleSheet.create({
8855 padding : 24 ,
8956 } ,
9057 footer : {
58+ alignSelf : 'flex-end' ,
9159 justifyContent : 'center' ,
9260 alignItems : 'center' ,
93- marginHorizontal : 12 ,
94- padding : 12 ,
95- marginBottom : 12 ,
96- borderRadius : 24 ,
61+ marginHorizontal : 24 ,
62+ width : 50 ,
63+ height : 50 ,
64+ borderRadius : 25 ,
9765 backgroundColor : '#80f' ,
66+ shadowOffset : {
67+ width : 0 ,
68+ height : 12 ,
69+ } ,
70+ shadowOpacity : 0.25 ,
71+ shadowRadius : 8.0 ,
72+
73+ elevation : 24 ,
9874 } ,
9975 footerText : {
10076 fontSize : 16 ,
0 commit comments