octopitus / rn-sliding-up-panel

Draggable sliding up panel implemented in React Native https://octopitus.github.io/rn-sliding-up-panel/
MIT License
928 stars 157 forks source link

SafeAreaView not working #133

Open Dr1992 opened 5 years ago

Dr1992 commented 5 years ago

Issue Description

I am trying to put SlidingUpPanel inside SafeAreaView but is not working. SlidingUpPanel looks like without SafeAreaView in bootom screen and it is not cool on iPhone X

Steps to Reproduce / Code Snippets / Screenshots

image

image

image


Environment

octopitus commented 5 years ago

Are you using the built-in SafeAreaView?

octopitus commented 5 years ago

If you are using the built-in one, consider switching to community's SafeAreaView. Works as expected.

Screen Shot 2019-07-11 at 2 15 18 PM

Dr1992 commented 5 years ago

Yeah Thanks. It worked fine but anyway it should be able to work with import { SafeAreaView } from 'react-navigation'

jamesholcomb commented 5 years ago

Did you try setting the backdropStyle.top to a negative offset to account for your header and statusbar?

joelrorseth commented 5 years ago

I just found your issue while trying to debug my own problems with SafeAreaView. I couldn't seem to calculate the correct draggableRange, to allow my header to stay within the top and bottom safe areas. After a lot of trial and error, I found that the following worked. Hopefully this helps somebody else:

import { getInset } from 'react-native-safe-area-view';
const { width, height } = Dimensions.get('window');
const landScape = width > height;
const topPadding = getInset('top', landScape);
const bottomPadding = getInset('bottom', landScape);
<SlidingUpPanel
    draggableRange={{
        top: height - topPadding - bottomPadding,
        bottom: PANEL_HEADER_HEIGHT,
    }}
    height={height - topPadding}
/>

This manages to keep my header (in purple) within the safe area. Seems to work with the community and built in versions of SafeAreaView. The height is set so that the fully dragged up view aligns its bottom with the bottom of screen.

Simulator Screen Shot - iPhone X - 2019-08-14 at 18 58 08 Simulator Screen Shot - iPhone X - 2019-08-14 at 18 58 05