Skip to content

Commit

Permalink
[splash-screen] fix preventAutoHideAsync on ios bridgeless (#28234)
Browse files Browse the repository at this point in the history
# Why

fix `preventAutoHideAsync()` not working on ios bridgeless
close ENG-11901 

# How

- fix react root view type checking for bridgeless which is kind of
`RCTSurfaceHostingView`
- the splash screen will be covered / overlaid by subview.
this pr tries to keep splash screen with highest zIndex.
  • Loading branch information
Kudo committed Apr 17, 2024
1 parent 0e21431 commit 2796e8c
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
1 change: 1 addition & 0 deletions packages/expo-splash-screen/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
### 🐛 Bug fixes

- Fixed white screen flickering when using expo-updates with longer `fallbackToCacheTimeout`. ([#28227](https://github.com/expo/expo/pull/28227) by [@kudo](https://github.com/kudo))
- Fixed `preventAutoHideAsync()` broken on iOS bridgeless mode. ([#28234](https://github.com/expo/expo/pull/28234) by [@kudo](https://github.com/kudo))

### 💡 Others

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#import <EXSplashScreen/EXSplashScreenModule.h>
#import <EXSplashScreen/EXSplashScreenService.h>
#import <React/RCTRootView.h>
#import <React/RCTSurfaceHostingView.h>
#import <ExpoModulesCore/EXAppLifecycleService.h>
#import <ExpoModulesCore/EXUtilities.h>

Expand Down Expand Up @@ -152,12 +153,12 @@ - (nullable UIViewController *)viewControllerContainingRCTRootView

for (UIWindow *window in allWindows) {
UIViewController *controller = window.rootViewController;
if ([controller.view isKindOfClass:[RCTRootView class]]) {
if ([self isReactRootView:controller.view]) {
return controller;
}
UIViewController *presentedController = controller.presentedViewController;
while (presentedController && ![presentedController isBeingDismissed]) {
if ([presentedController.view isKindOfClass:[RCTRootView class]]) {
if ([self isReactRootView:presentedController.view]) {
return presentedController;
}
controller = presentedController;
Expand All @@ -169,4 +170,9 @@ - (nullable UIViewController *)viewControllerContainingRCTRootView
return nil;
}

- (BOOL)isReactRootView:(UIView*)view
{
return [view isKindOfClass:RCTRootView.class] || [view isKindOfClass:RCTSurfaceHostingView.class];
}

@end
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ - (void)showWithCallback:(nullable void(^)(void))successCallback
[EXUtilities performSynchronouslyOnMainThread:^{
UIView *rootView = self.rootView;
self.splashScreenView.frame = rootView.bounds;
self.splashScreenView.layer.zPosition = MAXFLOAT;
[rootView addSubview:self.splashScreenView];
self.splashScreenShown = YES;
if (successCallback) {
Expand Down

0 comments on commit 2796e8c

Please sign in to comment.