2024-06-19 15:15:27 +00:00
|
|
|
import Foundation
|
|
|
|
import SwiftUI
|
|
|
|
|
|
|
|
public extension View {
|
2024-08-11 00:28:01 +00:00
|
|
|
func loadingOverlay() -> some View {
|
|
|
|
modifier(LoadingOverlay())
|
2024-06-19 15:15:27 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-08-11 00:28:01 +00:00
|
|
|
struct LoadingOverlay: ViewModifier {
|
2024-06-19 15:15:27 +00:00
|
|
|
func body(content: Content) -> some View {
|
|
|
|
ZStack {
|
|
|
|
content
|
2024-08-11 00:28:01 +00:00
|
|
|
loadingView
|
2024-06-19 15:15:27 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private var loadingView: some View {
|
|
|
|
GeometryReader { proxyReader in
|
|
|
|
ZStack {
|
2024-07-04 08:21:12 +00:00
|
|
|
Color.Material.Elements.active.opacity(0.3)
|
2024-06-19 15:15:27 +00:00
|
|
|
.frame(maxWidth: .infinity, maxHeight: .infinity)
|
|
|
|
|
|
|
|
// loader
|
|
|
|
ProgressView()
|
|
|
|
.progressViewStyle(
|
2024-07-04 08:21:12 +00:00
|
|
|
CircularProgressViewStyle(tint: .Material.Elements.active)
|
2024-06-19 15:15:27 +00:00
|
|
|
)
|
|
|
|
.position(x: proxyReader.size.width / 2, y: proxyReader.size.height / 2)
|
|
|
|
.controlSize(.large)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
.ignoresSafeArea()
|
|
|
|
.transition(AnyTransition.opacity.animation(.easeInOut(duration: 0.1)))
|
|
|
|
}
|
|
|
|
}
|