From 6a4678570d4e03081f48c28215b51ac98d453b3b Mon Sep 17 00:00:00 2001 From: Alexandr Romanov Date: Sat, 10 Sep 2022 22:43:49 +0300 Subject: [PATCH] Add progress view on background --- .../Controls/Loader/LoaderOverlayView.swift | 50 +++++++++++++------ 1 file changed, 36 insertions(+), 14 deletions(-) diff --git a/Sources/OversizeUI/Controls/Loader/LoaderOverlayView.swift b/Sources/OversizeUI/Controls/Loader/LoaderOverlayView.swift index 12bf9c1..ca93368 100644 --- a/Sources/OversizeUI/Controls/Loader/LoaderOverlayView.swift +++ b/Sources/OversizeUI/Controls/Loader/LoaderOverlayView.swift @@ -25,14 +25,14 @@ public struct LoaderOverlayView: View { loaderType = type showText = false text = "" - surface = true + surface = false _isLoading = isLoading } public init(type: LoaderOverlayType = .spiner, showText: Bool = false, text: String = "", - surface: Bool = true, + surface: Bool = false, isLoading: Binding = .constant(true)) { loaderType = type @@ -50,20 +50,43 @@ public struct LoaderOverlayView: View { Color.surfaceSecondary.opacity(0.5) #endif - Surface { - VStack(spacing: 20) { - containedView() - - if showText { - Text(text.isEmpty ? "Loading" : text) - .fontStyle(.headline, color: .onSurfaceDisabled) - .offset(y: 8) + VStack { + Spacer() + + if surface { + Surface { + VStack(spacing: 20) { + containedView() + + if showText { + Text(text.isEmpty ? "Loading" : text) + .fontStyle(.headline, color: .onSurfaceDisabled) + .offset(y: 8) + } + } + .padding() + } + .surfaceStyle(.primary) + .elevation(.z4) + } else { + VStack(spacing: 20) { + containedView() + + if showText { + Text(text.isEmpty ? "Loading" : text) + .fontStyle(.headline, color: .onSurfaceDisabled) + .offset(y: 8) + } + } + .padding() + .background { + Capsule() + .fillSurfaceSecondary() } } - .padding() + + Spacer() } - .surfaceStyle(.primary) - .elevation(.z4) } .ignoresSafeArea() .opacity(isLoading ? 1 : 0) @@ -103,7 +126,6 @@ public struct LoaderOverlayView: View { case .spiner: ProgressView() - .scaleEffect(1.6, anchor: .center) } }