37 lines
1,014 B
Swift
37 lines
1,014 B
Swift
import Foundation
|
|
import SwiftUI
|
|
|
|
public extension View {
|
|
func loadingOverlay() -> some View {
|
|
modifier(LoadingOverlay())
|
|
}
|
|
}
|
|
|
|
struct LoadingOverlay: ViewModifier {
|
|
func body(content: Content) -> some View {
|
|
ZStack {
|
|
content
|
|
loadingView
|
|
}
|
|
}
|
|
|
|
private var loadingView: some View {
|
|
GeometryReader { proxyReader in
|
|
ZStack {
|
|
Color.Material.Elements.active.opacity(0.3)
|
|
.frame(maxWidth: .infinity, maxHeight: .infinity)
|
|
|
|
// loader
|
|
ProgressView()
|
|
.progressViewStyle(
|
|
CircularProgressViewStyle(tint: .Material.Elements.active)
|
|
)
|
|
.position(x: proxyReader.size.width / 2, y: proxyReader.size.height / 2)
|
|
.controlSize(.large)
|
|
}
|
|
}
|
|
.ignoresSafeArea()
|
|
.transition(AnyTransition.opacity.animation(.easeInOut(duration: 0.1)))
|
|
}
|
|
}
|