-
-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: conflict when using
fullScreenModal
presentation in native-sta…
…ck (#272) ## 📜 Description Fixed a conflict when using `fullScreenModal` presentation in `native-stack`. ## 💡 Motivation and Context `willMove(toWindow)` (with `newWindow == nil`) will be called in two cases: - view is unmounted; - a navigation to modal window has occurred. And we don't need to cleanup a listener if navigation has occurred. So in this PR I'm switching to `willMove(toSuperview)` method that called only when view is destroyed (when navigation occurs nothing happens). Also I decided to unify initialization mechanism between architectures. The view creation steps are following: - init - prop setters - willMove(toSuperview) On paper I did an initialization and mounting in `willMove` method (setter was called on non initialized object). On fabric I initialized in init method and mounted in prop setters (I didn't use lifecycle methods in Fabric). However I think that ignoring lifecycle method and keeping subscriptions is not a good idea (though events are not propagated and there is no crashes) - potentially we may have bad memory and other unpleasant exceptions. So in this PR I decided to unify approach and now we're using next schema: - initialize observers in `init`; - mount/unmount in prop setter; - mount/unmount in lifecycle. With such approach potentially on initial mount we can initialize observer 2 times. To avoid that I've added `isMounted` property to observers. So now they can be initialized only once (even if you call `.mount` several times). Last but not least - I've added private methods mount/unmount on view level to reduce code duplication (now we have two observers, so one method initialize both of them). Closes #271 ## 📢 Changelog ### iOS - switched from `willMove(toWindow)` to `willMove(toSuperview)`; ## 🤔 How Has This Been Tested? Tested on iPhone 15 Pro (iOS 17.0.1). ## 📝 Checklist - [x] CI successfully passed
- Loading branch information
1 parent
ecd237f
commit a8bd87b
Showing
4 changed files
with
64 additions
and
22 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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