Skip to content

Repository files navigation

License: MIT Swift

Alerts

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.

Usage

Installation

Swift Package Manager: .package(url: "https://github.com/DuetHealth/Alerts.git", from: "2.0.0")

Examples

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)

About

Simple Alerts for ViewModels

Resources

Stars

0 stars

Watchers

7 watching

Forks

Releases

Packages

Used by

Contributors

Languages