https://github.com/mshibanami/confirmation
Await-able native alert/sheet wrapper for iOS and macOS.
https://github.com/mshibanami/confirmation
appkit async-await ios macos swift uikit
Last synced: 4 months ago
JSON representation
Await-able native alert/sheet wrapper for iOS and macOS.
- Host: GitHub
- URL: https://github.com/mshibanami/confirmation
- Owner: mshibanami
- License: mit
- Created: 2022-09-02T23:46:45.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2025-04-07T07:32:40.000Z (about 1 year ago)
- Last Synced: 2025-11-21T14:16:07.660Z (7 months ago)
- Topics: appkit, async-await, ios, macos, swift, uikit
- Language: Swift
- Homepage:
- Size: 24.4 KB
- Stars: 4
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# 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
```swift
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
https://user-images.githubusercontent.com/1333214/188247963-c440cde4-77e4-4281-8162-c5c29adcb696.mov
### macOS
https://user-images.githubusercontent.com/1333214/188248181-6e7594ed-3d1d-4a8b-9d9e-29b3a47e9af1.mov
## Apps that use this package
- [Redirect Web for Safari](https://apps.apple.com/app/id1571283503)