|
20 | 20 |
|
21 | 21 | using namespace facebook::react; |
22 | 22 |
|
| 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 | + |
23 | 45 | @interface RCTActionSheetManager () <NativeActionSheetManagerSpec> |
24 | 46 |
|
25 | 47 | @property (nonatomic, strong) NSMutableArray<UIAlertController *> *alertControllers; |
@@ -154,17 +176,8 @@ - (void)presentViewController:(UIViewController *)alertController |
154 | 176 | if ([destructiveButtonIndices containsObject:@(index)]) { |
155 | 177 | style = UIAlertActionStyleDestructive; |
156 | 178 | } else if (index == cancelButtonIndex) { |
157 | | - style = UIAlertActionStyleCancel; |
| 179 | + style = RCTActionStyleForCancelButton(); |
158 | 180 | 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 |
168 | 181 | } |
169 | 182 |
|
170 | 183 | NSInteger localIndex = index; |
|
0 commit comments