Mercurial > public > stock-charts
changeset 60:e16e6bdaa31d
Add dragGesture argument
author | Dennis Concepción Martín <66180929+denniscm190@users.noreply.github.com> |
---|---|
date | Fri, 07 May 2021 12:20:48 +0200 |
parents | e54c96a5c652 |
children | d689500c785e |
files | .swiftpm/xcode/package.xcworkspace/xcuserdata/dennis.xcuserdatad/UserInterfaceState.xcuserstate .swiftpm/xcode/xcuserdata/dennis.xcuserdatad/xcschemes/xcschememanagement.plist DemoProject/DemoProject.xcodeproj/project.xcworkspace/xcuserdata/dennis.xcuserdatad/UserInterfaceState.xcuserstate README.md Sources/StockCharts/Info.plist Sources/StockCharts/LineChart/ChartView.swift Sources/StockCharts/LineChart/Helpers/LineView.swift Sources/StockCharts/LineChart/LineChartView.swift StockCharts.xcodeproj/project.pbxproj StockCharts.xcodeproj/project.xcworkspace/xcuserdata/dennis.xcuserdatad/UserInterfaceState.xcuserstate |
diffstat | 10 files changed, 60 insertions(+), 40 deletions(-) [+] |
line wrap: on
line diff
Binary file .swiftpm/xcode/package.xcworkspace/xcuserdata/dennis.xcuserdatad/UserInterfaceState.xcuserstate has changed
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/.swiftpm/xcode/xcuserdata/dennis.xcuserdatad/xcschemes/xcschememanagement.plist Fri May 07 12:20:48 2021 +0200 @@ -0,0 +1,14 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> +<plist version="1.0"> +<dict> + <key>SchemeUserState</key> + <dict> + <key>StockCharts.xcscheme_^#shared#^_</key> + <dict> + <key>orderHint</key> + <integer>0</integer> + </dict> + </dict> +</dict> +</plist>
Binary file DemoProject/DemoProject.xcodeproj/project.xcworkspace/xcuserdata/dennis.xcuserdatad/UserInterfaceState.xcuserstate has changed
--- a/README.md Mon May 03 17:51:39 2021 +0200 +++ b/README.md Fri May 07 12:20:48 2021 +0200 @@ -26,7 +26,7 @@ ### Line chart ```swift -ChartView(data: [Double], dates: [String]?, hours: [String]?) +LineChartView(data: [Double], dates: [String]?, hours: [String]?, dragGesture: Bool?) ``` #### Arguments @@ -34,5 +34,6 @@ data: [120.3, 121.0, 132.4, ...] dates: ["yyyy-MM-dd", "2021-01-01", "2021-01-02", ...] hours: ["10:20", "10:21", "10:22", ...] // It could be any format +dragGesture: false // By default is true ``` <img width="374" alt="LineChartVideo" src="https://user-images.githubusercontent.com/66180929/116899623-137c6e80-ac38-11eb-8ec0-e678aea54062.gif">
--- a/Sources/StockCharts/Info.plist Mon May 03 17:51:39 2021 +0200 +++ b/Sources/StockCharts/Info.plist Fri May 07 12:20:48 2021 +0200 @@ -15,7 +15,7 @@ <key>CFBundlePackageType</key> <string>$(PRODUCT_BUNDLE_PACKAGE_TYPE)</string> <key>CFBundleShortVersionString</key> - <string>1.0</string> + <string>$(MARKETING_VERSION)</string> <key>CFBundleVersion</key> <string>$(CURRENT_PROJECT_VERSION)</string> </dict>
--- a/Sources/StockCharts/LineChart/ChartView.swift Mon May 03 17:51:39 2021 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,33 +0,0 @@ -// -// ChartView.swift -// StockCharts -// -// Created by Dennis Concepción Martín on 30/4/21. -// - -import SwiftUI - -public struct ChartView: View { - public var data: [Double] - public var dates: [String]? - public var hours: [String]? - - @State var showingIndicators = false - @State var indexPosition = Int() - - public init(data: [Double], dates: [String]?, hours: [String]?) { - self.data = data - self.dates = dates - self.hours = hours - } - - public var body: some View { - VStack { - ChartLabel(data: data, dates: dates, hours: hours, indexPosition: $indexPosition) - .opacity(showingIndicators ? 1: 0) - .padding(.vertical) - - LineView(data: data, showingIndicators: $showingIndicators, indexPosition: $indexPosition) - } - } -}
--- a/Sources/StockCharts/LineChart/Helpers/LineView.swift Mon May 03 17:51:39 2021 +0200 +++ b/Sources/StockCharts/LineChart/Helpers/LineView.swift Fri May 07 12:20:48 2021 +0200 @@ -11,6 +11,7 @@ public var data: [Double] public var dates: [String]? public var hours: [String]? + public var dragGesture: Bool? @Binding var showingIndicators: Bool @Binding var indexPosition: Int @@ -32,7 +33,7 @@ .rotationEffect(.degrees(180), anchor: .center) .rotation3DEffect(.degrees(180), axis: (x: 0.0, y: 1.0, z: 0.0)) .contentShape(Rectangle()) // Control tappable area - .gesture( + .gesture(dragGesture ?? true ? LongPressGesture(minimumDuration: 0.2) .sequenced(before: DragGesture(minimumDistance: 0, coordinateSpace: .local)) .onChanged({ value in // Get value of the gesture @@ -49,6 +50,7 @@ .onEnded({ value in self.showingIndicators = false }) + : nil // On dragGesture = false ) }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Sources/StockCharts/LineChart/LineChartView.swift Fri May 07 12:20:48 2021 +0200 @@ -0,0 +1,34 @@ +// +// LineChartView.swift +// StockCharts +// +// Created by Dennis Concepción Martín on 30/4/21. +// + +import SwiftUI + +public struct LineChartView: View { + public var data: [Double] + public var dates: [String]? + public var hours: [String]? + public var dragGesture: Bool? + + @State var showingIndicators = false + @State var indexPosition = Int() + + public init(data: [Double], dates: [String]?, hours: [String]?) { + self.data = data + self.dates = dates + self.hours = hours + } + + public var body: some View { + VStack { + ChartLabel(data: data, dates: dates, hours: hours, indexPosition: $indexPosition) + .opacity(showingIndicators ? 1: 0) + .padding(.vertical) + + LineView(data: data, dates: dates, hours: hours, dragGesture: dragGesture, showingIndicators: $showingIndicators, indexPosition: $indexPosition) + } + } +}
--- a/StockCharts.xcodeproj/project.pbxproj Mon May 03 17:51:39 2021 +0200 +++ b/StockCharts.xcodeproj/project.pbxproj Fri May 07 12:20:48 2021 +0200 @@ -10,7 +10,7 @@ 95770B8B263C57B5003FA924 /* StockCharts.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 95770B81263C57B5003FA924 /* StockCharts.framework */; }; 95770B90263C57B5003FA924 /* StockChartsTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 95770B8F263C57B5003FA924 /* StockChartsTests.swift */; }; 95770B92263C57B5003FA924 /* StockCharts.h in Headers */ = {isa = PBXBuildFile; fileRef = 95770B84263C57B5003FA924 /* StockCharts.h */; settings = {ATTRIBUTES = (Public, ); }; }; - 95770BA0263C590C003FA924 /* ChartView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 95770B9F263C590C003FA924 /* ChartView.swift */; }; + 95770BA0263C590C003FA924 /* LineChartView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 95770B9F263C590C003FA924 /* LineChartView.swift */; }; 95770BA3263C5934003FA924 /* ChartLabel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 95770BA2263C5934003FA924 /* ChartLabel.swift */; }; 95770BA5263C594C003FA924 /* IndicatorPoint.swift in Sources */ = {isa = PBXBuildFile; fileRef = 95770BA4263C594C003FA924 /* IndicatorPoint.swift */; }; 95770BA7263C596E003FA924 /* LinePath.swift in Sources */ = {isa = PBXBuildFile; fileRef = 95770BA6263C596E003FA924 /* LinePath.swift */; }; @@ -35,7 +35,7 @@ 95770B8F263C57B5003FA924 /* StockChartsTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StockChartsTests.swift; sourceTree = "<group>"; }; 95770B91263C57B5003FA924 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; }; 95770B9D263C58B1003FA924 /* README.md */ = {isa = PBXFileReference; lastKnownFileType = net.daringfireball.markdown; path = README.md; sourceTree = "<group>"; }; - 95770B9F263C590C003FA924 /* ChartView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ChartView.swift; sourceTree = "<group>"; }; + 95770B9F263C590C003FA924 /* LineChartView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LineChartView.swift; sourceTree = "<group>"; }; 95770BA2263C5934003FA924 /* ChartLabel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ChartLabel.swift; sourceTree = "<group>"; }; 95770BA4263C594C003FA924 /* IndicatorPoint.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = IndicatorPoint.swift; sourceTree = "<group>"; }; 95770BA6263C596E003FA924 /* LinePath.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LinePath.swift; sourceTree = "<group>"; }; @@ -122,7 +122,7 @@ 95770B9E263C58F4003FA924 /* LineChart */ = { isa = PBXGroup; children = ( - 95770B9F263C590C003FA924 /* ChartView.swift */, + 95770B9F263C590C003FA924 /* LineChartView.swift */, 95770BA1263C5927003FA924 /* Helpers */, ); path = LineChart; @@ -248,7 +248,7 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( - 95770BA0263C590C003FA924 /* ChartView.swift in Sources */, + 95770BA0263C590C003FA924 /* LineChartView.swift in Sources */, 95770BA3263C5934003FA924 /* ChartLabel.swift in Sources */, 95770BA7263C596E003FA924 /* LinePath.swift in Sources */, 95770BA9263C5988003FA924 /* LineView.swift in Sources */, @@ -414,6 +414,7 @@ "@executable_path/Frameworks", "@loader_path/Frameworks", ); + MARKETING_VERSION = 1.1; PRODUCT_BUNDLE_IDENTIFIER = io.dennistech.StockCharts; PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)"; SKIP_INSTALL = YES; @@ -441,6 +442,7 @@ "@executable_path/Frameworks", "@loader_path/Frameworks", ); + MARKETING_VERSION = 1.1; PRODUCT_BUNDLE_IDENTIFIER = io.dennistech.StockCharts; PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)"; SKIP_INSTALL = YES;