wix / react-native-navigation

A complete native navigation solution for React Native
https://wix.github.io/react-native-navigation/
MIT License
13.04k stars 2.67k forks source link

Addition of some sort of WillFocus, DidFocus mechanism. #150

Closed lprhodes closed 7 years ago

lprhodes commented 8 years ago

Hi,

I just saw that you were currently working on 2.0 of RCC/RNN. I'd love for WillFocus, DidFocus notifications to be included within this.

In my case I need to perform actions when a user moves to a specific tab.

I've hacked this into the current version by sending the navigatorEventID to the RCCNavigationController and sending an app event from the viewWillAppear of RCCViewController in the same way the back buttons are handled.

onNavigatorEvent (event) { if (event.type === 'DidFocus') { this.doSomething() } }

Thanks! Luke

guyca commented 8 years ago

Hey @lprhodes We're going to add life cycle events to the screens, this should give us indication when a screen is displayed after tab press or back button press etc.

phuna commented 8 years ago

@guyca will those life cycle events be available soon? I need something like viewWillAppear to update list view after adding a record to the list. Thank you.

phuna commented 8 years ago

@lprhodes : can you elaborate the mechanism you're using to achieve that kind of 'DidFocus' event with react-native-navigation? Thanks in advance.

lprhodes commented 8 years ago

Hi @phuna,

I've just forked in order to integrate this now - I imagine the implementation @guyca has in mind will be vastly different but it achieves what I need right now.

It requires amends to both RNC and RNN:

https://github.com/lprhodes/react-native-controllers/commit/f6f0ba1b0fe5e0d0e0fc1d7a232b124a88dce16b

https://github.com/lprhodes/react-native-navigation/commit/31bd2c5d7c3b33febebcdae0c6621af0ed7ad09c

Then you can intercept with the same navigator events as you use for nav bar button actions:

onNavigatorEvent (event) {
  if (event.type === 'DidFocus') {
    this.doSomething()
  }
}
phuna commented 8 years ago

Hi @lprhodes : Thanks a lot for sharing

kkesley commented 8 years ago

is this feature implemented yet?

DanielZlotin commented 8 years ago

Nope. soon. first, RN31, merge controllers, and a bunch of redesign :)

kkesley commented 8 years ago

Ok, Thanks for the info @DanielZlotin ! You guys are awesome!

adamski commented 8 years ago

This would be great to have on Android too!

indivisable commented 8 years ago

Any updates on this? What is best way to implement for now?

musicode commented 7 years ago

any update?

musicode commented 7 years ago

Any updates about this?

DanielZlotin commented 7 years ago

follow the progress in this branch

musicode commented 7 years ago

Is 2.0.0 done and 2.1.0 developing?

guyca commented 7 years ago

@musicode Yes, As Daniel said in https://github.com/wix/react-native-navigation/issues/150#issuecomment-280913247, v2 is under development.

musicode commented 7 years ago

that is said,screen lifecycle is supported, right?

guyca commented 7 years ago

Yes.

musicode commented 7 years ago

v2 branch is supported for RN0.40 ?

I am confused by master branch and v2 branch.

guyca commented 7 years ago

v2 branch is under development and not production ready.