36

GitHub - a2/shortcuts-swift: Write Shortcuts in Playgrounds

 5 years ago
source link: https://github.com/a2/shortcuts-swift
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

README.md

Banner

Shortcuts Swift

Build Status

Subscription feed link or click here on your iPad with Swift Playgrounds 2 installed.

Example

Warn for Low Battery Level

var batteryLevel = Variable.actionOutput()
let shortcut = buildShortcut(
    comment("This Shortcut was generated in Swift.") +
    getBatteryLevel.savingOutput(to: &batteryLevel) +
    ifLessThan(20, ifTrue: (
        setLowPowerMode(true) +
        showResult("Your battery is at \(batteryLevel)%, you might want to charge it.")
    ), ifFalse: (
        showResult("Your battery is at \(batteryLevel)%, you're probably fine for now.")
    ))
)

Clap Along

let shortcut = buildShortcut(
    comment("This Shortcut was generated in Swift.") +
    ask(question: "WHAT ? DO ? YOU ? WANT ? TO ? SAY") +
    changeCase(to: .uppercase) +
    replaceText("[\\s]", replaceWith: " ? ", regularExpression: true) +
    chooseFromMenu(items: [
        ("Share", share()),
        ("Copy to Clipboard", copyToClipboard()),
    ])
)

Contributing

Please read the Contributions Guide and the Code of Conduct before getting started. You will need Xcode 10 or newer to build the project.

Authors

Alexsander Akers and Alexis Aubry

License

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


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK