All Projects → ricardopereira → Quickactions

ricardopereira / Quickactions

Licence: mit
Swift wrapper for iOS Home Screen Quick Actions (App Icon Shortcuts)

Programming Languages

swift
15916 projects

Projects that are alternatives of or similar to Quickactions

Macgesture
Global mouse gestures for macOS
Stars: ✭ 626 (+164.14%)
Mutual labels:  shortcuts
Xcactionbar
"Alfred for Xcode" plugin
Stars: ✭ 1,217 (+413.5%)
Mutual labels:  shortcuts
Njt
njt (npm jump to): a quick navigation tool for npm packages
Stars: ✭ 179 (-24.47%)
Mutual labels:  shortcuts
Gata
Bookmarks made better
Stars: ✭ 17 (-92.83%)
Mutual labels:  shortcuts
Manaflux
The app needs a rewrite. It might not work anymore. An assistant that can choose your runes, summoner spells, and item sets for League of Legends.
Stars: ✭ 57 (-75.95%)
Mutual labels:  shortcuts
Foundationextension
Foundation/Cocoa/UIKit extension kit. Reference document:
Stars: ✭ 115 (-51.48%)
Mutual labels:  shortcuts
Python Shortcuts
Create Siri Shortcuts with Python
Stars: ✭ 525 (+121.52%)
Mutual labels:  shortcuts
Icanhazshortcut
simple shortcut manager for macOS
Stars: ✭ 204 (-13.92%)
Mutual labels:  shortcuts
Shrtcts
Make Anything an RStudio Shortcut
Stars: ✭ 71 (-70.04%)
Mutual labels:  shortcuts
Hotkeys
🤖 A declarative library for handling hotkeys in Angular applications
Stars: ✭ 158 (-33.33%)
Mutual labels:  shortcuts
Better Chrome Native Video
Add keyboard support to Chrome's native HTML5 video player.
Stars: ✭ 31 (-86.92%)
Mutual labels:  shortcuts
Shortcuts
Super performant and feature rich shortcuts management library.
Stars: ✭ 40 (-83.12%)
Mutual labels:  shortcuts
Shortcuts Swift
Write Shortcuts in Playgrounds
Stars: ✭ 116 (-51.05%)
Mutual labels:  shortcuts
Shortcutmapper
A visual keyboard shortcuts explorer for popular applications.
Stars: ✭ 657 (+177.22%)
Mutual labels:  shortcuts
Hotkey
Trigger an action on an element with a keyboard shortcut.
Stars: ✭ 2,389 (+908.02%)
Mutual labels:  shortcuts
Hotkeys
➷ A robust Javascript library for capturing keyboard input. It has no dependencies.
Stars: ✭ 5,165 (+2079.32%)
Mutual labels:  shortcuts
Shortcuts Js
A JavaScript iOS 12 Shortcuts creator
Stars: ✭ 1,278 (+439.24%)
Mutual labels:  shortcuts
Devcomrade
DevComrade - A copy/paste/run productivity improvement utility for developers
Stars: ✭ 206 (-13.08%)
Mutual labels:  shortcuts
Inkscape Shortcut Manager
Inkscape shorcut manager
Stars: ✭ 200 (-15.61%)
Mutual labels:  shortcuts
Sketch Plugin Monster
A Sketch plugin for managing all plugin shortcuts.
Stars: ✭ 143 (-39.66%)
Mutual labels:  shortcuts

Carthage Compatible CocoaPods Compatible Swift 5.0 Platforms iOS License MIT

QuickActions

Swift wrapper for iOS Home Screen Quick Actions

This wrapper creates dynamic quick actions. It is possible to define static quick actions in your app’s Info.plist file but I think it is nicer to add localizable shortcuts dynamically and handle them with type safety.

Usage

import QuickActions

Define your application shortcuts with an enum. Don't forget to declare the enum with String and ShortcutType:

enum AppShortcut: String, ShortcutType {
    case createExpense
    case lastItems
}

Install a list of shortcuts:

var quickActions: QuickActions<AppShortcut>?

func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? = nil) -> Bool {
    let shortcuts = [Shortcut(type: AppShortcut.CreateExpense, title: NSLocalizedString("CreateExpenseTitle", comment: ""), subtitle: NSLocalizedString("CreateExpenseSubTitle", comment: ""), icon: .Add)]

    if let actionHandler = window?.rootViewController as? QuickActionSupport, bundleIdentifier = Bundle.main.bundleIdentifier {
        quickActions = QuickActions(application, actionHandler: actionHandler, bundleIdentifier: bundleIdentifier, shortcuts: shortcuts, launchOptions: launchOptions)
    }
}

Add more shortcuts:

func applicationDidEnterBackground(application: UIApplication) {
    let shortcuts = [Shortcut(type: AppShortcut.lastItems, title: "Last items", subtitle: nil, icon: nil)]
    quickActions?.add(shortcuts, toApplication: application)
}

Handle each shortcut:

@available(iOS 9, *)
func application(_ application: UIApplication, performActionFor shortcutItem: UIApplicationShortcutItem, completionHandler: @escaping (Bool) -> Swift.Void) {
    // This callback is used if your application is already launched in the background, if not application(_:,willFinishLaunchingWithOptions:) or application(_:didFinishLaunchingWithOptions) will be called (handle the shortcut in those callbacks and return `false`)
    guard let quickActions = quickActions else {
        return completionHandler(false)
    }
    guard let actionHandler = window?.rootViewController as? QuickActionSupport else {
        return completionHandler(false)
    }
    completionHandler(quickActions.handle(actionHandler, shortcutItem: shortcutItem))
}

Prepare your view controller using the QuickActionSupport protocol:

class MainViewController: UIViewController, QuickActionSupport {

    func prepareForQuickAction<T: ShortcutType>(_ shortcutType: T) {
        if let shortcut = AppShortcut(rawValue: shortcutType.value), case .createExpense = shortcut {
            print("Prepare the view to create a new expense")
        }

        //or

        if let shortcut = AppShortcut(rawValue: shortcutType.value) {
            switch shortcut {
            case .createExpense:
                print("Prepare the view to create a new expense")
            case .lastItems:
                print("Prepare the view to show last items")
            }
        }
    }    

}

Installation

Carthage

To install it, simply add the following line to your Cartfile:

github "ricardopereira/QuickActions" ~> 6.0.0

Then run carthage update.

Follow the current instructions in Carthage's README for up to date installation instructions.

CocoaPods

To install it, simply add the following line to your Podfile:

pod 'QuickActions' '~> 6.0.0'

You will also need to make sure you're opting into using frameworks:

use_frameworks!

Then run pod install with CocoaPods 1.8.0 or newer.

Manually

  1. Download and drop QuickActions.swift in your project.
  2. Congratulations!

Requirements

  • iOS 10.0+
  • Xcode 11.0 (Swift 5)

Author

Ricardo Pereira, @ricardopereiraw

License

QuickActions is available under the MIT license. See the LICENSE file for more info.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].