Skip to content

Commit

Permalink
Fix warnings and update specs
Browse files Browse the repository at this point in the history
- Migrate schemes
- Remove redundant public annotations on macOS
- Update podspec and .swift-version
  • Loading branch information
zenangst committed May 21, 2019
1 parent 6d11c86 commit 70e585f
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 25 deletions.
2 changes: 1 addition & 1 deletion .swift-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
4.2
5.0
2 changes: 1 addition & 1 deletion Hue.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,5 @@ Pod::Spec.new do |s|
s.osx.source_files = 'Source/macOS/**/*'
s.osx.frameworks = 'AppKit'

s.pod_target_xcconfig = { 'SWIFT_VERSION' => '4.2' }
s.pod_target_xcconfig = { 'SWIFT_VERSION' => '5.0' }
end
7 changes: 4 additions & 3 deletions Hue.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,7 @@
isa = PBXProject;
attributes = {
LastSwiftUpdateCheck = 0720;
LastUpgradeCheck = 1010;
LastUpgradeCheck = 1020;
ORGANIZATIONNAME = "Hyper Interaktiv AS";
TargetAttributes = {
386887901C8343CF005A8868 = {
Expand Down Expand Up @@ -414,10 +414,9 @@
};
buildConfigurationList = D528620C1C3EAC1D00AD11AD /* Build configuration list for PBXProject "Hue" */;
compatibilityVersion = "Xcode 3.2";
developmentRegion = English;
developmentRegion = en;
hasScannedForEncodings = 0;
knownRegions = (
English,
en,
Base,
);
Expand Down Expand Up @@ -716,6 +715,7 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
Expand Down Expand Up @@ -775,6 +775,7 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
Expand Down
2 changes: 1 addition & 1 deletion Hue.xcodeproj/xcshareddata/xcschemes/Hue-iOS.xcscheme
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1010"
LastUpgradeVersion = "1020"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
2 changes: 1 addition & 1 deletion Hue.xcodeproj/xcshareddata/xcschemes/Hue-macOS.xcscheme
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1010"
LastUpgradeVersion = "1020"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
2 changes: 1 addition & 1 deletion Hue.xcodeproj/xcshareddata/xcschemes/Hue-tvOS.xcscheme
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1010"
LastUpgradeVersion = "1020"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
33 changes: 16 additions & 17 deletions Source/macOS/NSColor+Hue.swift
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public extension NSColor {
///
/// - Parameter minSaturation: The minimun saturation value
/// - Returns: The adjusted color
public func color(minSaturation: CGFloat) -> NSColor {
func color(minSaturation: CGFloat) -> NSColor {
var (hue, saturation, brightness, alpha): (CGFloat, CGFloat, CGFloat, CGFloat) = (0.0, 0.0, 0.0, 0.0)
getHue(&hue, saturation: &saturation, brightness: &brightness, alpha: &alpha)

Expand All @@ -50,7 +50,7 @@ public extension NSColor {
///
/// - Parameter value: The alpha value
/// - Returns: The alpha adjusted color
public func alpha(_ value: CGFloat) -> NSColor {
func alpha(_ value: CGFloat) -> NSColor {
return withAlphaComponent(value)
}
}
Expand All @@ -59,7 +59,7 @@ public extension NSColor {

public extension NSColor {

public func hex(hashPrefix: Bool = true) -> String {
func hex(hashPrefix: Bool = true) -> String {
var (r, g, b, a): (CGFloat, CGFloat, CGFloat, CGFloat) = (0.0, 0.0, 0.0, 0.0)
usingColorSpace(NSColorSpace.genericRGB)!.getRed(&r, green: &g, blue: &b, alpha: &a)

Expand All @@ -75,27 +75,27 @@ public extension NSColor {
return [r, g, b]
}

public var isDark: Bool {
var isDark: Bool {
let RGB = rgbComponents()
return (0.2126 * RGB[0] + 0.7152 * RGB[1] + 0.0722 * RGB[2]) < 0.5
}

public var isBlackOrWhite: Bool {
var isBlackOrWhite: Bool {
let RGB = rgbComponents()
return (RGB[0] > 0.91 && RGB[1] > 0.91 && RGB[2] > 0.91) || (RGB[0] < 0.09 && RGB[1] < 0.09 && RGB[2] < 0.09)
}

public var isBlack: Bool {
var isBlack: Bool {
let RGB = rgbComponents()
return (RGB[0] < 0.09 && RGB[1] < 0.09 && RGB[2] < 0.09)
}

public var isWhite: Bool {
var isWhite: Bool {
let RGB = rgbComponents()
return (RGB[0] > 0.91 && RGB[1] > 0.91 && RGB[2] > 0.91)
}

public func isDistinct(from color: NSColor) -> Bool {
func isDistinct(from color: NSColor) -> Bool {
let bg = rgbComponents()
let fg = color.rgbComponents()
let threshold: CGFloat = 0.25
Expand All @@ -113,7 +113,7 @@ public extension NSColor {
return result
}

public func isContrasting(with color: NSColor) -> Bool {
func isContrasting(with color: NSColor) -> Bool {

func colorLum(rgb: [CGFloat]) -> CGFloat {
let r = 0.2126 * rgb[0]
Expand Down Expand Up @@ -145,8 +145,7 @@ public extension NSColor {
// MARK: - Gradient

public extension Array where Element : NSColor {

public func gradient(_ transform: ((_ gradient: inout CAGradientLayer) -> CAGradientLayer)? = nil) -> CAGradientLayer {
func gradient(_ transform: ((_ gradient: inout CAGradientLayer) -> CAGradientLayer)? = nil) -> CAGradientLayer {
var gradient = CAGradientLayer()
gradient.colors = self.map { $0.cgColor }

Expand Down Expand Up @@ -212,7 +211,7 @@ public extension NSColor {
public extension NSColor {

/**adds hue, saturation, and brightness to the HSB components of this color (self)*/
public func add(hue: CGFloat, saturation: CGFloat, brightness: CGFloat, alpha: CGFloat) -> NSColor {
func add(hue: CGFloat, saturation: CGFloat, brightness: CGFloat, alpha: CGFloat) -> NSColor {
var (oldHue, oldSat, oldBright, oldAlpha) : (CGFloat, CGFloat, CGFloat, CGFloat) = (0,0,0,0)
self.getHue(&oldHue, saturation: &oldSat, brightness: &oldBright, alpha: &oldAlpha)

Expand All @@ -229,7 +228,7 @@ public extension NSColor {
}

/**adds red, green, and blue to the RGB components of this color (self)*/
public func add(red: CGFloat, green: CGFloat, blue: CGFloat, alpha: CGFloat) -> NSColor {
func add(red: CGFloat, green: CGFloat, blue: CGFloat, alpha: CGFloat) -> NSColor {
// make sure new values doesn't overflow
let newRed: CGFloat = max(min(self.getRed() + red, 1.0), 0)
let newGreen: CGFloat = max(min(self.getGreen() + green, 1.0), 0)
Expand All @@ -238,24 +237,24 @@ public extension NSColor {
return NSColor(red: newRed, green: newGreen, blue: newBlue, alpha: newAlpha)
}

public func add(hsb color: NSColor) -> NSColor {
func add(hsb color: NSColor) -> NSColor {
var (h,s,b,a) : (CGFloat, CGFloat, CGFloat, CGFloat) = (0,0,0,0)
color.getHue(&h, saturation: &s, brightness: &b, alpha: &a)
return self.add(hue: h, saturation: s, brightness: b, alpha: 0)
}

public func add(rgb color: NSColor) -> NSColor {
func add(rgb color: NSColor) -> NSColor {
return self.add(red: color.getRed(), green: color.getGreen(), blue: color.getBlue(), alpha: 0)
}

public func add(hsba color: NSColor) -> NSColor {
func add(hsba color: NSColor) -> NSColor {
var (h,s,b,a) : (CGFloat, CGFloat, CGFloat, CGFloat) = (0,0,0,0)
color.getHue(&h, saturation: &s, brightness: &b, alpha: &a)
return self.add(hue: h, saturation: s, brightness: b, alpha: a)
}

/**adds the rgb components of two colors*/
public func add(rgba color: NSColor) -> NSColor {
func add(rgba color: NSColor) -> NSColor {
return self.add(red: color.getRed(), green: color.getGreen(), blue: color.getBlue(), alpha: color.getAlpha())
}
}

0 comments on commit 70e585f

Please sign in to comment.