react-native-raw-bottom-sheet icon indicating copy to clipboard operation
react-native-raw-bottom-sheet copied to clipboard

[Feature Request]: Dynamic Sizing

Open Praisecodes opened this issue 1 year ago • 5 comments

Could the team enable dynamic sizing for bottom sheets? It'll be really nice if the bottom sheet could automatically adjust to the height of the content. We could have the option of snap points to show points to which the bottom sheet opens to.

Praisecodes avatar Sep 25 '24 12:09 Praisecodes

yes i have same request. dynamic height from children and snappoints

rthic23 avatar Sep 25 '24 15:09 rthic23

I also have this need

TallNutAlt avatar Dec 03 '24 05:12 TallNutAlt

I came up with a little hack that works..

import React, { useRef, useEffect } from 'react';
import RBSheet from 'react-native-raw-bottom-sheet';
import { StyleSheet, SafeAreaView, View, Dimensions } from 'react-native';

export default function BottomSheet({ children, height = '92%', openDuration = 250 }: any) {
    const sheetRef = useRef(null) as any;

    // Convert percentage string to actual height if needed
    const getHeight = () => {
        if (typeof height === 'string' && height.includes('%')) {
            const percentage = parseInt(height) / 100;
            return Dimensions.get('window').height * percentage;
        }
        return height;
    };

    useEffect(() => {
        // Automatically open the bottom sheet when the component mounts
        sheetRef.current.open();
    }, []);

    return (
        <SafeAreaView style={{ flex: 1 }}>
            <RBSheet ref={sheetRef} height={getHeight()} openDuration={openDuration}
                customStyles={{ container: styles.container }}>
                <View style={styles.sheetContent}>
                    {children}
                </View>
            </RBSheet>
        </SafeAreaView>
    );
}

const styles = StyleSheet.create({
    container: {
        borderTopLeftRadius: 14,
        borderTopRightRadius: 14,
    },
    sheetContent: {
        padding: 24,
        alignItems: 'stretch',
    },
});

iamvinny avatar Dec 28 '24 06:12 iamvinny

The package excellent but for this dynamic height support I am in search for different package.

IKTANIM avatar Feb 21 '25 04:02 IKTANIM

You can just add in customStyle:

 container: {
      height: 'auto',
 }

angelopedroso avatar Mar 25 '25 13:03 angelopedroso