@@ -36,7 +36,7 @@ public struct RotatingCircleWithGap: View {
36
36
private struct LoadingCircle : View {
37
37
let circleColor : Color
38
38
let scale : CGFloat
39
- private let circleWidth : CGFloat = 8
39
+ let circleWidth : CGFloat
40
40
41
41
var body : some View {
42
42
Circle ( )
@@ -47,6 +47,7 @@ private struct LoadingCircle: View {
47
47
}
48
48
49
49
public struct LoadingFlowerView : View {
50
+
50
51
private let animationDuration : Double = 0.6
51
52
private var singleCircleAnimationDuration : Double {
52
53
return animationDuration/ 3
@@ -56,37 +57,58 @@ public struct LoadingFlowerView: View {
56
57
. repeatForever ( autoreverses: true )
57
58
}
58
59
59
- @State private var color : Color = . init( white: 0.3 )
60
- @State private var scale : CGFloat = 0.98
60
+ private let originalColor : Color
61
+ public init ( color: Color = . white) {
62
+ self . originalColor = color
63
+ self . color = color. opacity ( 0.3 )
64
+ }
61
65
62
- public init ( ) { }
66
+ @State private var color = Color . white. opacity ( 0.3 )
67
+ @State private var scale : CGFloat = 0.98
63
68
64
69
public var body : some View {
65
- HStack ( spacing: 1 ) {
66
- VStack ( spacing: 2 ) {
67
- LoadingCircle ( circleColor: color, scale: scale)
68
- . animation ( foreverAnimation. delay ( singleCircleAnimationDuration*5) )
69
- LoadingCircle ( circleColor: color, scale: scale)
70
- . animation ( foreverAnimation. delay ( singleCircleAnimationDuration*4) )
71
- }
72
- VStack ( alignment: . center, spacing: 1 ) {
73
- LoadingCircle ( circleColor: color, scale: scale)
74
- . animation ( foreverAnimation)
75
- LoadingCircle ( circleColor: . clear, scale: 1 )
76
- LoadingCircle ( circleColor: color, scale: scale)
77
- . animation ( foreverAnimation. delay ( singleCircleAnimationDuration*3) )
78
- }
79
- VStack ( alignment: . center, spacing: 2 ) {
80
- LoadingCircle ( circleColor: color, scale: scale)
81
- . animation ( foreverAnimation. delay ( singleCircleAnimationDuration*1) )
82
- LoadingCircle ( circleColor: color, scale: scale)
83
- . animation ( foreverAnimation. delay ( singleCircleAnimationDuration*2) )
84
- }
70
+ GeometryReader { [ color, scale, singleCircleAnimationDuration, foreverAnimation] reader -> AnyView in
71
+
72
+ let minLength = min ( reader. size. width, reader. size. height)
73
+ let thirdOfMinLength = minLength / 3
74
+
75
+ let proportionalSpacing : CGFloat = 1 / 26
76
+ let spacing = minLength * proportionalSpacing
77
+
78
+ // THIS IS FINE :D
79
+ // Fix later, ok?
80
+ let leafDiameter = thirdOfMinLength - ( spacing - proportionalSpacing * thirdOfMinLength)
81
+
82
+ return AnyView (
83
+ HStack ( spacing: spacing) {
84
+ VStack ( spacing: spacing) {
85
+ LoadingCircle ( circleColor: color, scale: scale, circleWidth: leafDiameter)
86
+ . animation ( foreverAnimation. delay ( singleCircleAnimationDuration*5) )
87
+ LoadingCircle ( circleColor: color, scale: scale, circleWidth: leafDiameter)
88
+ . animation ( foreverAnimation. delay ( singleCircleAnimationDuration*4) )
89
+ }
90
+ VStack ( alignment: . center, spacing: spacing) {
91
+ LoadingCircle ( circleColor: color, scale: scale, circleWidth: leafDiameter)
92
+ . animation ( foreverAnimation)
93
+ LoadingCircle ( circleColor: . clear, scale: 1 , circleWidth: leafDiameter)
94
+ LoadingCircle ( circleColor: color, scale: scale, circleWidth: leafDiameter)
95
+ . animation ( foreverAnimation. delay ( singleCircleAnimationDuration*3) )
96
+ }
97
+ VStack ( alignment: . center, spacing: spacing) {
98
+ LoadingCircle ( circleColor: color, scale: scale, circleWidth: leafDiameter)
99
+ . animation ( foreverAnimation. delay ( singleCircleAnimationDuration*1) )
100
+ LoadingCircle ( circleColor: color, scale: scale, circleWidth: leafDiameter)
101
+ . animation ( foreverAnimation. delay ( singleCircleAnimationDuration*2) )
102
+ }
103
+ }
104
+ )
85
105
}
86
106
. onAppear {
87
- self . color = . white
88
- self . scale = 1.02
107
+ self . color = self . originalColor
108
+ self . scale = 1
89
109
}
110
+ . aspectRatio ( contentMode: . fit)
111
+ . frame ( idealWidth: 26 )
90
112
}
91
113
}
92
114
@@ -198,7 +220,6 @@ public struct StretchProgressView: View {
198
220
199
221
public var body : some View {
200
222
StretchyShape ( progress: progress, mode: . stretchy)
201
- . frame ( width: 140 , height: 10 )
202
223
}
203
224
}
204
225
0 commit comments