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

Panel does not come up on android #166

Open Wugka opened 4 years ago

Wugka commented 4 years ago

Issue Description

Panel does not come up on android when I click on the button "Show panel". It does come up on ios. Yours is the best sliding lib so far. Please guide me on this. BHVpr

Steps to Reproduce / Code Snippets / Screenshots

const CCTVTab = () => {
  return (
    <React.Fragment>
      <View
        style={{
          flex: 1,
          marginTop: 30,
          flexDirection: 'column',
          justifyContent: 'center',
          alignContent: 'center',
        }}>
        <Button title="Show panel" onPress={() => _panel.show(300)} />
      </View>

        <SlidingUpPanel
          style={{borderTopLeftRadius: 10}}
          ref={c => (_panel = c)}>
          <View
            style={{
              flex: 1,
              backgroundColor: 'black',
              alignItems: 'center',
              borderTopRightRadius: 18,
              borderTopLeftRadius: 18,
            }}>
            <Text>Header</Text>
            <Text>Content</Text>
            <Button title="Hide" onPress={() => _panel.hide()} />
          </View>
        </SlidingUpPanel>

    </React.Fragment>
  );
};

Environment

drb1 commented 4 years ago

I am also stuck in same problem.It works well on ios but not in android..

afrojuju1 commented 4 years ago

same here. The panel does not slide down on android

octopitus commented 4 years ago

@Wugka which emulator device were you using? I've tried on a Nexus 5X with API 29 and real devices (Pixel 4, Samsung s10) it worked just fine.

octopitus commented 4 years ago

@afrojuju1 @drb1 Which device did you use to test?

Wugka commented 4 years ago

@Wugka which emulator device were you using? I've tried on a Nexus 5X with API 29 and real devices (Pixel 4, Samsung s10) it worked just fine.

Thanks for ther response,

I'm using Pixel 2 API 27. With above code, It does not work on Android, but there's a change in opacity when I click the button. I've tried Nexus 5X API 29 and the outcome is still the same. If yours work then there must be something wrong with my code.

On the left is Nexus 5X API 29 and on the right is Pixel 2 API 27. Capture1

drb1 commented 4 years ago

I have also checked in google nexus emulator but now i have removed the package and used another one.Thank you for your response.

octopitus commented 4 years ago

@Wugka Have you tried testing without the navigator? I suspect the navigator library (react-navigation?) somehow mess up the style of the panel.

If that doesn't work, try replacing:

- <SlidingUpPanel
-   style={{borderTopLeftRadius: 10}}
-   ref={c => (_panel = c)}>
+ <SlidingUpPanel
+   containerStyle={{flex: undefined, alignSelf: undefined}}
+   ref={(c) => (_panel = c)}>

This basically is to remove the flex properties of the panel.

lukemcgregor commented 4 years ago

I've had this on android also when using react-navigation drawers. It looks like its to do with content that is positioned off the screen and then translated back onto the screen. I imagine what's happening is that android is optimising the render away and then it's null as it gets moved into view.

I don't know why this could possibly help (but I found it while debugging), but if you set borderColor: 'transparent' on the screen view the SlidingUpPanel is in it seems to avoid the issue. eg:

  <View style={{ flex: 1, borderColor: 'transparent' }}>
    //other stuff
    <SlideUpPanel. .... />
 </View>

Touching borders must do something to the render optimisation, go figure...

bakerac4 commented 4 years ago

I've tried everything listed and nothing has seemed to help. Im using a real Samsung Galaxy 9+

ghobashy commented 4 years ago

same issue, anyone found a solution?

ghobashy commented 4 years ago

I removed the parent <View> tag and that fixed my problem. Maybe that would help someone.

Wugka commented 4 years ago

@ghobashy I do not have parent <View> tag on my <SlidingUpPanel>as you can see in my example. Can you please share what you did to make it work ?

hasanej commented 2 years ago

anyone found the solution yet? just using this package and stumble into the same issue