Skip to content

Commit

Permalink
Make sure not to override user background color (#36215)
Browse files Browse the repository at this point in the history
Summary:
Pull Request resolved: #36215

When we introduced the RCTAppDelegate library, we prepared some template methods for the user to customise their views.

However, after they customized their view, we were chaing the background color to match the system background. This would actually override the background color they set in their own customisation step.

This change make sure that we set the background color before they apply their customisations. In this way, we set the background color and, if they want, they can change it and that changw would be honoured.

This change also fixes [this issue](#35937)

## Changelog
[iOS][Fixed] - Honour background color customisation in RCTAppDelegate

Reviewed By: cortinico

Differential Revision: D43435946

fbshipit-source-id: cdbdbd5b07082ae7843a4dab352dd1195c69e036
  • Loading branch information
cipolleschi authored and facebook-github-bot committed Feb 20, 2023
1 parent f8d8764 commit 5d6f21d
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions Libraries/AppDelegate/RCTAppDelegate.mm
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,6 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(
NSDictionary *initProps = [self prepareInitialProps];
UIView *rootView = [self createRootViewWithBridge:self.bridge moduleName:self.moduleName initProps:initProps];

if (@available(iOS 13.0, *)) {
rootView.backgroundColor = [UIColor systemBackgroundColor];
} else {
rootView.backgroundColor = [UIColor whiteColor];
}

self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
UIViewController *rootViewController = [self createRootViewController];
rootViewController.view = rootView;
Expand Down Expand Up @@ -101,7 +95,14 @@ - (UIView *)createRootViewWithBridge:(RCTBridge *)bridge
#if RCT_NEW_ARCH_ENABLED
enableFabric = self.fabricEnabled;
#endif
return RCTAppSetupDefaultRootView(bridge, moduleName, initProps, enableFabric);
UIView *rootView = RCTAppSetupDefaultRootView(bridge, moduleName, initProps, enableFabric);
if (@available(iOS 13.0, *)) {
rootView.backgroundColor = [UIColor systemBackgroundColor];
} else {
rootView.backgroundColor = [UIColor whiteColor];
}

return rootView;
}

- (UIViewController *)createRootViewController
Expand Down

0 comments on commit 5d6f21d

Please sign in to comment.