@lodev09/react-native-true-sheet 3.7.2 → 3.7.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -26,6 +26,7 @@ class RNScreensFragmentObserver(
|
|
|
26
26
|
private val activeModalFragments: MutableSet<Fragment> = mutableSetOf()
|
|
27
27
|
private var isActivityInForeground = true
|
|
28
28
|
private var pendingDismissRunnable: Runnable? = null
|
|
29
|
+
private var isInitialized = false
|
|
29
30
|
|
|
30
31
|
/**
|
|
31
32
|
* Start observing fragment lifecycle events.
|
|
@@ -53,6 +54,9 @@ class RNScreensFragmentObserver(
|
|
|
53
54
|
// Ignore if app is resuming from background
|
|
54
55
|
if (!isActivityInForeground) return
|
|
55
56
|
|
|
57
|
+
// Ignore initial fragment attachments during app startup (cold start deep links)
|
|
58
|
+
if (!isInitialized) return
|
|
59
|
+
|
|
56
60
|
if (isModalFragment(f) && !activeModalFragments.contains(f)) {
|
|
57
61
|
// Cancel any pending dismiss since a modal is being presented
|
|
58
62
|
cancelPendingDismiss()
|
|
@@ -95,6 +99,11 @@ class RNScreensFragmentObserver(
|
|
|
95
99
|
}
|
|
96
100
|
|
|
97
101
|
fragmentManager.registerFragmentLifecycleCallbacks(fragmentLifecycleCallback!!, true)
|
|
102
|
+
|
|
103
|
+
// Mark as initialized after a frame to ignore initial fragment attachments during cold start
|
|
104
|
+
activity.window?.decorView?.post {
|
|
105
|
+
isInitialized = true
|
|
106
|
+
}
|
|
98
107
|
}
|
|
99
108
|
|
|
100
109
|
/**
|
package/ios/TrueSheetView.mm
CHANGED
|
@@ -19,7 +19,6 @@
|
|
|
19
19
|
#import "events/TrueSheetLifecycleEvents.h"
|
|
20
20
|
#import "events/TrueSheetStateEvents.h"
|
|
21
21
|
#import "utils/LayoutUtil.h"
|
|
22
|
-
#import "utils/WindowUtil.h"
|
|
23
22
|
|
|
24
23
|
#import <react/renderer/components/TrueSheetSpec/EventEmitters.h>
|
|
25
24
|
#import <react/renderer/components/TrueSheetSpec/Props.h>
|
|
@@ -91,8 +90,16 @@ using namespace facebook::react;
|
|
|
91
90
|
}
|
|
92
91
|
|
|
93
92
|
if (_initialDetentIndex >= 0 && !_didInitiallyPresent) {
|
|
94
|
-
|
|
95
|
-
|
|
93
|
+
UIViewController *vc = [self findPresentingViewController];
|
|
94
|
+
|
|
95
|
+
// Only present if the view controller is in the same window and not being dismissed
|
|
96
|
+
if (vc && vc.view.window == self.window && !vc.isBeingDismissed) {
|
|
97
|
+
_didInitiallyPresent = YES;
|
|
98
|
+
[self presentAtIndex:_initialDetentIndex animated:_initialDetentAnimated completion:nil];
|
|
99
|
+
} else {
|
|
100
|
+
// Animate next time when sheet finally moves to the correct window
|
|
101
|
+
_initialDetentAnimated = YES;
|
|
102
|
+
}
|
|
96
103
|
}
|
|
97
104
|
}
|
|
98
105
|
|
|
@@ -106,6 +113,8 @@ using namespace facebook::react;
|
|
|
106
113
|
[root dismissViewControllerAnimated:YES completion:nil];
|
|
107
114
|
}
|
|
108
115
|
|
|
116
|
+
_didInitiallyPresent = NO;
|
|
117
|
+
|
|
109
118
|
_controller.delegate = nil;
|
|
110
119
|
_controller = nil;
|
|
111
120
|
|
|
@@ -551,11 +560,10 @@ using namespace facebook::react;
|
|
|
551
560
|
#pragma mark - Private Helpers
|
|
552
561
|
|
|
553
562
|
- (UIViewController *)findPresentingViewController {
|
|
554
|
-
|
|
555
|
-
if (!keyWindow)
|
|
563
|
+
if (!self.window)
|
|
556
564
|
return nil;
|
|
557
565
|
|
|
558
|
-
UIViewController *rootViewController =
|
|
566
|
+
UIViewController *rootViewController = self.window.rootViewController;
|
|
559
567
|
if (!rootViewController)
|
|
560
568
|
return nil;
|
|
561
569
|
|
package/package.json
CHANGED