diff --git a/README.md b/README.md index 9ed992e..d3d3ba2 100644 --- a/README.md +++ b/README.md @@ -93,6 +93,7 @@ const shortcutItem = { shortTitle: "Do it", subtitle: "iOS only", iconName: "ic_awesome", + symbolName: "house.fill", // SF Symbol Name (iOS only) data: { "foo": "bar", }, @@ -125,7 +126,9 @@ const shortcutItems = await Shortcuts.getShortcuts(); To display icons with your shortcuts / actions you will need to add them to your project. Once added use the name of your iOS asset or Android drawable as the -value for `iconName` above. +value for `iconName` above. You can also use SF Symbol Name like "house.fill" +or `globe.europe.africa` for `symbolName` above (iOS only). If `symbolName` is +filled, `iconName` is not taken into account. ### iOS - Asset catalog @@ -134,7 +137,7 @@ Add new assets to your [Asset catalog](https://developer.apple.com/library/archi Refer [Custom Icons : Home Screen Quick Action Icon -Size](https://developer.apple.com/design/human-interface-guidelines/ios/icons-and-images/custom-icons/) +Size](https://developer.apple.com/design/human-interface-guidelines/home-screen-quick-actions) to learn about the dimensions and design specifications. ### Android - drawable diff --git a/ios/Shortcuts.swift b/ios/Shortcuts.swift index ad77cd9..0c5a85f 100644 --- a/ios/Shortcuts.swift +++ b/ios/Shortcuts.swift @@ -96,7 +96,7 @@ fileprivate extension UIApplicationShortcutItem { } let subtitle = value["subtitle"] as? String - let icon = UIApplicationShortcutIcon.from(value["iconName"] as? String) + let icon = UIApplicationShortcutIcon.from(value) let userInfo = value["data"] as? [String: NSSecureCoding] return UIApplicationShortcutItem( @@ -110,10 +110,13 @@ fileprivate extension UIApplicationShortcutItem { } fileprivate extension UIApplicationShortcutIcon { - static func from(_ imageName: String?) -> UIApplicationShortcutIcon? { - guard let imageName = imageName else { - return nil + static func from(_ value: [String: Any]) -> UIApplicationShortcutIcon? { + guard let symbolName = value["symbolName"] as? String else { + guard let imageName = value["iconName"] as? String else { + return nil + } + return UIApplicationShortcutIcon(templateImageName: imageName) } - return UIApplicationShortcutIcon(templateImageName: imageName) + return UIApplicationShortcutIcon(systemImageName: symbolName) } } diff --git a/src/index.tsx b/src/index.tsx index e0d0e46..8b7c21c 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -28,6 +28,11 @@ export interface ShortcutItem { */ iconName?: string; + /** + * The name of the iOS SF Symbol Name + */ + symbolName?: string; + /** * Custom payload for the action */