Skip to content

Await-able native alert/sheet wrapper for iOS and macOS.

License

Notifications You must be signed in to change notification settings

mshibanami/Confirmation

Repository files navigation

Confirmation

This is an alert/sheet library for iOS and macOS, which internally use the native APIs as follows:

  • iOS: UIAlertController of UIKit
  • macOS: NSAlert of AppKit

This wrapper supports async/await so you can write a sequential flow easier.

Sample Code

let selectedAction = await Confirmation.show(
    title: "Title",
    description: "Description",
    actions: [
        .default(title: "Default"),
        .default(title: "Default (Preferred)", isPreferred: true),
        .destructive(title: "Destructive"),
        .cancel()
    ],
    style: .alert()) // .alert() can also take UIViewController or NSWindow

switch selectedAction {
case .cancel:
    print("Canceled")
case .destructive(title: let title, _):
    print("\"\(title)\" has been selected.")
case .default(title: let title, _):
    print("\"\(title)\" has been selected.")
case .none:
    break
}

Open Example/ in Xcode for more details.

Demo

iOS

Screen.Recording.2022-09-03.at.10.07.59.am.mov

macOS

Screen.Recording.2022-09-03.at.10.12.51.am.mov

Apps that use this package

About

Await-able native alert/sheet wrapper for iOS and macOS.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages