Swiftpack.co - DuetHealth/Alerts as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by DuetHealth.
DuetHealth/Alerts 2.0.1
Simple Alerts for ViewModels
⭐️ 0
🕓 48 weeks ago
.package(url: "https://github.com/DuetHealth/Alerts.git", from: "2.0.1")

License: MIT Swift Package Manager Actions Status Actions Status


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)


  • As of now, the podspec is only configured for iOS.

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics