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.
版权所有:中国计算机学会技术支持:开源发展技术委员会 京ICP备13000930号-9 京公网安备 11010802032778号
AlertState
Manage
Alerts in one place!Overview
Features
Super easy to use
Views. 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
AlertStatelike this:Example
For more informations, check the example projects.