Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow changing mode in navigationOptions for dynamic modal #2308

Closed
wants to merge 31 commits into from

Conversation

JulianKingman
Copy link

@JulianKingman JulianKingman commented Aug 3, 2017

I need dynamic modals in my project and couldn't wait for #1378. It looked simple enough to implement, so I went ahead with it :)

I've got navigation animations working, but I'm having a heck of a time configuring the "back" animation.

Any idea where I can configure the navigator in such a way that I can influence the animation, and have per-screen navigationOptions available? As far as I can tell, isModal is currently defined in CardStackTransitioner here: https://github.com/react-community/react-navigation/blob/master/src/views/CardStack/CardStackTransitioner.js#L77, which seems to apply isModal to the navigator universally.

@JulianKingman
Copy link
Author

Turns out I was wrong, setting isModal in CardStackTransitioner doesn't do the trick either, so I have no idea where the back animation comes from if not there, I can't find any reference to it.

@davojan
Copy link

davojan commented Aug 8, 2017

@JulianKingman Back animation seems to be a separate issue. Even without your changes it's behaviour is odd in "Modal Stack Example" - "Go to profile screen" is animated vertically, but back-animation is horizontal.

In your modified example back navigation starts to work as expected if you click "Go to a photos screen" one more deeper and then click "Go back".

@davojan
Copy link

davojan commented Aug 8, 2017

Nope, I was wrong. In "Modal Stack Example" there is a nested navigator that causing unintuitive behaviour.

But the good news is I made it to work correctly during back navigation! Check this out:
procraft@fa2a383#diff-95db94c88696779a7ac6a0fe1af87ebeR390

@JulianKingman
Copy link
Author

Brilliant, thanks @davojan! I added the fix to my PR.

@JulianKingman
Copy link
Author

  • Test thoroughly and describe how you tested it
    I added examples to the NavigationPlayground and tested a modal type screen in a card stack, and a card type screen in a modal
  • Add an example to the playground app that utilizes this new option
    Yes, done (see SimpleStack and ModalStack for examples)
  • Take screenshots/videos of the behavior on both platforms
    Here:
    modalnavigationoption
  • Write documentation
    Done

@JulianKingman
Copy link
Author

@ericvicenti FYI, ready for review

@davojan
Copy link

davojan commented Aug 28, 2017

@JulianKingman I guess you should fix linter errors reported by the circleci before they'll consider reviewing :)

@JulianKingman
Copy link
Author

Fixed.

@claykohut
Copy link

claykohut commented Aug 31, 2017

Getting this error when trying to use this fork:
screen shot 2017-08-31 at 1 00 27 pm

@maxstoller
Copy link

maxstoller commented Sep 11, 2017

Working well for me, would be nice to see it merged. Thanks for sharing @JulianKingman!

@kelset
Copy link

kelset commented Sep 11, 2017

Looks like there are some conflicts, can you fix them? I'll try to check the PR asap

@@ -15,7 +15,7 @@
"flow-bin": "^0.49.1",
"react": "16.0.0-alpha.12",
"react-native": "^0.45.1",
"react-navigation": "*"
"react-navigation": "designmanio/react-navigation"

This comment was marked as abuse.

@dccarmo
Copy link

dccarmo commented Oct 23, 2017

Any updates on this? It seems the conflicts are minimal (documentation and dependencies), so I guess it shouldn't be too hard to update and approve it?

@helielson
Copy link

@JulianKingman good job.
Are you having any issues to update this branch?

"minify": false,
"urlType": "exp",
"urlRandomness": null
}

This comment was marked as abuse.

This comment was marked as abuse.

@codecov-io
Copy link

codecov-io commented Feb 1, 2018

Codecov Report

Merging #2308 into master will increase coverage by 0.07%.
The diff coverage is 86.66%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2308      +/-   ##
==========================================
+ Coverage   72.75%   72.83%   +0.07%     
==========================================
  Files          53       53              
  Lines        1659     1671      +12     
  Branches      435      439       +4     
==========================================
+ Hits         1207     1217      +10     
- Misses        357      359       +2     
  Partials       95       95
