[PR] Add subtitle support for menu items
Closed this issue ยท 1 comments
jacobp100 commented
Sorry for the format of this
I believe if you just save this as a .patch file, you can do git apply file.patch
Hi! ๐
Firstly, thanks for your work on this project! ๐
Today I used patch-package to patch react-native-context-menu-view@1.8.0
for the project I'm working on.
Here is the diff that solved my problem:
diff --git a/node_modules/react-native-context-menu-view/README.md b/node_modules/react-native-context-menu-view/README.md
index 7f0d745..cb89a5d 100644
--- a/node_modules/react-native-context-menu-view/README.md
+++ b/node_modules/react-native-context-menu-view/README.md
@@ -48,7 +48,9 @@ Optional. The title above the popup menu.
###### `actions`
-Array of `{ title: string, systemIcon?: string, destructive?: boolean, disabled?: boolean, inlineChildren?: boolean, actions?: Array<ContextMenuAction> }`.
+Array of `{ title: string, subtitle?: string, systemIcon?: string, destructive?: boolean, disabled?: boolean, inlineChildren?: boolean, actions?: Array<ContextMenuAction> }`.
+
+Subtitle is only available on iOS 15+.
System icon refers to an icon name within [SF Symbols](https://developer.apple.com/design/human-interface-guidelines/sf-symbols/overview/).
diff --git a/node_modules/react-native-context-menu-view/index.d.ts b/node_modules/react-native-context-menu-view/index.d.ts
index aa8c2ec..0bdab8a 100644
--- a/node_modules/react-native-context-menu-view/index.d.ts
+++ b/node_modules/react-native-context-menu-view/index.d.ts
@@ -6,6 +6,10 @@ export interface ContextMenuAction {
* The title of the action
*/
title: string;
+ /**
+ * The subtitle of the action. iOS 15+.
+ */
+ subtitletitle: string;
/**
* The icon to use on ios. This is the name of the SFSymbols icon to use. On Android nothing will happen if you set this option.
*/
diff --git a/node_modules/react-native-context-menu-view/ios/ContextMenuAction.h b/node_modules/react-native-context-menu-view/ios/ContextMenuAction.h
index 094a7ce..a0eba9e 100644
--- a/node_modules/react-native-context-menu-view/ios/ContextMenuAction.h
+++ b/node_modules/react-native-context-menu-view/ios/ContextMenuAction.h
@@ -11,6 +11,7 @@
@interface ContextMenuAction : NSObject
@property (nonnull, nonatomic, copy) NSString* title;
+@property (nonnull, nonatomic, copy) NSString* subtitle;
@property (nullable, nonatomic, copy) NSString* systemIcon;
@property (nonatomic, assign) BOOL destructive;
@property (nonatomic, assign) BOOL disabled;
diff --git a/node_modules/react-native-context-menu-view/ios/ContextMenuView.m b/node_modules/react-native-context-menu-view/ios/ContextMenuView.m
index b8fe1c7..1b1b6d5 100644
--- a/node_modules/react-native-context-menu-view/ios/ContextMenuView.m
+++ b/node_modules/react-native-context-menu-view/ios/ContextMenuView.m
@@ -132,6 +132,11 @@ - (UIMenuElement*) createMenuElementForAction:(ContextMenuAction *)action atInde
identifier:nil
options:actionMenuOptions
children:children];
+
+ if (@available(iOS 15.0, *)) {
+ actionMenu.subtitle = action.subtitle;
+ }
+
menuElement = actionMenu;
} else {
UIAction* actionMenuItem =
@@ -146,6 +151,10 @@ - (UIMenuElement*) createMenuElementForAction:(ContextMenuAction *)action atInde
}
}];
+ if (@available(iOS 15.0, *)) {
+ actionMenuItem.subtitle = action.subtitle;
+ }
+
actionMenuItem.attributes =
(action.destructive ? UIMenuElementAttributesDestructive : 0) |
(action.disabled ? UIMenuElementAttributesDisabled : 0);
diff --git a/node_modules/react-native-context-menu-view/ios/RCTConvert+ContextMenuAction.m b/node_modules/react-native-context-menu-view/ios/RCTConvert+ContextMenuAction.m
index c13666a..28b8c8c 100644
--- a/node_modules/react-native-context-menu-view/ios/RCTConvert+ContextMenuAction.m
+++ b/node_modules/react-native-context-menu-view/ios/RCTConvert+ContextMenuAction.m
@@ -14,6 +14,7 @@ + (ContextMenuAction*) ContextMenuAction:(id)json {
json = [self NSDictionary:json];
ContextMenuAction* action = [[ContextMenuAction alloc] init];
action.title = [self NSString:json[@"title"]];
+ action.subtitle = [self NSString:json[@"subtitle"]];
action.systemIcon = [self NSString:json[@"systemIcon"]];
action.destructive = [self BOOL:json[@"destructive"]];
action.disabled = [self BOOL:json[@"disabled"]];
This issue body was partially generated by patch-package.