Moving towards UIWindowScene support (#28058)

Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/28058

I'm taking the first step towards supporting iOS 13 UIScene APIs and modernizing React Native not to assume an app only has a single window. See discussion here: https://github.com/facebook/react-native/issues/25181#issuecomment-505612941

The approach I'm taking is to take advantage of `RootTagContext` and passing it to NativeModules so that they can identify correctly which window they refer to. Here I'm just laying groundwork.

- [x] `Alert` and `ActionSheetIOS` take an optional `rootTag` argument that will cause them to appear on the correct window
- [x] `StatusBar` methods also have `rootTag` argument added, but it's not fully hooked up on the native side — this turns out to require some more work, see: https://github.com/facebook/react-native/issues/25181#issuecomment-506690818
- [x] `setNetworkActivityIndicatorVisible` is deprecated in iOS 13
- [x] `RCTPerfMonitor`, `RCTProfile` no longer assume `UIApplicationDelegate` has a `window` property (no longer the best practice) — they now just render on the key window

Next steps: Add VC-based status bar management (if I get the OK on https://github.com/facebook/react-native/issues/25181#issuecomment-506690818 ), add multiple window demo to RNTester, deprecate Dimensions in favor of a layout context, consider adding hook-based APIs for native modules such as Alert that automatically know which rootTag to pass

## Changelog

[Internal] [Changed] - Modernize Modal to use RootTagContext
[iOS] [Changed] - `Alert`, `ActionSheetIOS`, `StatusBar` methods now take an optional `surface` argument (for future iPadOS 13 support)
[iOS] [Changed] - RCTPresentedViewController now takes a nullable `window` arg
[Internal] [Changed] - Do not assume `UIApplicationDelegate` has a `window` property
Pull Request resolved: https://github.com/facebook/react-native/pull/25425

Test Plan:
- Open RNTester and:
- go to Modal and check if it still works
- Alert → see if works
- ACtionSheetIOS → see if it works
- StatusBar → see if it works
- Share → see if it works

Reviewed By: PeteTheHeat

Differential Revision: D16957751

Pulled By: hramos

fbshipit-source-id: ae2a4478e2e7f8d2be3022c9c4861561ec244a26
This commit is contained in:
radex
2020-03-04 14:25:12 -08:00
committed by Facebook Github Bot
parent fcec815368
commit b58e176af0
23 changed files with 236 additions and 89 deletions
@@ -40,10 +40,10 @@ public abstract class NativeStatusBarManagerIOSSpec extends ReactContextBaseJava
public abstract void removeListeners(double count);
@ReactMethod
public abstract void setHidden(boolean hidden, String withAnimation);
public abstract void setHidden(boolean hidden, String withAnimation, double reactTag);
@ReactMethod
public abstract void setStyle(@Nullable String statusBarStyle, boolean animated);
public abstract void setStyle(@Nullable String statusBarStyle, boolean animated, double reactTag);
@ReactMethod
public abstract void addListener(String eventType);
@@ -2029,11 +2029,11 @@ namespace facebook {
}
static facebook::jsi::Value __hostFunction_NativeStatusBarManagerIOSSpecJSI_setStyle(facebook::jsi::Runtime& rt, TurboModule &turboModule, const facebook::jsi::Value* args, size_t count) {
return static_cast<JavaTurboModule&>(turboModule).invokeJavaMethod(rt, VoidKind, "setStyle", "(Ljava/lang/String;Z)V", args, count);
return static_cast<JavaTurboModule&>(turboModule).invokeJavaMethod(rt, VoidKind, "setStyle", "(Ljava/lang/String;ZD)V", args, count);
}
static facebook::jsi::Value __hostFunction_NativeStatusBarManagerIOSSpecJSI_setHidden(facebook::jsi::Runtime& rt, TurboModule &turboModule, const facebook::jsi::Value* args, size_t count) {
return static_cast<JavaTurboModule&>(turboModule).invokeJavaMethod(rt, VoidKind, "setHidden", "(ZLjava/lang/String;)V", args, count);
return static_cast<JavaTurboModule&>(turboModule).invokeJavaMethod(rt, VoidKind, "setHidden", "(ZLjava/lang/String;D)V", args, count);
}
static facebook::jsi::Value __hostFunction_NativeStatusBarManagerIOSSpecJSI_getConstants(facebook::jsi::Runtime& rt, TurboModule &turboModule, const facebook::jsi::Value* args, size_t count) {
@@ -2056,10 +2056,10 @@ namespace facebook {
methodMap_["removeListeners"] = MethodMetadata {1, __hostFunction_NativeStatusBarManagerIOSSpecJSI_removeListeners};
methodMap_["setStyle"] = MethodMetadata {2, __hostFunction_NativeStatusBarManagerIOSSpecJSI_setStyle};
methodMap_["setStyle"] = MethodMetadata {3, __hostFunction_NativeStatusBarManagerIOSSpecJSI_setStyle};
methodMap_["setHidden"] = MethodMetadata {2, __hostFunction_NativeStatusBarManagerIOSSpecJSI_setHidden};
methodMap_["setHidden"] = MethodMetadata {3, __hostFunction_NativeStatusBarManagerIOSSpecJSI_setHidden};
methodMap_["getConstants"] = MethodMetadata {0, __hostFunction_NativeStatusBarManagerIOSSpecJSI_getConstants};