cesardeazevedo / react-native-collapsing-toolbar

react-native wrapper for android CollapsingToolbarLayout
MIT License
293 stars 33 forks source link

bug when the phone is turned off in the app with the component #15

Open magestein opened 6 years ago

magestein commented 6 years ago

Hello, I found a bug.. When the phone is turned off in the application and then the phone is turned on again then the collapsing component no longer works, is there any way to solve this? I add a video of the problem: https://streamable.com/7e3g8

Regards,

cesardeazevedo commented 6 years ago

Hi, thanks for report, have you experience this issue even with a production build? which react-native version are you using?

magestein commented 6 years ago

Hi Cesar, thats happen in react-native 0.55.0.. and also happen with '--variant=release'. Is there a suggestion of compatibility with some version of react-native? Thanks

cesardeazevedo commented 6 years ago

I haven't tried new version from react-native yet, so i presume that new versions "just works".

Have you tried call the redraw() function from the AppBarLayout ref on componentDidMount or when the app came back from the background (by AppState)?

magestein commented 6 years ago

I have try:

_handleAppStateChange = (nextAppState) => {
    if (this.state.appState.match(/inactive|background/) && nextAppState === 'active') {
        this.appBar.redraw();
    }
    this.setState({appState: nextAppState});
};

componentDidMount() {
    AppState.addEventListener('change', this._handleAppStateChange);
}

componentWillUnmount() {
    AppState.removeEventListener('change', this._handleAppStateChange);
}

<AppBarLayout ref={(ref) => { this.appBar = ref }}>
</AppBarLayout>

but without luck :(

magestein commented 6 years ago

I have noted that redraw() some times work and some times not. Maybe the code that I showed is wrong?

cesardeazevedo commented 6 years ago

Interesting, i will take a look at it as soon as i get some time this week

magestein commented 6 years ago

Thank you! I appreciate that very much!

cesardeazevedo commented 6 years ago

Hi, sorry for delayed response, i've fully reproduced your issue on my simulator, and i have tested your code and worked, i tested multiple times and never had any single attempt that didn't worked.

Here's a demonstration collapsing

Or maybe i am testing wrong? any idea?

I also don't think this is the best solution at all, it's actually really hard to understand how native modules behave in certain situations, i will still think in some pleasant solution.

mahmoudelfeky commented 6 years ago

try it in on real device you will see the problem

A-ANing commented 5 years ago

@magestein Hello, how did you solve it? I'm just like you, but I happened when the application was started, not when the application was waked up. #21