From a23f09963781e38983609c6e1377c03b8eb309f8 Mon Sep 17 00:00:00 2001 From: Stefanos Zachariadis Date: Wed, 9 Oct 2019 22:30:19 +0100 Subject: [PATCH 1/2] introduce gracefully degrading abstractions for dark mode for ios and macos and use them to draw text --- .../Contents.swift | 2 +- .../LineChart.xcplaygroundpage/Contents.swift | 2 +- Source/Charts/Charts/ChartViewBase.swift | 2 +- Source/Charts/Charts/PieChartView.swift | 2 +- Source/Charts/Components/AxisBase.swift | 2 +- Source/Charts/Components/ChartLimitLine.swift | 2 +- Source/Charts/Components/Description.swift | 2 +- Source/Charts/Components/Legend.swift | 2 +- .../Implementations/ChartBaseDataSet.swift | 4 +-- Source/Charts/Utils/Platform.swift | 36 +++++++++++++++++++ 10 files changed, 46 insertions(+), 10 deletions(-) diff --git a/ChartsDemo-macOS/PlaygroundChart.playground/Pages/BubbleChart.xcplaygroundpage/Contents.swift b/ChartsDemo-macOS/PlaygroundChart.playground/Pages/BubbleChart.xcplaygroundpage/Contents.swift index 1e574aa7d4..0fc6d448e8 100644 --- a/ChartsDemo-macOS/PlaygroundChart.playground/Pages/BubbleChart.xcplaygroundpage/Contents.swift +++ b/ChartsDemo-macOS/PlaygroundChart.playground/Pages/BubbleChart.xcplaygroundpage/Contents.swift @@ -59,7 +59,7 @@ for index in 0.. UIColor +{ + if #available(iOS 13, tvOS 13, *) + { + return .label + } + else + { + return .black + } +} +private let labelColor: UIColor = fetchLabelColor() + +extension UIColor +{ + static var labelOrBlack: UIColor { labelColor } +} + extension NSUITapGestureRecognizer { @objc final func nsuiNumberOfTouches() -> Int @@ -520,6 +538,24 @@ extension NSTouch } } +private func fetchLabelColor() -> NSColor +{ + if #available(macOS 10.14, *) + { + return .label + } + else + { + return .black + } +} +private let labelColor: NSColor = fetchLabelColor() + +extension NSColor +{ + static var labelOrBlack: NSColor { labelColor } +} + extension NSScrollView { var scrollEnabled: Bool From a90cdffe17cd8bca0a9e17a024b4007163be5e0c Mon Sep 17 00:00:00 2001 From: Stefanos Zachariadis Date: Fri, 11 Oct 2019 20:11:40 +0100 Subject: [PATCH 2/2] it's .labelColor not .label on NSColor --- Source/Charts/Utils/Platform.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/Charts/Utils/Platform.swift b/Source/Charts/Utils/Platform.swift index f3b07e81de..38a6e2c598 100644 --- a/Source/Charts/Utils/Platform.swift +++ b/Source/Charts/Utils/Platform.swift @@ -542,7 +542,7 @@ private func fetchLabelColor() -> NSColor { if #available(macOS 10.14, *) { - return .label + return .labelColor } else {