From c8d678abcf93fd3f6daf4bebfdf25937995c1fdf Mon Sep 17 00:00:00 2001 From: Valentin Shergin Date: Tue, 19 May 2020 16:34:13 -0700 Subject: [PATCH] Revert D21396409: Add possibility to disable buttons in action sheet ios Differential Revision: D21396409 Original commit changeset: b3c3e4429651 fbshipit-source-id: 073bea94d96f0ebbb474c474c73e4e3f01f27b2e --- Libraries/ActionSheetIOS/ActionSheetIOS.js | 2 - .../NativeActionSheetManager.js | 1 - .../FBReactNativeSpec/FBReactNativeSpec.h | 6 --- .../ActionSheetIOS/ActionSheetIOSExample.js | 38 ------------------- React/CoreModules/RCTActionSheetManager.mm | 17 --------- 5 files changed, 64 deletions(-) diff --git a/Libraries/ActionSheetIOS/ActionSheetIOS.js b/Libraries/ActionSheetIOS/ActionSheetIOS.js index 9852791cdf67a7..076ab004a56eb3 100644 --- a/Libraries/ActionSheetIOS/ActionSheetIOS.js +++ b/Libraries/ActionSheetIOS/ActionSheetIOS.js @@ -33,7 +33,6 @@ const ActionSheetIOS = { * - `destructiveButtonIndex` (int or array of ints) - index or indices of destructive buttons in `options` * - `title` (string) - a title to show above the action sheet * - `message` (string) - a message to show below the title - * - `disabledButtonIndices` (array of numbers) - a list of button indices which should be disabled * * The 'callback' function takes one parameter, the zero-based index * of the selected item. @@ -50,7 +49,6 @@ const ActionSheetIOS = { +anchor?: ?number, +tintColor?: ColorValue | ProcessedColorValue, +userInterfaceStyle?: string, - +disabledButtonIndices?: Array, |}, callback: (buttonIndex: number) => void, ) { diff --git a/Libraries/ActionSheetIOS/NativeActionSheetManager.js b/Libraries/ActionSheetIOS/NativeActionSheetManager.js index 6d86200d9accd6..063d9147e1d69b 100644 --- a/Libraries/ActionSheetIOS/NativeActionSheetManager.js +++ b/Libraries/ActionSheetIOS/NativeActionSheetManager.js @@ -25,7 +25,6 @@ export interface Spec extends TurboModule { +anchor?: ?number, +tintColor?: ?number, +userInterfaceStyle?: ?string, - +disabledButtonIndices?: Array, |}, callback: (buttonIndex: number) => void, ) => void; diff --git a/Libraries/FBReactNativeSpec/FBReactNativeSpec/FBReactNativeSpec.h b/Libraries/FBReactNativeSpec/FBReactNativeSpec/FBReactNativeSpec.h index 99c9b8871dda3d..8cd831f027231c 100644 --- a/Libraries/FBReactNativeSpec/FBReactNativeSpec/FBReactNativeSpec.h +++ b/Libraries/FBReactNativeSpec/FBReactNativeSpec/FBReactNativeSpec.h @@ -118,7 +118,6 @@ namespace JS { folly::Optional anchor() const; folly::Optional tintColor() const; NSString *userInterfaceStyle() const; - folly::Optional> disabledButtonIndices() const; SpecShowActionSheetWithOptionsOptions(NSDictionary *const v) : _v(v) {} private: @@ -2942,11 +2941,6 @@ inline NSString *JS::NativeActionSheetManager::SpecShowActionSheetWithOptionsOpt id const p = _v[@"userInterfaceStyle"]; return RCTBridgingToString(p); } -inline folly::Optional> JS::NativeActionSheetManager::SpecShowActionSheetWithOptionsOptions::disabledButtonIndices() const -{ - id const p = _v[@"disabledButtonIndices"]; - return RCTBridgingToOptionalVec(p, ^double(id itemValue_0) { return RCTBridgingToDouble(itemValue_0); }); -} inline NSString *JS::NativeActionSheetManager::SpecShowShareActionSheetWithOptionsOptions::message() const { id const p = _v[@"message"]; diff --git a/RNTester/js/examples/ActionSheetIOS/ActionSheetIOSExample.js b/RNTester/js/examples/ActionSheetIOS/ActionSheetIOSExample.js index a5ea2d79771d82..c1130357829df5 100644 --- a/RNTester/js/examples/ActionSheetIOS/ActionSheetIOSExample.js +++ b/RNTester/js/examples/ActionSheetIOS/ActionSheetIOSExample.js @@ -25,7 +25,6 @@ const ScreenshotManager = NativeModules.ScreenshotManager; const BUTTONS = ['Option 0', 'Option 1', 'Option 2', 'Delete', 'Cancel']; const DESTRUCTIVE_INDEX = 3; const CANCEL_INDEX = 4; -const DISABLED_BUTTON_INDICES = [1, 2]; type Props = $ReadOnly<{||}>; type State = {|clicked: string|}; @@ -139,37 +138,6 @@ class ActionSheetAnchorExample extends React.Component< }; } -class ActionSheetDisabledExample extends React.Component { - state = { - clicked: 'none', - }; - - render() { - return ( - - - Click to show the ActionSheet - - Clicked button: {this.state.clicked} - - ); - } - - showActionSheet = () => { - ActionSheetIOS.showActionSheetWithOptions( - { - options: BUTTONS, - cancelButtonIndex: CANCEL_INDEX, - destructiveButtonIndex: DESTRUCTIVE_INDEX, - disabledButtonIndices: DISABLED_BUTTON_INDICES, - }, - buttonIndex => { - this.setState({clicked: BUTTONS[buttonIndex]}); - }, - ); - }; -} - class ShareActionSheetExample extends React.Component< $FlowFixMeProps, $FlowFixMeState, @@ -347,12 +315,6 @@ exports.examples = [ return ; }, }, - { - title: 'Show Action Sheet with disabled buttons', - render(): React.Element { - return ; - }, - }, { title: 'Show Share Action Sheet', render(): React.Element { diff --git a/React/CoreModules/RCTActionSheetManager.mm b/React/CoreModules/RCTActionSheetManager.mm index a8199934eaf106..754e461157349d 100644 --- a/React/CoreModules/RCTActionSheetManager.mm +++ b/React/CoreModules/RCTActionSheetManager.mm @@ -76,10 +76,6 @@ - (void)presentViewController:(UIViewController *)alertController NSInteger cancelButtonIndex = options.cancelButtonIndex() ? [RCTConvert NSInteger:@(*options.cancelButtonIndex())] : -1; NSArray *destructiveButtonIndices; - NSArray *disabledButtonIndices = - RCTConvertVecToArray(*options.disabledButtonIndices(), ^id(double element) { - return @(element); - }); if (options.destructiveButtonIndices()) { destructiveButtonIndices = RCTConvertVecToArray(*options.destructiveButtonIndices(), ^id(double element) { return @(element); @@ -102,7 +98,6 @@ - (void)presentViewController:(UIViewController *)alertController @"destructiveButtonIndices" : destructiveButtonIndices, @"anchor" : anchor, @"tintColor" : tintColor, - @"disabledButtonIndices" : disabledButtonIndices, }); return; } @@ -137,18 +132,6 @@ - (void)presentViewController:(UIViewController *)alertController index++; } - for (NSNumber *disabledButtonIndex in disabledButtonIndices) { - if ([disabledButtonIndex integerValue] < buttons.count) { - [alertController.actions[[disabledButtonIndex integerValue]] setEnabled:false]; - } else { - RCTLogError( - @"Index %@ from `disabledButtonIndices` is out of bounds. Maximum index value is %@.", - @([disabledButtonIndex integerValue]), - @(buttons.count - 1)); - return; - } - } - alertController.view.tintColor = tintColor; #if defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && defined(__IPHONE_13_0) && \ __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_13_0