Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[RN] Add Patch to for RCTActionSheetManager.m to have possibility to disable buttons in ActionSheet #14062

Merged
merged 5 commits into from
May 22, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,9 @@ target 'WordPress' do
post_install do
puts 'Patching RCTShadowView to fix nested group block - it could be removed after upgrade to 0.62'
%x(patch Pods/React-Core/React/Views/RCTShadowView.m < patches/react-native+0.61.5.patch)

puts 'Patching RCTActionSheet to add possibility to disable action sheet buttons -
it could be removed once PR with that functionality will be merged into RN'
%x(patch Pods/React-RCTActionSheet/RCTActionSheetManager.m < patches/react-native+0.61.5.patch)

## Convert the 3rd-party license acknowledgements markdown into html for use in the app
require 'commonmarker'
Expand Down
2 changes: 1 addition & 1 deletion Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -725,6 +725,6 @@ SPEC CHECKSUMS:
ZendeskSupportSDK: a87ab1e4badace92c75eb11dc77ede1e995b2adc
ZIPFoundation: 249fa8890597086cd536bb2df5c9804d84e122b0

PODFILE CHECKSUM: 8ac727e03852bdec0c5bf5e901e73fc823a66725
PODFILE CHECKSUM: e130e9863883c1e89bb3c516322f0dfdb950b673

COCOAPODS: 1.8.4
23 changes: 23 additions & 0 deletions patches/react-native+0.61.5.patch
Original file line number Diff line number Diff line change
@@ -1,3 +1,26 @@
diff --git a/node_modules/react-native/Libraries/ActionSheetIOS/RCTActionSheetManager.m b/node_modules/react-native/Libraries/ActionSheetIOS/RCTActionSheetManager.m
index 65fa2bb..c5f265b 100644
--- a/node_modules/react-native/Libraries/ActionSheetIOS/RCTActionSheetManager.m
+++ b/node_modules/react-native/Libraries/ActionSheetIOS/RCTActionSheetManager.m
@@ -66,6 +66,7 @@ - (void)presentViewController:(UIViewController *)alertController
NSArray<NSString *> *buttons = [RCTConvert NSStringArray:options[@"options"]];
NSInteger cancelButtonIndex = options[@"cancelButtonIndex"] ? [RCTConvert NSInteger:options[@"cancelButtonIndex"]] : -1;
NSArray<NSNumber *> *destructiveButtonIndices;
+ NSArray<NSNumber *> *disabledButtonIndices = [RCTConvert NSArray:options[@"disabledButtonIndices"]];
if ([options[@"destructiveButtonIndex"] isKindOfClass:[NSArray class]]) {
destructiveButtonIndices = [RCTConvert NSArray:options[@"destructiveButtonIndex"]];
} else {
@@ -108,6 +109,10 @@ - (void)presentViewController:(UIViewController *)alertController
callback(@[@(localIndex)]);
}]];

+ if ([disabledButtonIndices containsObject:@(localIndex)]) {
+ [alertController.actions[localIndex] setEnabled:false];
+ }
+
index++;
}

diff --git a/node_modules/react-native/React/Views/RCTShadowView.m b/node_modules/react-native/React/Views/RCTShadowView.m
index 40c0cda..646f137 100644
--- a/node_modules/react-native/React/Views/RCTShadowView.m
Expand Down