From a5fda8febb1aa66769e8029d35eeb6d41af158cf Mon Sep 17 00:00:00 2001 From: Stefanos Zachariadis Date: Mon, 28 Oct 2019 09:07:18 +0000 Subject: [PATCH] =?UTF-8?q?introduce=20gracefully=20degrading=20abstractio?= =?UTF-8?q?ns=20for=20dark=20mode=20for=20ios=20and=E2=80=A6=20(#4171)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * introduce gracefully degrading abstractions for dark mode for ios and macos and use them to draw text * it's .labelColor not .label on NSColor --- .../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 .labelColor + } + else + { + return .black + } +} +private let labelColor: NSColor = fetchLabelColor() + +extension NSColor +{ + static var labelOrBlack: NSColor { labelColor } +} + extension NSScrollView { var scrollEnabled: Bool