mirror of
https://codeberg.org/secana/Forji.git
synced 2026-06-16 05:13:55 -07:00
22 lines
686 B
Swift
22 lines
686 B
Swift
import SwiftUI
|
|
|
|
struct ErrorAlertModifier: ViewModifier {
|
|
@Binding var errorMessage: String?
|
|
@Binding var isPresented: Bool
|
|
var title: String = "Error"
|
|
|
|
func body(content: Content) -> some View {
|
|
content
|
|
.alert(title, isPresented: $isPresented) {
|
|
Button("OK", role: .cancel) {}
|
|
} message: {
|
|
Text(errorMessage ?? "An unknown error occurred")
|
|
}
|
|
}
|
|
}
|
|
|
|
extension View {
|
|
func errorAlert(_ title: String = "Error", message: Binding<String?>, isPresented: Binding<Bool>) -> some View {
|
|
modifier(ErrorAlertModifier(errorMessage: message, isPresented: isPresented, title: title))
|
|
}
|
|
}
|