[Android] Provide a PopupMenu component
Currently there is no way to specify an overflow menu icon for Navigator.NavigationBar (or is there?). I can add a custom button, sure, but I cannot find a way to show a menu. Does such a functionality exist?
The Menu component is widely used on Android, and it'll be awesome to have it.
Can you please use Stack Overflow to ask questions and tag them with react-native? http://stackoverflow.com/questions/tagged/react-native
Many people from the community hang out on Stack Overflow and will be able to see your question. Using Stack Overflow for questions also helps us use Github issues to keep track of bugs that need to be fixed.
@mkonicek Hmm... I guess no menu component exists for Android? May be I should change the title. This is more of a feature request than just a question.
@satya164 Do you mean something like the Android Spinner? http://developer.android.com/intl/zh-cn/guide/topics/ui/controls/spinner.html
It's planned for one of the future releases: https://facebook.github.io/react-native/docs/known-issues.html
There's also http://developer.android.com/intl/zh-cn/reference/android/widget/PopupMenu.html
You probably mean this one, right? http://i.stack.imgur.com/j67fB.gif
@mkonicek Yes. I'm talking about the popup menu. I should change my title :)
Adding an overflow icon is not an issue since I can add any custom view. Popup menu is the one. Thanks :)
For now, you can make your own custom button for the navigation bar.
Speaking of the menu, you'd need to build a separate menu or modal dialog separately and use the button as a trigger to open a menu.
@hedgerwang Unfortunately, the Modal component is not yet implemented for Android.
I cannot build a menu either, as everything is overflow: hidden and cannot be changed. Hence there cannot be content larger than the container.
You can make a large container that is transparent and has pointerEvents="box-none" on it, and put a smaller, visible view inside.
Also Modal is intended for hybrid apps. If you are using only React Native, I recommend you use a Navigator w/out NavigationBar.
@ide I'll try it out. I actually need a PopupMenu, not a modal. I'll try to make a native component and send a pull request.
@ide @satya164 Why don't the React Native docs for Modal say "Android is not supported"? This is frustrating.
@niftylettuce want to send a PR to clarify this in Modal's docblock?
@ide Don't really have time, trying to crank out a project.
When Modal component is worked for android also.Thanks
+1
+1
+1
For anyone looking for a quick replacement, react-native-dialogs is a good solution that plugs into native dialogs.
+1
Some way to force a component to the front of the "stack" would be even more helpful, since it'd apply to more than just the Dialog spec.
@Ehesp Totally agree. We used to have a JS-based solution internally but later realized a native implementation works better in hybrid apps (apps where only parts are built with React Native). Here is the JS implementation, feel free to try it out: https://gist.github.com/mkonicek/1a8bd7253e3257687228
It hooks into the Portal here: https://github.com/facebook/react-native/blob/master/Libraries/ReactIOS/renderApplication.android.js#L92
I believe we started working on a native implementation of Modals internally. @AaaChiuuu do we use it in any fb app it ready to be open sourced?
Oh man, I don't think anyone currently uses it. In fact, it got broken when we removed BaseViewPropertyApplicator so styles weren't properly applied to the host view. I really, really wish I could get on this to unblock you guys but my hands are all tied with internal integration and it sounds like the London side of our team is getting stretched too. Krzysztof attempted a fix before he left but it seemed pretty hard to him.
If the community could take this on that would be amazing. The gist of the current implementation before the breakage is creating an Android Dialog in the ReactModalHostView extends ViewGroup and attaching a newly defined DismissEvent to the Dialog in the addEventEmitters(...) of ReactModalHostManager extends ViewGroupManager<ReactModalHostView>.