Forji/Forji/Forji/Views/ErrorAlert.swift
Stefan Hausotte 5adc0102eb feat: inital commit
Forji is an iOS app to interact with a Forgejo instance
2026-02-28 21:08:13 +01:00

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))
}
}