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