-
-
Notifications
You must be signed in to change notification settings - Fork 6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Added system dark mode support for primary label colors in the framework Moved Color to its own Platform file * Relocated color file * Reverted demo change * Separated `Platform` into multiple files for better organization * Updated from master
- Loading branch information
Showing
9 changed files
with
516 additions
and
429 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
// | ||
// Platform+Color.swift | ||
// Charts | ||
// | ||
// Created by Jacob Christie on 2019-10-15. | ||
// | ||
|
||
#if canImport(UIKit) | ||
import UIKit | ||
|
||
public typealias NSUIColor = UIColor | ||
private func fetchLabelColor() -> UIColor | ||
{ | ||
if #available(iOS 13, tvOS 13, *) | ||
{ | ||
return .label | ||
} | ||
else | ||
{ | ||
return .black | ||
} | ||
} | ||
private let labelColor: UIColor = fetchLabelColor() | ||
|
||
extension UIColor | ||
{ | ||
static var labelOrBlack: UIColor { labelColor } | ||
} | ||
#endif | ||
|
||
#if canImport(AppKit) | ||
|
||
import AppKit | ||
|
||
public typealias NSUIColor = NSColor | ||
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 } | ||
} | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,168 @@ | ||
// | ||
// Platform+Gestures.swift | ||
// | ||
// | ||
// Created by Jacob Christie on 2019-10-15. | ||
// | ||
|
||
// MARK: - UIKit | ||
#if canImport(UIKit) | ||
import UIKit | ||
|
||
public typealias NSUIGestureRecognizer = UIGestureRecognizer | ||
public typealias NSUIGestureRecognizerState = UIGestureRecognizer.State | ||
public typealias NSUIGestureRecognizerDelegate = UIGestureRecognizerDelegate | ||
public typealias NSUITapGestureRecognizer = UITapGestureRecognizer | ||
public typealias NSUIPanGestureRecognizer = UIPanGestureRecognizer | ||
|
||
extension NSUITapGestureRecognizer | ||
{ | ||
@objc final func nsuiNumberOfTouches() -> Int | ||
{ | ||
return numberOfTouches | ||
} | ||
|
||
@objc final var nsuiNumberOfTapsRequired: Int | ||
{ | ||
get | ||
{ | ||
return self.numberOfTapsRequired | ||
} | ||
set | ||
{ | ||
self.numberOfTapsRequired = newValue | ||
} | ||
} | ||
} | ||
|
||
extension NSUIPanGestureRecognizer | ||
{ | ||
@objc final func nsuiNumberOfTouches() -> Int | ||
{ | ||
return numberOfTouches | ||
} | ||
|
||
@objc final func nsuiLocationOfTouch(_ touch: Int, inView: UIView?) -> CGPoint | ||
{ | ||
return super.location(ofTouch: touch, in: inView) | ||
} | ||
} | ||
|
||
#if !os(tvOS) | ||
public typealias NSUIPinchGestureRecognizer = UIPinchGestureRecognizer | ||
public typealias NSUIRotationGestureRecognizer = UIRotationGestureRecognizer | ||
|
||
extension NSUIRotationGestureRecognizer | ||
{ | ||
@objc final var nsuiRotation: CGFloat | ||
{ | ||
get { return rotation } | ||
set { rotation = newValue } | ||
} | ||
} | ||
|
||
extension NSUIPinchGestureRecognizer | ||
{ | ||
@objc final var nsuiScale: CGFloat | ||
{ | ||
get | ||
{ | ||
return scale | ||
} | ||
set | ||
{ | ||
scale = newValue | ||
} | ||
} | ||
|
||
@objc final func nsuiLocationOfTouch(_ touch: Int, inView: UIView?) -> CGPoint | ||
{ | ||
return super.location(ofTouch: touch, in: inView) | ||
} | ||
} | ||
#endif | ||
#endif | ||
|
||
// MARK: - AppKit | ||
#if canImport(AppKit) | ||
import AppKit | ||
|
||
public typealias NSUIGestureRecognizer = NSGestureRecognizer | ||
public typealias NSUIGestureRecognizerState = NSGestureRecognizer.State | ||
public typealias NSUIGestureRecognizerDelegate = NSGestureRecognizerDelegate | ||
public typealias NSUITapGestureRecognizer = NSClickGestureRecognizer | ||
public typealias NSUIPanGestureRecognizer = NSPanGestureRecognizer | ||
public typealias NSUIPinchGestureRecognizer = NSMagnificationGestureRecognizer | ||
public typealias NSUIRotationGestureRecognizer = NSRotationGestureRecognizer | ||
|
||
/** The 'tap' gesture is mapped to clicks. */ | ||
extension NSUITapGestureRecognizer | ||
{ | ||
final func nsuiNumberOfTouches() -> Int | ||
{ | ||
return 1 | ||
} | ||
|
||
final var nsuiNumberOfTapsRequired: Int | ||
{ | ||
get | ||
{ | ||
return self.numberOfClicksRequired | ||
} | ||
set | ||
{ | ||
self.numberOfClicksRequired = newValue | ||
} | ||
} | ||
} | ||
|
||
extension NSUIPanGestureRecognizer | ||
{ | ||
final func nsuiNumberOfTouches() -> Int | ||
{ | ||
return 1 | ||
} | ||
|
||
/// FIXME: Currently there are no more than 1 touch in OSX gestures, and not way to create custom touch gestures. | ||
final func nsuiLocationOfTouch(_ touch: Int, inView: NSView?) -> NSPoint | ||
{ | ||
return super.location(in: inView) | ||
} | ||
} | ||
|
||
extension NSUIRotationGestureRecognizer | ||
{ | ||
/// FIXME: Currently there are no velocities in OSX gestures, and not way to create custom touch gestures. | ||
final var velocity: CGFloat | ||
{ | ||
return 0.1 | ||
} | ||
|
||
final var nsuiRotation: CGFloat | ||
{ | ||
get { return -rotation } | ||
set { rotation = -newValue } | ||
} | ||
} | ||
|
||
extension NSUIPinchGestureRecognizer | ||
{ | ||
final var nsuiScale: CGFloat | ||
{ | ||
get | ||
{ | ||
return magnification + 1.0 | ||
} | ||
set | ||
{ | ||
magnification = newValue - 1.0 | ||
} | ||
} | ||
|
||
/// FIXME: Currently there are no more than 1 touch in OSX gestures, and not way to create custom touch gestures. | ||
final func nsuiLocationOfTouch(_ touch: Int, inView view: NSView?) -> NSPoint | ||
{ | ||
return super.location(in: view) | ||
} | ||
} | ||
#endif |
Oops, something went wrong.