@@ -36,7 +36,7 @@ public struct RotatingCircleWithGap: View {
3636private struct LoadingCircle : View {
3737 let circleColor : Color
3838 let scale : CGFloat
39- private let circleWidth : CGFloat = 8
39+ let circleWidth : CGFloat
4040
4141 var body : some View {
4242 Circle ( )
@@ -47,6 +47,7 @@ private struct LoadingCircle: View {
4747}
4848
4949public struct LoadingFlowerView : View {
50+
5051 private let animationDuration : Double = 0.6
5152 private var singleCircleAnimationDuration : Double {
5253 return animationDuration/ 3
@@ -56,37 +57,58 @@ public struct LoadingFlowerView: View {
5657 . repeatForever ( autoreverses: true )
5758 }
5859
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+ }
6165
62- public init ( ) { }
66+ @State private var color = Color . white. opacity ( 0.3 )
67+ @State private var scale : CGFloat = 0.98
6368
6469 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+ )
85105 }
86106 . onAppear {
87- self . color = . white
88- self . scale = 1.02
107+ self . color = self . originalColor
108+ self . scale = 1
89109 }
110+ . aspectRatio ( contentMode: . fit)
111+ . frame ( idealWidth: 26 )
90112 }
91113}
92114
@@ -198,7 +220,6 @@ public struct StretchProgressView: View {
198220
199221 public var body : some View {
200222 StretchyShape ( progress: progress, mode: . stretchy)
201- . frame ( width: 140 , height: 10 )
202223 }
203224}
204225
0 commit comments