Fix: comments
Manage Alerts in one place!
Alert
View
isPresented
cancel
default
destructive
It only supprots SPM yet.
https://github.com/enebin/AlertState
After some setup, You can use AlertState like this:
AlertState
import SwiftUI import AlertState struct ContentView: View { // @State var alertState: SystemAlert? // or... @AlertState<SystemAlert> var alertState var body: some View { VStack(spacing: 30) { Button(action: { alertState = .warning }) { Text("Warning") } Button(action: { alertState = .errorHappend(/* SomeError */, dismissAction: { /* some dismiss action */ }) }) { Text("Error") } Button(action: { alertState = .retry(primaryAction: { /* some actions */ }, secondaryAction: { /* some actions */ }) }) { Text("Retry") } } .showAlert(with: $alertState) } }
For more informations, check the example projects.
©Copyright 2023 CCF 开源发展委员会 Powered by Trustie& IntelliDE 京ICP备13000930号
AlertState
Manage
Alert
s in one place!Overview
Features
Super easy to use
View
s. No needs to write extra variables likeisPresented
!Manage everything in one place
100% compatible with native features
cancel
,default
,destructive
) in the same way you did in SwiftUIRequirements
How to install
Swift Package Manager
It only supprots SPM yet.
Usage
After some setup, You can use
AlertState
like this:Example
For more informations, check the example projects.