Skip to content

Commit ca7e043

Browse files
committed
covers iPad, extracts static inline util
1 parent 9b24809 commit ca7e043

File tree

1 file changed

+23
-10
lines changed

1 file changed

+23
-10
lines changed

packages/react-native/React/CoreModules/RCTActionSheetManager.mm

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,28 @@
2020

2121
using namespace facebook::react;
2222

23+
// With popover action sheet, cancel button disappears with style = UIAlertActionStyleCancel
24+
// Reverting to default style when:
25+
// - building with SDK 26+ AND running on iOS 26+ AND UIDesignRequiresCompatibility is disabled
26+
// - running on iPad
27+
static inline UIAlertActionStyle RCTActionStyleForCancelButton(void)
28+
{
29+
if (UIDevice.currentDevice.userInterfaceIdiom == UIUserInterfaceIdiomPad) {
30+
return UIAlertActionStyleDefault;
31+
}
32+
33+
#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 260000
34+
if (@available(iOS 26, *)) {
35+
if ([[[NSBundle mainBundle] objectForInfoDictionaryKey:@"UIDesignRequiresCompatibility"] boolValue]) {
36+
return UIAlertActionStyleCancel;
37+
}
38+
39+
return UIAlertActionStyleDefault;
40+
}
41+
#endif
42+
return UIAlertActionStyleCancel;
43+
}
44+
2345
@interface RCTActionSheetManager () <NativeActionSheetManagerSpec>
2446

2547
@property (nonatomic, strong) NSMutableArray<UIAlertController *> *alertControllers;
@@ -154,17 +176,8 @@ - (void)presentViewController:(UIViewController *)alertController
154176
if ([destructiveButtonIndices containsObject:@(index)]) {
155177
style = UIAlertActionStyleDestructive;
156178
} else if (index == cancelButtonIndex) {
157-
style = UIAlertActionStyleCancel;
179+
style = RCTActionStyleForCancelButton();
158180
isCancelButtonIndex = true;
159-
// With Liquid Glass Action Sheet, cancel button disappears with style = UIAlertActionStyleCancel
160-
// Reverting to default style when: building with SDK 26+ AND running on iOS 26+ AND UIDesignRequiresCompatibility is disabled
161-
#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 260000
162-
if (@available(iOS 26, *)) {
163-
if (![[[NSBundle mainBundle] objectForInfoDictionaryKey:@"UIDesignRequiresCompatibility"] boolValue]) {
164-
style = UIAlertActionStyleDefault;
165-
}
166-
}
167-
#endif
168181
}
169182

170183
NSInteger localIndex = index;

0 commit comments

Comments
 (0)