Impacted Files Coverage Δ
src/routers/createConfigGetter.js 96.42% <ø> (ø) ⬆️
src/TypeDefinition.js 0% <ø> (ø) ⬆️
src/views/CardStack/CardStack.js 44.61% <100%> (+2.21%) ⬆️
src/views/CardStack/CardStackTransitioner.js 81.25% <75%> (-7.64%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 7141f66...8e62e01. Read the comment docs.

@@ -14,32 +14,44 @@ const MyNavScreen = ({ navigation, banner }) => (
top: navigation.state.routeName === 'HeaderTest' ? 'always' : 'never',
}}
>
<SampleText>{banner}</SampleText>
<SampleText>{banner}</SampleText>

This comment was marked as abuse.

This comment was marked as abuse.

<Button onPress={() => navigation.goBack(null)} title="Go back" />
<StatusBar barStyle="default" />
</SafeAreaView>
);
}
}

const Modal = ({navigation}) => (
<MyNavScreen
banner={`Modal in Screen Navigator`}

This comment was marked as abuse.

@@ -14,7 +14,7 @@
"expo": "^25.0.0",
"react": "16.2.0",
"react-native": "^0.52.0",
"react-navigation": "link:../.."
"react-navigation": "file:../.."

This comment was marked as abuse.

This comment was marked as abuse.

This comment was marked as abuse.

This comment was marked as abuse.

@helielson
Copy link

@spencercarli @stereodenis @Andreyco @kelset the branch is now updated.
Can you review it again?

@kelset
Copy link

kelset commented Feb 1, 2018

I think @ericvicenti should be the one reviewing this because we are undergoing some massive changes so I'm not sure this will be needed

@raarts
Copy link

raarts commented Feb 1, 2018

we are undergoing some massive changes

is that documented somewhere, this makes me worried.

@kelset
Copy link

kelset commented Feb 1, 2018

You can check the commits on master. We are not yet ready release a new version / post the release notes because we are still changing stuff, but yeah PR section & commits in master are the best way to be up-to-date if you don't want to wait for next release.

Copy link
Contributor

@ericvicenti ericvicenti left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One concern is that horizontal (non-modal) mode is super tricky, because you need to animate the previous screen at the same time as the active scene. So I think we do want to support this use case, but I'm not sure that hacking on CardStack is the best way to do it.

if (navigation.state.routes && navigation.state.routes[1]) {
screenOptions = router.getScreenOptions(
addNavigationHelpers({
state: navigation.state.routes[1],

This comment was marked as abuse.

@ericvicenti
Copy link
Contributor

And yes, as @kelset mentioned, we do have some big changes happening in this area. It should make features like this easier to add, moving forward!

See the suggested changes here: #3392
and the RFC here: https://github.com/react-navigation/rfcs/blob/master/text/0002-navigator-view-api.md

@raarts , we are ramping up support, it shouldn't concern you! Feel free to follow along with progress on the issues and PRs in this repo, and by keeping an eye on the RFCs repo: https://github.com/react-navigation/rfcs

SoundBlaster and others added 2 commits February 7, 2018 18:17
This property very useful for customising TabBar look, but available only on Android. This commit add support for it for iOS.
Support iconStyle Tab Bar property on iOS
@RobPando
Copy link

RobPando commented Feb 9, 2018

My bad for the intrusion, but is this still in consideration to merge in or similar future solution? I need this bad.

@brentvatne
Copy link
Member

I agree with @ericvicenti's assessment here, I'm not sure that this is the way we want to go for supporting modals. It may be, but I'd like to discuss further and have a proper RFC for this as it's a really key piece of the ergonomics of a navigation library (that we have up until now not provided a well-defined and supported path for, aside from creating a modal stack navigator). Please see this RFC placeholder issue: react-navigation/rfcs#15 -- if you want to take a stab at designing a solution to this, let's discuss there and we can take it into a formal RFC. Thank you @JulianKingman for this PR and creating good discussion around this, and sorry to everyone who has to continue to use a fork to support this feature!

@brentvatne brentvatne closed this Feb 9, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet