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

Modal does not support landscape / horizontal view #7

Closed
mikaello opened this issue Aug 14, 2017 · 4 comments
Closed

Modal does not support landscape / horizontal view #7

mikaello opened this issue Aug 14, 2017 · 4 comments

Comments

@mikaello
Copy link
Collaborator

It does not seem to work with landscape view of phone with RNMS (see also issue 41 in old repo).

In theory it is as easy as adding supportedOrientations={['portrait', 'landscape']} to the Modal-component, and this works as long as the orientation is fixed, but if orientation is not fixed and you turn the phone the width is not recalculated because it depends on const { width } = Dimensions.get('window'), and that does not change when orientation changes. See discussion and possible workarounds in react-native issue #25. You can see the problem here (the screengif program is not perfect):
rotate_700

A fix can be to use flex to adjust size instead of Dimensions.get('window'):
rotate_fix

It seems to work on iOS simulator, but it should be tested on other devices as well. This attempt to fix horizontal view with flex can be tested in branch support-for-landscape-view. Add this in package.json:
"react-native-modal-selector": "peacechen/react-native-modal-selector#support-for-landscape-view"

@peacechen
Copy link
Owner

peacechen commented Aug 16, 2017

That looks like a great solution. Thanks @mikaello

Merged PR #10 from branch support-for-landscape-view

@peacechen
Copy link
Owner

@mikaello
Do the other orientations ('portrait-upside-down', 'landscape-left', 'landscape-right') need to be added to supportedOrientations ?

RN Modal docs:
https://facebook.github.io/react-native/docs/modal.html

@mikaello
Copy link
Collaborator Author

I can't see any difference in iOS simulator between having 'portrait', 'landscape', 'portrait-upside-down', 'landscape-left', 'landscape-right' or just 'portrait', 'landscape'. But I am not sure about the implications of adding or avoiding those extra options.

But one thing I was thinking about adding, was a prop to react-native-modal-selection, so the user could force it in either portrait or landscape (and having both as default). This would only apply to iOS, since Android seem to ignore this prop.

@peacechen
Copy link
Owner

I agree, a prop would allow users to choose how they want ModalSelector to behave 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants