File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -89,7 +89,7 @@ public struct QuickActionsItem<T>: Hashable where T: QuickActionType {
8989 public let icon : Icon ?
9090
9191 /// The quick action availability.
92- public let availability : Bool
92+ public let availability : ( ) -> Bool
9393
9494 // MARK: Lifecycle
9595 /// Construct a new `QuickActionsItem` with all the properties.
@@ -98,7 +98,7 @@ public struct QuickActionsItem<T>: Hashable where T: QuickActionType {
9898 title: String ,
9999 subtitle: String ? = nil ,
100100 icon: Icon ? = nil ,
101- availability: Bool = true
101+ availability: @escaping ( ) -> Bool = { true }
102102 ) {
103103 self . type = type
104104 self . title = title
@@ -107,9 +107,13 @@ public struct QuickActionsItem<T>: Hashable where T: QuickActionType {
107107 self . availability = availability
108108 }
109109
110- static public func == ( lhs: QuickActionsItem , rhs: QuickActionsItem ) -> Bool {
110+ public static func == ( lhs: QuickActionsItem < T > , rhs: QuickActionsItem < T > ) -> Bool {
111111 lhs. type == rhs. type
112112 }
113+
114+ public func hash( into hasher: inout Hasher ) {
115+ hasher. combine ( type)
116+ }
113117}
114118
115119extension QuickActionsItem {
@@ -139,3 +143,4 @@ extension QuickActionsItem {
139143 case template( String )
140144 }
141145}
146+
Original file line number Diff line number Diff line change @@ -19,7 +19,9 @@ final class MyQuickActions: QuickActions {
1919 title: " Create " ,
2020 subtitle: nil ,
2121 icon: . systemName( " plus " ) ,
22- availability: MyApplicationSingleton . current. isUserLogged
22+ availability: {
23+ MyApplicationSingleton . current. isUserLogged
24+ }
2325 )
2426 ]
2527 }
Original file line number Diff line number Diff line change @@ -3,7 +3,7 @@ import QuickActionsKit
33
44class SceneDelegate : UIResponder , UIWindowSceneDelegate {
55 // MARK: Properties
6- private let actions : QuickActionsManager = QuickActionsManager ( HMQuickActions ( ) )
6+ private var manager : QuickActionsManager < MyQuickActions , SceneDelegate > ?
77
88 // MARK: Lifecycle
99 func scene(
Original file line number Diff line number Diff line change @@ -3,7 +3,7 @@ import QuickActionsKit
33
44class SceneDelegate : UIResponder , UIWindowSceneDelegate {
55 // MARK: Properties
6- private let actions : QuickActionsManager = QuickActionsManager ( HMQuickActions ( ) )
6+ private var manager : QuickActionsManager < MyQuickActions , SceneDelegate > ?
77
88 // MARK: Lifecycle
99 func scene(
Original file line number Diff line number Diff line change @@ -13,7 +13,7 @@ enum QuickActionsMapper {
1313 static func map< T> (
1414 from item: QuickActionsItem < T >
1515 ) -> UIApplicationShortcutItem ? where T: QuickActionType {
16- guard item. availability else { return nil }
16+ guard item. availability ( ) else { return nil }
1717
1818 return UIApplicationShortcutItem (
1919 type: item. type. rawValue,
You can’t perform that action at this time.
0 commit comments