@@ -16,18 +16,7 @@ public struct CheesyChart: View {
16
16
private let dCount : Int // Count of total price data
17
17
private var alignment : YAxiesAlignment
18
18
var setup : SetupChart
19
-
20
- @State var tap : Bool = false
21
-
22
- @GestureState private var isPressed : Bool = false
23
- private var drag : GestureStateGesture < DragGesture , Bool > {
24
- return DragGesture ( minimumDistance: 0 )
25
- . updating ( $isPressed) { value, gestureState, transaction in
26
- handleGesture ( value: value)
27
- gestureState = true
28
- }
29
- }
30
-
19
+
31
20
/// Standart init if you don't want to use the custom header
32
21
public init ( setup: SetupChart ) {
33
22
self . setup = setup
@@ -59,19 +48,13 @@ public struct CheesyChart: View {
59
48
ChartYAxiesStatsView ( setup: setup)
60
49
, alignment: alignment == . leading ? . leading : . trailing
61
50
)
62
- . gesture ( drag)
63
- . onChange ( of: isPressed, perform: { pressed in
64
- if !isPressed && tap == true {
65
- vm. hide. toggle ( )
66
- }
67
- } )
68
- // .gesture(
69
- // DragGesture(minimumDistance: 0)
70
- // .onChanged(handleGesture)
71
- // .onEnded({ value in
72
- // vm.hide.toggle()
73
- // })
74
- // )
51
+ . gesture (
52
+ DragGesture ( minimumDistance: 0 )
53
+ . onChanged ( handleGesture)
54
+ . onEnded ( { value in
55
+ vm. hide. toggle ( )
56
+ } )
57
+ )
75
58
. onAppear {
76
59
DispatchQueue . main. asyncAfter ( deadline: . now( ) + setup. startAnimationAfterAppeariance) {
77
60
withAnimation ( . linear( duration: setup. chartAnimationDuration) ) {
@@ -83,6 +66,10 @@ public struct CheesyChart: View {
83
66
. environmentObject ( vm)
84
67
}
85
68
69
+ private func initVars( ) {
70
+
71
+ }
72
+
86
73
private func handleGesture( value: DragGesture . Value ) {
87
74
vm. hide = true
88
75
vm. touchLocation = value. location
@@ -93,9 +80,7 @@ public struct CheesyChart: View {
93
80
94
81
/// If we are using a custom header and we are passing a tapPoint binding, we assign vm.point to tapPoint to show the current drag price externally
95
82
if tapPoint != nil {
96
- DispatchQueue . main. async {
97
- tapPoint = vm. point
98
- }
83
+ tapPoint = vm. point
99
84
}
100
85
}
101
86
}
0 commit comments