47 lines
1.2 KiB
Swift
47 lines
1.2 KiB
Swift
//
|
|
// LoadingView.swift
|
|
// app
|
|
//
|
|
// Created by Sebastian Pobel on 20.12.19.
|
|
// Copyright © 2019 Marcus Handte. All rights reserved.
|
|
//
|
|
|
|
import SwiftUI
|
|
|
|
struct Loading<Content>: View where Content: View {
|
|
|
|
@Binding var isShowing: Bool
|
|
var infoText: LocalizedStringKey
|
|
|
|
var content: () -> Content
|
|
|
|
var body: some View {
|
|
ZStack(alignment: .center) {
|
|
self.content()
|
|
.disabled(self.isShowing)
|
|
.blur(radius: self.isShowing ? 3 : 0)
|
|
VStack {
|
|
Text(self.infoText)
|
|
ActivityIndicator(style: .large)
|
|
}
|
|
.frame(minWidth: 200, minHeight: 100, alignment: .center)
|
|
.background(Color.secondary.colorInvert())
|
|
.foregroundColor(Color.primary)
|
|
.cornerRadius(20)
|
|
.opacity(self.isShowing ? 1 : 0)
|
|
}
|
|
}
|
|
}
|
|
|
|
struct Loading_Previews: PreviewProvider {
|
|
static var previews: some View {
|
|
Loading(isShowing: .constant(true), infoText: "Loading...") {
|
|
VStack{
|
|
Text("Content")
|
|
.font(.title)
|
|
Spacer()
|
|
}
|
|
}
|
|
}
|
|
}
|