mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Back out "Moving towards UIWindowScene support"
Summary: Original commit changeset: ae2a4478e2e7 Changelog: [Internal] Reviewed By: hramos Differential Revision: D20289851 fbshipit-source-id: 1167ce8f5135411b80630b523c91c10e2b7eece1
This commit is contained in:
committed by
Facebook Github Bot
parent
f4538e5777
commit
b85cb0cf7a
@@ -11,7 +11,6 @@
|
||||
'use strict';
|
||||
|
||||
import RCTActionSheetManager from './NativeActionSheetManager';
|
||||
import ReactNative from '../Renderer/shims/ReactNative';
|
||||
|
||||
const invariant = require('invariant');
|
||||
const processColor = require('../StyleSheet/processColor');
|
||||
@@ -44,13 +43,12 @@ const ActionSheetIOS = {
|
||||
options: {|
|
||||
+title?: ?string,
|
||||
+message?: ?string,
|
||||
+options: ?Array<string>,
|
||||
+options: Array<string>,
|
||||
+destructiveButtonIndex?: ?number | ?Array<number>,
|
||||
+cancelButtonIndex?: ?number,
|
||||
+anchor?: ?number,
|
||||
+tintColor?: ColorValue | ProcessedColorValue,
|
||||
+userInterfaceStyle?: string,
|
||||
+surface?: mixed,
|
||||
|},
|
||||
callback: (buttonIndex: number) => void,
|
||||
) {
|
||||
@@ -61,13 +59,7 @@ const ActionSheetIOS = {
|
||||
invariant(typeof callback === 'function', 'Must provide a valid callback');
|
||||
invariant(RCTActionSheetManager, "ActionSheetManager does't exist");
|
||||
|
||||
const {
|
||||
tintColor,
|
||||
destructiveButtonIndex,
|
||||
surface,
|
||||
...remainingOptions
|
||||
} = options;
|
||||
const reactTag = ReactNative.findNodeHandle(surface) ?? -1;
|
||||
const {tintColor, destructiveButtonIndex, ...remainingOptions} = options;
|
||||
let destructiveButtonIndices = null;
|
||||
|
||||
if (Array.isArray(destructiveButtonIndex)) {
|
||||
@@ -84,7 +76,6 @@ const ActionSheetIOS = {
|
||||
RCTActionSheetManager.showActionSheetWithOptions(
|
||||
{
|
||||
...remainingOptions,
|
||||
reactTag,
|
||||
tintColor: processedTintColor,
|
||||
destructiveButtonIndices,
|
||||
},
|
||||
@@ -133,16 +124,8 @@ 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(
|
||||
{
|
||||
...remainingOptions,
|
||||
reactTag,
|
||||
tintColor: processColor(options.tintColor),
|
||||
},
|
||||
{...options, tintColor: processColor(options.tintColor)},
|
||||
failureCallback,
|
||||
successCallback,
|
||||
);
|
||||
|
||||
@@ -25,7 +25,6 @@ export interface Spec extends TurboModule {
|
||||
+anchor?: ?number,
|
||||
+tintColor?: ?number,
|
||||
+userInterfaceStyle?: ?string,
|
||||
+reactTag?: number,
|
||||
|},
|
||||
callback: (buttonIndex: number) => void,
|
||||
) => void;
|
||||
@@ -38,7 +37,6 @@ export interface Spec extends TurboModule {
|
||||
+tintColor?: ?number,
|
||||
+excludedActivityTypes?: ?Array<string>,
|
||||
+userInterfaceStyle?: ?string,
|
||||
+reactTag?: number,
|
||||
|},
|
||||
failureCallback: (error: {|
|
||||
+domain: string,
|
||||
|
||||
@@ -15,7 +15,6 @@ import NativeDialogManagerAndroid, {
|
||||
type DialogOptions,
|
||||
} from '../NativeModules/specs/NativeDialogManagerAndroid';
|
||||
import RCTAlertManager from './RCTAlertManager';
|
||||
import ReactNative from '../Renderer/shims/ReactNative';
|
||||
|
||||
export type AlertType =
|
||||
| 'default'
|
||||
@@ -33,14 +32,9 @@ export type Buttons = Array<{
|
||||
type Options = {
|
||||
cancelable?: ?boolean,
|
||||
onDismiss?: ?() => void,
|
||||
surface?: mixed,
|
||||
...
|
||||
};
|
||||
|
||||
type PromptOptions = {
|
||||
surface?: mixed,
|
||||
};
|
||||
|
||||
/**
|
||||
* Launches an alert dialog with the specified title and message.
|
||||
*
|
||||
@@ -51,12 +45,10 @@ class Alert {
|
||||
title: ?string,
|
||||
message?: ?string,
|
||||
buttons?: Buttons,
|
||||
options?: Options = {},
|
||||
options?: Options,
|
||||
): void {
|
||||
if (Platform.OS === 'ios') {
|
||||
Alert.prompt(title, message, buttons, 'default', undefined, undefined, {
|
||||
surface: options.surface,
|
||||
});
|
||||
Alert.prompt(title, message, buttons, 'default');
|
||||
} else if (Platform.OS === 'android') {
|
||||
if (!NativeDialogManagerAndroid) {
|
||||
return;
|
||||
@@ -69,7 +61,7 @@ class Alert {
|
||||
cancelable: false,
|
||||
};
|
||||
|
||||
if (options.cancelable) {
|
||||
if (options && options.cancelable) {
|
||||
config.cancelable = options.cancelable;
|
||||
}
|
||||
// At most three buttons (neutral, negative, positive). Ignore rest.
|
||||
@@ -102,7 +94,7 @@ class Alert {
|
||||
buttonPositive.onPress && buttonPositive.onPress();
|
||||
}
|
||||
} else if (action === constants.dismissed) {
|
||||
options.onDismiss && options.onDismiss();
|
||||
options && options.onDismiss && options.onDismiss();
|
||||
}
|
||||
};
|
||||
const onError = errorMessage => console.warn(errorMessage);
|
||||
@@ -117,7 +109,6 @@ class Alert {
|
||||
type?: ?AlertType = 'plain-text',
|
||||
defaultValue?: string,
|
||||
keyboardType?: string,
|
||||
options?: PromptOptions = {surface: undefined},
|
||||
): void {
|
||||
if (Platform.OS === 'ios') {
|
||||
let callbacks = [];
|
||||
@@ -152,7 +143,6 @@ class Alert {
|
||||
cancelButtonKey,
|
||||
destructiveButtonKey,
|
||||
keyboardType,
|
||||
reactTag: ReactNative.findNodeHandle(options.surface) ?? -1,
|
||||
},
|
||||
(id, value) => {
|
||||
const cb = callbacks[id];
|
||||
|
||||
@@ -22,7 +22,6 @@ export type Args = {|
|
||||
cancelButtonKey?: string,
|
||||
destructiveButtonKey?: string,
|
||||
keyboardType?: string,
|
||||
reactTag?: number,
|
||||
|};
|
||||
|
||||
export interface Spec extends TurboModule {
|
||||
|
||||
@@ -204,7 +204,7 @@ didFinishPickingMediaWithInfo:(NSDictionary<NSString *, id> *)info
|
||||
[_pickerCallbacks addObject:callback];
|
||||
[_pickerCancelCallbacks addObject:cancelCallback];
|
||||
|
||||
UIViewController *rootViewController = RCTPresentedViewController(nil);
|
||||
UIViewController *rootViewController = RCTPresentedViewController();
|
||||
[rootViewController presentViewController:imagePicker animated:YES completion:nil];
|
||||
}
|
||||
|
||||
@@ -223,7 +223,7 @@ didFinishPickingMediaWithInfo:(NSDictionary<NSString *, id> *)info
|
||||
[_pickerCallbacks removeObjectAtIndex:index];
|
||||
[_pickerCancelCallbacks removeObjectAtIndex:index];
|
||||
|
||||
UIViewController *rootViewController = RCTPresentedViewController(nil);
|
||||
UIViewController *rootViewController = RCTPresentedViewController();
|
||||
[rootViewController dismissViewControllerAnimated:YES completion:nil];
|
||||
|
||||
if (args) {
|
||||
|
||||
@@ -31,19 +31,11 @@ export interface Spec extends TurboModule {
|
||||
* - 'dark-content'
|
||||
* - 'light-content'
|
||||
*/
|
||||
+setStyle: (
|
||||
statusBarStyle?: ?string,
|
||||
animated: boolean,
|
||||
reactTag?: number,
|
||||
) => void;
|
||||
+setStyle: (statusBarStyle?: ?string, animated: boolean) => void;
|
||||
/**
|
||||
* - withAnimation can be: 'none' | 'fade' | 'slide'
|
||||
*/
|
||||
+setHidden: (
|
||||
hidden: boolean,
|
||||
withAnimation: string,
|
||||
reactTag?: number,
|
||||
) => void;
|
||||
+setHidden: (hidden: boolean, withAnimation: string) => void;
|
||||
}
|
||||
|
||||
export default (TurboModuleRegistry.getEnforcing<Spec>(
|
||||
|
||||
@@ -11,8 +11,6 @@
|
||||
'use strict';
|
||||
|
||||
const Platform = require('../../Utilities/Platform');
|
||||
const RootTagContext = require('../../ReactNative/RootTagContext');
|
||||
import ReactNative from '../../Renderer/shims/ReactNative';
|
||||
const React = require('react');
|
||||
|
||||
const invariant = require('invariant');
|
||||
@@ -266,19 +264,11 @@ class StatusBar extends React.Component<Props> {
|
||||
* @param animation Optional animation when
|
||||
* changing the status bar hidden property.
|
||||
*/
|
||||
static setHidden(
|
||||
hidden: boolean,
|
||||
animation?: StatusBarAnimation,
|
||||
surface?: mixed,
|
||||
) {
|
||||
static setHidden(hidden: boolean, animation?: StatusBarAnimation) {
|
||||
animation = animation || 'none';
|
||||
StatusBar._defaultProps.hidden.value = hidden;
|
||||
if (Platform.OS === 'ios') {
|
||||
NativeStatusBarManagerIOS.setHidden(
|
||||
hidden,
|
||||
animation,
|
||||
ReactNative.findNodeHandle(surface) ?? -1,
|
||||
);
|
||||
NativeStatusBarManagerIOS.setHidden(hidden, animation);
|
||||
} else if (Platform.OS === 'android') {
|
||||
NativeStatusBarManagerAndroid.setHidden(hidden);
|
||||
}
|
||||
@@ -289,19 +279,11 @@ class StatusBar extends React.Component<Props> {
|
||||
* @param style Status bar style to set
|
||||
* @param animated Animate the style change.
|
||||
*/
|
||||
static setBarStyle(
|
||||
style: StatusBarStyle,
|
||||
animated?: boolean,
|
||||
surface?: mixed,
|
||||
) {
|
||||
static setBarStyle(style: StatusBarStyle, animated?: boolean) {
|
||||
animated = animated || false;
|
||||
StatusBar._defaultProps.barStyle.value = style;
|
||||
if (Platform.OS === 'ios') {
|
||||
NativeStatusBarManagerIOS.setStyle(
|
||||
style,
|
||||
animated,
|
||||
ReactNative.findNodeHandle(surface) ?? -1,
|
||||
);
|
||||
NativeStatusBarManagerIOS.setStyle(style, animated);
|
||||
} else if (Platform.OS === 'android') {
|
||||
NativeStatusBarManagerAndroid.setStyle(style);
|
||||
}
|
||||
@@ -310,7 +292,6 @@ class StatusBar extends React.Component<Props> {
|
||||
/**
|
||||
* Control the visibility of the network activity indicator
|
||||
* @param visible Show the indicator.
|
||||
* @platform ios
|
||||
*/
|
||||
static setNetworkActivityIndicatorVisible(visible: boolean) {
|
||||
if (Platform.OS !== 'ios') {
|
||||
@@ -327,7 +308,6 @@ class StatusBar extends React.Component<Props> {
|
||||
* 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') {
|
||||
@@ -355,7 +335,6 @@ class StatusBar extends React.Component<Props> {
|
||||
/**
|
||||
* Control the translucency of the status bar
|
||||
* @param translucent Set as translucent.
|
||||
* @platform android
|
||||
*/
|
||||
static setTranslucent(translucent: boolean) {
|
||||
if (Platform.OS !== 'android') {
|
||||
@@ -372,10 +351,10 @@ class StatusBar extends React.Component<Props> {
|
||||
*
|
||||
* @param props Object containing the StatusBar props to use in the stack entry.
|
||||
*/
|
||||
static pushStackEntry(props: any, surface?: mixed): any {
|
||||
static pushStackEntry(props: any): any {
|
||||
const entry = createStackEntry(props);
|
||||
StatusBar._propsStack.push(entry);
|
||||
StatusBar._updatePropsStack(surface);
|
||||
StatusBar._updatePropsStack();
|
||||
return entry;
|
||||
}
|
||||
|
||||
@@ -384,12 +363,12 @@ class StatusBar extends React.Component<Props> {
|
||||
*
|
||||
* @param entry Entry returned from `pushStackEntry`.
|
||||
*/
|
||||
static popStackEntry(entry: any, surface?: mixed) {
|
||||
static popStackEntry(entry: any) {
|
||||
const index = StatusBar._propsStack.indexOf(entry);
|
||||
if (index !== -1) {
|
||||
StatusBar._propsStack.splice(index, 1);
|
||||
}
|
||||
StatusBar._updatePropsStack(surface);
|
||||
StatusBar._updatePropsStack();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -398,13 +377,13 @@ class StatusBar extends React.Component<Props> {
|
||||
* @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): any {
|
||||
static replaceStackEntry(entry: any, props: any): any {
|
||||
const newEntry = createStackEntry(props);
|
||||
const index = StatusBar._propsStack.indexOf(entry);
|
||||
if (index !== -1) {
|
||||
StatusBar._propsStack[index] = newEntry;
|
||||
}
|
||||
StatusBar._updatePropsStack(surface);
|
||||
StatusBar._updatePropsStack();
|
||||
return newEntry;
|
||||
}
|
||||
|
||||
@@ -416,9 +395,6 @@ class StatusBar extends React.Component<Props> {
|
||||
showHideTransition: 'fade',
|
||||
};
|
||||
|
||||
// $FlowFixMe (signature-verification-failure)
|
||||
static contextType = RootTagContext;
|
||||
|
||||
_stackEntry = null;
|
||||
|
||||
componentDidMount() {
|
||||
@@ -426,27 +402,26 @@ class StatusBar extends React.Component<Props> {
|
||||
// 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 hierarchy will have priority.
|
||||
this._stackEntry = StatusBar.pushStackEntry(this.props, this.context);
|
||||
this._stackEntry = StatusBar.pushStackEntry(this.props);
|
||||
}
|
||||
|
||||
componentWillUnmount() {
|
||||
// When a StatusBar is unmounted, remove itself from the stack and update
|
||||
// the native bar with the next props.
|
||||
StatusBar.popStackEntry(this._stackEntry, this.context);
|
||||
StatusBar.popStackEntry(this._stackEntry);
|
||||
}
|
||||
|
||||
componentDidUpdate() {
|
||||
this._stackEntry = StatusBar.replaceStackEntry(
|
||||
this._stackEntry,
|
||||
this.props,
|
||||
this.context,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the native status bar with the props from the stack.
|
||||
*/
|
||||
static _updatePropsStack = (surface?: mixed) => {
|
||||
static _updatePropsStack = () => {
|
||||
// Send the update to the native module only once at the end of the frame.
|
||||
clearImmediate(StatusBar._updateImmediate);
|
||||
StatusBar._updateImmediate = setImmediate(() => {
|
||||
@@ -465,7 +440,6 @@ class StatusBar extends React.Component<Props> {
|
||||
NativeStatusBarManagerIOS.setStyle(
|
||||
mergedProps.barStyle.value,
|
||||
mergedProps.barStyle.animated || false,
|
||||
ReactNative.findNodeHandle(surface) ?? -1,
|
||||
);
|
||||
}
|
||||
if (!oldProps || oldProps.hidden.value !== mergedProps.hidden.value) {
|
||||
@@ -474,7 +448,6 @@ class StatusBar extends React.Component<Props> {
|
||||
mergedProps.hidden.animated
|
||||
? mergedProps.hidden.transition
|
||||
: 'none',
|
||||
ReactNative.findNodeHandle(surface) ?? -1,
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -2310,11 +2310,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<ObjCTurboModule&>(turboModule).invokeObjCMethod(rt, VoidKind, "setStyle", @selector(setStyle:animated:reactTag:), args, count);
|
||||
return static_cast<ObjCTurboModule&>(turboModule).invokeObjCMethod(rt, VoidKind, "setStyle", @selector(setStyle:animated:), 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<ObjCTurboModule&>(turboModule).invokeObjCMethod(rt, VoidKind, "setHidden", @selector(setHidden:withAnimation:reactTag:), args, count);
|
||||
return static_cast<ObjCTurboModule&>(turboModule).invokeObjCMethod(rt, VoidKind, "setHidden", @selector(setHidden:withAnimation:), args, count);
|
||||
}
|
||||
|
||||
static facebook::jsi::Value __hostFunction_NativeStatusBarManagerIOSSpecJSI_getConstants(facebook::jsi::Runtime& rt, TurboModule &turboModule, const facebook::jsi::Value* args, size_t count) {
|
||||
@@ -2337,10 +2337,10 @@ namespace facebook {
|
||||
methodMap_["removeListeners"] = MethodMetadata {1, __hostFunction_NativeStatusBarManagerIOSSpecJSI_removeListeners};
|
||||
|
||||
|
||||
methodMap_["setStyle"] = MethodMetadata {3, __hostFunction_NativeStatusBarManagerIOSSpecJSI_setStyle};
|
||||
methodMap_["setStyle"] = MethodMetadata {2, __hostFunction_NativeStatusBarManagerIOSSpecJSI_setStyle};
|
||||
|
||||
|
||||
methodMap_["setHidden"] = MethodMetadata {3, __hostFunction_NativeStatusBarManagerIOSSpecJSI_setHidden};
|
||||
methodMap_["setHidden"] = MethodMetadata {2, __hostFunction_NativeStatusBarManagerIOSSpecJSI_setHidden};
|
||||
|
||||
|
||||
methodMap_["getConstants"] = MethodMetadata {0, __hostFunction_NativeStatusBarManagerIOSSpecJSI_getConstants};
|
||||
|
||||
@@ -118,7 +118,6 @@ namespace JS {
|
||||
folly::Optional<double> anchor() const;
|
||||
folly::Optional<double> tintColor() const;
|
||||
NSString *userInterfaceStyle() const;
|
||||
folly::Optional<double> reactTag() const;
|
||||
|
||||
SpecShowActionSheetWithOptionsOptions(NSDictionary *const v) : _v(v) {}
|
||||
private:
|
||||
@@ -141,7 +140,6 @@ namespace JS {
|
||||
folly::Optional<double> tintColor() const;
|
||||
folly::Optional<facebook::react::LazyVector<NSString *>> excludedActivityTypes() const;
|
||||
NSString *userInterfaceStyle() const;
|
||||
folly::Optional<double> reactTag() const;
|
||||
|
||||
SpecShowShareActionSheetWithOptionsOptions(NSDictionary *const v) : _v(v) {}
|
||||
private:
|
||||
@@ -206,7 +204,6 @@ namespace JS {
|
||||
NSString *cancelButtonKey() const;
|
||||
NSString *destructiveButtonKey() const;
|
||||
NSString *keyboardType() const;
|
||||
folly::Optional<double> reactTag() const;
|
||||
|
||||
Args(NSDictionary *const v) : _v(v) {}
|
||||
private:
|
||||
@@ -2489,11 +2486,9 @@ namespace JS {
|
||||
- (void)addListener:(NSString *)eventType;
|
||||
- (void)removeListeners:(double)count;
|
||||
- (void)setStyle:(NSString * _Nullable)statusBarStyle
|
||||
animated:(BOOL)animated
|
||||
reactTag:(double)reactTag;
|
||||
animated:(BOOL)animated;
|
||||
- (void)setHidden:(BOOL)hidden
|
||||
withAnimation:(NSString *)withAnimation
|
||||
reactTag:(double)reactTag;
|
||||
withAnimation:(NSString *)withAnimation;
|
||||
- (facebook::react::ModuleConstants<JS::NativeStatusBarManagerIOS::Constants::Builder>)constantsToExport;
|
||||
- (facebook::react::ModuleConstants<JS::NativeStatusBarManagerIOS::Constants::Builder>)getConstants;
|
||||
|
||||
@@ -2947,11 +2942,6 @@ inline NSString *JS::NativeActionSheetManager::SpecShowActionSheetWithOptionsOpt
|
||||
id const p = _v[@"userInterfaceStyle"];
|
||||
return RCTBridgingToString(p);
|
||||
}
|
||||
inline folly::Optional<double> JS::NativeActionSheetManager::SpecShowActionSheetWithOptionsOptions::reactTag() const
|
||||
{
|
||||
id const p = _v[@"reactTag"];
|
||||
return RCTBridgingToOptionalDouble(p);
|
||||
}
|
||||
inline NSString *JS::NativeActionSheetManager::SpecShowShareActionSheetWithOptionsOptions::message() const
|
||||
{
|
||||
id const p = _v[@"message"];
|
||||
@@ -2987,11 +2977,6 @@ inline NSString *JS::NativeActionSheetManager::SpecShowShareActionSheetWithOptio
|
||||
id const p = _v[@"userInterfaceStyle"];
|
||||
return RCTBridgingToString(p);
|
||||
}
|
||||
inline folly::Optional<double> JS::NativeActionSheetManager::SpecShowShareActionSheetWithOptionsOptions::reactTag() const
|
||||
{
|
||||
id const p = _v[@"reactTag"];
|
||||
return RCTBridgingToOptionalDouble(p);
|
||||
}
|
||||
inline NSString *JS::NativeActionSheetManager::SpecShowShareActionSheetWithOptionsFailureCallbackError::domain() const
|
||||
{
|
||||
id const p = _v[@"domain"];
|
||||
@@ -3052,11 +3037,6 @@ inline NSString *JS::NativeAlertManager::Args::keyboardType() const
|
||||
id const p = _v[@"keyboardType"];
|
||||
return RCTBridgingToString(p);
|
||||
}
|
||||
inline folly::Optional<double> JS::NativeAlertManager::Args::reactTag() const
|
||||
{
|
||||
id const p = _v[@"reactTag"];
|
||||
return RCTBridgingToOptionalDouble(p);
|
||||
}
|
||||
inline bool JS::NativeAnimatedModule::EndResult::finished() const
|
||||
{
|
||||
id const p = _v[@"finished"];
|
||||
|
||||
@@ -11,7 +11,6 @@
|
||||
'use strict';
|
||||
|
||||
const AppContainer = require('../ReactNative/AppContainer');
|
||||
const RootTagContext = require('../ReactNative/RootTagContext');
|
||||
const I18nManager = require('../ReactNative/I18nManager');
|
||||
const PropTypes = require('prop-types');
|
||||
const React = require('react');
|
||||
@@ -147,6 +146,10 @@ class Modal extends React.Component<Props> {
|
||||
hardwareAccelerated: false,
|
||||
};
|
||||
|
||||
static contextTypes: any | {|rootTag: React$PropType$Primitive<number>|} = {
|
||||
rootTag: PropTypes.number,
|
||||
};
|
||||
|
||||
_identifier: number;
|
||||
_eventSubscription: ?EmitterSubscription;
|
||||
|
||||
@@ -214,11 +217,9 @@ class Modal extends React.Component<Props> {
|
||||
}
|
||||
|
||||
const innerChildren = __DEV__ ? (
|
||||
<RootTagContext.Consumer>
|
||||
{rootTag => (
|
||||
<AppContainer rootTag={rootTag}>{this.props.children}</AppContainer>
|
||||
)}
|
||||
</RootTagContext.Consumer>
|
||||
<AppContainer rootTag={this.context.rootTag}>
|
||||
{this.props.children}
|
||||
</AppContainer>
|
||||
) : (
|
||||
this.props.children
|
||||
);
|
||||
|
||||
@@ -169,7 +169,7 @@ class ShareActionSheetExample extends React.Component<
|
||||
(completed, method) => {
|
||||
let text;
|
||||
if (completed) {
|
||||
text = `Shared via ${method || 'null'}`;
|
||||
text = `Shared via ${method}`;
|
||||
} 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 || 'null'}`;
|
||||
text = `Shared via ${method}`;
|
||||
} 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 || 'null'}`;
|
||||
text = `Shared via ${method}`;
|
||||
} else {
|
||||
text = "You didn't share";
|
||||
}
|
||||
|
||||
@@ -31,13 +31,9 @@ const alertMessage =
|
||||
type Props = $ReadOnly<{||}>;
|
||||
|
||||
class SimpleAlertExampleBlock extends React.Component<Props> {
|
||||
viewRef: React.MutableRefObject<React.ElementRef<
|
||||
typeof View,
|
||||
> | void> = React.createRef();
|
||||
|
||||
render() {
|
||||
return (
|
||||
<View ref={this.viewRef}>
|
||||
<View>
|
||||
<TouchableHighlight
|
||||
style={styles.wrapper}
|
||||
onPress={() => Alert.alert('Alert Title', alertMessage)}>
|
||||
@@ -124,17 +120,6 @@ class SimpleAlertExampleBlock extends React.Component<Props> {
|
||||
<Text>Alert without title</Text>
|
||||
</View>
|
||||
</TouchableHighlight>
|
||||
<TouchableHighlight
|
||||
style={styles.wrapper}
|
||||
onPress={() =>
|
||||
Alert.alert('Surfaced!', alertMessage, null, {
|
||||
surface: this.viewRef.current,
|
||||
})
|
||||
}>
|
||||
<View style={styles.button}>
|
||||
<Text>Alert with surface passed</Text>
|
||||
</View>
|
||||
</TouchableHighlight>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
'use strict';
|
||||
|
||||
const React = require('react');
|
||||
|
||||
const {
|
||||
StatusBar,
|
||||
StyleSheet,
|
||||
@@ -257,14 +258,9 @@ class StatusBarTranslucentExample extends React.Component<
|
||||
}
|
||||
|
||||
class StatusBarStaticIOSExample extends React.Component<{...}> {
|
||||
// $FlowFixMe
|
||||
viewRef: React.MutableRefObject<React.ElementRef<
|
||||
typeof View,
|
||||
> | void> = React.createRef();
|
||||
|
||||
render() {
|
||||
return (
|
||||
<View ref={this.viewRef}>
|
||||
<View>
|
||||
<TouchableHighlight
|
||||
style={styles.wrapper}
|
||||
onPress={() => {
|
||||
@@ -283,15 +279,6 @@ class StatusBarStaticIOSExample extends React.Component<{...}> {
|
||||
<Text>setHidden(false, 'fade')</Text>
|
||||
</View>
|
||||
</TouchableHighlight>
|
||||
<TouchableHighlight
|
||||
style={styles.wrapper}
|
||||
onPress={() => {
|
||||
StatusBar.setHidden(true, 'fade', this.viewRef.current);
|
||||
}}>
|
||||
<View style={styles.button}>
|
||||
<Text>setHidden(true, 'fade', componentRef)</Text>
|
||||
</View>
|
||||
</TouchableHighlight>
|
||||
<TouchableHighlight
|
||||
style={styles.wrapper}
|
||||
onPress={() => {
|
||||
@@ -310,15 +297,6 @@ class StatusBarStaticIOSExample extends React.Component<{...}> {
|
||||
<Text>setBarStyle('light-content', true)</Text>
|
||||
</View>
|
||||
</TouchableHighlight>
|
||||
<TouchableHighlight
|
||||
style={styles.wrapper}
|
||||
onPress={() => {
|
||||
StatusBar.setBarStyle('default', false, this.viewRef.current);
|
||||
}}>
|
||||
<View style={styles.button}>
|
||||
<Text>setBarStyle('default', false, componentRef)</Text>
|
||||
</View>
|
||||
</TouchableHighlight>
|
||||
<TouchableHighlight
|
||||
style={styles.wrapper}
|
||||
onPress={() => {
|
||||
|
||||
@@ -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(UIWindow* _Nullable window);
|
||||
RCT_EXTERN UIViewController *__nullable RCTPresentedViewController(void);
|
||||
|
||||
// Does this device support force touch (aka 3D Touch)?
|
||||
RCT_EXTERN BOOL RCTForceTouchAvailable(void);
|
||||
|
||||
@@ -505,14 +505,13 @@ UIWindow *__nullable RCTKeyWindow(void)
|
||||
return nil;
|
||||
}
|
||||
|
||||
UIViewController *__nullable RCTPresentedViewController(UIWindow* _Nullable window)
|
||||
UIViewController *__nullable RCTPresentedViewController(void)
|
||||
{
|
||||
if ([RCTUtilsUIOverride hasPresentedViewController]) {
|
||||
return [RCTUtilsUIOverride presentedViewController];
|
||||
}
|
||||
|
||||
UIWindow *keyWindow = window ?: RCTKeyWindow();
|
||||
UIViewController *controller = keyWindow.rootViewController;
|
||||
UIViewController *controller = RCTKeyWindow().rootViewController;
|
||||
UIViewController *presentedController = controller.presentedViewController;
|
||||
while (presentedController && ![presentedController isBeingDismissed]) {
|
||||
controller = presentedController;
|
||||
|
||||
@@ -80,10 +80,7 @@ RCT_EXPORT_METHOD(showActionSheetWithOptions:(JS::NativeActionSheetManager::Spec
|
||||
destructiveButtonIndices = @[destructiveButtonIndex];
|
||||
}
|
||||
|
||||
NSNumber *reactTag = [RCTConvert NSNumber:options.reactTag() ? @(*options.reactTag()) : @-1];
|
||||
UIView *view = [self.bridge.uiManager viewForReactTag:reactTag];
|
||||
UIViewController *controller = RCTPresentedViewController(view.window);
|
||||
|
||||
UIViewController *controller = RCTPresentedViewController();
|
||||
NSNumber *anchor = [RCTConvert NSNumber:options.anchor() ? @(*options.anchor()) : nil];
|
||||
UIColor *tintColor = [RCTConvert UIColor:options.tintColor() ? @(*options.tintColor()) : nil];
|
||||
|
||||
@@ -197,10 +194,7 @@ RCT_EXPORT_METHOD(showShareActionSheetWithOptions:(JS::NativeActionSheetManager:
|
||||
shareController.excludedActivityTypes = excludedActivityTypes;
|
||||
}
|
||||
|
||||
NSNumber *reactTag = [RCTConvert NSNumber:options.reactTag() ? @(*options.reactTag()) : @-1];
|
||||
UIView *view = [self.bridge.uiManager viewForReactTag:reactTag];
|
||||
UIViewController *controller = RCTPresentedViewController(view.window);
|
||||
|
||||
UIViewController *controller = RCTPresentedViewController();
|
||||
shareController.completionWithItemsHandler = ^(NSString *activityType, BOOL completed, __unused NSArray *returnedItems, NSError *activityError) {
|
||||
if (activityError) {
|
||||
failureCallback(@[RCTJSErrorFromNSError(activityError)]);
|
||||
|
||||
@@ -12,7 +12,6 @@
|
||||
#import <React/RCTAssert.h>
|
||||
#import <React/RCTConvert.h>
|
||||
#import <React/RCTLog.h>
|
||||
#import <React/RCTUIManager.h>
|
||||
#import <React/RCTUtils.h>
|
||||
|
||||
#import "CoreModulesPlugins.h"
|
||||
@@ -37,8 +36,6 @@ RCT_ENUM_CONVERTER(RCTAlertViewStyle, (@{
|
||||
NSHashTable *_alertControllers;
|
||||
}
|
||||
|
||||
@synthesize bridge = _bridge;
|
||||
|
||||
RCT_EXPORT_MODULE()
|
||||
|
||||
- (dispatch_queue_t)methodQueue
|
||||
@@ -78,7 +75,6 @@ RCT_EXPORT_METHOD(alertWithArgs:(JS::NativeAlertManager::Args &)args
|
||||
NSString *cancelButtonKey = [RCTConvert NSString:args.cancelButtonKey()];
|
||||
NSString *destructiveButtonKey = [RCTConvert NSString:args.destructiveButtonKey()];
|
||||
UIKeyboardType keyboardType = [RCTConvert UIKeyboardType:args.keyboardType()];
|
||||
NSNumber *reactTag = [RCTConvert NSNumber:args.reactTag() ? @(*args.reactTag()) : @-1];
|
||||
|
||||
if (!title && !message) {
|
||||
RCTLogError(@"Must specify either an alert title, or message, or both");
|
||||
@@ -98,6 +94,21 @@ RCT_EXPORT_METHOD(alertWithArgs:(JS::NativeAlertManager::Args &)args
|
||||
}
|
||||
}
|
||||
|
||||
UIViewController *presentingController = RCTPresentedViewController();
|
||||
if (presentingController == nil) {
|
||||
RCTLogError(@"Tried to display alert view but there is no application window. args: %@", @{
|
||||
@"title": args.title() ?: [NSNull null],
|
||||
@"message": args.message() ?: [NSNull null],
|
||||
@"buttons": RCTConvertOptionalVecToArray(args.buttons(), ^id(id<NSObject> element) { return element; }) ?: [NSNull null],
|
||||
@"type": args.type() ?: [NSNull null],
|
||||
@"defaultValue": args.defaultValue() ?: [NSNull null],
|
||||
@"cancelButtonKey": args.cancelButtonKey() ?: [NSNull null],
|
||||
@"destructiveButtonKey": args.destructiveButtonKey() ?: [NSNull null],
|
||||
@"keyboardType": args.keyboardType() ?: [NSNull null],
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
UIAlertController *alertController = [UIAlertController
|
||||
alertControllerWithTitle:title
|
||||
message:nil
|
||||
@@ -180,23 +191,6 @@ RCT_EXPORT_METHOD(alertWithArgs:(JS::NativeAlertManager::Args &)args
|
||||
[_alertControllers addObject:alertController];
|
||||
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
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: %@", @{
|
||||
@"title": args.title() ?: [NSNull null],
|
||||
@"message": args.message() ?: [NSNull null],
|
||||
@"buttons": RCTConvertOptionalVecToArray(args.buttons(), ^id(id<NSObject> element) { return element; }) ?: [NSNull null],
|
||||
@"type": args.type() ?: [NSNull null],
|
||||
@"defaultValue": args.defaultValue() ?: [NSNull null],
|
||||
@"cancelButtonKey": args.cancelButtonKey() ?: [NSNull null],
|
||||
@"destructiveButtonKey": args.destructiveButtonKey() ?: [NSNull null],
|
||||
@"keyboardType": args.keyboardType() ?: [NSNull null],
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
[presentingController presentViewController:alertController animated:YES completion:nil];
|
||||
});
|
||||
}
|
||||
|
||||
@@ -241,7 +241,7 @@ RCT_EXPORT_MODULE()
|
||||
dismissViewControllerAnimated:YES
|
||||
completion:nil];
|
||||
}]];
|
||||
[RCTPresentedViewController(nil) presentViewController:alertController
|
||||
[RCTPresentedViewController() presentViewController:alertController
|
||||
animated:YES
|
||||
completion:NULL];
|
||||
}]];
|
||||
@@ -266,7 +266,7 @@ RCT_EXPORT_MODULE()
|
||||
[RCTInspectorDevServerHelper
|
||||
attachDebugger:@"ReactNative"
|
||||
withBundleURL:bridge.bundleURL
|
||||
withView:RCTPresentedViewController(nil)];
|
||||
withView:RCTPresentedViewController()];
|
||||
#endif
|
||||
}]];
|
||||
}
|
||||
@@ -313,7 +313,7 @@ RCT_EXPORT_MODULE()
|
||||
dismissViewControllerAnimated:YES
|
||||
completion:nil];
|
||||
}]];
|
||||
[RCTPresentedViewController(nil) presentViewController:alertController
|
||||
[RCTPresentedViewController() presentViewController:alertController
|
||||
animated:YES
|
||||
completion:NULL];
|
||||
} else {
|
||||
@@ -388,7 +388,7 @@ RCT_EXPORT_MODULE()
|
||||
handler:^(__unused UIAlertAction *action) {
|
||||
return;
|
||||
}]];
|
||||
[RCTPresentedViewController(nil) presentViewController:alertController animated:YES completion:NULL];
|
||||
[RCTPresentedViewController() presentViewController:alertController animated:YES completion:NULL];
|
||||
}]];
|
||||
|
||||
[items addObjectsFromArray:_extraMenuItems];
|
||||
@@ -425,7 +425,7 @@ RCT_EXPORT_METHOD(show)
|
||||
handler:[self alertActionHandlerForDevItem:nil]]];
|
||||
|
||||
_presentedItems = items;
|
||||
[RCTPresentedViewController(nil) presentViewController:_actionSheet animated:YES completion:nil];
|
||||
[RCTPresentedViewController() presentViewController:_actionSheet animated:YES completion:nil];
|
||||
|
||||
[_bridge enqueueJSCall:@"RCTNativeAppEventEmitter"
|
||||
method:@"emit"
|
||||
|
||||
@@ -329,7 +329,9 @@ RCT_EXPORT_MODULE()
|
||||
|
||||
[self updateStats];
|
||||
|
||||
[RCTKeyWindow() addSubview:self.container];
|
||||
UIWindow *window = RCTSharedApplication().delegate.window;
|
||||
[window addSubview:self.container];
|
||||
|
||||
|
||||
_uiDisplayLink = [CADisplayLink displayLinkWithTarget:self
|
||||
selector:@selector(threadUpdate:)];
|
||||
|
||||
@@ -8,10 +8,8 @@
|
||||
#import "RCTStatusBarManager.h"
|
||||
#import "CoreModulesPlugins.h"
|
||||
|
||||
#import <React/RCTBridge.h>
|
||||
#import <React/RCTEventDispatcher.h>
|
||||
#import <React/RCTLog.h>
|
||||
#import <React/RCTUIManager.h>
|
||||
#import <React/RCTUtils.h>
|
||||
|
||||
#if !TARGET_OS_TV
|
||||
@@ -151,50 +149,37 @@ RCT_EXPORT_METHOD(getHeight : (RCTResponseSenderBlock)callback)
|
||||
} ]);
|
||||
}
|
||||
|
||||
RCT_EXPORT_METHOD(setStyle:(NSString *)style
|
||||
animated:(BOOL)animated
|
||||
reactTag:(double)reactTag)
|
||||
RCT_EXPORT_METHOD(setStyle : (NSString *)style animated : (BOOL)animated)
|
||||
{
|
||||
UIStatusBarStyle statusBarStyle = [RCTConvert UIStatusBarStyle:style];
|
||||
if (RCTViewControllerBasedStatusBarAppearance()) {
|
||||
RCTLogError(@"RCTStatusBarManager module requires that the \
|
||||
UIViewControllerBasedStatusBarAppearance key in the Info.plist is set to NO");
|
||||
return;
|
||||
}
|
||||
|
||||
// TODO (T62270453): Add proper support for UIScenes (this requires view controller based status bar management)
|
||||
} else {
|
||||
#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:(NSString *)withAnimation
|
||||
reactTag:(double)reactTag)
|
||||
RCT_EXPORT_METHOD(setHidden : (BOOL)hidden withAnimation : (NSString *)withAnimation)
|
||||
{
|
||||
UIStatusBarAnimation animation = [RCTConvert UIStatusBarAnimation:withAnimation];
|
||||
if (RCTViewControllerBasedStatusBarAppearance()) {
|
||||
RCTLogError(@"RCTStatusBarManager module requires that the \
|
||||
UIViewControllerBasedStatusBarAppearance key in the Info.plist is set to NO");
|
||||
return;
|
||||
}
|
||||
|
||||
// TODO (T62270453): Add proper support for UIScenes (this requires view controller based status bar management)
|
||||
} else {
|
||||
#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
|
||||
}
|
||||
|
||||
- (facebook::react::ModuleConstants<JS::NativeStatusBarManagerIOS::Constants>)getConstants
|
||||
|
||||
@@ -401,9 +401,9 @@ void RCTProfileUnhookModules(RCTBridge *bridge)
|
||||
};
|
||||
RCTProfileControlsWindow.hidden = YES;
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
[RCTPresentedViewController(nil) presentViewController:activityViewController
|
||||
animated:YES
|
||||
completion:nil];
|
||||
[[[[RCTSharedApplication() delegate] window] rootViewController] presentViewController:activityViewController
|
||||
animated:YES
|
||||
completion:nil];
|
||||
});
|
||||
#endif
|
||||
});
|
||||
@@ -777,7 +777,7 @@ void RCTProfileSendResult(RCTBridge *bridge, NSString *route, NSData *data)
|
||||
[alertController addAction:[UIAlertAction actionWithTitle:@"OK"
|
||||
style:UIAlertActionStyleCancel
|
||||
handler:nil]];
|
||||
[RCTPresentedViewController(nil) presentViewController:alertController animated:YES completion:nil];
|
||||
[RCTPresentedViewController() presentViewController:alertController animated:YES completion:nil];
|
||||
});
|
||||
#endif
|
||||
}
|
||||
|
||||
+2
-2
@@ -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, double reactTag);
|
||||
public abstract void setHidden(boolean hidden, String withAnimation);
|
||||
|
||||
@ReactMethod
|
||||
public abstract void setStyle(@Nullable String statusBarStyle, boolean animated, double reactTag);
|
||||
public abstract void setStyle(@Nullable String statusBarStyle, boolean animated);
|
||||
|
||||
@ReactMethod
|
||||
public abstract void addListener(String eventType);
|
||||
|
||||
+4
-4
@@ -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;ZD)V", args, count);
|
||||
return static_cast<JavaTurboModule&>(turboModule).invokeJavaMethod(rt, VoidKind, "setStyle", "(Ljava/lang/String;Z)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;D)V", args, count);
|
||||
return static_cast<JavaTurboModule&>(turboModule).invokeJavaMethod(rt, VoidKind, "setHidden", "(ZLjava/lang/String;)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 {3, __hostFunction_NativeStatusBarManagerIOSSpecJSI_setStyle};
|
||||
methodMap_["setStyle"] = MethodMetadata {2, __hostFunction_NativeStatusBarManagerIOSSpecJSI_setStyle};
|
||||
|
||||
|
||||
methodMap_["setHidden"] = MethodMetadata {3, __hostFunction_NativeStatusBarManagerIOSSpecJSI_setHidden};
|
||||
methodMap_["setHidden"] = MethodMetadata {2, __hostFunction_NativeStatusBarManagerIOSSpecJSI_setHidden};
|
||||
|
||||
|
||||
methodMap_["getConstants"] = MethodMetadata {0, __hostFunction_NativeStatusBarManagerIOSSpecJSI_getConstants};
|
||||
|
||||
Reference in New Issue
Block a user