Closed JonnyBurger closed 6 years ago
This sounds great to me! @JonnyBurger, would you be able to implement this? If so, I think we shoul d move forward!
Sure, will aim to PR within the next week.
It will require some upstream approval first.
react-native-tab-view
--> PR created https://github.com/react-native-community/react-native-tab-view/pull/573react-navigation-tabs
needs to be updated. Will make PR once (1) is published.(1) is done!
Thank you!
Waiting for new version of react-native-tab-view
to be released on npm, then I'll make the next PR.
Made a PR for (2)! I can be responsive over the next few days, if we want to get this into react-navigation 3.0 (which by the way I'm very excited for!)
By the way, possible bug, need to update the import?
react-navigation-tabs/example/App.js
4:38 error Unable to resolve path to module 'react-navigation' import/no-unresolved
thank you @JonnyBurger! that should be fixed on master if you rebase the branch. I left one comment there, otherwise looks good
Summary
Allow to define a handler to be executed upon long pressing a tab item.
Basic example
It is already possible to define a
tabBarOnPress
in the navigationOptions of a tab bar. My proposal is to duplicate this exact handler, but call ittabBarOnLongPress
and use instead of using theonPress
method from react-native, use theonLongPress
method instead. You could use this to for example show a drawer or more navigation items (see Motivation section).Motivation
Consider the pattern that Instagram uses for account switching. It is possible to long press the last tab item, and then switch to another account from a drawer.
Here is another example: You can long-press on a tab bar item in Tweetbot to reveal more sections of the app that do not fit in the tab bar.
The motivation for this proposal is to enable more UI patterns for developers such as the ones shown above. Instagram is a mainstream app with over a billion users and includes this gesture. This means that users are quickly getting more familiar with this gesture, which is why
react-navigation
should support it as well.Detailed design
The underlying logic of the
tabBarOnPress
event handler should be duplicated, but it should listen to theonLongPress
event fromreact-native
instead. For consistency, the event handler inreact-navigation
should be calledtabBarOnLongPress
.Drawbacks
I don't see any drawbacks of supporting this. However see the following section:
Alternatives
When considering to add support for
tabBarOnLongPress
, it also brings up the question what to do with the other events likeonPressIn
,onMagicTap
,onAccessibilityTap
etc. Instead of explicitly adding support fortabBarOnLongPress
, you may want to opt for a more generic design.Adoption strategy
No breaking change, no codemod or coordination with other projects needed. It should be added to documentation and mentioned in the release notes to spread the word.
How we teach this
The new feature is analogue to the
tabBarOnPress
event handler and does not introduce a new paradigm.react-navigation
can still be teached in the exact same way.Unresolved questions
See alternatives.