-
-
Notifications
You must be signed in to change notification settings - Fork 518
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
fix(iOS): fullscreenmodal color scheme adaptability #2211
Conversation
Needs to be cleaned up
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 <kacper.kafara@swmansion.com>
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 💪🏻 🎉
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 <kacperkafara@gmail.com> Co-authored-by: Kacper Kafara <kacper.kafara@swmansion.com>
…#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 <kacperkafara@gmail.com> Co-authored-by: Kacper Kafara <kacper.kafara@swmansion.com>
Description
This PR fixes the color scheme adaptability when using
presentation: fullScreenModal
.When changing the appearance mode between
light
anddark
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 withpresentation: fullScreenModal
it turned out that theRCTRootView
is removed, thus thetraitCollectionDidChange
observer (see here) 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
Test2002.tsx
traitCollectionDidChange
observer 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.tsx
to test examplesChecklist