Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch from dark color to labelColor to fix darkmode issues. #3766

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Source/Charts/Charts/ChartViewBase.swift
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ open class ChartViewBase: NSUIView, ChartDataProvider, AnimatorDelegate
@objc open var noDataFont: NSUIFont! = NSUIFont(name: "HelveticaNeue", size: 12.0)

/// color of the no data text
@objc open var noDataTextColor: NSUIColor = NSUIColor.black
@objc open var noDataTextColor: NSUIColor = NSUIColor.labelColor

/// alignment of the no data text
open var noDataTextAlignment: NSTextAlignment = .left
Expand Down
2 changes: 1 addition & 1 deletion Source/Charts/Components/AxisBase.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ open class AxisBase: ComponentBase
private var _axisValueFormatter: IAxisValueFormatter?

@objc open var labelFont = NSUIFont.systemFont(ofSize: 10.0)
@objc open var labelTextColor = NSUIColor.black
@objc open var labelTextColor = NSUIColor.labelColor

@objc open var axisLineColor = NSUIColor.gray
@objc open var axisLineWidth = CGFloat(0.5)
Expand Down
2 changes: 1 addition & 1 deletion Source/Charts/Components/ChartLimitLine.swift
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ open class ChartLimitLine: ComponentBase
@objc open var lineDashPhase = CGFloat(0.0)
@objc open var lineDashLengths: [CGFloat]?

@objc open var valueTextColor = NSUIColor.black
@objc open var valueTextColor = NSUIColor.labelColor
@objc open var valueFont = NSUIFont.systemFont(ofSize: 13.0)

@objc open var drawLabelEnabled = true
Expand Down
2 changes: 1 addition & 1 deletion Source/Charts/Components/Description.swift
Original file line number Diff line number Diff line change
Expand Up @@ -46,5 +46,5 @@ open class Description: ComponentBase
@objc open var font: NSUIFont

/// Text color used for drawing the description text
@objc open var textColor = NSUIColor.black
@objc open var textColor = NSUIColor.labelColor
}
2 changes: 1 addition & 1 deletion Source/Charts/Components/Legend.swift
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ open class Legend: ComponentBase
@objc open var direction: Direction = Direction.leftToRight

@objc open var font: NSUIFont = NSUIFont.systemFont(ofSize: 10.0)
@objc open var textColor = NSUIColor.black
@objc open var textColor = NSUIColor.labelColor

/// The form/shape of the legend forms
@objc open var form = Form.square
Expand Down
4 changes: 2 additions & 2 deletions Source/Charts/Data/Implementations/ChartBaseDataSet.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ open class ChartBaseDataSet: NSObject, IChartDataSet, NSCopying

// default color
colors.append(NSUIColor(red: 140.0/255.0, green: 234.0/255.0, blue: 255.0/255.0, alpha: 1.0))
valueColors.append(NSUIColor.black)
valueColors.append(NSUIColor.labelColor)
}

@objc public init(label: String?)
Expand All @@ -30,7 +30,7 @@ open class ChartBaseDataSet: NSObject, IChartDataSet, NSCopying

// default color
colors.append(NSUIColor(red: 140.0/255.0, green: 234.0/255.0, blue: 255.0/255.0, alpha: 1.0))
valueColors.append(NSUIColor.black)
valueColors.append(NSUIColor.labelColor)

self.label = label
}
Expand Down
8 changes: 8 additions & 0 deletions Source/Charts/Utils/Platform.swift
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,14 @@ public typealias NSUIGestureRecognizerState = UIGestureRecognizer.State
}
}

extension UIColor
{
static var labelColor : UIColor
{
return UIColor.black

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I get that this is an old PR, but if UIColor.label is returned here, we can get Dark Mode support for labels on iOS as well, which would be nice.

Copy link
Collaborator

@jjatie jjatie Sep 18, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Simply removing the declaration will solve the issue for iOS 13+.

extension UIColor {
    @available(iOS, introduced: 9.0, obsoleted: 13.0)
    @available(tvOS, introduced: 9.0, obsoleted: 13.0)
    static var label: UIColor { .black }
}

and doing the same for NSColor

extension NSColor {
    @available(macOS, introduced: 10.11, obsoleted: 10.14)
    static var label: UIColor { .black }
}

}
}

extension UIView
{
@objc final var nsuiGestureRecognizers: [NSUIGestureRecognizer]?
Expand Down