react-native icon indicating copy to clipboard operation
react-native copied to clipboard

[Android] Provide a PopupMenu component

Open satya164 opened this issue 11 years ago • 53 comments

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.

satya164 avatar Sep 24 '15 14:09 satya164

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 avatar Sep 24 '15 15:09 mkonicek

@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 avatar Sep 24 '15 16:09 satya164

@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

mkonicek avatar Sep 24 '15 16:09 mkonicek

There's also http://developer.android.com/intl/zh-cn/reference/android/widget/PopupMenu.html

mkonicek avatar Sep 24 '15 16:09 mkonicek

You probably mean this one, right? http://i.stack.imgur.com/j67fB.gif

mkonicek avatar Sep 24 '15 16:09 mkonicek

@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 :)

satya164 avatar Sep 24 '15 16:09 satya164

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 avatar Sep 24 '15 17:09 hedgerwang

@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.

satya164 avatar Sep 25 '15 01:09 satya164

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 avatar Sep 25 '15 01:09 ide

@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.

satya164 avatar Sep 26 '15 19:09 satya164

@ide @satya164 Why don't the React Native docs for Modal say "Android is not supported"? This is frustrating.

niftylettuce avatar Oct 31 '15 18:10 niftylettuce

@niftylettuce want to send a PR to clarify this in Modal's docblock?

ide avatar Nov 01 '15 00:11 ide

@ide Don't really have time, trying to crank out a project.

niftylettuce avatar Nov 02 '15 00:11 niftylettuce

When Modal component is worked for android also.Thanks

prashanthmerugucs avatar Nov 18 '15 06:11 prashanthmerugucs

+1

leeight avatar Nov 21 '15 04:11 leeight

+1

pewh avatar Dec 10 '15 02:12 pewh

+1

For anyone looking for a quick replacement, react-native-dialogs is a good solution that plugs into native dialogs.

atc3 avatar Dec 11 '15 20:12 atc3

+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 avatar Dec 14 '15 14:12 Ehesp

@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?

mkonicek avatar Dec 18 '15 14:12 mkonicek

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>.

aaronechiu avatar Dec 19 '15 16:12 aaronechiu