From 9cc5b5ef903c967d034cbb1a2247f47b3cb199d1 Mon Sep 17 00:00:00 2001 From: radex Date: Fri, 28 Jun 2019 11:15:50 +0200 Subject: [PATCH 01/19] [Modal] Modernize Modal to use RootTagContext --- Libraries/Modal/Modal.js | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/Libraries/Modal/Modal.js b/Libraries/Modal/Modal.js index be8fc84cde329f..7a80845ec84752 100644 --- a/Libraries/Modal/Modal.js +++ b/Libraries/Modal/Modal.js @@ -11,6 +11,7 @@ 'use strict'; const AppContainer = require('../ReactNative/AppContainer'); +const RootTagContext = require('../ReactNative/RootTagContext'); const I18nManager = require('../ReactNative/I18nManager'); const NativeEventEmitter = require('../EventEmitter/NativeEventEmitter'); import NativeModalManager from './NativeModalManager'; @@ -151,10 +152,6 @@ class Modal extends React.Component { hardwareAccelerated: false, }; - static contextTypes = { - rootTag: PropTypes.number, - }; - _identifier: number; _eventSubscription: ?EmitterSubscription; @@ -240,9 +237,11 @@ class Modal extends React.Component { } const innerChildren = __DEV__ ? ( - - {this.props.children} - + + {rootTag => ( + {this.props.children} + )} + ) : ( this.props.children ); From 7c3913cb97ea389626761804ade405d46a75d58c Mon Sep 17 00:00:00 2001 From: radex Date: Fri, 28 Jun 2019 12:28:49 +0200 Subject: [PATCH 02/19] [StatusBar] Support UIWindowScene APIs - WIP --- Libraries/Components/StatusBar/StatusBar.js | 48 +++++++++++++++------ React/Modules/RCTStatusBarManager.m | 45 ++++++++++++++----- 2 files changed, 70 insertions(+), 23 deletions(-) diff --git a/Libraries/Components/StatusBar/StatusBar.js b/Libraries/Components/StatusBar/StatusBar.js index 7617f77dbc152d..e3b2b7d0a15a7f 100644 --- a/Libraries/Components/StatusBar/StatusBar.js +++ b/Libraries/Components/StatusBar/StatusBar.js @@ -12,6 +12,7 @@ const React = require('react'); const Platform = require('../../Utilities/Platform'); +const RootTagContext = require('../../ReactNative/RootTagContext'); const processColor = require('../../StyleSheet/processColor'); @@ -255,12 +256,17 @@ class StatusBar extends React.Component { * @param hidden Hide the status bar. * @param animation Optional animation when * changing the status bar hidden property. + * @param rootTag Optional reactTag of your app's root view (only necessary to support multiple windows on iOS 13+) */ - static setHidden(hidden: boolean, animation?: StatusBarAnimation) { + static setHidden( + hidden: boolean, + animation?: StatusBarAnimation, + rootTag?: number, + ) { animation = animation || 'none'; StatusBar._defaultProps.hidden.value = hidden; if (Platform.OS === 'ios') { - StatusBarManager.setHidden(hidden, animation); + StatusBarManager.setHidden(hidden, animation, rootTag ?? -1); } else if (Platform.OS === 'android') { StatusBarManager.setHidden(hidden); } @@ -270,12 +276,17 @@ class StatusBar extends React.Component { * Set the status bar style * @param style Status bar style to set * @param animated Animate the style change. + * @param rootTag Optional reactTag of your app's root view (only necessary to support multiple windows on iOS 13+) */ - static setBarStyle(style: StatusBarStyle, animated?: boolean) { + static setBarStyle( + style: StatusBarStyle, + animated?: boolean, + rootTag?: number, + ) { animated = animated || false; StatusBar._defaultProps.barStyle.value = style; if (Platform.OS === 'ios') { - StatusBarManager.setStyle(style, animated); + StatusBarManager.setStyle(style, animated, rootTag ?? -1); } else if (Platform.OS === 'android') { StatusBarManager.setStyle(style); } @@ -284,6 +295,7 @@ class StatusBar extends React.Component { /** * Control the visibility of the network activity indicator * @param visible Show the indicator. + * @platform ios */ static setNetworkActivityIndicatorVisible(visible: boolean) { if (Platform.OS !== 'ios') { @@ -300,6 +312,7 @@ class StatusBar extends React.Component { * Set the background color for the status bar * @param color Background color. * @param animated Animate the style change. + * @platform android */ static setBackgroundColor(color: string, animated?: boolean) { if (Platform.OS !== 'android') { @@ -314,6 +327,7 @@ class StatusBar extends React.Component { /** * Control the translucency of the status bar * @param translucent Set as translucent. + * @platform android */ static setTranslucent(translucent: boolean) { if (Platform.OS !== 'android') { @@ -329,11 +343,12 @@ class StatusBar extends React.Component { * The return value should be passed to `popStackEntry` when complete. * * @param props Object containing the StatusBar props to use in the stack entry. + * @param rootTag Optional reactTag of your app's root view (only necessary to support multiple windows on iOS 13+) */ - static pushStackEntry(props: any) { + static pushStackEntry(props: any, rootTag?: number) { const entry = createStackEntry(props); StatusBar._propsStack.push(entry); - StatusBar._updatePropsStack(); + StatusBar._updatePropsStack(rootTag); return entry; } @@ -341,13 +356,14 @@ class StatusBar extends React.Component { * Pop a StatusBar entry from the stack. * * @param entry Entry returned from `pushStackEntry`. + * @param rootTag Optional reactTag of your app's root view (only necessary to support multiple windows on iOS 13+) */ - static popStackEntry(entry: any) { + static popStackEntry(entry: any, rootTag?: number) { const index = StatusBar._propsStack.indexOf(entry); if (index !== -1) { StatusBar._propsStack.splice(index, 1); } - StatusBar._updatePropsStack(); + StatusBar._updatePropsStack(rootTag); } /** @@ -355,14 +371,15 @@ class StatusBar extends React.Component { * * @param entry Entry returned from `pushStackEntry` to replace. * @param props Object containing the StatusBar props to use in the replacement stack entry. + * @param rootTag Optional reactTag of your app's root view (only necessary to support multiple windows on iOS 13+) */ - static replaceStackEntry(entry: any, props: any) { + static replaceStackEntry(entry: any, props: any, rootTag?: number) { const newEntry = createStackEntry(props); const index = StatusBar._propsStack.indexOf(entry); if (index !== -1) { StatusBar._propsStack[index] = newEntry; } - StatusBar._updatePropsStack(); + StatusBar._updatePropsStack(rootTag); return newEntry; } @@ -371,6 +388,8 @@ class StatusBar extends React.Component { showHideTransition: 'fade', }; + static contextType = RootTagContext; + _stackEntry = null; componentDidMount() { @@ -378,26 +397,27 @@ class StatusBar extends React.Component { // and always update the native status bar with the props from the top of then // stack. This allows having multiple StatusBar components and the one that is // added last or is deeper in the view hierachy will have priority. - this._stackEntry = StatusBar.pushStackEntry(this.props); + this._stackEntry = StatusBar.pushStackEntry(this.props, this.context); } componentWillUnmount() { // When a StatusBar is unmounted, remove itself from the stack and update // the native bar with the next props. - StatusBar.popStackEntry(this._stackEntry); + StatusBar.popStackEntry(this._stackEntry, this.context); } componentDidUpdate() { this._stackEntry = StatusBar.replaceStackEntry( this._stackEntry, this.props, + this.context, ); } /** * Updates the native status bar with the props from the stack. */ - static _updatePropsStack = () => { + static _updatePropsStack = (rootTag?: number) => { // Send the update to the native module only once at the end of the frame. clearImmediate(StatusBar._updateImmediate); StatusBar._updateImmediate = setImmediate(() => { @@ -416,6 +436,7 @@ class StatusBar extends React.Component { StatusBarManager.setStyle( mergedProps.barStyle.value, mergedProps.barStyle.animated || false, + rootTag ?? -1, ); } if (!oldProps || oldProps.hidden.value !== mergedProps.hidden.value) { @@ -424,6 +445,7 @@ class StatusBar extends React.Component { mergedProps.hidden.animated ? mergedProps.hidden.transition : 'none', + rootTag ?? -1, ); } diff --git a/React/Modules/RCTStatusBarManager.m b/React/Modules/RCTStatusBarManager.m index 9b6f9d6698c156..a468b8710f2554 100644 --- a/React/Modules/RCTStatusBarManager.m +++ b/React/Modules/RCTStatusBarManager.m @@ -10,6 +10,8 @@ #import "RCTEventDispatcher.h" #import "RCTLog.h" #import "RCTUtils.h" +#import "RCTUIManager.h" +#import "RCTBridge.h" #if !TARGET_OS_TV @implementation RCTConvert (UIStatusBar) @@ -102,38 +104,61 @@ - (void)applicationWillChangeStatusBarFrame:(NSNotification *)notification } RCT_EXPORT_METHOD(setStyle:(UIStatusBarStyle)statusBarStyle - animated:(BOOL)animated) + animated:(BOOL)animated + rootTag:(nonnull NSNumber *)rootTag) { if (RCTViewControllerBasedStatusBarAppearance()) { RCTLogError(@"RCTStatusBarManager module requires that the \ UIViewControllerBasedStatusBarAppearance key in the Info.plist is set to NO"); - } else { + return; + } + +#if defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && __IPHONE_OS_VERSION_MAX_ALLOWED >= 130000 /* __IPHONE_13_0 */ + if (@available(iOS 13.0, *)) { + UIView *rootView = [self.bridge.uiManager viewForReactTag:rootTag]; + UIWindowScene *windowScene = rootView.window.windowScene; + + if (windowScene) { +// windowScene.statusBarManager.statusBarStyle = statusBarStyle + } else { + RCTLogWarn(@"RCTStatusBarManager setStyle called on a RCTRootView that's not attached to a window scene"); + } + + return; + } +#endif + #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wdeprecated-declarations" - [RCTSharedApplication() setStatusBarStyle:statusBarStyle - animated:animated]; - } + [RCTSharedApplication() setStatusBarStyle:statusBarStyle + animated:animated]; #pragma clang diagnostic pop } RCT_EXPORT_METHOD(setHidden:(BOOL)hidden - withAnimation:(UIStatusBarAnimation)animation) + withAnimation:(UIStatusBarAnimation)animation + rootTag:(nonnull NSNumber *)rootTag) { if (RCTViewControllerBasedStatusBarAppearance()) { RCTLogError(@"RCTStatusBarManager module requires that the \ UIViewControllerBasedStatusBarAppearance key in the Info.plist is set to NO"); - } else { + return; + } + #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wdeprecated-declarations" - [RCTSharedApplication() setStatusBarHidden:hidden - withAnimation:animation]; + [RCTSharedApplication() setStatusBarHidden:hidden + withAnimation:animation]; #pragma clang diagnostic pop - } + } RCT_EXPORT_METHOD(setNetworkActivityIndicatorVisible:(BOOL)visible) { +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" RCTSharedApplication().networkActivityIndicatorVisible = visible; +#pragma clang diagnostic pop } #endif //TARGET_OS_TV From 55a8a682dceb03fb678806c6f999913d2b1e1e35 Mon Sep 17 00:00:00 2001 From: radex Date: Fri, 28 Jun 2019 16:08:59 +0200 Subject: [PATCH 03/19] [ios] RCTPresentedViewController - make window explicit --- Libraries/ActionSheetIOS/RCTActionSheetManager.m | 4 ++-- React/Base/RCTUtils.h | 2 +- React/Base/RCTUtils.m | 5 +++-- React/DevSupport/RCTDevMenu.m | 10 +++++----- React/Modules/RCTAlertManager.m | 2 +- React/Profiler/RCTProfile.m | 2 +- 6 files changed, 13 insertions(+), 12 deletions(-) diff --git a/Libraries/ActionSheetIOS/RCTActionSheetManager.m b/Libraries/ActionSheetIOS/RCTActionSheetManager.m index 9eca118126ca16..157a85bd556ba9 100644 --- a/Libraries/ActionSheetIOS/RCTActionSheetManager.m +++ b/Libraries/ActionSheetIOS/RCTActionSheetManager.m @@ -73,7 +73,7 @@ - (void)presentViewController:(UIViewController *)alertController destructiveButtonIndices = @[destructiveButtonIndex]; } - UIViewController *controller = RCTPresentedViewController(); + UIViewController *controller = RCTPresentedViewController(nil); if (controller == nil) { RCTLogError(@"Tried to display action sheet but there is no application window. options: %@", options); @@ -162,7 +162,7 @@ - (void)presentViewController:(UIViewController *)alertController shareController.excludedActivityTypes = excludedActivityTypes; } - UIViewController *controller = RCTPresentedViewController(); + UIViewController *controller = RCTPresentedViewController(nil); shareController.completionWithItemsHandler = ^(NSString *activityType, BOOL completed, __unused NSArray *returnedItems, NSError *activityError) { if (activityError) { failureCallback(activityError); diff --git a/React/Base/RCTUtils.h b/React/Base/RCTUtils.h index 8b2b4063dfb66f..46d22da9a58ab3 100644 --- a/React/Base/RCTUtils.h +++ b/React/Base/RCTUtils.h @@ -84,7 +84,7 @@ RCT_EXTERN UIWindow *__nullable RCTKeyWindow(void); // Returns the presented view controller, useful if you need // e.g. to present a modal view controller or alert over it -RCT_EXTERN UIViewController *__nullable RCTPresentedViewController(void); +RCT_EXTERN UIViewController *__nullable RCTPresentedViewController(UIWindow* _Nullable window); // Does this device support force touch (aka 3D Touch)? RCT_EXTERN BOOL RCTForceTouchAvailable(void); diff --git a/React/Base/RCTUtils.m b/React/Base/RCTUtils.m index 2cdd3f6ebc78d6..441d2b40b74bd6 100644 --- a/React/Base/RCTUtils.m +++ b/React/Base/RCTUtils.m @@ -499,13 +499,14 @@ BOOL RCTRunningInAppExtension(void) return RCTSharedApplication().keyWindow; } -UIViewController *__nullable RCTPresentedViewController(void) +UIViewController *__nullable RCTPresentedViewController(UIWindow* _Nullable window) { if (RCTRunningInAppExtension()) { return nil; } - UIViewController *controller = RCTKeyWindow().rootViewController; + UIWindow *keyWindow = window ?: RCTKeyWindow(); + UIViewController *controller = keyWindow.rootViewController; UIViewController *presentedController = controller.presentedViewController; while (presentedController && ![presentedController isBeingDismissed]) { controller = presentedController; diff --git a/React/DevSupport/RCTDevMenu.m b/React/DevSupport/RCTDevMenu.m index ee37aed75591ba..2baf4099dc357c 100644 --- a/React/DevSupport/RCTDevMenu.m +++ b/React/DevSupport/RCTDevMenu.m @@ -225,7 +225,7 @@ - (void)setDefaultJSBundle { [UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault handler:^(__unused UIAlertAction *action){ [weakAlertController dismissViewControllerAnimated:YES completion:nil]; }]]; - [RCTPresentedViewController() presentViewController:alertController animated:YES completion:NULL]; + [RCTPresentedViewController(nil) presentViewController:alertController animated:YES completion:NULL]; }]]; } else { [items addObject:[RCTDevMenuItem buttonItemWithTitleBlock:^NSString *{ @@ -242,7 +242,7 @@ - (void)setDefaultJSBundle { if (devSettings.isNuclideDebuggingAvailable && !devSettings.isDebuggingRemotely) { [items addObject:[RCTDevMenuItem buttonItemWithTitle:@"Debug with Nuclide" handler:^{ #if RCT_ENABLE_INSPECTOR - [RCTInspectorDevServerHelper attachDebugger:@"ReactNative" withBundleURL:bridge.bundleURL withView: RCTPresentedViewController()]; + [RCTInspectorDevServerHelper attachDebugger:@"ReactNative" withBundleURL:bridge.bundleURL withView: RCTPresentedViewController(nil)]; #endif }]]; } @@ -281,7 +281,7 @@ - (void)setDefaultJSBundle { [UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault handler:^(__unused UIAlertAction *action){ [weakAlertController dismissViewControllerAnimated:YES completion:nil]; }]]; - [RCTPresentedViewController() presentViewController:alertController animated:YES completion:NULL]; + [RCTPresentedViewController(nil) presentViewController:alertController animated:YES completion:NULL]; } else { devSettings.isProfilingEnabled = !devSettings.isProfilingEnabled; } @@ -348,7 +348,7 @@ - (void)setDefaultJSBundle { [alertController addAction:[UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleCancel handler:^(__unused UIAlertAction *action) { return; }]]; - [RCTPresentedViewController() presentViewController:alertController animated:YES completion:NULL]; + [RCTPresentedViewController(nil) presentViewController:alertController animated:YES completion:NULL]; }]]; [items addObjectsFromArray:_extraMenuItems]; @@ -384,7 +384,7 @@ - (void)setDefaultJSBundle { handler:[self alertActionHandlerForDevItem:nil]]]; _presentedItems = items; - [RCTPresentedViewController() presentViewController:_actionSheet animated:YES completion:nil]; + [RCTPresentedViewController(nil) presentViewController:_actionSheet animated:YES completion:nil]; } - (RCTDevMenuAlertActionHandler)alertActionHandlerForDevItem:(RCTDevMenuItem *__nullable)item diff --git a/React/Modules/RCTAlertManager.m b/React/Modules/RCTAlertManager.m index bb1f3ceaa42e10..6f4c5ed6fb1c7b 100644 --- a/React/Modules/RCTAlertManager.m +++ b/React/Modules/RCTAlertManager.m @@ -90,7 +90,7 @@ - (void)invalidate } } - UIViewController *presentingController = RCTPresentedViewController(); + UIViewController *presentingController = RCTPresentedViewController(nil); if (presentingController == nil) { RCTLogError(@"Tried to display alert view but there is no application window. args: %@", args); return; diff --git a/React/Profiler/RCTProfile.m b/React/Profiler/RCTProfile.m index 4d7460268fa4a0..5b886b34951e77 100644 --- a/React/Profiler/RCTProfile.m +++ b/React/Profiler/RCTProfile.m @@ -777,7 +777,7 @@ void RCTProfileSendResult(RCTBridge *bridge, NSString *route, NSData *data) [alertController addAction:[UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleCancel handler:nil]]; - [RCTPresentedViewController() presentViewController:alertController animated:YES completion:nil]; + [RCTPresentedViewController(nil) presentViewController:alertController animated:YES completion:nil]; }); #endif } From 4601e22ff6225cb8e03e21930215b7aeb36d796e Mon Sep 17 00:00:00 2001 From: radex Date: Fri, 28 Jun 2019 16:28:02 +0200 Subject: [PATCH 04/19] [ios] pass rootTag to Alert, ActionSheetIOS --- Libraries/ActionSheetIOS/ActionSheetIOS.js | 1 + .../ActionSheetIOS/RCTActionSheetManager.m | 9 +++++++-- Libraries/Alert/Alert.js | 17 +++++++++++++---- Libraries/Alert/NativeAlertManager.js | 1 + React/Modules/RCTAlertManager.m | 18 ++++++++++++------ 5 files changed, 34 insertions(+), 12 deletions(-) diff --git a/Libraries/ActionSheetIOS/ActionSheetIOS.js b/Libraries/ActionSheetIOS/ActionSheetIOS.js index f8dfab12dd3d34..4c4ab125fc08c7 100644 --- a/Libraries/ActionSheetIOS/ActionSheetIOS.js +++ b/Libraries/ActionSheetIOS/ActionSheetIOS.js @@ -46,6 +46,7 @@ const ActionSheetIOS = { +cancelButtonIndex?: ?number, +anchor?: ?number, +tintColor?: number | string, + +rootTag?: number, |}, callback: (buttonIndex: number) => void, ) { diff --git a/Libraries/ActionSheetIOS/RCTActionSheetManager.m b/Libraries/ActionSheetIOS/RCTActionSheetManager.m index 157a85bd556ba9..84a5ef6ce02880 100644 --- a/Libraries/ActionSheetIOS/RCTActionSheetManager.m +++ b/Libraries/ActionSheetIOS/RCTActionSheetManager.m @@ -73,7 +73,9 @@ - (void)presentViewController:(UIViewController *)alertController destructiveButtonIndices = @[destructiveButtonIndex]; } - UIViewController *controller = RCTPresentedViewController(nil); + NSNumber *rootTag = options[@"rootTag"] ? [RCTConvert NSNumber:options[@"rootTag"]] : @-1; + UIView *rootView = [self.bridge.uiManager viewForReactTag:rootTag]; + UIViewController *controller = RCTPresentedViewController(rootView.window); if (controller == nil) { RCTLogError(@"Tried to display action sheet but there is no application window. options: %@", options); @@ -162,7 +164,10 @@ - (void)presentViewController:(UIViewController *)alertController shareController.excludedActivityTypes = excludedActivityTypes; } - UIViewController *controller = RCTPresentedViewController(nil); + NSNumber *rootTag = options[@"rootTag"] ? [RCTConvert NSNumber:options[@"rootTag"]] : @-1; + UIView *rootView = [self.bridge.uiManager viewForReactTag:rootTag]; + UIViewController *controller = RCTPresentedViewController(rootView.window); + shareController.completionWithItemsHandler = ^(NSString *activityType, BOOL completed, __unused NSArray *returnedItems, NSError *activityError) { if (activityError) { failureCallback(activityError); diff --git a/Libraries/Alert/Alert.js b/Libraries/Alert/Alert.js index 55bdce3fd40704..7c9215cb13166c 100644 --- a/Libraries/Alert/Alert.js +++ b/Libraries/Alert/Alert.js @@ -31,6 +31,11 @@ export type Buttons = Array<{ type Options = { cancelable?: ?boolean, onDismiss?: ?() => void, + rootTag?: number, +}; + +type PromptOptions = { + rootTag?: number, }; /** @@ -43,10 +48,12 @@ class Alert { title: ?string, message?: ?string, buttons?: Buttons, - options?: Options, + options?: Options = {}, ): void { if (Platform.OS === 'ios') { - Alert.prompt(title, message, buttons, 'default'); + Alert.prompt(title, message, buttons, 'default', undefined, undefined, { + rootTag: options.rootTag, + }); } else if (Platform.OS === 'android') { if (!NativeDialogManagerAndroid) { return; @@ -59,7 +66,7 @@ class Alert { cancelable: false, }; - if (options && options.cancelable) { + if (options.cancelable) { config.cancelable = options.cancelable; } // At most three buttons (neutral, negative, positive). Ignore rest. @@ -92,7 +99,7 @@ class Alert { buttonPositive.onPress && buttonPositive.onPress(); } } else if (action === constants.dismissed) { - options && options.onDismiss && options.onDismiss(); + options.onDismiss && options.onDismiss(); } }; const onError = errorMessage => console.warn(errorMessage); @@ -107,6 +114,7 @@ class Alert { type?: ?AlertType = 'plain-text', defaultValue?: string, keyboardType?: string, + options?: PromptOptions = {}, ): void { if (Platform.OS === 'ios') { if (typeof type === 'function') { @@ -163,6 +171,7 @@ class Alert { cancelButtonKey, destructiveButtonKey, keyboardType, + rootTag: options.rootTag ?? -1, }, (id, value) => { const cb = callbacks[id]; diff --git a/Libraries/Alert/NativeAlertManager.js b/Libraries/Alert/NativeAlertManager.js index 1dcae0d265bd17..9555c1ecff8921 100644 --- a/Libraries/Alert/NativeAlertManager.js +++ b/Libraries/Alert/NativeAlertManager.js @@ -22,6 +22,7 @@ export type Args = {| cancelButtonKey?: string, destructiveButtonKey?: string, keyboardType?: string, + rootTag?: number, |}; export interface Spec extends TurboModule { diff --git a/React/Modules/RCTAlertManager.m b/React/Modules/RCTAlertManager.m index 6f4c5ed6fb1c7b..be01cd9c5c4c8e 100644 --- a/React/Modules/RCTAlertManager.m +++ b/React/Modules/RCTAlertManager.m @@ -8,6 +8,7 @@ #import "RCTAlertManager.h" #import "RCTAssert.h" +#import "RCTUIManager.h" #import "RCTConvert.h" #import "RCTLog.h" #import "RCTUtils.h" @@ -32,6 +33,8 @@ @implementation RCTAlertManager NSHashTable *_alertControllers; } +@synthesize bridge = _bridge; + RCT_EXPORT_MODULE() - (dispatch_queue_t)methodQueue @@ -71,6 +74,7 @@ - (void)invalidate NSString *cancelButtonKey = [RCTConvert NSString:args[@"cancelButtonKey"]]; NSString *destructiveButtonKey = [RCTConvert NSString:args[@"destructiveButtonKey"]]; UIKeyboardType keyboardType = [RCTConvert UIKeyboardType:args[@"keyboardType"]]; + NSNumber *rootTag = args[@"rootTag"] ? [RCTConvert NSNumber:args[@"rootTag"]] : @-1; if (!title && !message) { RCTLogError(@"Must specify either an alert title, or message, or both"); @@ -90,12 +94,6 @@ - (void)invalidate } } - UIViewController *presentingController = RCTPresentedViewController(nil); - if (presentingController == nil) { - RCTLogError(@"Tried to display alert view but there is no application window. args: %@", args); - return; - } - UIAlertController *alertController = [UIAlertController alertControllerWithTitle:title message:nil @@ -178,6 +176,14 @@ - (void)invalidate [_alertControllers addObject:alertController]; dispatch_async(dispatch_get_main_queue(), ^{ + UIView *rootView = [self.bridge.uiManager viewForReactTag:rootTag]; + UIViewController *presentingController = RCTPresentedViewController(rootView.window); + + if (presentingController == nil) { + RCTLogError(@"Tried to display alert view but there is no application window. args: %@", args); + return; + } + [presentingController presentViewController:alertController animated:YES completion:nil]; }); } From 43259a4bcb747a95a7e35bc615d25c2e03deba54 Mon Sep 17 00:00:00 2001 From: radex Date: Fri, 28 Jun 2019 16:38:43 +0200 Subject: [PATCH 05/19] Don't rely on UIAppDelegate.window --- React/Modules/RCTRedBox.m | 1 + React/Profiler/RCTPerfMonitor.m | 3 +-- React/Profiler/RCTProfile.m | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/React/Modules/RCTRedBox.m b/React/Modules/RCTRedBox.m index 7ed4900d319ce7..d2492edbbc1751 100644 --- a/React/Modules/RCTRedBox.m +++ b/React/Modules/RCTRedBox.m @@ -212,6 +212,7 @@ - (void)dismiss { self.hidden = YES; [self resignFirstResponder]; + // TODO: We shouldn't rely on UIApplicationDelegate window -- it's not guaranteed to be there + it's deprecated in iOS 13 [RCTSharedApplication().delegate.window makeKeyWindow]; } diff --git a/React/Profiler/RCTPerfMonitor.m b/React/Profiler/RCTPerfMonitor.m index 1db32322a33b78..0b3e3eef24ec62 100644 --- a/React/Profiler/RCTPerfMonitor.m +++ b/React/Profiler/RCTPerfMonitor.m @@ -318,8 +318,7 @@ - (void)show [self updateStats]; - UIWindow *window = RCTSharedApplication().delegate.window; - [window addSubview:self.container]; + [RCTKeyWindow() addSubview:self.container]; _uiDisplayLink = [CADisplayLink displayLinkWithTarget:self diff --git a/React/Profiler/RCTProfile.m b/React/Profiler/RCTProfile.m index 5b886b34951e77..eccb41cd6137bb 100644 --- a/React/Profiler/RCTProfile.m +++ b/React/Profiler/RCTProfile.m @@ -401,9 +401,9 @@ + (void)toggle:(UIButton *)target }; RCTProfileControlsWindow.hidden = YES; dispatch_async(dispatch_get_main_queue(), ^{ - [[[[RCTSharedApplication() delegate] window] rootViewController] presentViewController:activityViewController - animated:YES - completion:nil]; + [RCTPresentedViewController(nil) presentViewController:activityViewController + animated:YES + completion:nil]; }); #endif }); From 7b329fbf9d22e77419793ef939b68b5172d611b6 Mon Sep 17 00:00:00 2001 From: radex Date: Fri, 28 Jun 2019 16:43:52 +0200 Subject: [PATCH 06/19] [ios] clean up --- Libraries/Components/StatusBar/StatusBar.js | 5 ----- React/Modules/RCTStatusBarManager.m | 21 +++++---------------- 2 files changed, 5 insertions(+), 21 deletions(-) diff --git a/Libraries/Components/StatusBar/StatusBar.js b/Libraries/Components/StatusBar/StatusBar.js index e3b2b7d0a15a7f..ea322f7016b019 100644 --- a/Libraries/Components/StatusBar/StatusBar.js +++ b/Libraries/Components/StatusBar/StatusBar.js @@ -256,7 +256,6 @@ class StatusBar extends React.Component { * @param hidden Hide the status bar. * @param animation Optional animation when * changing the status bar hidden property. - * @param rootTag Optional reactTag of your app's root view (only necessary to support multiple windows on iOS 13+) */ static setHidden( hidden: boolean, @@ -276,7 +275,6 @@ class StatusBar extends React.Component { * Set the status bar style * @param style Status bar style to set * @param animated Animate the style change. - * @param rootTag Optional reactTag of your app's root view (only necessary to support multiple windows on iOS 13+) */ static setBarStyle( style: StatusBarStyle, @@ -343,7 +341,6 @@ class StatusBar extends React.Component { * The return value should be passed to `popStackEntry` when complete. * * @param props Object containing the StatusBar props to use in the stack entry. - * @param rootTag Optional reactTag of your app's root view (only necessary to support multiple windows on iOS 13+) */ static pushStackEntry(props: any, rootTag?: number) { const entry = createStackEntry(props); @@ -356,7 +353,6 @@ class StatusBar extends React.Component { * Pop a StatusBar entry from the stack. * * @param entry Entry returned from `pushStackEntry`. - * @param rootTag Optional reactTag of your app's root view (only necessary to support multiple windows on iOS 13+) */ static popStackEntry(entry: any, rootTag?: number) { const index = StatusBar._propsStack.indexOf(entry); @@ -371,7 +367,6 @@ class StatusBar extends React.Component { * * @param entry Entry returned from `pushStackEntry` to replace. * @param props Object containing the StatusBar props to use in the replacement stack entry. - * @param rootTag Optional reactTag of your app's root view (only necessary to support multiple windows on iOS 13+) */ static replaceStackEntry(entry: any, props: any, rootTag?: number) { const newEntry = createStackEntry(props); diff --git a/React/Modules/RCTStatusBarManager.m b/React/Modules/RCTStatusBarManager.m index a468b8710f2554..66453486240d88 100644 --- a/React/Modules/RCTStatusBarManager.m +++ b/React/Modules/RCTStatusBarManager.m @@ -105,7 +105,7 @@ - (void)applicationWillChangeStatusBarFrame:(NSNotification *)notification RCT_EXPORT_METHOD(setStyle:(UIStatusBarStyle)statusBarStyle animated:(BOOL)animated - rootTag:(nonnull NSNumber *)rootTag) + rootTag:(nonnull __unused NSNumber *)rootTag) { if (RCTViewControllerBasedStatusBarAppearance()) { RCTLogError(@"RCTStatusBarManager module requires that the \ @@ -113,20 +113,7 @@ - (void)applicationWillChangeStatusBarFrame:(NSNotification *)notification return; } -#if defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && __IPHONE_OS_VERSION_MAX_ALLOWED >= 130000 /* __IPHONE_13_0 */ - if (@available(iOS 13.0, *)) { - UIView *rootView = [self.bridge.uiManager viewForReactTag:rootTag]; - UIWindowScene *windowScene = rootView.window.windowScene; - - if (windowScene) { -// windowScene.statusBarManager.statusBarStyle = statusBarStyle - } else { - RCTLogWarn(@"RCTStatusBarManager setStyle called on a RCTRootView that's not attached to a window scene"); - } - - return; - } -#endif + // TODO: Add proper support for UIScenes (this requires view controller based status bar management) #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wdeprecated-declarations" @@ -137,7 +124,7 @@ - (void)applicationWillChangeStatusBarFrame:(NSNotification *)notification RCT_EXPORT_METHOD(setHidden:(BOOL)hidden withAnimation:(UIStatusBarAnimation)animation - rootTag:(nonnull NSNumber *)rootTag) + rootTag:(nonnull __unused NSNumber *)rootTag) { if (RCTViewControllerBasedStatusBarAppearance()) { RCTLogError(@"RCTStatusBarManager module requires that the \ @@ -145,6 +132,8 @@ - (void)applicationWillChangeStatusBarFrame:(NSNotification *)notification return; } + // TODO: Add proper support for UIScenes (this requires view controller based status bar management) + #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wdeprecated-declarations" [RCTSharedApplication() setStatusBarHidden:hidden From 5724e11e54948b5b61a922a89cf26f57ed1f2e11 Mon Sep 17 00:00:00 2001 From: radex Date: Fri, 2 Aug 2019 10:24:01 +0200 Subject: [PATCH 07/19] [uiscene] rootTag -> any surface (root tag, host object, component ref) --- Libraries/ActionSheetIOS/ActionSheetIOS.js | 27 +++++++++++--- .../ActionSheetIOS/RCTActionSheetManager.m | 16 ++++----- Libraries/Alert/Alert.js | 11 +++--- Libraries/Alert/NativeAlertManager.js | 2 +- Libraries/Components/StatusBar/StatusBar.js | 35 ++++++++++++------- React/Modules/RCTAlertManager.m | 6 ++-- React/Modules/RCTStatusBarManager.m | 4 +-- 7 files changed, 65 insertions(+), 36 deletions(-) diff --git a/Libraries/ActionSheetIOS/ActionSheetIOS.js b/Libraries/ActionSheetIOS/ActionSheetIOS.js index 2620f3393204fe..8f28bc0d8264ed 100644 --- a/Libraries/ActionSheetIOS/ActionSheetIOS.js +++ b/Libraries/ActionSheetIOS/ActionSheetIOS.js @@ -10,6 +10,7 @@ 'use strict'; import RCTActionSheetManager from './NativeActionSheetManager'; +import ReactNative from '../../Renderer/shims/ReactNative'; const invariant = require('invariant'); const processColor = require('../StyleSheet/processColor'); @@ -45,7 +46,7 @@ const ActionSheetIOS = { +cancelButtonIndex?: ?number, +anchor?: ?number, +tintColor?: number | string, - +rootTag?: number, + +surface?: mixed, |}, callback: (buttonIndex: number) => void, ) { @@ -56,10 +57,11 @@ const ActionSheetIOS = { invariant(typeof callback === 'function', 'Must provide a valid callback'); invariant(RCTActionSheetManager, "ActionSheetManager does't exist"); - const {tintColor, ...remainingOptions} = options; + const {tintColor, surface, ...remainingOptions} = options; + const reactTag = ReactNative.findNodeHandle(surface) ?? -1; RCTActionSheetManager.showActionSheetWithOptions( - {...remainingOptions, tintColor: processColor(tintColor)}, + {...remainingOptions, reactTag, tintColor: processColor(tintColor)}, callback, ); }, @@ -88,7 +90,14 @@ const ActionSheetIOS = { * See http://facebook.github.io/react-native/docs/actionsheetios.html#showshareactionsheetwithoptions */ showShareActionSheetWithOptions( - options: Object, + options: {| + +url?: ?string, + +message?: ?string, + +subject?: ?string, + +excludedActivityTypes?: ?(string[]), + +tintColor?: number | string, + +surface?: mixed, + |}, failureCallback: Function, successCallback: Function, ) { @@ -105,8 +114,16 @@ const ActionSheetIOS = { 'Must provide a valid successCallback', ); invariant(RCTActionSheetManager, "ActionSheetManager does't exist"); + + const {tintColor, surface, ...remainingOptions} = options; + const reactTag = ReactNative.findNodeHandle(surface) ?? -1; + RCTActionSheetManager.showShareActionSheetWithOptions( - {...options, tintColor: processColor(options.tintColor)}, + { + ...remainingOptions, + reactTag, + tintColor: processColor(options.tintColor), + }, failureCallback, successCallback, ); diff --git a/Libraries/ActionSheetIOS/RCTActionSheetManager.m b/Libraries/ActionSheetIOS/RCTActionSheetManager.m index c4cb42453f6b0d..0411061d916b72 100644 --- a/Libraries/ActionSheetIOS/RCTActionSheetManager.m +++ b/Libraries/ActionSheetIOS/RCTActionSheetManager.m @@ -73,9 +73,9 @@ - (void)presentViewController:(UIViewController *)alertController destructiveButtonIndices = @[destructiveButtonIndex]; } - NSNumber *rootTag = options[@"rootTag"] ? [RCTConvert NSNumber:options[@"rootTag"]] : @-1; - UIView *rootView = [self.bridge.uiManager viewForReactTag:rootTag]; - UIViewController *controller = RCTPresentedViewController(rootView.window); + NSNumber *reactTag = options[@"reactTag"] ? [RCTConvert NSNumber:options[@"reactTag"]] : @-1; + UIView *view = [self.bridge.uiManager viewForReactTag:reactTag]; + UIViewController *controller = RCTPresentedViewController(view.window); if (controller == nil) { RCTLogError(@"Tried to display action sheet but there is no application window. options: %@", options); @@ -88,7 +88,7 @@ - (void)presentViewController:(UIViewController *)alertController * defaults to centering the share popup on screen without any arrows. */ NSNumber *anchorViewTag = [RCTConvert NSNumber:options[@"anchor"]]; - + UIAlertController *alertController = [UIAlertController alertControllerWithTitle:title message:message @@ -164,9 +164,9 @@ - (void)presentViewController:(UIViewController *)alertController shareController.excludedActivityTypes = excludedActivityTypes; } - NSNumber *rootTag = options[@"rootTag"] ? [RCTConvert NSNumber:options[@"rootTag"]] : @-1; - UIView *rootView = [self.bridge.uiManager viewForReactTag:rootTag]; - UIViewController *controller = RCTPresentedViewController(rootView.window); + NSNumber *reactTag = options[@"reactTag"] ? [RCTConvert NSNumber:options[@"reactTag"]] : @-1; + UIView *view = [self.bridge.uiManager viewForReactTag:reactTag]; + UIViewController *controller = RCTPresentedViewController(view.window); shareController.completionWithItemsHandler = ^(NSString *activityType, BOOL completed, __unused NSArray *returnedItems, NSError *activityError) { if (activityError) { @@ -178,7 +178,7 @@ - (void)presentViewController:(UIViewController *)alertController NSNumber *anchorViewTag = [RCTConvert NSNumber:options[@"anchor"]]; shareController.view.tintColor = [RCTConvert UIColor:options[@"tintColor"]]; - + [self presentViewController:shareController onParentViewController:controller anchorViewTag:anchorViewTag]; } diff --git a/Libraries/Alert/Alert.js b/Libraries/Alert/Alert.js index 7c9215cb13166c..c4defa83ac2bff 100644 --- a/Libraries/Alert/Alert.js +++ b/Libraries/Alert/Alert.js @@ -15,6 +15,7 @@ import NativeDialogManagerAndroid, { type DialogOptions, } from '../NativeModules/specs/NativeDialogManagerAndroid'; import RCTAlertManager from './RCTAlertManager'; +import ReactNative from '../../Renderer/shims/ReactNative'; export type AlertType = | 'default' @@ -31,11 +32,11 @@ export type Buttons = Array<{ type Options = { cancelable?: ?boolean, onDismiss?: ?() => void, - rootTag?: number, + surface?: mixed, }; type PromptOptions = { - rootTag?: number, + surface?: mixed, }; /** @@ -52,7 +53,7 @@ class Alert { ): void { if (Platform.OS === 'ios') { Alert.prompt(title, message, buttons, 'default', undefined, undefined, { - rootTag: options.rootTag, + reactTag: ReactNative.findNodeHandle(options.surface), }); } else if (Platform.OS === 'android') { if (!NativeDialogManagerAndroid) { @@ -171,7 +172,9 @@ class Alert { cancelButtonKey, destructiveButtonKey, keyboardType, - rootTag: options.rootTag ?? -1, + reactTag: options.surface + ? ReactNative.findNodeHandle(options.surface) + : -1, }, (id, value) => { const cb = callbacks[id]; diff --git a/Libraries/Alert/NativeAlertManager.js b/Libraries/Alert/NativeAlertManager.js index 9555c1ecff8921..709ddde7ffc466 100644 --- a/Libraries/Alert/NativeAlertManager.js +++ b/Libraries/Alert/NativeAlertManager.js @@ -22,7 +22,7 @@ export type Args = {| cancelButtonKey?: string, destructiveButtonKey?: string, keyboardType?: string, - rootTag?: number, + reactTag?: number, |}; export interface Spec extends TurboModule { diff --git a/Libraries/Components/StatusBar/StatusBar.js b/Libraries/Components/StatusBar/StatusBar.js index 7c58f2bcdf97a3..8dfd93138a3f0b 100644 --- a/Libraries/Components/StatusBar/StatusBar.js +++ b/Libraries/Components/StatusBar/StatusBar.js @@ -13,6 +13,7 @@ const React = require('react'); const Platform = require('../../Utilities/Platform'); const RootTagContext = require('../../ReactNative/RootTagContext'); +import ReactNative from '../../../Renderer/shims/ReactNative'; const processColor = require('../../StyleSheet/processColor'); import NativeStatusBarManager from './NativeStatusBarManager'; @@ -260,12 +261,16 @@ class StatusBar extends React.Component { static setHidden( hidden: boolean, animation?: StatusBarAnimation, - rootTag?: number, + surface?: mixed, ) { animation = animation || 'none'; StatusBar._defaultProps.hidden.value = hidden; if (Platform.OS === 'ios') { - NativeStatusBarManager.setHidden(hidden, animation, rootTag ?? -1); + NativeStatusBarManager.setHidden( + hidden, + animation, + ReactNative.findNodeHandle(surface) ?? -1, + ); } else if (Platform.OS === 'android') { NativeStatusBarManager.setHidden(hidden); } @@ -279,12 +284,16 @@ class StatusBar extends React.Component { static setBarStyle( style: StatusBarStyle, animated?: boolean, - rootTag?: number, + surface?: mixed, ) { animated = animated || false; StatusBar._defaultProps.barStyle.value = style; if (Platform.OS === 'ios') { - NativeStatusBarManager.setStyle(style, animated, rootTag ?? -1); + NativeStatusBarManager.setStyle( + style, + animated, + ReactNative.findNodeHandle(surface) ?? -1, + ); } else if (Platform.OS === 'android') { NativeStatusBarManager.setStyle(style); } @@ -351,10 +360,10 @@ class StatusBar extends React.Component { * * @param props Object containing the StatusBar props to use in the stack entry. */ - static pushStackEntry(props: any, rootTag?: number) { + static pushStackEntry(props: any, surface?: mixed) { const entry = createStackEntry(props); StatusBar._propsStack.push(entry); - StatusBar._updatePropsStack(rootTag); + StatusBar._updatePropsStack(surface); return entry; } @@ -363,12 +372,12 @@ class StatusBar extends React.Component { * * @param entry Entry returned from `pushStackEntry`. */ - static popStackEntry(entry: any, rootTag?: number) { + static popStackEntry(entry: any, surface?: mixed) { const index = StatusBar._propsStack.indexOf(entry); if (index !== -1) { StatusBar._propsStack.splice(index, 1); } - StatusBar._updatePropsStack(rootTag); + StatusBar._updatePropsStack(surface); } /** @@ -377,13 +386,13 @@ class StatusBar extends React.Component { * @param entry Entry returned from `pushStackEntry` to replace. * @param props Object containing the StatusBar props to use in the replacement stack entry. */ - static replaceStackEntry(entry: any, props: any, rootTag?: number) { + static replaceStackEntry(entry: any, props: any, surface?: mixed) { const newEntry = createStackEntry(props); const index = StatusBar._propsStack.indexOf(entry); if (index !== -1) { StatusBar._propsStack[index] = newEntry; } - StatusBar._updatePropsStack(rootTag); + StatusBar._updatePropsStack(surface); return newEntry; } @@ -421,7 +430,7 @@ class StatusBar extends React.Component { /** * Updates the native status bar with the props from the stack. */ - static _updatePropsStack = (rootTag?: number) => { + static _updatePropsStack = (surface?: mixed) => { // Send the update to the native module only once at the end of the frame. clearImmediate(StatusBar._updateImmediate); StatusBar._updateImmediate = setImmediate(() => { @@ -440,7 +449,7 @@ class StatusBar extends React.Component { NativeStatusBarManager.setStyle( mergedProps.barStyle.value, mergedProps.barStyle.animated || false, - rootTag ?? -1, + ReactNative.findNodeHandle(surface) ?? -1, ); } if (!oldProps || oldProps.hidden.value !== mergedProps.hidden.value) { @@ -449,7 +458,7 @@ class StatusBar extends React.Component { mergedProps.hidden.animated ? mergedProps.hidden.transition : 'none', - rootTag ?? -1, + ReactNative.findNodeHandle(surface) ?? -1, ); } diff --git a/React/Modules/RCTAlertManager.m b/React/Modules/RCTAlertManager.m index be01cd9c5c4c8e..e43e4af362c977 100644 --- a/React/Modules/RCTAlertManager.m +++ b/React/Modules/RCTAlertManager.m @@ -74,7 +74,7 @@ - (void)invalidate NSString *cancelButtonKey = [RCTConvert NSString:args[@"cancelButtonKey"]]; NSString *destructiveButtonKey = [RCTConvert NSString:args[@"destructiveButtonKey"]]; UIKeyboardType keyboardType = [RCTConvert UIKeyboardType:args[@"keyboardType"]]; - NSNumber *rootTag = args[@"rootTag"] ? [RCTConvert NSNumber:args[@"rootTag"]] : @-1; + NSNumber *reactTag = args[@"reactTag"] ? [RCTConvert NSNumber:args[@"reactTag"]] : @-1; if (!title && !message) { RCTLogError(@"Must specify either an alert title, or message, or both"); @@ -176,8 +176,8 @@ - (void)invalidate [_alertControllers addObject:alertController]; dispatch_async(dispatch_get_main_queue(), ^{ - UIView *rootView = [self.bridge.uiManager viewForReactTag:rootTag]; - UIViewController *presentingController = RCTPresentedViewController(rootView.window); + UIView *view = [self.bridge.uiManager viewForReactTag:reactTag]; + UIViewController *presentingController = RCTPresentedViewController(view.window); if (presentingController == nil) { RCTLogError(@"Tried to display alert view but there is no application window. args: %@", args); diff --git a/React/Modules/RCTStatusBarManager.m b/React/Modules/RCTStatusBarManager.m index 66453486240d88..7c14979f0a009e 100644 --- a/React/Modules/RCTStatusBarManager.m +++ b/React/Modules/RCTStatusBarManager.m @@ -105,7 +105,7 @@ - (void)applicationWillChangeStatusBarFrame:(NSNotification *)notification RCT_EXPORT_METHOD(setStyle:(UIStatusBarStyle)statusBarStyle animated:(BOOL)animated - rootTag:(nonnull __unused NSNumber *)rootTag) + reactTag:(nonnull __unused NSNumber *)reactTag) { if (RCTViewControllerBasedStatusBarAppearance()) { RCTLogError(@"RCTStatusBarManager module requires that the \ @@ -124,7 +124,7 @@ - (void)applicationWillChangeStatusBarFrame:(NSNotification *)notification RCT_EXPORT_METHOD(setHidden:(BOOL)hidden withAnimation:(UIStatusBarAnimation)animation - rootTag:(nonnull __unused NSNumber *)rootTag) + reactTag:(nonnull __unused NSNumber *)reactTag) { if (RCTViewControllerBasedStatusBarAppearance()) { RCTLogError(@"RCTStatusBarManager module requires that the \ From 303e7a7a8cfd2a0c7584758fe39265fbc587265f Mon Sep 17 00:00:00 2001 From: radex Date: Fri, 2 Aug 2019 10:38:03 +0200 Subject: [PATCH 08/19] fix imports --- Libraries/ActionSheetIOS/ActionSheetIOS.js | 2 +- Libraries/Alert/Alert.js | 2 +- Libraries/Components/StatusBar/StatusBar.js | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Libraries/ActionSheetIOS/ActionSheetIOS.js b/Libraries/ActionSheetIOS/ActionSheetIOS.js index 8f28bc0d8264ed..a97ee9bc5f68c1 100644 --- a/Libraries/ActionSheetIOS/ActionSheetIOS.js +++ b/Libraries/ActionSheetIOS/ActionSheetIOS.js @@ -10,7 +10,7 @@ 'use strict'; import RCTActionSheetManager from './NativeActionSheetManager'; -import ReactNative from '../../Renderer/shims/ReactNative'; +import ReactNative from '../Renderer/shims/ReactNative'; const invariant = require('invariant'); const processColor = require('../StyleSheet/processColor'); diff --git a/Libraries/Alert/Alert.js b/Libraries/Alert/Alert.js index c4defa83ac2bff..71e53d49e59b12 100644 --- a/Libraries/Alert/Alert.js +++ b/Libraries/Alert/Alert.js @@ -15,7 +15,7 @@ import NativeDialogManagerAndroid, { type DialogOptions, } from '../NativeModules/specs/NativeDialogManagerAndroid'; import RCTAlertManager from './RCTAlertManager'; -import ReactNative from '../../Renderer/shims/ReactNative'; +import ReactNative from '../Renderer/shims/ReactNative'; export type AlertType = | 'default' diff --git a/Libraries/Components/StatusBar/StatusBar.js b/Libraries/Components/StatusBar/StatusBar.js index 8dfd93138a3f0b..b26a68b2013bd2 100644 --- a/Libraries/Components/StatusBar/StatusBar.js +++ b/Libraries/Components/StatusBar/StatusBar.js @@ -13,7 +13,7 @@ const React = require('react'); const Platform = require('../../Utilities/Platform'); const RootTagContext = require('../../ReactNative/RootTagContext'); -import ReactNative from '../../../Renderer/shims/ReactNative'; +import ReactNative from '../../Renderer/shims/ReactNative'; const processColor = require('../../StyleSheet/processColor'); import NativeStatusBarManager from './NativeStatusBarManager'; From e3dd9765abf079e70bab0d4b892763d4baee0e7f Mon Sep 17 00:00:00 2001 From: radex Date: Fri, 2 Aug 2019 10:44:46 +0200 Subject: [PATCH 09/19] fix potential crash --- Libraries/Alert/Alert.js | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/Libraries/Alert/Alert.js b/Libraries/Alert/Alert.js index 71e53d49e59b12..fc52429ebb0d54 100644 --- a/Libraries/Alert/Alert.js +++ b/Libraries/Alert/Alert.js @@ -53,7 +53,7 @@ class Alert { ): void { if (Platform.OS === 'ios') { Alert.prompt(title, message, buttons, 'default', undefined, undefined, { - reactTag: ReactNative.findNodeHandle(options.surface), + surface: options.surface, }); } else if (Platform.OS === 'android') { if (!NativeDialogManagerAndroid) { @@ -172,9 +172,7 @@ class Alert { cancelButtonKey, destructiveButtonKey, keyboardType, - reactTag: options.surface - ? ReactNative.findNodeHandle(options.surface) - : -1, + reactTag: ReactNative.findNodeHandle(options.surface) ?? -1, }, (id, value) => { const cb = callbacks[id]; From 47e2475c7271740347487e413004473ed71b66e7 Mon Sep 17 00:00:00 2001 From: radex Date: Fri, 2 Aug 2019 10:55:05 +0200 Subject: [PATCH 10/19] Add RNTester examples of passing surface --- RNTester/js/examples/Alert/AlertExample.js | 18 ++++++++++++- .../js/examples/StatusBar/StatusBarExample.js | 25 ++++++++++++++++++- 2 files changed, 41 insertions(+), 2 deletions(-) diff --git a/RNTester/js/examples/Alert/AlertExample.js b/RNTester/js/examples/Alert/AlertExample.js index 4e362a525f91f9..34ad6169d7a46e 100644 --- a/RNTester/js/examples/Alert/AlertExample.js +++ b/RNTester/js/examples/Alert/AlertExample.js @@ -31,9 +31,14 @@ const alertMessage = type Props = $ReadOnly<{||}>; class SimpleAlertExampleBlock extends React.Component { + constructor(props) { + super(props); + this.viewRef = React.createRef(); + } + render() { return ( - + Alert.alert('Alert Title', alertMessage)}> @@ -120,6 +125,17 @@ class SimpleAlertExampleBlock extends React.Component { Alert without title + + Alert.alert('Surfaced!', alertMessage, null, { + surface: this.viewRef.current, + }) + }> + + Alert with surface passed + + ); } diff --git a/RNTester/js/examples/StatusBar/StatusBarExample.js b/RNTester/js/examples/StatusBar/StatusBarExample.js index 09972b3c92d9ca..3293baa36ff544 100644 --- a/RNTester/js/examples/StatusBar/StatusBarExample.js +++ b/RNTester/js/examples/StatusBar/StatusBarExample.js @@ -254,9 +254,14 @@ class StatusBarTranslucentExample extends React.Component<{}, $FlowFixMeState> { } class StatusBarStaticIOSExample extends React.Component<{}> { + constructor(props) { + super(props); + this.viewRef = React.createRef(); + } + render() { return ( - + { @@ -275,6 +280,15 @@ class StatusBarStaticIOSExample extends React.Component<{}> { setHidden(false, 'fade') + { + StatusBar.setHidden(true, 'fade', this.viewRef.current); + }}> + + setHidden(true, 'fade', componentRef) + + { @@ -293,6 +307,15 @@ class StatusBarStaticIOSExample extends React.Component<{}> { setBarStyle('light-content', true) + { + StatusBar.setBarStyle('default', false, this.viewRef.current); + }}> + + setBarStyle('default', false, componentRef) + + { From dc448482945fcde5d79b6c88c95c3ee57249042e Mon Sep 17 00:00:00 2001 From: radex Date: Fri, 2 Aug 2019 11:07:25 +0200 Subject: [PATCH 11/19] fix types --- Libraries/ActionSheetIOS/ActionSheetIOS.js | 21 ++++++++++++------- .../NativeActionSheetManager.js | 2 ++ .../StatusBar/NativeStatusBarManager.js | 12 +++++++++-- RNTester/js/examples/Alert/AlertExample.js | 5 +---- .../js/examples/StatusBar/StatusBarExample.js | 5 +---- 5 files changed, 28 insertions(+), 17 deletions(-) diff --git a/Libraries/ActionSheetIOS/ActionSheetIOS.js b/Libraries/ActionSheetIOS/ActionSheetIOS.js index a97ee9bc5f68c1..fd317e832fccb2 100644 --- a/Libraries/ActionSheetIOS/ActionSheetIOS.js +++ b/Libraries/ActionSheetIOS/ActionSheetIOS.js @@ -41,11 +41,12 @@ const ActionSheetIOS = { options: {| +title?: ?string, +message?: ?string, - +options: Array, + +options: ?Array, + // Supports Array as well. +destructiveButtonIndex?: ?number, +cancelButtonIndex?: ?number, +anchor?: ?number, - +tintColor?: number | string, + +tintColor?: ?number, +surface?: mixed, |}, callback: (buttonIndex: number) => void, @@ -91,15 +92,21 @@ const ActionSheetIOS = { */ showShareActionSheetWithOptions( options: {| - +url?: ?string, +message?: ?string, + +url?: ?string, +subject?: ?string, - +excludedActivityTypes?: ?(string[]), - +tintColor?: number | string, + +anchor?: ?number, + +tintColor?: ?number, + +excludedActivityTypes?: ?Array, +surface?: mixed, |}, - failureCallback: Function, - successCallback: Function, + failureCallback: (error: {| + +domain: string, + +code: string, + +userInfo?: ?Object, + +message: string, + |}) => void, + successCallback: (completed: boolean, activityType: ?string) => void, ) { invariant( typeof options === 'object' && options !== null, diff --git a/Libraries/ActionSheetIOS/NativeActionSheetManager.js b/Libraries/ActionSheetIOS/NativeActionSheetManager.js index 5f2a1ad0682c4c..0c39f60180645f 100644 --- a/Libraries/ActionSheetIOS/NativeActionSheetManager.js +++ b/Libraries/ActionSheetIOS/NativeActionSheetManager.js @@ -25,6 +25,7 @@ export interface Spec extends TurboModule { +cancelButtonIndex?: ?number, +anchor?: ?number, +tintColor?: ?number, + +reactTag?: number, |}, callback: (buttonIndex: number) => void, ) => void; @@ -36,6 +37,7 @@ export interface Spec extends TurboModule { +anchor?: ?number, +tintColor?: ?number, +excludedActivityTypes?: ?Array, + +reactTag?: number, |}, failureCallback: (error: {| +domain: string, diff --git a/Libraries/Components/StatusBar/NativeStatusBarManager.js b/Libraries/Components/StatusBar/NativeStatusBarManager.js index 4c7337ad9d2f7f..6b2000bbc61fd6 100644 --- a/Libraries/Components/StatusBar/NativeStatusBarManager.js +++ b/Libraries/Components/StatusBar/NativeStatusBarManager.js @@ -37,12 +37,20 @@ export interface Spec extends TurboModule { * - 'dark-content' (iOS and Android) * - 'light-content' (iOS) */ - +setStyle: (statusBarStyle?: ?string, animated?: ?boolean) => void; + +setStyle: ( + statusBarStyle?: ?string, + animated?: ?boolean, + reactTag?: number, + ) => void; /** * - withAnimation is iOS only * - withAnimation can be: 'none' | 'fade' | 'slide' */ - +setHidden: (hidden: boolean, withAnimation?: ?string) => void; + +setHidden: ( + hidden: boolean, + withAnimation?: ?string, + reactTag?: number, + ) => void; } export default TurboModuleRegistry.getEnforcing('StatusBarManager'); diff --git a/RNTester/js/examples/Alert/AlertExample.js b/RNTester/js/examples/Alert/AlertExample.js index 34ad6169d7a46e..34bccabd630286 100644 --- a/RNTester/js/examples/Alert/AlertExample.js +++ b/RNTester/js/examples/Alert/AlertExample.js @@ -31,10 +31,7 @@ const alertMessage = type Props = $ReadOnly<{||}>; class SimpleAlertExampleBlock extends React.Component { - constructor(props) { - super(props); - this.viewRef = React.createRef(); - } + viewRef = React.createRef(); render() { return ( diff --git a/RNTester/js/examples/StatusBar/StatusBarExample.js b/RNTester/js/examples/StatusBar/StatusBarExample.js index 3293baa36ff544..0a77f4a88ded55 100644 --- a/RNTester/js/examples/StatusBar/StatusBarExample.js +++ b/RNTester/js/examples/StatusBar/StatusBarExample.js @@ -254,10 +254,7 @@ class StatusBarTranslucentExample extends React.Component<{}, $FlowFixMeState> { } class StatusBarStaticIOSExample extends React.Component<{}> { - constructor(props) { - super(props); - this.viewRef = React.createRef(); - } + viewRef = React.createRef(); render() { return ( From 1b90cb8b00cf0070471efa06d0e28daa49efbe16 Mon Sep 17 00:00:00 2001 From: radex Date: Fri, 2 Aug 2019 11:23:37 +0200 Subject: [PATCH 12/19] fix types - take 2 --- Libraries/ActionSheetIOS/ActionSheetIOS.js | 11 +++-------- RNTester/js/examples/Alert/AlertExample.js | 2 +- RNTester/js/examples/StatusBar/StatusBarExample.js | 2 +- 3 files changed, 5 insertions(+), 10 deletions(-) diff --git a/Libraries/ActionSheetIOS/ActionSheetIOS.js b/Libraries/ActionSheetIOS/ActionSheetIOS.js index fd317e832fccb2..cda71da76dc308 100644 --- a/Libraries/ActionSheetIOS/ActionSheetIOS.js +++ b/Libraries/ActionSheetIOS/ActionSheetIOS.js @@ -46,7 +46,7 @@ const ActionSheetIOS = { +destructiveButtonIndex?: ?number, +cancelButtonIndex?: ?number, +anchor?: ?number, - +tintColor?: ?number, + +tintColor?: ?number | string, +surface?: mixed, |}, callback: (buttonIndex: number) => void, @@ -96,16 +96,11 @@ const ActionSheetIOS = { +url?: ?string, +subject?: ?string, +anchor?: ?number, - +tintColor?: ?number, + +tintColor?: ?number | string, +excludedActivityTypes?: ?Array, +surface?: mixed, |}, - failureCallback: (error: {| - +domain: string, - +code: string, - +userInfo?: ?Object, - +message: string, - |}) => void, + failureCallback: Function, successCallback: (completed: boolean, activityType: ?string) => void, ) { invariant( diff --git a/RNTester/js/examples/Alert/AlertExample.js b/RNTester/js/examples/Alert/AlertExample.js index 34bccabd630286..1bceb372af9e9f 100644 --- a/RNTester/js/examples/Alert/AlertExample.js +++ b/RNTester/js/examples/Alert/AlertExample.js @@ -31,7 +31,7 @@ const alertMessage = type Props = $ReadOnly<{||}>; class SimpleAlertExampleBlock extends React.Component { - viewRef = React.createRef(); + viewRef = React.createRef(); render() { return ( diff --git a/RNTester/js/examples/StatusBar/StatusBarExample.js b/RNTester/js/examples/StatusBar/StatusBarExample.js index 0a77f4a88ded55..4b5ae76b49dd45 100644 --- a/RNTester/js/examples/StatusBar/StatusBarExample.js +++ b/RNTester/js/examples/StatusBar/StatusBarExample.js @@ -254,7 +254,7 @@ class StatusBarTranslucentExample extends React.Component<{}, $FlowFixMeState> { } class StatusBarStaticIOSExample extends React.Component<{}> { - viewRef = React.createRef(); + viewRef = React.createRef(); render() { return ( From 2a286257a6553a80a34e2b1f1ad94fc7bae36ea3 Mon Sep 17 00:00:00 2001 From: radex Date: Fri, 2 Aug 2019 11:28:36 +0200 Subject: [PATCH 13/19] fix types - take 3 --- RNTester/js/examples/Alert/AlertExample.js | 2 +- RNTester/js/examples/StatusBar/StatusBarExample.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/RNTester/js/examples/Alert/AlertExample.js b/RNTester/js/examples/Alert/AlertExample.js index 1bceb372af9e9f..761c278492ae72 100644 --- a/RNTester/js/examples/Alert/AlertExample.js +++ b/RNTester/js/examples/Alert/AlertExample.js @@ -31,7 +31,7 @@ const alertMessage = type Props = $ReadOnly<{||}>; class SimpleAlertExampleBlock extends React.Component { - viewRef = React.createRef(); + viewRef: React.Ref | null> = React.createRef(); render() { return ( diff --git a/RNTester/js/examples/StatusBar/StatusBarExample.js b/RNTester/js/examples/StatusBar/StatusBarExample.js index 4b5ae76b49dd45..72a5ccd390a898 100644 --- a/RNTester/js/examples/StatusBar/StatusBarExample.js +++ b/RNTester/js/examples/StatusBar/StatusBarExample.js @@ -254,7 +254,7 @@ class StatusBarTranslucentExample extends React.Component<{}, $FlowFixMeState> { } class StatusBarStaticIOSExample extends React.Component<{}> { - viewRef = React.createRef(); + viewRef: React.Ref | null> = React.createRef(); render() { return ( From 4ca185d7e1a042bd433760887b89d2e3a0f9d221 Mon Sep 17 00:00:00 2001 From: radex Date: Fri, 2 Aug 2019 13:15:03 +0200 Subject: [PATCH 14/19] fix types - take 4 --- .../js/examples/ActionSheetIOS/ActionSheetIOSExample.js | 6 +++--- RNTester/js/examples/Alert/AlertExample.js | 2 +- RNTester/js/examples/StatusBar/StatusBarExample.js | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/RNTester/js/examples/ActionSheetIOS/ActionSheetIOSExample.js b/RNTester/js/examples/ActionSheetIOS/ActionSheetIOSExample.js index c1130357829df5..15749a029dc097 100644 --- a/RNTester/js/examples/ActionSheetIOS/ActionSheetIOSExample.js +++ b/RNTester/js/examples/ActionSheetIOS/ActionSheetIOSExample.js @@ -169,7 +169,7 @@ class ShareActionSheetExample extends React.Component< (completed, method) => { let text; if (completed) { - text = `Shared via ${method}`; + text = `Shared via ${method || 'null'}`; } else { text = "You didn't share"; } @@ -212,7 +212,7 @@ class ShareScreenshotExample extends React.Component< (completed, method) => { let text; if (completed) { - text = `Shared via ${method}`; + text = `Shared via ${method || 'null'}`; } else { text = "You didn't share"; } @@ -270,7 +270,7 @@ class ShareScreenshotAnchorExample extends React.Component< (completed, method) => { let text; if (completed) { - text = `Shared via ${method}`; + text = `Shared via ${method || 'null'}`; } else { text = "You didn't share"; } diff --git a/RNTester/js/examples/Alert/AlertExample.js b/RNTester/js/examples/Alert/AlertExample.js index 761c278492ae72..ea22af5581b30e 100644 --- a/RNTester/js/examples/Alert/AlertExample.js +++ b/RNTester/js/examples/Alert/AlertExample.js @@ -31,7 +31,7 @@ const alertMessage = type Props = $ReadOnly<{||}>; class SimpleAlertExampleBlock extends React.Component { - viewRef: React.Ref | null> = React.createRef(); + viewRef: React.Ref | undefined> = React.createRef(); render() { return ( diff --git a/RNTester/js/examples/StatusBar/StatusBarExample.js b/RNTester/js/examples/StatusBar/StatusBarExample.js index 72a5ccd390a898..126438dfd50081 100644 --- a/RNTester/js/examples/StatusBar/StatusBarExample.js +++ b/RNTester/js/examples/StatusBar/StatusBarExample.js @@ -254,7 +254,7 @@ class StatusBarTranslucentExample extends React.Component<{}, $FlowFixMeState> { } class StatusBarStaticIOSExample extends React.Component<{}> { - viewRef: React.Ref | null> = React.createRef(); + viewRef: React.Ref | undefined> = React.createRef(); render() { return ( From e699526f51b0c209b87d6cf44a58f8612ad3d96b Mon Sep 17 00:00:00 2001 From: radex Date: Fri, 2 Aug 2019 13:26:19 +0200 Subject: [PATCH 15/19] i give up, flow --- RNTester/js/examples/Alert/AlertExample.js | 4 +++- RNTester/js/examples/StatusBar/StatusBarExample.js | 7 +++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/RNTester/js/examples/Alert/AlertExample.js b/RNTester/js/examples/Alert/AlertExample.js index ea22af5581b30e..5ffe67edb279b1 100644 --- a/RNTester/js/examples/Alert/AlertExample.js +++ b/RNTester/js/examples/Alert/AlertExample.js @@ -31,7 +31,9 @@ const alertMessage = type Props = $ReadOnly<{||}>; class SimpleAlertExampleBlock extends React.Component { - viewRef: React.Ref | undefined> = React.createRef(); + viewRef: React.MutableRefObject | void> = React.createRef(); render() { return ( diff --git a/RNTester/js/examples/StatusBar/StatusBarExample.js b/RNTester/js/examples/StatusBar/StatusBarExample.js index 126438dfd50081..85d2c107e7b58f 100644 --- a/RNTester/js/examples/StatusBar/StatusBarExample.js +++ b/RNTester/js/examples/StatusBar/StatusBarExample.js @@ -10,7 +10,7 @@ 'use strict'; -const React = require('react'); +import React from 'react'; const { StatusBar, StyleSheet, @@ -254,7 +254,10 @@ class StatusBarTranslucentExample extends React.Component<{}, $FlowFixMeState> { } class StatusBarStaticIOSExample extends React.Component<{}> { - viewRef: React.Ref | undefined> = React.createRef(); + // $FlowFixMe + viewRef: React.MutableRefObject | void> = React.createRef(); render() { return ( From ccfb397b7ec41e6fa1a6267bf3e3270abc37dbcf Mon Sep 17 00:00:00 2001 From: radex Date: Fri, 27 Sep 2019 09:09:49 +0200 Subject: [PATCH 16/19] unbreak merge? --- RNTester/Podfile.lock | 56 ++++++++++++++++++++++--------------------- 1 file changed, 29 insertions(+), 27 deletions(-) diff --git a/RNTester/Podfile.lock b/RNTester/Podfile.lock index cab692d2f3fd60..04eae6654a45d3 100644 --- a/RNTester/Podfile.lock +++ b/RNTester/Podfile.lock @@ -47,7 +47,7 @@ PODS: - React-cxxreact (= 1000.0.0) - React-jsi (= 1000.0.0) - React-jsiexecutor (= 1000.0.0) - - yoga (= 1000.0.0.React) + - Yoga - React-Core/ARTHeaders (1000.0.0): - Folly (= 2018.10.22.00) - glog @@ -55,7 +55,7 @@ PODS: - React-cxxreact (= 1000.0.0) - React-jsi (= 1000.0.0) - React-jsiexecutor (= 1000.0.0) - - yoga (= 1000.0.0.React) + - Yoga - React-Core/CoreModulesHeaders (1000.0.0): - Folly (= 2018.10.22.00) - glog @@ -63,14 +63,14 @@ PODS: - React-cxxreact (= 1000.0.0) - React-jsi (= 1000.0.0) - React-jsiexecutor (= 1000.0.0) - - yoga (= 1000.0.0.React) + - Yoga - React-Core/Default (1000.0.0): - Folly (= 2018.10.22.00) - glog - React-cxxreact (= 1000.0.0) - React-jsi (= 1000.0.0) - React-jsiexecutor (= 1000.0.0) - - yoga (= 1000.0.0.React) + - Yoga - React-Core/DevSupport (1000.0.0): - Folly (= 2018.10.22.00) - glog @@ -80,7 +80,7 @@ PODS: - React-jsi (= 1000.0.0) - React-jsiexecutor (= 1000.0.0) - React-jsinspector (= 1000.0.0) - - yoga (= 1000.0.0.React) + - Yoga - React-Core/RCTActionSheetHeaders (1000.0.0): - Folly (= 2018.10.22.00) - glog @@ -88,7 +88,7 @@ PODS: - React-cxxreact (= 1000.0.0) - React-jsi (= 1000.0.0) - React-jsiexecutor (= 1000.0.0) - - yoga (= 1000.0.0.React) + - Yoga - React-Core/RCTAnimationHeaders (1000.0.0): - Folly (= 2018.10.22.00) - glog @@ -96,7 +96,7 @@ PODS: - React-cxxreact (= 1000.0.0) - React-jsi (= 1000.0.0) - React-jsiexecutor (= 1000.0.0) - - yoga (= 1000.0.0.React) + - Yoga - React-Core/RCTBlobHeaders (1000.0.0): - Folly (= 2018.10.22.00) - glog @@ -104,7 +104,7 @@ PODS: - React-cxxreact (= 1000.0.0) - React-jsi (= 1000.0.0) - React-jsiexecutor (= 1000.0.0) - - yoga (= 1000.0.0.React) + - Yoga - React-Core/RCTImageHeaders (1000.0.0): - Folly (= 2018.10.22.00) - glog @@ -112,7 +112,7 @@ PODS: - React-cxxreact (= 1000.0.0) - React-jsi (= 1000.0.0) - React-jsiexecutor (= 1000.0.0) - - yoga (= 1000.0.0.React) + - Yoga - React-Core/RCTLinkingHeaders (1000.0.0): - Folly (= 2018.10.22.00) - glog @@ -120,7 +120,7 @@ PODS: - React-cxxreact (= 1000.0.0) - React-jsi (= 1000.0.0) - React-jsiexecutor (= 1000.0.0) - - yoga (= 1000.0.0.React) + - Yoga - React-Core/RCTNetworkHeaders (1000.0.0): - Folly (= 2018.10.22.00) - glog @@ -128,7 +128,7 @@ PODS: - React-cxxreact (= 1000.0.0) - React-jsi (= 1000.0.0) - React-jsiexecutor (= 1000.0.0) - - yoga (= 1000.0.0.React) + - Yoga - React-Core/RCTPushNotificationHeaders (1000.0.0): - Folly (= 2018.10.22.00) - glog @@ -136,7 +136,7 @@ PODS: - React-cxxreact (= 1000.0.0) - React-jsi (= 1000.0.0) - React-jsiexecutor (= 1000.0.0) - - yoga (= 1000.0.0.React) + - Yoga - React-Core/RCTSettingsHeaders (1000.0.0): - Folly (= 2018.10.22.00) - glog @@ -144,7 +144,7 @@ PODS: - React-cxxreact (= 1000.0.0) - React-jsi (= 1000.0.0) - React-jsiexecutor (= 1000.0.0) - - yoga (= 1000.0.0.React) + - Yoga - React-Core/RCTTextHeaders (1000.0.0): - Folly (= 2018.10.22.00) - glog @@ -152,7 +152,7 @@ PODS: - React-cxxreact (= 1000.0.0) - React-jsi (= 1000.0.0) - React-jsiexecutor (= 1000.0.0) - - yoga (= 1000.0.0.React) + - Yoga - React-Core/RCTVibrationHeaders (1000.0.0): - Folly (= 2018.10.22.00) - glog @@ -160,7 +160,7 @@ PODS: - React-cxxreact (= 1000.0.0) - React-jsi (= 1000.0.0) - React-jsiexecutor (= 1000.0.0) - - yoga (= 1000.0.0.React) + - Yoga - React-Core/RCTWebSocket (1000.0.0): - Folly (= 2018.10.22.00) - glog @@ -168,11 +168,13 @@ PODS: - React-cxxreact (= 1000.0.0) - React-jsi (= 1000.0.0) - React-jsiexecutor (= 1000.0.0) - - yoga (= 1000.0.0.React) + - Yoga - React-CoreModules (1000.0.0): - FBReactNativeSpec (= 1000.0.0) - Folly (= 2018.10.22.00) + - RCTTypeSafety (= 1000.0.0) - React-Core/CoreModulesHeaders (= 1000.0.0) + - React-RCTImage (= 1000.0.0) - ReactCommon/turbomodule/core (= 1000.0.0) - React-cxxreact (1000.0.0): - boost-for-react-native (= 1.63.0) @@ -224,7 +226,7 @@ PODS: - React-Core/RCTTextHeaders (= 1000.0.0) - React-RCTVibration (1000.0.0): - React-Core/RCTVibrationHeaders (= 1000.0.0) - - ReactCommon/jscallinvoker (1000.0.0): + - ReactCommon/callinvoker (1000.0.0): - DoubleConversion - Folly (= 2018.10.22.00) - glog @@ -236,7 +238,7 @@ PODS: - React-Core (= 1000.0.0) - React-cxxreact (= 1000.0.0) - React-jsi (= 1000.0.0) - - ReactCommon/jscallinvoker (= 1000.0.0) + - ReactCommon/callinvoker (= 1000.0.0) - ReactCommon/turbomodule/samples (1000.0.0): - DoubleConversion - Folly (= 2018.10.22.00) @@ -244,9 +246,9 @@ PODS: - React-Core (= 1000.0.0) - React-cxxreact (= 1000.0.0) - React-jsi (= 1000.0.0) - - ReactCommon/jscallinvoker (= 1000.0.0) + - ReactCommon/callinvoker (= 1000.0.0) - ReactCommon/turbomodule/core (= 1000.0.0) - - yoga (1000.0.0.React) + - Yoga (1.14.0) DEPENDENCIES: - DoubleConversion (from `../third-party-podspecs/DoubleConversion.podspec`) @@ -277,10 +279,10 @@ DEPENDENCIES: - React-RCTTest (from `RCTTest`) - React-RCTText (from `../Libraries/Text`) - React-RCTVibration (from `../Libraries/Vibration`) - - ReactCommon/jscallinvoker (from `../ReactCommon`) + - ReactCommon/callinvoker (from `../ReactCommon`) - ReactCommon/turbomodule/core (from `../ReactCommon`) - ReactCommon/turbomodule/samples (from `../ReactCommon`) - - yoga (from `../ReactCommon/yoga`) + - Yoga (from `../ReactCommon/yoga`) SPEC REPOS: https://github.com/cocoapods/specs.git: @@ -341,7 +343,7 @@ EXTERNAL SOURCES: :path: "../Libraries/Vibration" ReactCommon: :path: "../ReactCommon" - yoga: + Yoga: :path: "../ReactCommon/yoga" SPEC CHECKSUMS: @@ -355,8 +357,8 @@ SPEC CHECKSUMS: RCTTypeSafety: 2b1cb2d92b779aa9a3522f67bd4f07e6b6d0797e React: 28a654b69575941571c073a656bc06795825e7f7 React-ART: a5da06a892342d03896e0db45a7072525981f63c - React-Core: 47b8ab211d9325292811e62ee23c54b464853111 - React-CoreModules: 38d8cc34497674ae3d411e644a9b17ad75ef3f74 + React-Core: f8656b21cfe16b1fe276686f3b921bce0fa6de4d + React-CoreModules: 96b2f1e0b84493e6c1b7f3bb21357f24fdcfce2f React-cxxreact: 7c4242192149ce0205b53efaa03e3bf86ba4337c React-jsi: 98d1f9d8a79d2720ba6a44c2d928a77f315b7e4f React-jsiexecutor: c0ab8c80a6e88380d63f583690a50d4a723b47b5 @@ -372,8 +374,8 @@ SPEC CHECKSUMS: React-RCTTest: 73df09ec226fcad6e7e058a313e5dd16cccf86a8 React-RCTText: 9078167d3bc011162326f2d8ef4dd580ec1eca17 React-RCTVibration: 63c20d89204937ff8c7bbc1e712383347e6fbd90 - ReactCommon: 63d1a6355d5810a21a61efda9ac93804571a1b8b - yoga: b72aa5b3708cc93c5897f8297122d6eba1331e07 + ReactCommon: 9d212865526209dc2d01be40340c8d27b53e6bea + Yoga: d88d8b51ee5b247f43211e2edf272438df1b484f PODFILE CHECKSUM: 060903e270072f1e192b064848e6c34528af1c87 From 2267b91fb574faf5b7d6c657674044dbbb1f0d1c Mon Sep 17 00:00:00 2001 From: radex Date: Fri, 27 Sep 2019 10:02:40 +0200 Subject: [PATCH 17/19] Alert - make options read-only --- Libraries/Alert/Alert.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Libraries/Alert/Alert.js b/Libraries/Alert/Alert.js index fc52429ebb0d54..3690b18e28f86f 100644 --- a/Libraries/Alert/Alert.js +++ b/Libraries/Alert/Alert.js @@ -30,9 +30,9 @@ export type Buttons = Array<{ }>; type Options = { - cancelable?: ?boolean, - onDismiss?: ?() => void, - surface?: mixed, + +cancelable?: ?boolean, + +onDismiss?: ?() => void, + +surface?: mixed, }; type PromptOptions = { From 1800be99a82e400c8b137fb0f54a03769ada3727 Mon Sep 17 00:00:00 2001 From: radex Date: Fri, 27 Sep 2019 10:09:39 +0200 Subject: [PATCH 18/19] fix some flow issues --- RNTester/js/examples/StatusBar/StatusBarExample.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/RNTester/js/examples/StatusBar/StatusBarExample.js b/RNTester/js/examples/StatusBar/StatusBarExample.js index 265aba0378313e..f7d816b8f5dac7 100644 --- a/RNTester/js/examples/StatusBar/StatusBarExample.js +++ b/RNTester/js/examples/StatusBar/StatusBarExample.js @@ -10,7 +10,7 @@ 'use strict'; -import React from 'react'; +const React = require('react'); const { StatusBar, StyleSheet, From e6f5e93be31fc0cb37e146a05d2de1fefcd9c5d6 Mon Sep 17 00:00:00 2001 From: radex Date: Fri, 27 Sep 2019 10:21:34 +0200 Subject: [PATCH 19/19] fix flow issues --- Libraries/Components/StatusBar/StatusBar.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Libraries/Components/StatusBar/StatusBar.js b/Libraries/Components/StatusBar/StatusBar.js index 05fbaf32a581a2..007ecef7ddd9d5 100644 --- a/Libraries/Components/StatusBar/StatusBar.js +++ b/Libraries/Components/StatusBar/StatusBar.js @@ -361,7 +361,7 @@ class StatusBar extends React.Component { * * @param props Object containing the StatusBar props to use in the stack entry. */ - static pushStackEntry(props: any, surface?: mixed) { + static pushStackEntry(props: any, surface?: mixed): any { const entry = createStackEntry(props); StatusBar._propsStack.push(entry); StatusBar._updatePropsStack(surface); @@ -387,7 +387,7 @@ class StatusBar extends React.Component { * @param entry Entry returned from `pushStackEntry` to replace. * @param props Object containing the StatusBar props to use in the replacement stack entry. */ - static replaceStackEntry(entry: any, props: any, surface?: mixed) { + static replaceStackEntry(entry: any, props: any, surface?: mixed): any { const newEntry = createStackEntry(props); const index = StatusBar._propsStack.indexOf(entry); if (index !== -1) { @@ -405,6 +405,7 @@ class StatusBar extends React.Component { showHideTransition: 'fade', }; + // $FlowFixMe (signature-verification-failure) static contextType = RootTagContext; _stackEntry = null;