File tree Expand file tree Collapse file tree 4 files changed +21
-2
lines changed
Sources/ChartUI/LineChart Expand file tree Collapse file tree 4 files changed +21
-2
lines changed Original file line number Diff line number Diff line change 11Pod ::Spec . new do |spec |
22
33 spec . name = "ChartUI"
4- spec . version = "0.4 .0"
4+ spec . version = "0.5 .0"
55 spec . summary = "📈 A SwiftUI chart library"
66 spec . homepage = "https://github.com/theo-brlle/chart-ui"
77 spec . license = { :type => "MIT" , :file => "LICENSE" }
Original file line number Diff line number Diff line change @@ -15,7 +15,7 @@ Just add this repo as a dependency of your project. Here is the repo URL: https:
1515Add ChartUI as a dependency in your ` Podfile ` .
1616
1717```
18- pod 'ChartUI', '~> 0.4 .0'
18+ pod 'ChartUI', '~> 0.5 .0'
1919```
2020
2121Then run ` pod install ` and open the ` .xcworkspace ` file in Xcode.
Original file line number Diff line number Diff line change @@ -25,6 +25,10 @@ final class LineChartViewModel: ObservableObject {
2525 @Published var plotDetailsViewSize : CGSize = . zero
2626 @Published var rightLabelsViewSize : CGSize = . zero
2727
28+ // MARK: - Callbacks
29+
30+ var onDragAction : ( ( Bool ) -> Void ) ?
31+
2832 // MARK: - Computed properties
2933
3034 var chartColor : Color {
Original file line number Diff line number Diff line change @@ -238,20 +238,35 @@ private extension LineChartView {
238238 var dragGesture : some Gesture {
239239 DragGesture ( minimumDistance: 0 )
240240 . onChanged { value in
241+ if !viewModel. isPlotDetailsViewPresented {
242+ viewModel. onDragAction ? ( true )
243+ }
244+
241245 withAnimation {
242246 viewModel. isPlotDetailsViewPresented = true
243247 }
244248
245249 viewModel. updateSelectedPlot ( from: value. location. x)
246250 }
247251 . onEnded { value in
252+ viewModel. onDragAction ? ( false )
253+
248254 withAnimation {
249255 viewModel. isPlotDetailsViewPresented = false
250256 }
251257 }
252258 }
253259}
254260
261+ // MARK: - Callbacks
262+
263+ public extension LineChartView {
264+ func onDrag( _ action: @escaping ( Bool ) -> Void ) -> Self {
265+ self . viewModel. onDragAction = action
266+ return self
267+ }
268+ }
269+
255270// MARK: - Previews
256271
257272struct LineChartView_Previews : PreviewProvider {
You can’t perform that action at this time.
0 commit comments