a native ios client for gitbay

client ios swift

https://gitbay.org

gitbay/Views/Repos/LoadStateOverlay.swift

ui-smoke
gitbay-ios/gitbay/Views/Repos/LoadStateOverlay.swift history · blame · raw

33 lines · 946 bytes

 1import SwiftUI
 2
 3/// The three non-content states of any screen, rendered consistently.
 4struct LoadStateOverlay<Value: Sendable>: View {
 5
 6    let state: LoadState<Value>
 7    /// Whether the underlying screen is showing nothing  a filter can
 8    /// empty a loaded list.
 9    var isEmpty = false
10
11    var body: some View {
12        switch state {
13        case .loading:
14            ProgressView()
15        case .empty(let message):
16            ContentUnavailableView {
17                Label("Nothing here", systemImage: "tray")
18            } description: {
19                Text(message)
20            }
21        case .failed(let message):
22            ContentUnavailableView {
23                Label("Could not load", systemImage: "wifi.exclamationmark")
24            } description: {
25                Text(message)
26            }
27        case .loaded:
28            if isEmpty {
29                ContentUnavailableView.search
30            }
31        }
32    }
33}