-
-
Notifications
You must be signed in to change notification settings - Fork 574
feat(iOS, Tabs, ScreenStack): orientation for Tabs and ScreenStack #3014
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
Merged
kligarski
merged 18 commits into
main
from
@kligarski/gamma-orientation-tabs-screenstack
Aug 14, 2025
Merged
feat(iOS, Tabs, ScreenStack): orientation for Tabs and ScreenStack #3014
kligarski
merged 18 commits into
main
from
@kligarski/gamma-orientation-tabs-screenstack
Aug 14, 2025
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
742454b
to
6f180f8
Compare
t0maboro
reviewed
Aug 8, 2025
t0maboro
approved these changes
Aug 14, 2025
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Adds orientation management for
Tabs
.Closes https://github.com/software-mansion/react-native-screens-labs/issues/97.
Moved from https://github.com/software-mansion/react-native-screens-labs/pull/262.
Overriding
supportedInterfaceOrientaitons
forTabBarController
andTabsScreenViewController
is not enough. UIKit calls these methods only once and does not enforce orientation they return. UIKit asks root view controller more often - that's why we already swizzledsupportedInterfaceOrientations
to get access to return value from rootUIViewController
(from react-native) inScreenStack
implementation (useful article about UIKit's behavior).I decided to use our own methods to handle orientation instead of overriding
supportedInterfaceOrientations
for tabs-related view controllers and use swizzledsupportedInterfaceOrientation
in root to return appropriate orientation mask to UIKit.In
ScreenStack
,orientation: 'default'
is mapped toUIInterfaceOrientationMaskAllButUpsideDown
but this is correct only for iPhones (e.g. iPads useUIInterfaceOrientationMaskAll
). There is no other option that maps toUIInterfaceOrientationMaskAllButUpsideDown
.In new implementation, I added options for all
UIInterfaceOrientationMask
enum values and changed'default'
into'inherit'
to use as default value. This value means that view controller does not have any preference for orientation. When root is asked forsupportedInterfaceOrientations
, it checks if their last child conforms toRNSOrientationProviding
. If so, it asks the child view controller for orientation. These calls are propagated down the hierarchy with the last child having priority. If the last child returnsInherit
, view controller above returns its preference. If root receivesInherit
, it uses mask defined inInfo.plist
(docs), otherwise it maps receivedRNSOrientation
intoUIInterfaceOrientationMask
.For
ScreenStack
, we use old implementation of handling orientation at the screen level (we map result from itssupportedInterfaceOrientations
toRNSOrientation
). Old stack does not support new props, includingRNSOrientationInherit
.Example
In the future, we need to implement orientation management for new
Stack
implementation as well asSplitView
. This should be straightforward.Stack
implementation will be a mix of oldScreenStack
and newTabs
implementations.SplitView
implementation should take into account orientation defined via prop at host controller.Note
Changing orientation manually (editing and saving file) via config in
TestBottomTabs.tsx
seems buggy but it is due to "Refreshing..." bar in debug mode. If you change the prop in JS (e.g. withsetInterval
), it works as expected.Simulator.Screen.Recording.-.iPhone.16.Pro.-.2025-07-15.at.11.05.47.mov
Simulator.Screen.Recording.-.iPhone.16.Pro.-.2025-07-15.at.11.04.51.mov
Changes
RNSOrientationProviding
protocolTest code and steps to reproduce
Run example app and switch between tabs/screens in nested stack.
Checklist