Alerts is a μ-framework abstraction of modal contexts ("alerts"). The core library exposes the necessary data constructs for creating abstract alerts; the codebase also includes platform-specific functions for automatically producing resultant controls.
Cocoapods: pod 'Alerts', git: 'https://github.com/DuetHealth/Alerts.git'
. See Alerts.podspec for more information.
Carthage: github "DuetHealth/Alerts" ~> 2.0 && carthage update
Swift Package Manager: .package(url: "https://github.com/DuetHealth/Alerts.git", from: "2.0.0")
Alert is a struct designed to represent an alert not requiring any knowledge about how to display or present that alert. This allows the alert to be generated in ViewModels which conceivably could be reused on multiple platforms.
// SomeViewModel.swift
// Alerts take a series of actions:
import Alerts
let someAction = AlertAction.default(title: "Some Action") {
print("Some action was selected")
}
// Creating an Alert is similar to creating a UIAlertController:
let alert = Alert(title: "Hello", message: "This is a sample alert", textFields: [], actions: someAction, .cancel(title: "OK"))`
// SomeViewController.swift
// Alerts can be transformed into UIAlertControllers very simply:
import AlertsUI
alert.asController(style: .alert)
link |
Stars: 0 |
Last commit: 3 weeks ago |
Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics