@@ -2,7 +2,13 @@ import ExpoModulesCore
2
2
import UIKit
3
3
4
4
public class RNASAppLifecycleDelegate : ExpoAppDelegateSubscriber {
5
- private var launchScreenViewController : UIViewController ?
5
+ private lazy var launchScreenWindow : UIWindow ? = {
6
+ let window = UIWindow ( frame: UIScreen . main. bounds)
7
+ let launchScreen = UIStoryboard ( name: " SplashScreen " , bundle: nil ) . instantiateInitialViewController ( ) !
8
+ window. rootViewController = launchScreen
9
+ window. windowLevel = . alert + 2 // React Native alert uses .alert + 1
10
+ return window
11
+ } ( )
6
12
7
13
public func applicationDidFinishLaunching( _ application: UIApplication ) {
8
14
if ( !isPreventRecentScreenshotsEnabled( ) ) {
@@ -18,18 +24,12 @@ public class RNASAppLifecycleDelegate: ExpoAppDelegateSubscriber {
18
24
}
19
25
20
26
// https://developer.apple.com/documentation/uikit/app_and_environment/scenes/preparing_your_ui_to_run_in_the_background
21
-
22
- if let launchScreen = UIStoryboard ( name: " SplashScreen " , bundle: nil ) . instantiateInitialViewController ( ) {
23
- launchScreen. modalPresentationStyle = . overFullScreen
24
- getTopMostViewController ( ) . present ( launchScreen, animated: false )
25
- launchScreenViewController = launchScreen
26
- }
27
+
28
+ launchScreenWindow? . makeKeyAndVisible ( )
27
29
}
28
30
29
31
public func applicationDidBecomeActive( _ application: UIApplication ) {
30
- launchScreenViewController? . dismiss ( animated: false ) {
31
- self . launchScreenViewController = nil
32
- }
32
+ launchScreenWindow? . isHidden = true
33
33
}
34
34
}
35
35
@@ -41,15 +41,3 @@ func isPreventRecentScreenshotsEnabled() -> Bool {
41
41
return false
42
42
}
43
43
44
-
45
- func getTopMostViewController( ) -> UIViewController {
46
- // We want to display the overlay over any content currently presented, including modals
47
-
48
- var topController : UIViewController = UIApplication . shared. windows. first!. rootViewController!
49
-
50
- while ( topController. presentedViewController != nil ) {
51
- topController = topController. presentedViewController!
52
- }
53
-
54
- return topController
55
- }
0 commit comments