payfrit-works-ios/PayfritWorks/Views/Components/ErrorView.swift
Schwifty 1c427a0902 feat: add reusable ErrorView and LoadingView components
Extract duplicated inline error/loading patterns from TaskListScreen,
MyTasksScreen, BusinessSelectionScreen, AccountScreen, and TaskDetailScreen
into shared components under Views/Components/.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-24 22:15:03 +00:00

34 lines
936 B
Swift

import SwiftUI
/// Reusable error state view with icon, message, and optional retry button.
/// Replaces inline error patterns across all screens.
struct ErrorView: View {
let message: String
var onRetry: (() -> Void)?
var body: some View {
VStack(spacing: 16) {
Image(systemName: "exclamationmark.circle")
.font(.system(size: 48))
.foregroundColor(.red)
Text(message)
.multilineTextAlignment(.center)
.foregroundColor(.primary)
if let onRetry = onRetry {
Button("Retry", action: onRetry)
.buttonStyle(.borderedProminent)
}
}
.padding()
}
}
#Preview("With Retry") {
ErrorView(message: "Something went wrong. Please try again.") {
print("Retry tapped")
}
}
#Preview("No Retry") {
ErrorView(message: "Could not load data.")
}