@@ -9,38 +9,45 @@ import UIKit;
99
1010@available ( iOS 13 . 0 , * )
1111class RCTMenuAction {
12-
12+
1313 var identifier : UIAction . Identifier ? ;
1414 var title : String ;
1515 var subtitle : String ?
16+ var displayInline : Bool
1617 var image : UIImage ?
1718 var attributes : UIAction . Attributes = [ ]
1819 var state : UIAction . State = . off
1920 var subactions : [ RCTMenuAction ] = [ ]
20-
21+
2122 init ( details: NSDictionary ) {
22-
23+
2324 if let identifier = details [ " id " ] as? NSString {
2425 self . identifier = UIAction . Identifier ( rawValue: identifier as String ) ;
2526 }
26-
27+
2728 if let image = details [ " image " ] as? NSString {
2829 self . image = UIImage ( systemName: image as String ) ;
2930 if let imageColor = details [ " imageColor " ] {
3031 self . image = self . image? . withTintColor ( RCTConvert . uiColor ( imageColor) , renderingMode: . alwaysOriginal)
3132 }
3233 }
33-
34+
3435 if let title = details [ " title " ] as? NSString {
3536 self . title = title as String ;
3637 } else {
3738 self . title = " " ;
3839 }
39-
40+
4041 if let subtitle = details [ " subtitle " ] as? NSString {
4142 self . subtitle = subtitle as String ;
4243 }
43-
44+
45+ if let displayInline = details [ " displayInline " ] as? Bool {
46+ self . displayInline = displayInline as Bool ;
47+ } else {
48+ self . displayInline = false ;
49+ }
50+
4451 if let attributes = details [ " attributes " ] as? NSDictionary {
4552 if ( attributes [ " destructive " ] as? Bool ) == true {
4653 self . attributes. update ( with: . destructive)
@@ -52,7 +59,7 @@ class RCTMenuAction {
5259 self . attributes. update ( with: . hidden)
5360 }
5461 }
55-
62+
5663 if let state = details [ " state " ] as? NSString {
5764 if state== " on " {
5865 self . state = . on
@@ -64,25 +71,29 @@ class RCTMenuAction {
6471 self . state = . mixed
6572 }
6673 }
67-
74+
6875 if let subactions = details [ " subactions " ] as? NSArray {
6976 if subactions. count > 0 {
7077 for subaction in subactions {
7178 self . subactions. append ( RCTMenuAction ( details: subaction as! NSDictionary ) )
7279 }
7380 }
7481 }
75-
76-
82+
83+
7784 }
78-
85+
7986 func createUIMenuElement( _ handler: @escaping UIActionHandler ) -> UIMenuElement {
8087 if subactions. count > 0 {
8188 var subMenuActions : [ UIMenuElement ] = [ ]
8289 subactions. forEach { subaction in
8390 subMenuActions. append ( subaction. createUIMenuElement ( handler) )
8491 }
85- return UIMenu ( title: title, image: image, identifier: nil , children: subMenuActions)
92+ if self . displayInline {
93+ return UIMenu ( title: title, image: image, options: . displayInline, children: subMenuActions)
94+ } else {
95+ return UIMenu ( title: title, image: image, children: subMenuActions)
96+ }
8697 }
8798 return UIAction ( title: title, image: image, identifier: identifier, discoverabilityTitle: subtitle, attributes: attributes, state: state, handler: handler)
8899 }
0 commit comments