mirror of
https://github.com/bitwarden/ios.git
synced 2025-12-12 07:43:01 -06:00
23 lines
619 B
Swift
23 lines
619 B
Swift
import SwiftUI
|
|
|
|
// MARK: - LoadingView
|
|
|
|
/// A view that displays either a loading indicator or the content view for a set of loaded data.
|
|
struct LoadingView<T: Equatable, Contents: View>: View {
|
|
/// The state of this view.
|
|
var state: LoadingState<T>
|
|
|
|
/// A view builder for displaying the loaded contents of this view.
|
|
@ViewBuilder var contents: (T) -> Contents
|
|
|
|
var body: some View {
|
|
switch state {
|
|
case .loading:
|
|
ProgressView()
|
|
.frame(maxWidth: .infinity, maxHeight: .infinity)
|
|
case let .data(data):
|
|
contents(data)
|
|
}
|
|
}
|
|
}
|