|
@@ -17,13 +17,38 @@
|
|
|
import SwiftUI
|
|
|
|
|
|
struct BusyIndicator: View {
|
|
|
+ @Binding var progress: Float?
|
|
|
+
|
|
|
+ init(progress: Binding<Float?> = .constant(nil)) {
|
|
|
+ _progress = progress
|
|
|
+ }
|
|
|
+
|
|
|
var body: some View {
|
|
|
- Spinner(size: .large)
|
|
|
+ progressView
|
|
|
.frame(width: 100, height: 100, alignment: .center)
|
|
|
.foregroundColor(.white)
|
|
|
.background(Color.gray.opacity(0.5))
|
|
|
.clipShape(RoundedRectangle(cornerRadius: 25.0, style: .continuous))
|
|
|
}
|
|
|
+
|
|
|
+ #if os(macOS)
|
|
|
+ @ViewBuilder
|
|
|
+ private var progressView: some View {
|
|
|
+ if let progress = progress {
|
|
|
+ ProgressView(value: progress)
|
|
|
+ .progressViewStyle(.circular)
|
|
|
+ .controlSize(.large)
|
|
|
+ } else {
|
|
|
+ Spinner(size: .large)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ #else
|
|
|
+ // TODO: implement progress spinner for iOS
|
|
|
+ @ViewBuilder
|
|
|
+ private var progressView: some View {
|
|
|
+ Spinner(size: .large)
|
|
|
+ }
|
|
|
+ #endif
|
|
|
}
|
|
|
|
|
|
struct BusyIndicator_Previews: PreviewProvider {
|