# HG changeset patch # User Dennis Concepción Martín # Date 1624804343 -7200 # Node ID 766a1169564b81d5a7950abccfe86b12b8980b71 # Parent 7e524a9cc19459ce400aeca2d5be4b52e6337872 Add WatchOS compatability diff -r 7e524a9cc194 -r 766a1169564b Package.swift --- a/Package.swift Tue Jun 22 16:41:53 2021 +0200 +++ b/Package.swift Sun Jun 27 16:32:23 2021 +0200 @@ -9,7 +9,7 @@ let package = Package( name: "StockCharts", platforms: [ - .iOS(.v14) + .iOS(.v14), .watchOS(.v7) ], products: [ .library( diff -r 7e524a9cc194 -r 766a1169564b Sources/StockCharts/CapsuleChart/CapsuleChartView.swift --- a/Sources/StockCharts/CapsuleChart/CapsuleChartView.swift Tue Jun 22 16:41:53 2021 +0200 +++ b/Sources/StockCharts/CapsuleChart/CapsuleChartView.swift Sun Jun 27 16:32:23 2021 +0200 @@ -17,6 +17,7 @@ ZStack { GeometryReader { proxy in Group { + #if os(iOS) Capsule() .foregroundColor(Color(.systemGray)) .opacity(0.2) @@ -24,6 +25,16 @@ Capsule() .foregroundColor(Color(.systemBlue)) .frame(width: proxy.size.width * percentageOfWidth) + #elseif os(watchOS) + Capsule() + .foregroundColor(Color(.gray)) + .opacity(0.2) + + Capsule() + .foregroundColor(Color(.blue)) + .frame(width: proxy.size.width * percentageOfWidth) + #endif + } .frame(height: 10) } diff -r 7e524a9cc194 -r 766a1169564b Sources/StockCharts/LineChart/Helpers/ChartLabel.swift --- a/Sources/StockCharts/LineChart/Helpers/ChartLabel.swift Tue Jun 22 16:41:53 2021 +0200 +++ b/Sources/StockCharts/LineChart/Helpers/ChartLabel.swift Sun Jun 27 16:32:23 2021 +0200 @@ -27,8 +27,16 @@ Text(hour) .opacity(0.5) } + + #if os(iOS) Text("\(data[indexPosition], specifier: "%.2f")") .foregroundColor(Color(.systemBlue)) + + #elseif os(watchOS) + Text("\(data[indexPosition], specifier: "%.2f")") + .foregroundColor(Color(.blue)) + #endif + } .font(.caption) } diff -r 7e524a9cc194 -r 766a1169564b Sources/StockCharts/LineChart/Helpers/IndicatorPoint.swift --- a/Sources/StockCharts/LineChart/Helpers/IndicatorPoint.swift Tue Jun 22 16:41:53 2021 +0200 +++ b/Sources/StockCharts/LineChart/Helpers/IndicatorPoint.swift Sun Jun 27 16:32:23 2021 +0200 @@ -9,9 +9,16 @@ public struct IndicatorPoint: View { public var body: some View { + #if os(iOS) Circle() .frame(width: 20, height: 20) .foregroundColor(Color(.systemBlue)) + + #elseif os(watchOS) + Circle() + .frame(width: 20, height: 20) + .foregroundColor(Color(.blue)) + #endif } } diff -r 7e524a9cc194 -r 766a1169564b Sources/StockCharts/LineChart/Helpers/LineView.swift --- a/Sources/StockCharts/LineChart/Helpers/LineView.swift Tue Jun 22 16:41:53 2021 +0200 +++ b/Sources/StockCharts/LineChart/Helpers/LineView.swift Sun Jun 27 16:32:23 2021 +0200 @@ -58,14 +58,26 @@ Color path depending on data. */ public func colorLine() -> Color { + #if os(iOS) + let blue = Color(.systemBlue) + let teal = Color(.systemTeal) + let red = Color(.systemRed) + var color = Color(.systemGreen) + #elseif os(watchOS) + let blue = Color(.blue) + let teal = Color(.blue) + let red = Color(.red) + + var color = Color(.green) + #endif if showingIndicators { - color = Color(.systemBlue) + color = blue } else if data.first! > data.last! { - color = Color(.systemRed) + color = red } else if data.first! == data.last! { - color = Color(.systemTeal) + color = teal } return color diff -r 7e524a9cc194 -r 766a1169564b StockCharts.xcodeproj/project.xcworkspace/xcuserdata/dennis.xcuserdatad/UserInterfaceState.xcuserstate Binary file StockCharts.xcodeproj/project.xcworkspace/xcuserdata/dennis.xcuserdatad/UserInterfaceState.xcuserstate has changed