Recommended patterns for menus and dialogs
@brentvatne がすでに取り組んでいます。
2018年2月6日 から。
評価
この issue はまだ評価されていません。
説明
Copied from https://github.com/react-navigation/react-navigation/issues/1315
The preferred pattern for handling dialogs and menus don't seem to have been discussed yet.
Menus that open from a menu button are a fairly common pattern.
I can see 2 possible ways they might be implemented:
- As part of params: Menu is part of a scene's children, headerRight uses
setParamsto set a param indicating the menu is open and that param is passed to whatever prop on the menu indicates it is open. Closing the menu is anothersetParams. One would have to either use<Modal />or manually register aBackAndroid(nowBackHandler) to handle the Android "back button closes menu instead of navigating backwards" pattern. - As a navigator: Menus are implemented as a part of a MenuNavigator (or maybe a ModalNavigator), the navigator is used in place of the screen for a route in your {Stack,Drawer,Tab}Navigator and accepts one route that is the normal screen and other routes are menus. Menus are opened using
navigator.navigate('MenuName')and exited usingnavigator.goBack().
Dialogs are another modal type to consider (given the drawer is already considered a navigator).
Drawers make less sense as part of props but there are still 2-3 patterns I can think of for them:
- A DialogNavigator: Just like the MenuNavigator/ModalNavigator I described a DialogNavigator would be used in place of a normal screen and allow
navigator.navigateto open a specific dialog from the associated screen. - A top-level DialogNavigator: Instead of taking place of a deeper screen, the DialogNavigator would be top-level like the DrawerNavigator is. This would allow it to easily sit on top of everything else and put dialogs on top. Dialogs would become global, which could be a pro or a con depending on the app.
- As part of StackNavigator: Instead of a whole separate navigator StackNavigator would be modified to support modals (routes that can have no headers of their own, are drawn transparently over top of the other screens, and have a separate transition type). From the nesting and navigation perspectives this is a little simpler. There is no extra nesting of navigators that could make
navigation.navigatecalls more complex in any scenario, opening a dialog by navigating to it is simple, and closing a dialog vianavigator.goBack()is built-in. Also this would already handle full-screen dialogs pretty well and handle the tablet+mobile environment where a route may be a full-screen dialog with a header in the stack route on mobile but be a dialog on a tablet without a header.
Full-screen dialogs themselves are probably a separate more precise discussion.
- 主要言語
- JavaScript
- スター
- 324
- フォーク
- 2k
- PR マージ指標
- 30日以内にマージされた PR はありません
コントリビューションガイド
このリポジトリのコントリビューションガイドは索引されていません
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
react-navigation/react-navigation.github.io のほかの issue
-
難易度 1/5 1時間未満 初心者へのやさしさ 94/100
react-navigation/react-navigation.github.io#1516 · コメント 1 件 ·
-
難易度 1/5 1時間未満 初心者へのやさしさ 90/100
-
難易度 1/5 1時間未満 初心者へのやさしさ 72/100
-
難易度 1/5 1〜3時間 初心者へのやさしさ 68/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
react-navigation/react-navigation.github.io の issue をすべて見る
似ている issue
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
avniproject/avni-client#2135 ·
-
automated broken-link
難易度 1/5 1時間未満 初心者へのやさしさ 85/100
-
agent/security hive/hosted-available-lke648397-260827-5n31 security
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
-
enhancement
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
babalae/bettergi-scripts-list#3674 ·
-
A-Release-Notes C-Editing D-Modest S-Ready-For-Implementation
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
bevyengine/bevy-website#2595 ·