Skip to content

[quick_actions_ios] Support SF Symbols #170520

Open
@Maatteogekko

Description

@Maatteogekko

Use case

Native iOS quick actions allow the use of an SF Symbol as an icon. Right now this is not possible with the quick_actions package.

Proposal

I think something like this react-native package is doing could be good.

The following is what I am using in my app right now.

--- a/packages/quick_actions/quick_actions_ios/ios/quick_actions_ios/Sources/quick_actions_ios/QuickActionsPlugin.swift
+++ b/packages/quick_actions/quick_actions_ios/ios/quick_actions_ios/Sources/quick_actions_ios/QuickActionsPlugin.swift
@@ -90,8 +90,13 @@ public final class QuickActionsPlugin: NSObject, FlutterPlugin, IOSQuickActionsA
     -> UIApplicationShortcutItem?
   {
 
-    let icon = (shortcut.icon).map {
-      UIApplicationShortcutIcon(templateImageName: $0)
+    let icon = (shortcut.icon).map { iconName in
+      if iconName.hasPrefix("symbol:") {
+        let systemImageName = String(iconName.dropFirst("symbol:".count))
+        return UIApplicationShortcutIcon(systemImageName: systemImageName)
+      } else {
+        return UIApplicationShortcutIcon(templateImageName: iconName)
+      }
     }
 
     // type and localizedTitle are required.

This is how it would be used on the dart side:

ShortcutItem(
    type: 'scan',
    localizedTitle: 'Scan',
    icon: 'symbol:qrcode',
),

Metadata

Metadata

Assignees

No one assigned

    Labels

    c: new featureNothing broken; request for a new capabilityc: proposalA detailed proposal for a change to Flutterp: quick_actionsQuickActions pluginpackageflutter/packages repository. See also p: labels.platform-iosiOS applications specificallyteam-ecosystemOwned by Ecosystem team

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions