WIP: loading

pull/874/head
Ryan Zhao 2 years ago
parent cff9367c99
commit b7940e52ae

@ -7,27 +7,26 @@ public struct ActivityIndicator: View {
public var body: some View { public var body: some View {
GeometryReader { (geometry: GeometryProxy) in GeometryReader { (geometry: GeometryProxy) in
ForEach(0..<5) { index in
Group {
Circle() Circle()
.frame( .trim(from: 0, to: 0.9)
width: geometry.size.width / 5, .stroke(
height: geometry.size.height / 5 themeColor: .borderSeparator,
style: StrokeStyle(
lineWidth: 2,
lineCap: .round
)
) )
.scaleEffect(!self.isAnimating ? 1 - CGFloat(index) / 5 : 0.2 + CGFloat(index) / 5)
.offset(y: geometry.size.width / 10 - geometry.size.height / 2)
}
.frame( .frame(
width: geometry.size.width, width: geometry.size.width,
height: geometry.size.height height: geometry.size.height
) )
.
.rotationEffect(!self.isAnimating ? .degrees(0) : .degrees(360)) .rotationEffect(!self.isAnimating ? .degrees(0) : .degrees(360))
.animation(Animation .animation(Animation
.timingCurve(0.5, 0.15 + Double(index) / 5, 0.25, 1, duration: 1.5) .timingCurve(0.5, 1, 0.25, 1, duration: 1.5)
.repeatForever(autoreverses: false) .repeatForever(autoreverses: false)
) )
} }
}
.aspectRatio(1, contentMode: .fit) .aspectRatio(1, contentMode: .fit)
.onAppear { .onAppear {
self.isAnimating = true self.isAnimating = true

@ -16,4 +16,11 @@ public extension Shape {
ThemeManager.currentTheme.colorSwiftUI(for: themeColor) ?? Color.primary ThemeManager.currentTheme.colorSwiftUI(for: themeColor) ?? Color.primary
) )
} }
func stroke(themeColor: ThemeValue, style: StrokeStyle) -> some View {
return self.stroke(
ThemeManager.currentTheme.colorSwiftUI(for: themeColor) ?? Color.primary,
style: style
)
}
} }

Loading…
Cancel
Save