|
4 | 4 | #import "RNSDefines.h" |
5 | 5 | #import "RNSImageLoadingHelper.h" |
6 | 6 |
|
| 7 | +static UIMenuOptions RNSMakeUIMenuOptionsFromConfig(NSDictionary *config); |
| 8 | + |
7 | 9 | @implementation RNSBarButtonItem { |
8 | 10 | NSString *_buttonId; |
9 | 11 | RNSBarButtonItemAction _itemAction; |
@@ -160,10 +162,11 @@ + (UIMenu *)initUIMenuWithDict:(NSDictionary<NSString *, id> *)dict menuAction:( |
160 | 162 | } |
161 | 163 | NSString *title = dict[@"title"]; |
162 | 164 | NSString *sfSymbolName = dict[@"sfSymbolName"]; |
| 165 | + |
163 | 166 | return [UIMenu menuWithTitle:title |
164 | 167 | image:sfSymbolName ? [UIImage systemImageNamed:sfSymbolName] : nil |
165 | 168 | identifier:nil |
166 | | - options:0 |
| 169 | + options:RNSMakeUIMenuOptionsFromConfig(dict) |
167 | 170 | children:elements]; |
168 | 171 | } |
169 | 172 |
|
@@ -223,6 +226,11 @@ + (UIAction *)createActionItemFromConfig:(NSDictionary *)dict menuAction:(RNSBar |
223 | 226 | #endif |
224 | 227 | } |
225 | 228 |
|
| 229 | + NSString *subtitle = dict[@"subtitle"]; |
| 230 | + if (subtitle != nil) { |
| 231 | + actionElement.subtitle = subtitle; |
| 232 | + } |
| 233 | + |
226 | 234 | return actionElement; |
227 | 235 | } |
228 | 236 |
|
@@ -323,3 +331,30 @@ - (void)setBadgeFromConfig:(NSDictionary *)badgeObj |
323 | 331 | #endif |
324 | 332 |
|
325 | 333 | @end |
| 334 | + |
| 335 | +UIMenuOptions RNSMakeUIMenuOptionsFromConfig(NSDictionary *config) |
| 336 | +{ |
| 337 | + UIMenuOptions options = 0; |
| 338 | + NSNumber *singleSelection = config[@"singleSelection"]; |
| 339 | + NSNumber *displayAsPalette = config[@"displayAsPalette"]; |
| 340 | + NSNumber *displayInline = config[@"displayInline"]; |
| 341 | + NSNumber *destructive = config[@"destructive"]; |
| 342 | + |
| 343 | + if (singleSelection != nil && [singleSelection boolValue]) { |
| 344 | + options |= UIMenuOptionsSingleSelection; |
| 345 | + } |
| 346 | +#if RNS_IPHONE_OS_VERSION_AVAILABLE(17_0) |
| 347 | + if (@available(iOS 17.0, *)) { |
| 348 | + if (displayAsPalette != nil && [displayAsPalette boolValue]) { |
| 349 | + options |= UIMenuOptionsDisplayAsPalette; |
| 350 | + } |
| 351 | + } |
| 352 | +#endif // RNS_IPHONE_OS_VERSION_AVAILABLE(17_0) |
| 353 | + if (displayInline != nil && [displayInline boolValue]) { |
| 354 | + options |= UIMenuOptionsDisplayInline; |
| 355 | + } |
| 356 | + if (destructive != nil && [destructive boolValue]) { |
| 357 | + options |= UIMenuOptionsDestructive; |
| 358 | + } |
| 359 | + return options; |
| 360 | +} |
0 commit comments