Skip to content

Commit 2075653

Browse files
committed
-added new setup possebilities
1 parent 6ef31ed commit 2075653

File tree

1 file changed

+13
-28
lines changed

1 file changed

+13
-28
lines changed

Sources/CheesyChart/Main/CheesyChart.swift

Lines changed: 13 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -16,18 +16,7 @@ public struct CheesyChart: View {
1616
private let dCount: Int // Count of total price data
1717
private var alignment: YAxiesAlignment
1818
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+
3120
/// Standart init if you don't want to use the custom header
3221
public init(setup: SetupChart) {
3322
self.setup = setup
@@ -59,19 +48,13 @@ public struct CheesyChart: View {
5948
ChartYAxiesStatsView(setup: setup)
6049
,alignment: alignment == .leading ? .leading : .trailing
6150
)
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+
)
7558
.onAppear {
7659
DispatchQueue.main.asyncAfter(deadline: .now() + setup.startAnimationAfterAppeariance) {
7760
withAnimation(.linear(duration: setup.chartAnimationDuration)) {
@@ -83,6 +66,10 @@ public struct CheesyChart: View {
8366
.environmentObject(vm)
8467
}
8568

69+
private func initVars() {
70+
71+
}
72+
8673
private func handleGesture(value: DragGesture.Value) {
8774
vm.hide = true
8875
vm.touchLocation = value.location
@@ -93,9 +80,7 @@ public struct CheesyChart: View {
9380

9481
/// 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
9582
if tapPoint != nil {
96-
DispatchQueue.main.async {
97-
tapPoint = vm.point
98-
}
83+
tapPoint = vm.point
9984
}
10085
}
10186
}

0 commit comments

Comments
 (0)