numandev1 / react-native-bottomsheet-reanimated

React Native bottom sheet with fully native 60 FPS animations and awesome user experience
MIT License
276 stars 28 forks source link

[BUG] Bottom sheet cannot be hide in android phone with notch display #25

Open blackstoom opened 2 years ago

blackstoom commented 2 years ago

Hi, Thanks for the amazing library, I really appreciate that.

I recently encounter an issue where the bottom sheet cannot be hide even the snapPoints is set to 0. After some debugging, I suspect the problem occurred because of the notch display. This is because when I disable the notch display on my system setting, the bottom sheet works as expected. This happens on my Oneplus 6 device.

https://user-images.githubusercontent.com/49148287/135722480-8fe1ae77-e1eb-43ce-b234-41bea98def43.mp4

The video above shows that the bottom sheet cannot be hide. Please note that the little white section at the bottom part of the screen is the bottomsheet. The white section is 16px height which inline with my device notch display height.

https://user-images.githubusercontent.com/49148287/135722522-35051ef4-3a07-4b8f-a7cf-6500fbf3688a.mp4

The bottomsheet hide as expected when I turn of the notch display for my OnePlus 6 device.

import React, {useState, useRef, useCallback} from 'react';
import {ScrollView, StatusBar, StyleSheet, Text, TouchableOpacity, View} from 'react-native';
import {Button} from 'react-native-paper';
import {SafeAreaView} from 'react-native-safe-area-context';
import BottomSheet from 'react-native-bottomsheet-reanimated';
import MaterialIcons from 'react-native-vector-icons/MaterialIcons';

const TestPage = () => {
    const actionSheetRef = useRef(null);

    return (
        <View style={{backgroundColor: 'yellow'}}>
            <StatusBar barStyle={'dark-content'} backgroundColor={'transparent'} translucent />
            <SafeAreaView style={{width: '100%', height: '100%'}}>
                <ScrollView contentContainerStyle={{flexGrow: 1}} keyboardShouldPersistTaps="handled">
                    <View style={styles.bigContainer}>
                        <Button onPress={()=>{
                            actionSheetRef.current.snapTo(1);
                        }}> Testing</Button>

                    </View>
                </ScrollView>
            </SafeAreaView>

            <BottomSheet
                ref={actionSheetRef}
                bottomSheerColor="#FFFFFF"
                initialPosition={0}
                snapPoints={[0, 160]}
                isBackDrop={true}
                isBackDropDismissByPress={true}
                isRoundBorderWithTipHeader={true}
                body={
                    <View style={{paddingVertical: 16}}>
                        <TouchableOpacity
                            onPress={() => {
                                actionSheetRef.current.snapTo(0);
                            }}>
                            <View style={styles.actionButton}>
                                <View
                                    style={{
                                        width: 50,
                                        height: 50,
                                        borderRadius: 25,
                                        overflow: 'hidden',
                                        justifyContent: 'center',
                                        alignItems: 'center',
                                        backgroundColor: 'white',
                                    }}>
                                    <MaterialIcons name="mode-edit" size={24} color={'gray'} />
                                </View>
                                <Text style={styles.actionButtonLabel}>action 1</Text>
                            </View>
                        </TouchableOpacity>
                        <TouchableOpacity
                            onPress={() => {
                                actionSheetRef.current.snapTo(0);
                            }}>
                            <View style={styles.actionButton}>
                                <View
                                    style={{
                                        width: 50,
                                        height: 50,
                                        borderRadius: 25,
                                        overflow: 'hidden',
                                        justifyContent: 'center',
                                        alignItems: 'center',
                                        backgroundColor: 'white',
                                    }}>
                                    <MaterialIcons name="delete" size={24} color={'gray'} />
                                </View>
                                <Text style={styles.actionButtonLabel}>action 2</Text>
                            </View>
                        </TouchableOpacity>
                    </View>
                }
            />
        </View>
    );
};

export default TestPage;

const styles = StyleSheet.create({
    bigContainer: {
        width: '100%',
        height: '100%',
        flex: 1,
        backgroundColor: 'yellow',
        padding: 16,
    },    
    actionButton: {
        width: '100%',
        paddingVertical: 8,
        paddingHorizontal: 16,
        justifyContent: 'flex-start',
        alignItems: 'center',
        flexDirection: 'row',
    },
    actionButtonLabel: {
        fontSize: 14,
        color: 'black',
        marginHorizontal: 16,
    },
});

I have included a partial of my code for your debugging.

I really appreciate if you could fix this. Also anyone has any temporary workaround suggestion?

Thanks for your time.

numandev1 commented 2 years ago

@blackstoom i will fix it after one or two days

blackstoom commented 2 years ago

@nomi9995 Thank you so much for your support and assistance. I'm really appreciate that.

Neel2497 commented 2 years ago

@blackstoom have you solved the issue? I am also having the same issue.

murat0 commented 2 years ago

Same issue here +1 @nomi9995

filippobarcellos commented 2 years ago

Is this fixed? I would love to use the library but without this doesn't make any sense. Thanks

nickolasmdasilva commented 2 years ago

You should to add a header to your page. The only way that I found to fix it.

androidMarginHeader: {
      marginTop: Platform.OS === "android" ? StatusBar.currentHeight  : 0,
   }

and then

containerStyle={styles.androidMarginHeader}