Skip to content

Commit

Permalink
Add progress view on background
Browse files Browse the repository at this point in the history
  • Loading branch information
aromanov91 committed Sep 10, 2022
1 parent 71c812c commit 6a46785
Showing 1 changed file with 36 additions and 14 deletions.
50 changes: 36 additions & 14 deletions Sources/OversizeUI/Controls/Loader/LoaderOverlayView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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<Bool> = .constant(true))
{
loaderType = type
Expand All @@ -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)
Expand Down Expand Up @@ -103,7 +126,6 @@ public struct LoaderOverlayView: View {
case .spiner:

ProgressView()
.scaleEffect(1.6, anchor: .center)
}
}

Expand Down

0 comments on commit 6a46785

Please sign in to comment.