-
-
Notifications
You must be signed in to change notification settings - Fork 598
fix(iOS): fullscreenmodal color scheme adaptability #2211
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
Conversation
Needs to be cleaned up
kkafar
left a comment
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.
very good job!
I've asked for few changes and we're good to go.
Co-authored-by: Kacper Kafara <[email protected]>
kkafar
left a comment
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.
Looks solid now 💪🏻 🎉
tboba
left a comment
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.
LGTM!
## Description This PR fixes the color scheme adaptability when using `presentation: fullScreenModal`. When changing the appearance mode between `light` and `dark` the screens reacted immediately except for the fullScreenModal presentation style. When using a `UIModalPresentationFullScreen` the views belonging to the presenting view controller are removed after the presentation completes. After investigating the view hierarchy for a screen with `presentation: fullScreenModal` it turned out that the `RCTRootView` is removed, thus the `traitCollectionDidChange` observer ([see here](https://github.com/facebook/react-native/blob/d3e0430deac573fd44792e6005d5de20e9ad2797/packages/react-native/React/Base/RCTRootView.m#L362)) is not working anymore. The solution was to add an extra observer for `RNSScreenStackPresentationFullScreenModal` to be able to send proper notifications when no RCTRootView is present. As the observer is working synchronously it's usage is limited for this presentation style only. Fixes #2002. ## Changes - added repro `Test2002.tsx` - added `traitCollectionDidChange` observer for fullScreenModal ## Screenshots / GIFs ### Before https://github.com/software-mansion/react-native-screens/assets/91994767/52fa4e92-3baa-49e2-b278-7be57c4d28b3 ### After https://github.com/software-mansion/react-native-screens/assets/91994767/74c62c45-c793-4f63-81fc-d68d4000fea6 ## Test code and steps to reproduce - added `Test2002.tsx` to test examples ## Checklist - [ ] Included code example that can be used to test this change - [ ] Updated TS types - [ ] Updated documentation: <!-- For adding new props to native-stack --> - [ ] https://github.com/software-mansion/react-native-screens/blob/main/guides/GUIDE_FOR_LIBRARY_AUTHORS.md - [ ] https://github.com/software-mansion/react-native-screens/blob/main/native-stack/README.md - [ ] https://github.com/software-mansion/react-native-screens/blob/main/src/types.tsx - [ ] https://github.com/software-mansion/react-native-screens/blob/main/src/native-stack/types.tsx - [ ] Ensured that CI passes --------- Co-authored-by: Kacper Kafara <[email protected]> Co-authored-by: Kacper Kafara <[email protected]>
…#2211) ## Description This PR fixes the color scheme adaptability when using `presentation: fullScreenModal`. When changing the appearance mode between `light` and `dark` the screens reacted immediately except for the fullScreenModal presentation style. When using a `UIModalPresentationFullScreen` the views belonging to the presenting view controller are removed after the presentation completes. After investigating the view hierarchy for a screen with `presentation: fullScreenModal` it turned out that the `RCTRootView` is removed, thus the `traitCollectionDidChange` observer ([see here](https://github.com/facebook/react-native/blob/d3e0430deac573fd44792e6005d5de20e9ad2797/packages/react-native/React/Base/RCTRootView.m#L362)) is not working anymore. The solution was to add an extra observer for `RNSScreenStackPresentationFullScreenModal` to be able to send proper notifications when no RCTRootView is present. As the observer is working synchronously it's usage is limited for this presentation style only. Fixes software-mansion#2002. ## Changes - added repro `Test2002.tsx` - added `traitCollectionDidChange` observer for fullScreenModal ## Screenshots / GIFs ### Before https://github.com/software-mansion/react-native-screens/assets/91994767/52fa4e92-3baa-49e2-b278-7be57c4d28b3 ### After https://github.com/software-mansion/react-native-screens/assets/91994767/74c62c45-c793-4f63-81fc-d68d4000fea6 ## Test code and steps to reproduce - added `Test2002.tsx` to test examples ## Checklist - [ ] Included code example that can be used to test this change - [ ] Updated TS types - [ ] Updated documentation: <!-- For adding new props to native-stack --> - [ ] https://github.com/software-mansion/react-native-screens/blob/main/guides/GUIDE_FOR_LIBRARY_AUTHORS.md - [ ] https://github.com/software-mansion/react-native-screens/blob/main/native-stack/README.md - [ ] https://github.com/software-mansion/react-native-screens/blob/main/src/types.tsx - [ ] https://github.com/software-mansion/react-native-screens/blob/main/src/native-stack/types.tsx - [ ] Ensured that CI passes --------- Co-authored-by: Kacper Kafara <[email protected]> Co-authored-by: Kacper Kafara <[email protected]>
Description
This PR fixes the color scheme adaptability when using
presentation: fullScreenModal.When changing the appearance mode between
lightanddarkthe screens reacted immediately except for the fullScreenModal presentation style.When using a
UIModalPresentationFullScreenthe views belonging to the presenting view controller are removed after the presentation completes. After investigating the view hierarchy for a screen withpresentation: fullScreenModalit turned out that theRCTRootViewis removed, thus thetraitCollectionDidChangeobserver (see here) is not working anymore.The solution was to add an extra observer for
RNSScreenStackPresentationFullScreenModalto be able to send proper notifications when no RCTRootView is present. As the observer is working synchronously it's usage is limited for this presentation style only.Fixes #2002.
Changes
Test2002.tsxtraitCollectionDidChangeobserver for fullScreenModalScreenshots / GIFs
Before
Screen.Recording.2024-06-26.at.11.44.49.mov
After
Screen.Recording.2024-06-26.at.11.43.42.mov
Test code and steps to reproduce
Test2002.tsxto test examplesChecklist