diff --git a/Libraries/ActionSheetIOS/ActionSheetIOS.js b/Libraries/ActionSheetIOS/ActionSheetIOS.js index bda2844d4f666b..d3b904fbbbbfc5 100644 --- a/Libraries/ActionSheetIOS/ActionSheetIOS.js +++ b/Libraries/ActionSheetIOS/ActionSheetIOS.js @@ -46,6 +46,7 @@ const ActionSheetIOS = { +cancelButtonIndex?: ?number, +anchor?: ?number, +tintColor?: number | string, + +userInterfaceStyle?: string, |}, callback: (buttonIndex: number) => void, ) { diff --git a/Libraries/ActionSheetIOS/NativeActionSheetManager.js b/Libraries/ActionSheetIOS/NativeActionSheetManager.js index afc2b82f97af55..063d9147e1d69b 100644 --- a/Libraries/ActionSheetIOS/NativeActionSheetManager.js +++ b/Libraries/ActionSheetIOS/NativeActionSheetManager.js @@ -24,6 +24,7 @@ export interface Spec extends TurboModule { +cancelButtonIndex?: ?number, +anchor?: ?number, +tintColor?: ?number, + +userInterfaceStyle?: ?string, |}, callback: (buttonIndex: number) => void, ) => void; @@ -35,6 +36,7 @@ export interface Spec extends TurboModule { +anchor?: ?number, +tintColor?: ?number, +excludedActivityTypes?: ?Array, + +userInterfaceStyle?: ?string, |}, failureCallback: (error: {| +domain: string, diff --git a/Libraries/FBReactNativeSpec/FBReactNativeSpec/FBReactNativeSpec.h b/Libraries/FBReactNativeSpec/FBReactNativeSpec/FBReactNativeSpec.h index 265fcdf3770310..a6cdf54b5df982 100644 --- a/Libraries/FBReactNativeSpec/FBReactNativeSpec/FBReactNativeSpec.h +++ b/Libraries/FBReactNativeSpec/FBReactNativeSpec/FBReactNativeSpec.h @@ -117,6 +117,7 @@ namespace JS { folly::Optional cancelButtonIndex() const; folly::Optional anchor() const; folly::Optional tintColor() const; + NSString *userInterfaceStyle() const; SpecShowActionSheetWithOptionsOptions(NSDictionary *const v) : _v(v) {} private: @@ -138,6 +139,7 @@ namespace JS { folly::Optional anchor() const; folly::Optional tintColor() const; folly::Optional> excludedActivityTypes() const; + NSString *userInterfaceStyle() const; SpecShowShareActionSheetWithOptionsOptions(NSDictionary *const v) : _v(v) {} private: @@ -2935,6 +2937,11 @@ inline folly::Optional JS::NativeActionSheetManager::SpecShowActionSheet id const p = _v[@"tintColor"]; return RCTBridgingToOptionalDouble(p); } +inline NSString *JS::NativeActionSheetManager::SpecShowActionSheetWithOptionsOptions::userInterfaceStyle() const +{ + id const p = _v[@"userInterfaceStyle"]; + return RCTBridgingToString(p); +} inline NSString *JS::NativeActionSheetManager::SpecShowShareActionSheetWithOptionsOptions::message() const { id const p = _v[@"message"]; @@ -2965,6 +2972,11 @@ inline folly::Optional> JS::NativeAction id const p = _v[@"excludedActivityTypes"]; return RCTBridgingToOptionalVec(p, ^NSString *(id itemValue_0) { return RCTBridgingToString(itemValue_0); }); } +inline NSString *JS::NativeActionSheetManager::SpecShowShareActionSheetWithOptionsOptions::userInterfaceStyle() const +{ + id const p = _v[@"userInterfaceStyle"]; + return RCTBridgingToString(p); +} inline NSString *JS::NativeActionSheetManager::SpecShowShareActionSheetWithOptionsFailureCallbackError::domain() const { id const p = _v[@"domain"]; diff --git a/React/CoreModules/RCTActionSheetManager.mm b/React/CoreModules/RCTActionSheetManager.mm index ca8713692973ad..9ca746a40b68a1 100644 --- a/React/CoreModules/RCTActionSheetManager.mm +++ b/React/CoreModules/RCTActionSheetManager.mm @@ -129,6 +129,21 @@ - (void)presentViewController:(UIViewController *)alertController } alertController.view.tintColor = tintColor; +#if defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && defined(__IPHONE_13_0) && \ +__IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_13_0 + if (@available(iOS 13.0, *)) { + NSString *userInterfaceStyle = [RCTConvert NSString:options.userInterfaceStyle()]; + + if (userInterfaceStyle == nil || [userInterfaceStyle isEqualToString:@""]) { + alertController.overrideUserInterfaceStyle = UIUserInterfaceStyleUnspecified; + } else if ([userInterfaceStyle isEqualToString:@"dark"]) { + alertController.overrideUserInterfaceStyle = UIUserInterfaceStyleDark; + } else if ([userInterfaceStyle isEqualToString:@"light"]) { + alertController.overrideUserInterfaceStyle = UIUserInterfaceStyleLight; + } + } +#endif + [self presentViewController:alertController onParentViewController:controller anchorViewTag:anchorViewTag]; } @@ -191,6 +206,21 @@ - (void)presentViewController:(UIViewController *)alertController NSNumber *anchorViewTag = [RCTConvert NSNumber:options.anchor() ? @(*options.anchor()) : nil]; shareController.view.tintColor = [RCTConvert UIColor:options.tintColor() ? @(*options.tintColor()) : nil]; +#if defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && defined(__IPHONE_13_0) && \ +__IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_13_0 + if (@available(iOS 13.0, *)) { + NSString *userInterfaceStyle = [RCTConvert NSString:options.userInterfaceStyle()]; + + if (userInterfaceStyle == nil || [userInterfaceStyle isEqualToString:@""]) { + shareController.overrideUserInterfaceStyle = UIUserInterfaceStyleUnspecified; + } else if ([userInterfaceStyle isEqualToString:@"dark"]) { + shareController.overrideUserInterfaceStyle = UIUserInterfaceStyleDark; + } else if ([userInterfaceStyle isEqualToString:@"light"]) { + shareController.overrideUserInterfaceStyle = UIUserInterfaceStyleLight; + } + } +#endif + [self presentViewController:shareController onParentViewController:controller anchorViewTag:anchorViewTag]; } diff --git a/React/CoreModules/RCTDevLoadingView.mm b/React/CoreModules/RCTDevLoadingView.mm index a76f4a3e774d9a..fdfee9176e1696 100644 --- a/React/CoreModules/RCTDevLoadingView.mm +++ b/React/CoreModules/RCTDevLoadingView.mm @@ -103,10 +103,13 @@ -(void)showMessage:(NSString *)message color:(UIColor *)color backgroundColor:(U self->_window.backgroundColor = backgroundColor; self->_window.hidden = NO; +#if defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && defined(__IPHONE_13_0) && \ +__IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_13_0 if (@available(iOS 13.0, *)) { - id scene = [[RCTSharedApplication() valueForKey:@"connectedScenes"] anyObject]; - [self->_window setValue:scene forKey:@"windowScene"]; + UIWindowScene *scene = (UIWindowScene *)RCTSharedApplication().connectedScenes.anyObject; + self->_window.windowScene = scene; } +#endif }); }