Skip to content
This repository has been archived by the owner on Dec 12, 2023. It is now read-only.

Commit

Permalink
Merge pull request #14 from denniscm190/testing
Browse files Browse the repository at this point in the history
Add WatchOS compatibility
  • Loading branch information
denniscmcom authored Jun 27, 2021
2 parents 647f282 + 8d3790a commit 938387a
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import PackageDescription
let package = Package(
name: "StockCharts",
platforms: [
.iOS(.v14)
.iOS(.v14), .watchOS(.v7)
],
products: [
.library(
Expand Down
11 changes: 11 additions & 0 deletions Sources/StockCharts/CapsuleChart/CapsuleChartView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,24 @@ public struct CapsuleChartView: View {
ZStack {
GeometryReader { proxy in
Group {
#if os(iOS)
Capsule()
.foregroundColor(Color(.systemGray))
.opacity(0.2)

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)
}
Expand Down
8 changes: 8 additions & 0 deletions Sources/StockCharts/LineChart/Helpers/ChartLabel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,16 @@ public struct ChartLabel: View {
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)
}
Expand Down
7 changes: 7 additions & 0 deletions Sources/StockCharts/LineChart/Helpers/IndicatorPoint.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,16 @@ import SwiftUI

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

}
}
18 changes: 15 additions & 3 deletions Sources/StockCharts/LineChart/Helpers/LineView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,26 @@ public struct LineView: View {
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
Expand Down
Binary file not shown.

0 comments on commit 938387a

Please sign in to comment.