Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add-symbol-name-for-ios #55

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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",
},
Expand Down Expand Up @@ -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

Expand All @@ -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
Expand Down
13 changes: 8 additions & 5 deletions ios/Shortcuts.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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)
}
}
5 changes: 5 additions & 0 deletions src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@ export interface ShortcutItem {
*/
iconName?: string;

/**
* The name of the iOS SF Symbol Name
*/
symbolName?: string;

/**
* Custom payload for the action
*/
Expand Down