ricardopereira/QuickActions

Implement custom icon

Opened this issue · 4 comments

I'm currently implementing QuickActions with your framework. I want to set custom icons for the quick actions but I don't really know how exactly. In your source there's the following line:

if self == .custom {
            NSException(name: NSExceptionName(rawValue: "Invalid option"), reason: "`Custom` type need to be used with `toApplicationShortcutIcon:imageName`", userInfo: nil).raise()
            return nil
        }

To build the shortcuts my code looks like in your example:

let shortcuts = [
            Shortcut(
                type: AppShortcut.createExpense,
                title: NSLocalizedString("CreateExpenseTitle", comment: ""),
                subtitle: NSLocalizedString("CreateExpenseSubTitle", comment: ""),
                icon: .add
            )
        ]

There's this function:

func toApplicationShortcutIcon(_ imageName: String) -> UIApplicationShortcutIcon?

But I don't really know how to call this function or is there another way? Can someone give me an advice how to implement a custom icon?

@Yetispapa Unfortunately, a custom icon isn't available with the latest version.

I want to implement it like icon: .custom(imageName: "my-icon") but it's not ready. Sorry.

Ok. Thanks for your quick answer. When do think is the feature ready?

Any word on this?

@neoighodaro Sorry, I didn't have the time to implement that. Feel free to open a PR for it. Thanks