-
Notifications
You must be signed in to change notification settings - Fork 24.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow the app to control the Activity Indicator in Bridgeless mode #43195
Conversation
This pull request was exported from Phabricator. Differential Revision: D54191856 |
@zoontek After these changes are landed, you'll need the following changes in your #else
#import <React/RCTRootView.h>
#endif
+ #import "RCTAppDelegate.h"
// ...
+ (void)initWithStoryboard:(NSString * _Nonnull)storyboardName
rootView:(UIView * _Nullable)rootView {
// ...
#ifdef RCT_NEW_ARCH_ENABLED
if (rootView != nil && [rootView isKindOfClass:[RCTSurfaceHostingProxyRootView class]]) {
+ ((RCTSurfaceHostingProxyRootView *)rootView).preventAutoHide = YES;
_rootView = (RCTSurfaceHostingProxyRootView *)rootView;
#else
// ...
_loadingView.center = (CGPoint){CGRectGetMidX(_rootView.bounds), CGRectGetMidY(_rootView.bounds)};
_loadingView.hidden = NO;
+ RCTAppDelegate * appDelegate = (RCTAppDelegate *)[RCTSharedApplication() delegate];
+ if ([appDelegate bridgelessEnabled]) {
+ ((RCTRootView *)_rootView).loadingView = _loadingView;
+ } else {
- [_rootView addSubview:_loadingView];
+ [_rootView addSubview:_loadingView];
+ }
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(onJavaScriptDidLoad)
name:RCTJavaScriptDidLoadNotification
object:nil]; And then it should work as expected. If you want, you can also try to pick these changes and apply them to your examples and see how they behave. Let me know if something like this might work. The reason why we have to check whether bridgeless is enabled or not is because the Surface lifecycle is different between the Bridge and Bridgeless mode. |
83f6b87
to
a215a15
Compare
This pull request was exported from Phabricator. Differential Revision: D54191856 |
a215a15
to
0a871c5
Compare
This pull request was exported from Phabricator. Differential Revision: D54191856 |
@property (nonatomic, assign) BOOL preventActivityIndicatorAutoHide; | ||
|
||
/** | ||
* This method hides the activity indicator and remoes it from the view hierarchy. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
small typo here: removes
} | ||
} | ||
|
||
- (void)hideActivityIndicator |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
0a871c5
to
483ba98
Compare
This pull request was exported from Phabricator. Differential Revision: D54191856 |
483ba98
to
8478f05
Compare
This pull request was exported from Phabricator. Differential Revision: D54191856 |
@cipolleschi LGTM! |
8478f05
to
90639e5
Compare
This pull request was exported from Phabricator. Differential Revision: D54191856 |
90639e5
to
ef7cd22
Compare
This pull request was exported from Phabricator. Differential Revision: D54191856 |
…acebook#43195) Summary: Right now, the activity indicator is automatically hidden when the view is ready to be shown in bridgeless mode. There is no way to prevent that the activity indicator is automatically removed. In OSS, we have libraries (e.g.: `react-native-bootsplash`) that will allow the app to control when and how dismiss the splashscreen, but due to the current automatic behavior on Bridgeless, they stopped working. ***Note:** In the previous implementation, they were working because instead of using the `loadingView` property, they were adding the splashscreen view on top of the existing one. However, with the lazy behavior of the bridgeless mode, this is not working anymore because the RCTMountingManager [expect not to have any subview](https://www.internalfb.com/code/fbsource/[6962fa457dbc74ab3a760cf6090d9643c6748781]/xplat/js/react-native-github/packages/react-native/React/Fabric/Mounting/RCTMountingManager.mm?lines=176) when the first surface is mounted.* ## Changelog [iOS][Added] - Allow the activityIndicator to be controlled from JS in bridgeless mode Reviewed By: philIip Differential Revision: D54191856
ef7cd22
to
e5146d9
Compare
This pull request was exported from Phabricator. Differential Revision: D54191856 |
…acebook#43195) Summary: Right now, the activity indicator is automatically hidden when the view is ready to be shown in bridgeless mode. There is no way to prevent that the activity indicator is automatically removed. In OSS, we have libraries (e.g.: `react-native-bootsplash`) that will allow the app to control when and how dismiss the splashscreen, but due to the current automatic behavior on Bridgeless, they stopped working. ***Note:** In the previous implementation, they were working because instead of using the `loadingView` property, they were adding the splashscreen view on top of the existing one. However, with the lazy behavior of the bridgeless mode, this is not working anymore because the RCTMountingManager [expect not to have any subview](https://www.internalfb.com/code/fbsource/[6962fa457dbc74ab3a760cf6090d9643c6748781]/xplat/js/react-native-github/packages/react-native/React/Fabric/Mounting/RCTMountingManager.mm?lines=176) when the first surface is mounted.* ## Changelog [iOS][Added] - Allow the activityIndicator to be controlled from JS in bridgeless mode Reviewed By: philIip Differential Revision: D54191856
…acebook#43195) Summary: Right now, the activity indicator is automatically hidden when the view is ready to be shown in bridgeless mode. There is no way to prevent that the activity indicator is automatically removed. In OSS, we have libraries (e.g.: `react-native-bootsplash`) that will allow the app to control when and how dismiss the splashscreen, but due to the current automatic behavior on Bridgeless, they stopped working. ***Note:** In the previous implementation, they were working because instead of using the `loadingView` property, they were adding the splashscreen view on top of the existing one. However, with the lazy behavior of the bridgeless mode, this is not working anymore because the RCTMountingManager [expect not to have any subview](https://www.internalfb.com/code/fbsource/[6962fa457dbc74ab3a760cf6090d9643c6748781]/xplat/js/react-native-github/packages/react-native/React/Fabric/Mounting/RCTMountingManager.mm?lines=176) when the first surface is mounted.* ## Changelog [iOS][Added] - Allow the activityIndicator to be controlled from JS in bridgeless mode Reviewed By: philIip Differential Revision: D54191856
e5146d9
to
ad569e3
Compare
This pull request was exported from Phabricator. Differential Revision: D54191856 |
ad569e3
to
f0ef1d6
Compare
This pull request was exported from Phabricator. Differential Revision: D54191856 |
This pull request has been merged in 9aeb9f2. |
…43195) Summary: Pull Request resolved: #43195 Right now, the activity indicator is automatically hidden when the view is ready to be shown in bridgeless mode. There is no way to prevent that the activity indicator is automatically removed. In OSS, we have libraries (e.g.: `react-native-bootsplash`) that will allow the app to control when and how dismiss the splashscreen, but due to the current automatic behavior on Bridgeless, they stopped working. ***Note:** In the previous implementation, they were working because instead of using the `loadingView` property, they were adding the splashscreen view on top of the existing one. However, with the lazy behavior of the bridgeless mode, this is not working anymore because the RCTMountingManager [expect not to have any subview](https://www.internalfb.com/code/fbsource/[6962fa457dbc74ab3a760cf6090d9643c6748781]/xplat/js/react-native-github/packages/react-native/React/Fabric/Mounting/RCTMountingManager.mm?lines=176) when the first surface is mounted.* ## Changelog [iOS][Added] - Allow the activityIndicator to be controlled from JS in bridgeless mode Reviewed By: philIip Differential Revision: D54191856 fbshipit-source-id: 14738032f04adf7eaf7d200d889acd752aed0ed3
Summary:
Right now, the activity indicator is automatically hidden when the view is ready to be shown in bridgeless mode.
There is no way to prevent that the activity indicator is automatically removed.
In OSS, we have libraries (e.g.:
react-native-bootsplash
) that will allow the app to control when and how dismiss the splashscreen, but due to the current automatic behavior on Bridgeless, they stopped working.Note: In the previous implementation, they were working because instead of using the
loadingView
property, they were adding the splashscreen view on top of the existing one. However, with the lazy behavior of the bridgeless mode, this is not working anymore because the RCTMountingManager expect not to have any subview when the first surface is mounted.Changelog
[iOS][Added] - Allow the activityIndicator to be controlled from JS in bridgeless mode
Differential Revision: D54191856