WIP: loading

This commit is contained in:
Ryan Zhao 2023-09-21 15:46:56 +10:00
parent cff9367c99
commit b7940e52ae
2 changed files with 18 additions and 12 deletions

View File

@ -7,26 +7,25 @@ public struct ActivityIndicator: View {
public var body: some View {
GeometryReader { (geometry: GeometryProxy) in
ForEach(0..<5) { index in
Group {
Circle()
.frame(
width: geometry.size.width / 5,
height: geometry.size.height / 5
)
.scaleEffect(!self.isAnimating ? 1 - CGFloat(index) / 5 : 0.2 + CGFloat(index) / 5)
.offset(y: geometry.size.width / 10 - geometry.size.height / 2)
}
Circle()
.trim(from: 0, to: 0.9)
.stroke(
themeColor: .borderSeparator,
style: StrokeStyle(
lineWidth: 2,
lineCap: .round
)
)
.frame(
width: geometry.size.width,
height: geometry.size.height
)
.
.rotationEffect(!self.isAnimating ? .degrees(0) : .degrees(360))
.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)
)
}
}
.aspectRatio(1, contentMode: .fit)
.onAppear {

View File

@ -16,4 +16,11 @@ public extension Shape {
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
)
}
}