question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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

See original GitHub issue

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.

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
numandev1commented, Oct 4, 2021

@blackstoom i will fix it after one or two days

1reaction
nickolasmdasilvacommented, May 4, 2022

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}

Read more comments on GitHub >

github_iconTop Results From Across the Web

[BUG] Bottom sheet cannot be hide in android phone ... - GitHub
This is because when I disable the notch display on my system setting, the bottom sheet works as expected. This happens on my...
Read more >
android - Bottomsheet wont hide completely on some devices
I think there is a problem with NestedScrollView, try using just a ScrollView and if not working still just remove the scrollview to...
Read more >
Top and bottom look uneven when hiding the notch
When using the hide the notch option on the OnePlus 6, I can't help but notice that the top bezzle is so much...
Read more >
Layout - Foundations - Human Interface Guidelines - Design
If your app runs on a specific device, make sure it runs on every screen size for that device. In other words, an...
Read more >
Android Player settings - Unity - Manual
In this mode, the navigation bar is always hidden. ... where the bottom of the application's window aligns with the bottom of the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found