-
-
Notifications
You must be signed in to change notification settings - Fork 592
feat(iOS, SplitView): Add an option for changing number of columns dynamically #3339
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
feat(iOS, SplitView): Add an option for changing number of columns dynamically #3339
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't get something here.
If the entire UISplitNavigationController is remounted (I guess it is recreated, why do we remove the assert for column count, since it is instance-wise?
I think I don't see the benefits this PR introduces. Could you give me some more context here? Maybe a video of what effect we achieve?
The instance of SplitView is recreated when the number of columns changes. The assert is no longer necessary because there's no scenario where the number of columns can change dynamically without fully remounting SplitView. Once the
The goal of this PR is to improve the development experience. It makes it easier for developers to test different layouts (e.g. 2- or 3-column configurations) without having to rebuild the app each time. With this change, using fast refresh is enough to apply layout updates, which significantly speeds up the development workflow and makes testing layout variations much smoother (as it's presented on the 2nd video in the description). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, I see now.
So the assertions for column count in native code should stay, as nothing changes & the invariant must still be upheld, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
Description
Previously, the constructor of UISplitViewController relied on a predefined number of columns, and we enforced this constraint using an assert to prevent unexpected runtime behavior when the number of children changed dynamically.
Inspired by the
expo-routerapproach, this PR removes the static assert and introduces a more dynamic pattern: theSplitViewHostnow actively monitors the number of child columns. If the number of children changes, the entireUISplitViewControlleris remounted to reflect the updated configuration.Fixes https://github.com/software-mansion/react-native-screens-labs/issues/499 .
Changes
Screenshots / GIFs
Here you can add screenshots / GIFs documenting your change.
You can add before / after section if you're changing some behavior.
Before
before.mov
After
after.mov
Test code and steps to reproduce
Run any example with SplitView and add/remove columns or inspector.
Checklist