We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Hello. This is my code:
TestForBsm.tsx
const TestForBsm = ({}) => { /****************************************/ /* Bottom sheet setup */ // ref const bsmTestRef = useRef<BottomSheetModal>(null); // callbacks const handlePresentBsm = useCallback((bsmRef) => { bsmRef.current?.present(); }, []); /****************************************/ return ( <> <Appbar.Header elevated> <Appbar.Content title={"Bsm test"}/> </Appbar.Header> <BottomSheetModalProvider> <ScreenWrapper> <BsmTest bsmRef={bsmTestRef} /> <Button onPress={() => handlePresentBsm(bsmTestRef)} > Click here to open BSM </Button> </ScreenWrapper> </BottomSheetModalProvider> </> ) }
BsmTest.tsx
import React, {useCallback, useMemo} from 'react'; import {View,} from 'react-native'; import {IconButton, List, Text} from 'react-native-paper'; import { BottomSheetBackdrop, BottomSheetFlatList, BottomSheetModal, BottomSheetScrollView, BottomSheetView, } from '@gorhom/bottom-sheet'; import {styles} from "../../styles"; const BsmTest = ({ bsmRef }) => { // variables // const snapPoints = useMemo(() => ['50%', '80%'], []); const snapPoints = useMemo(() => ['50%'], []); // const snapPoints = useMemo(() => [], []); // callbacks const handleBsmDismiss = useCallback(() => { bsmRef.current?.dismiss(); }, []); // renders const renderBackdrop = useCallback( props => ( <BottomSheetBackdrop {...props} opacity={0.5} disappearsOnIndex={-1} appearsOnIndex={0} pressBehavior={"close"} /> ), [] ); // renders const renderItem = ({item}) => { return ( <List.Item {...item}/> ) } return ( <BottomSheetModal ref={bsmRef} index={0} // snapPoints={snapPoints} backdropComponent={renderBackdrop} enableDynamicSizing > <BottomSheetFlatList data={[ { title: "title1", description: "description1", }, { title: "title2", description: "description2", }, { title: "title3", description: "description3", }, ]} renderItem={renderItem} /> </BottomSheetModal> ); }; export default BsmTest;
I'm trying out the enableDynamicSizing prop and it's working fine in the code above.
enableDynamicSizing
Android
iOS
Now, I would like to add a title section in my BottomSheetModal. So I add this codeblock before the BottomSheetFlatList:
<BottomSheetView style={{ marginVertical: 6, marginHorizontal: 8, flexDirection: "row", alignItems: "center" }}> <View style={{flex: 1}}> <Text style={{ fontSize: 20, fontWeight: "bold" }}> My title </Text> </View> <IconButton icon={"close"} size={30} onPress={() => handleBsmDismiss()} /> </BottomSheetView>
What happens with this new codeblock is shown in the videos below.
Android: the Flatlist is not shown in its entirety.
iOS: the BSM height is random.
To fix this I wrap the BottomSheetView and the BottomSheetFlatList in a BottomSheetScrollView.
Android: both the BSSheetView and the BSFlatList are shown correctly.
iOS: the previous issue still persists.
Any ideas on how to fix this?
Describe what you expected to happen:
import React, {useCallback, useMemo} from 'react'; import {View,} from 'react-native'; import {IconButton, List, Text} from 'react-native-paper'; import { BottomSheetBackdrop, BottomSheetFlatList, BottomSheetModal, BottomSheetScrollView, BottomSheetView, } from '@gorhom/bottom-sheet'; import {styles} from "../../styles"; const BsmTest = ({ bsmRef }) => { // variables // const snapPoints = useMemo(() => ['50%', '80%'], []); const snapPoints = useMemo(() => ['50%'], []); // const snapPoints = useMemo(() => [], []); // callbacks const handleBsmDismiss = useCallback(() => { bsmRef.current?.dismiss(); }, []); // renders const renderBackdrop = useCallback( props => ( <BottomSheetBackdrop {...props} opacity={0.5} disappearsOnIndex={-1} appearsOnIndex={0} pressBehavior={"close"} /> ), [] ); // renders const renderItem = ({item}) => { return ( <List.Item {...item}/> ) } return ( <BottomSheetModal ref={bsmRef} index={0} // snapPoints={snapPoints} backdropComponent={renderBackdrop} enableDynamicSizing > <BottomSheetScrollView> <BottomSheetView style={{ marginVertical: 6, marginHorizontal: 8, flexDirection: "row", alignItems: "center" }}> <View style={{flex: 1}}> <Text style={{ fontSize: 20, fontWeight: "bold" }}> My title </Text> </View> <IconButton icon={"close"} size={30} onPress={() => handleBsmDismiss()} /> </BottomSheetView> <BottomSheetFlatList data={[ { title: "title1", description: "description1", }, { title: "title2", description: "description2", }, { title: "title3", description: "description3", }, ]} renderItem={renderItem} /> </BottomSheetScrollView> </BottomSheetModal> ); }; export default BsmTest;
The text was updated successfully, but these errors were encountered:
@MatteoBuffo any updates on this?
Sorry, something went wrong.
@plgrazon not yet, I'm still waiting for an answer.
you can't have BottomSheetFlatList/BottomSheetView inside BottomSheetScrollView. They could both update animatedContentHeight https://github.com/gorhom/react-native-bottom-sheet/blob/master/src/components/bottomSheetScrollable/createBottomSheetScrollableComponent.tsx#L88. Changing it to FlatList/View should work
BottomSheetFlatList
BottomSheetView
BottomSheetScrollView
animatedContentHeight
FlatList
View
@lsdimagine it works! Thanks!
No branches or pull requests
Hello. This is my code:
TestForBsm.tsx
BsmTest.tsx
I'm trying out the
enableDynamicSizing
prop and it's working fine in the code above.Android
bsm_android_1.mp4
iOS
bsm_ios_1.MOV
Now, I would like to add a title section in my BottomSheetModal. So I add this codeblock before the BottomSheetFlatList:
What happens with this new codeblock is shown in the videos below.
Android: the Flatlist is not shown in its entirety.
bsm_android_2.mp4
iOS: the BSM height is random.
bsm_ios_2.MOV
To fix this I wrap the BottomSheetView and the BottomSheetFlatList in a BottomSheetScrollView.
Android: both the BSSheetView and the BSFlatList are shown correctly.
bsm_android_3.mp4
iOS: the previous issue still persists.
Any ideas on how to fix this?
Environment info
Steps To Reproduce
Describe what you expected to happen:
Reproducible sample code
The text was updated successfully, but these errors were encountered: