import SwiftUI /// The three non-content states of any screen, rendered consistently. struct LoadStateOverlay: View { let state: LoadState /// Whether the underlying screen is showing nothing — a filter can /// empty a loaded list. var isEmpty = false var body: some View { switch state { case .loading: ProgressView() case .empty(let message): ContentUnavailableView { Label("Nothing here", systemImage: "tray") } description: { Text(message) } case .failed(let message): ContentUnavailableView { Label("Could not load", systemImage: "wifi.exclamationmark") } description: { Text(message) } case .loaded: if isEmpty { ContentUnavailableView.search } } } }