Skip to content

Commit c8d678a

Browse files
sherginfacebook-github-bot
authored andcommitted
Revert D21396409: Add possibility to disable buttons in action sheet ios
Differential Revision: D21396409 Original commit changeset: b3c3e4429651 fbshipit-source-id: 073bea94d96f0ebbb474c474c73e4e3f01f27b2e
1 parent 8ef0f1d commit c8d678a

File tree

5 files changed

+0
-64
lines changed

5 files changed

+0
-64
lines changed

Libraries/ActionSheetIOS/ActionSheetIOS.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ const ActionSheetIOS = {
3333
* - `destructiveButtonIndex` (int or array of ints) - index or indices of destructive buttons in `options`
3434
* - `title` (string) - a title to show above the action sheet
3535
* - `message` (string) - a message to show below the title
36-
* - `disabledButtonIndices` (array of numbers) - a list of button indices which should be disabled
3736
*
3837
* The 'callback' function takes one parameter, the zero-based index
3938
* of the selected item.
@@ -50,7 +49,6 @@ const ActionSheetIOS = {
5049
+anchor?: ?number,
5150
+tintColor?: ColorValue | ProcessedColorValue,
5251
+userInterfaceStyle?: string,
53-
+disabledButtonIndices?: Array<number>,
5452
|},
5553
callback: (buttonIndex: number) => void,
5654
) {

Libraries/ActionSheetIOS/NativeActionSheetManager.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ export interface Spec extends TurboModule {
2525
+anchor?: ?number,
2626
+tintColor?: ?number,
2727
+userInterfaceStyle?: ?string,
28-
+disabledButtonIndices?: Array<number>,
2928
|},
3029
callback: (buttonIndex: number) => void,
3130
) => void;

Libraries/FBReactNativeSpec/FBReactNativeSpec/FBReactNativeSpec.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,6 @@ namespace JS {
118118
folly::Optional<double> anchor() const;
119119
folly::Optional<double> tintColor() const;
120120
NSString *userInterfaceStyle() const;
121-
folly::Optional<facebook::react::LazyVector<double>> disabledButtonIndices() const;
122121

123122
SpecShowActionSheetWithOptionsOptions(NSDictionary *const v) : _v(v) {}
124123
private:
@@ -2942,11 +2941,6 @@ inline NSString *JS::NativeActionSheetManager::SpecShowActionSheetWithOptionsOpt
29422941
id const p = _v[@"userInterfaceStyle"];
29432942
return RCTBridgingToString(p);
29442943
}
2945-
inline folly::Optional<facebook::react::LazyVector<double>> JS::NativeActionSheetManager::SpecShowActionSheetWithOptionsOptions::disabledButtonIndices() const
2946-
{
2947-
id const p = _v[@"disabledButtonIndices"];
2948-
return RCTBridgingToOptionalVec(p, ^double(id itemValue_0) { return RCTBridgingToDouble(itemValue_0); });
2949-
}
29502944
inline NSString *JS::NativeActionSheetManager::SpecShowShareActionSheetWithOptionsOptions::message() const
29512945
{
29522946
id const p = _v[@"message"];

RNTester/js/examples/ActionSheetIOS/ActionSheetIOSExample.js

Lines changed: 0 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ const ScreenshotManager = NativeModules.ScreenshotManager;
2525
const BUTTONS = ['Option 0', 'Option 1', 'Option 2', 'Delete', 'Cancel'];
2626
const DESTRUCTIVE_INDEX = 3;
2727
const CANCEL_INDEX = 4;
28-
const DISABLED_BUTTON_INDICES = [1, 2];
2928

3029
type Props = $ReadOnly<{||}>;
3130
type State = {|clicked: string|};
@@ -139,37 +138,6 @@ class ActionSheetAnchorExample extends React.Component<
139138
};
140139
}
141140

142-
class ActionSheetDisabledExample extends React.Component<Props, State> {
143-
state = {
144-
clicked: 'none',
145-
};
146-
147-
render() {
148-
return (
149-
<View>
150-
<Text onPress={this.showActionSheet} style={style.button}>
151-
Click to show the ActionSheet
152-
</Text>
153-
<Text>Clicked button: {this.state.clicked}</Text>
154-
</View>
155-
);
156-
}
157-
158-
showActionSheet = () => {
159-
ActionSheetIOS.showActionSheetWithOptions(
160-
{
161-
options: BUTTONS,
162-
cancelButtonIndex: CANCEL_INDEX,
163-
destructiveButtonIndex: DESTRUCTIVE_INDEX,
164-
disabledButtonIndices: DISABLED_BUTTON_INDICES,
165-
},
166-
buttonIndex => {
167-
this.setState({clicked: BUTTONS[buttonIndex]});
168-
},
169-
);
170-
};
171-
}
172-
173141
class ShareActionSheetExample extends React.Component<
174142
$FlowFixMeProps,
175143
$FlowFixMeState,
@@ -347,12 +315,6 @@ exports.examples = [
347315
return <ActionSheetAnchorExample />;
348316
},
349317
},
350-
{
351-
title: 'Show Action Sheet with disabled buttons',
352-
render(): React.Element<any> {
353-
return <ActionSheetDisabledExample />;
354-
},
355-
},
356318
{
357319
title: 'Show Share Action Sheet',
358320
render(): React.Element<any> {

React/CoreModules/RCTActionSheetManager.mm

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -76,10 +76,6 @@ - (void)presentViewController:(UIViewController *)alertController
7676
NSInteger cancelButtonIndex =
7777
options.cancelButtonIndex() ? [RCTConvert NSInteger:@(*options.cancelButtonIndex())] : -1;
7878
NSArray<NSNumber *> *destructiveButtonIndices;
79-
NSArray<NSNumber *> *disabledButtonIndices =
80-
RCTConvertVecToArray(*options.disabledButtonIndices(), ^id(double element) {
81-
return @(element);
82-
});
8379
if (options.destructiveButtonIndices()) {
8480
destructiveButtonIndices = RCTConvertVecToArray(*options.destructiveButtonIndices(), ^id(double element) {
8581
return @(element);
@@ -102,7 +98,6 @@ - (void)presentViewController:(UIViewController *)alertController
10298
@"destructiveButtonIndices" : destructiveButtonIndices,
10399
@"anchor" : anchor,
104100
@"tintColor" : tintColor,
105-
@"disabledButtonIndices" : disabledButtonIndices,
106101
});
107102
return;
108103
}
@@ -137,18 +132,6 @@ - (void)presentViewController:(UIViewController *)alertController
137132
index++;
138133
}
139134

140-
for (NSNumber *disabledButtonIndex in disabledButtonIndices) {
141-
if ([disabledButtonIndex integerValue] < buttons.count) {
142-
[alertController.actions[[disabledButtonIndex integerValue]] setEnabled:false];
143-
} else {
144-
RCTLogError(
145-
@"Index %@ from `disabledButtonIndices` is out of bounds. Maximum index value is %@.",
146-
@([disabledButtonIndex integerValue]),
147-
@(buttons.count - 1));
148-
return;
149-
}
150-
}
151-
152135
alertController.view.tintColor = tintColor;
153136
#if defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && defined(__IPHONE_13_0) && \
154137
__IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_13_0

0 commit comments

Comments
 (0)