rn-sliding-up-panel icon indicating copy to clipboard operation
rn-sliding-up-panel copied to clipboard

SafeAreaView not working

Open Dr1992 opened this issue 5 years ago • 5 comments

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

  • Version: FILL THIS OUT
  • React Native version:0.59.5
  • React Native CLI: 2.0.1
  • Platform(s) (iOS, Android, or both?): iOS
  • Device info (Simulator/Device? OS version? Debug/Release?): Simulator iPhone X

Dr1992 avatar Jun 22 '19 21:06 Dr1992

Are you using the built-in SafeAreaView?

octopitus avatar Jul 11 '19 04:07 octopitus

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

octopitus avatar Jul 11 '19 06:07 octopitus

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

Dr1992 avatar Jul 20 '19 15:07 Dr1992

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

jamesholcomb avatar Aug 09 '19 19:08 jamesholcomb

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

joelrorseth avatar Aug 14 '19 23:08 joelrorseth