mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
8ca085c09c51357504adcb7fae3fe0c46f81a3ac
2
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
33e0521788 |
Add view getter on RCTRootView / RCTFabricSurfaceHostingProxyRootView (#37310)
Summary: Hi 👋 During the [react-native-bootsplash](https://github.com/zoontek/react-native-bootsplash) implementation of the new architecture, I noticed a few thing regarding `RCTRootView` / `RCTFabricSurfaceHostingProxyRootView` compat. Currently `RCTRootView` inherits from `UIView`, but `RCTFabricSurfaceHostingProxyRootView` does not, which this works: ```obj-c - (UIView *)createRootViewWithBridge:(RCTBridge *)bridge moduleName:(NSString *)moduleName initProps:(NSDictionary *)initProps { RCTRootView *rootView = (RCTRootView *) [super createRootViewWithBridge:bridge moduleName:moduleName initProps:initProps]; UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"LaunchScreen" bundle:nil]; UIView *loadingView = [[storyboard instantiateInitialViewController] view]; loadingView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight; loadingView.frame = rootView.bounds; loadingView.center = (CGPoint){CGRectGetMidX(rootView.bounds), CGRectGetMidY(rootView.bounds)}; loadingView.hidden = NO; [rootView addSubview:loadingView]; return rootView; } ``` But this doesn't: ```obj-c - (UIView *)createRootViewWithBridge:(RCTBridge *)bridge moduleName:(NSString *)moduleName initProps:(NSDictionary *)initProps { RCTFabricSurfaceHostingProxyRootView *rootView = (RCTFabricSurfaceHostingProxyRootView *) [super createRootViewWithBridge:bridge moduleName:moduleName initProps:initProps]; UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"LaunchScreen" bundle:nil]; UIView *loadingView = [[storyboard instantiateInitialViewController] view]; loadingView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight; loadingView.frame = rootView.bounds; loadingView.center = (CGPoint){CGRectGetMidX(rootView.bounds), CGRectGetMidY(rootView.bounds)}; loadingView.hidden = NO; [rootView addSubview:loadingView]; return rootView; } ``` Because `RCTFabricSurfaceHostingProxyRootView` is an imperfect proxy as it doesn't give access to the underlaying `UIView *`. As a solution, I added a prop on both: `UIView *view` PS: I'm well aware that `setLoadingView` also exists in both files, but it's currently not usable as the current `isActivityIndicatorViewVisible` / `isSurfaceViewVisible` / `_activityIndicatorViewFactory` logic in `RCTSurfaceHostingView.mm` doesn't work: a situation where `isActivityIndicatorViewVisible == true && isSurfaceViewVisible == false && _activityIndicatorViewFactory != nil` never happen: <img width="1162" alt="Screenshot_2023-05-06_at_18 10 18" src="https://user-images.githubusercontent.com/1902323/236883439-2256ddfb-7846-482a-b957-002a7d51a148.png"> ## Changelog: <!-- Help reviewers and the release process by writing your own changelog entry. Pick one each for the category and type tags: [ANDROID|GENERAL|IOS|INTERNAL] [BREAKING|ADDED|CHANGED|DEPRECATED|REMOVED|FIXED|SECURITY] - Message For more details, see: https://reactnative.dev/contributing/changelogs-in-pull-requests Pull Request resolved: https://github.com/facebook/react-native/pull/37310 Test Plan: Add this block of code in `AppDelegate.mm`: ```obj-c #import <React/RCTRootView.h> #if __has_include(<React/RCTFabricSurfaceHostingProxyRootView.h>) #import <React/RCTFabricSurfaceHostingProxyRootView.h> #endif // … - (UIView *)createRootViewWithBridge:(RCTBridge *)bridge moduleName:(NSString *)moduleName initProps:(NSDictionary *)initProps { #ifdef RCT_NEW_ARCH_ENABLED RCTFabricSurfaceHostingProxyRootView *rootView = (RCTFabricSurfaceHostingProxyRootView *) #else RCTRootView *rootView = (RCTRootView *) #endif [super createRootViewWithBridge:bridge moduleName:moduleName initProps:initProps]; // accessing the "real" root view on both arch UIView *view = rootView.view; UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"LaunchScreen" bundle:nil]; UIView *loadingView = [[storyboard instantiateInitialViewController] view]; loadingView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight; loadingView.frame = view.bounds; loadingView.center = (CGPoint){CGRectGetMidX(view.bounds), CGRectGetMidY(view.bounds)}; loadingView.hidden = NO; [view addSubview:loadingView]; return rootView; } ``` It should persist the splash screen on both old and new architecture. Reviewed By: sammy-SC Differential Revision: D45688644 Pulled By: cipolleschi fbshipit-source-id: b6f2fc8091a15189ea2eceb8ea426593f62674cb |
||
|
|
eebfd33b70 |
Expose StatusBar height on iOS
Summary: Following the PR https://github.com/facebook/react-native/pull/6195, this adds a `HEIGHT` constant on `StatusBar` for iOS. Combined with `statusBarFrameDidChange` and `statusBarFrameWillChange` StatusBar native events, it solves various problems with In-Call cellar bar / Location bar / others 40pt status bars, and offers a correct `keyboardVerticalOffset` value for the KeyboardAvoidingView component. Closes https://github.com/facebook/react-native/pull/12041 Differential Revision: D4450924 Pulled By: hramos fbshipit-source-id: 664798260f4226140f3fa3f9222a415a305d0d78 |