-
Notifications
You must be signed in to change notification settings - Fork 0
/
ArrowView.swift
70 lines (61 loc) · 2.79 KB
/
ArrowView.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
//
// ArrowView.swift
// SSSwiftUIAnimations
//
// Created by Mansi Prajapati on 15/05/24.
//
import SwiftUI
struct Arrow: View {
// MARK: - Variables
var arrowStyle: ArrowViewParams
var style: SSProgressViewStyle
@Binding var progress: Float
@Binding var bounceEffect: CGFloat
@State var verticalLine = true
var body: some View {
VStack(spacing: 0) {
// Vertical line of arrow
RoundedRectangle(cornerRadius: style.circleStrokeWidth/2)
.frame(
width: arrowStyle.isAnimating ? style.circleStrokeWidth : style.arrowStrokeWidth + 1,
height: arrowStyle.isAnimating ? (!arrowStyle.animationStarted ? style.circleStrokeWidth : style.circleStrokeWidth ) : style.circleSize * 0.40
).opacity((progress >= 0.001) ? 0 : 1)
.foregroundColor(arrowStyle.isAnimating ? style.fillStrokeColor : style.arrowColor)
.offset(y: arrowStyle.isAnimating ? (!arrowStyle.animationStarted ? -10 : -(style.circleSize/2)) : 0)
if progress <= 0.0 {
// if progress is less than 0.1 then showing down arrow animation
DownArrow(
initialAnim: arrowStyle.initialAnim,
isDownward: arrowStyle.isDownward,
progress: Float(progress),
circleSize: style.circleSize,
isAnimating: arrowStyle.isAnimating, bounceEffect: bounceEffect
)
.stroke(style: StrokeStyle(lineWidth: style.arrowStrokeWidth, lineCap: .round))
.frame(width: 10, height: 50)
.padding(.top, -50)
.offset(y: arrowStyle.isAnimating ? 22 : .zero)
.foregroundColor(style.arrowColor)
.scaleEffect(CGSize(width: 1, height: arrowStyle.isAnimating ? 1 : style.circleSize * 0.005))
} else if progress > 0.0 && progress < 1.0 {
// if progress is between >= 0.1 and < 1.0 starting wave animation
WaveView(
progress: $progress,
arrowStrokeWidth: style.arrowStrokeWidth,
width: style.circleSize
)
.frame(width: 10, height: 30)
.foregroundColor(style.arrowColor)
} else if progress >= 1.0 {
// if progress completed showing check mark
CheckView(
width: style.circleSize,
arrowStrokeWidth: style.arrowStrokeWidth
)
.padding(.top, -11)
.offset(y: 22)
.foregroundColor(style.arrowColor)
}
}
}
}