Skip to content
This repository was archived by the owner on Sep 19, 2024. It is now read-only.

Release/4.0 #24

Merged
merged 11 commits into from
Sep 5, 2017
Merged
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
55 changes: 55 additions & 0 deletions Library/Core/ColorPaletteItemResource.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
//
// ColorPaletteItemResource.swift
// R.swift.Library
//
// Created by Tom Lokhorst on 2016-03-13.
// From: https://github.com/mac-cain13/R.swift.Library
// License: MIT License
//

import Foundation

public protocol ColorPaletteItemResourceType {

/// Name of the color
var name: String { get }

/// Red componenent of color
var red: CGFloat { get }

/// Green componenent of color
var green: CGFloat { get }

/// Blue componenent of color
var blue: CGFloat { get }

/// Alpha componenent of color
var alpha: CGFloat { get }
}

@available(*, deprecated: 11, message: "Use color assets instead")
public struct ColorPaletteItemResource: ColorPaletteItemResourceType {

/// Name of the color
public let name: String

/// Red componenent of color
public let red: CGFloat

/// Green componenent of color
public let green: CGFloat

/// Blue componenent of color
public let blue: CGFloat

/// Alpha componenent of color
public let alpha: CGFloat

public init(name: String, red: CGFloat, green: CGFloat, blue: CGFloat, alpha: CGFloat) {
self.name = name
self.red = red
self.green = green
self.blue = blue
self.alpha = alpha
}
}
37 changes: 8 additions & 29 deletions Library/Core/ColorResource.swift
Original file line number Diff line number Diff line change
@@ -11,44 +11,23 @@ import Foundation

public protocol ColorResourceType {

/// Bundle this color is in
var bundle: Bundle { get }

/// Name of the color
var name: String { get }

/// Red componenent of color
var red: CGFloat { get }

/// Green componenent of color
var green: CGFloat { get }

/// Blue componenent of color
var blue: CGFloat { get }

/// Alpha componenent of color
var alpha: CGFloat { get }
}

public struct ColorResource: ColorResourceType {

/// Bundle this color is in
public let bundle: Bundle

/// Name of the color
public let name: String

/// Red componenent of color
public let red: CGFloat

/// Green componenent of color
public let green: CGFloat

/// Blue componenent of color
public let blue: CGFloat

/// Alpha componenent of color
public let alpha: CGFloat

public init(name: String, red: CGFloat, green: CGFloat, blue: CGFloat, alpha: CGFloat) {
public init(bundle: Bundle, name: String) {
self.bundle = bundle
self.name = name
self.red = red
self.green = green
self.blue = blue
self.alpha = alpha
}
}
42 changes: 0 additions & 42 deletions Library/Core/Core+Migration.swift

This file was deleted.

20 changes: 0 additions & 20 deletions Library/Core/Validatable.swift
Original file line number Diff line number Diff line change
@@ -27,23 +27,3 @@ public protocol Validatable {
*/
static func validate() throws
}

extension Validatable {
/**
Validates this entity and asserts if it encounters a invalid situation, a validatable should also validate it sub-validatables if it has any. In -O builds (the default for Xcode's Release configuration), validation is not evaluated, and there are no effects.
*/
@available(*, deprecated, message: "Use validate() instead, preferably from a testcase.")
public static func assertValid() {
assert( theRealAssert() )
}

fileprivate static func theRealAssert() -> Bool {
do {
try validate()
} catch {
assertionFailure("Validation of \(type(of: self)) failed with error: \(error)")
}

return true
}
}
26 changes: 0 additions & 26 deletions Library/Foundation/Foundation+Migration.swift

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// ColorResource+UIKit.swift
// ColorPaletteItemResource+UIKit.swift
// R.swift.Library
//
// Created by Tom Lokhorst on 2016-04-23.
@@ -9,11 +9,11 @@

import UIKit

public extension ColorResourceType {
public extension ColorPaletteItemResourceType {
/**
Returns the a UIColor

- returns: A UIColor for this color resource
- returns: A UIColor for this color palette item resource
*/
func color() -> UIColor {
return UIColor(red: red, green: green, blue: blue, alpha: alpha)
26 changes: 26 additions & 0 deletions Library/UIKit/UIColor+ColorResource.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
//
// UIColor+ColorResource.swift
// R.swift.Library
//
// Created by Tom Lokhorst on 2017-06-06.
// From: https://github.com/mac-cain13/R.swift.Library
// License: MIT License
//

import UIKit

@available(iOS 11.0, *)
@available(tvOS 11.0, *)
public extension UIColor {
/**
Returns the color from this resource (R.color.*) that is compatible with the trait collection.

- parameter resource: The resource you want the image of (R.color.*)
- parameter traitCollection: Traits that describe the desired color to retrieve, pass nil to use traits that describe the main screen.

- returns: A color that exactly or best matches the desired traits with the given resource (R.color.*), or nil if no suitable color was found.
*/
public convenience init?(resource: ColorResourceType, compatibleWith traitCollection: UITraitCollection? = nil) {
self.init(named: resource.name, in: resource.bundle, compatibleWith: traitCollection)
}
}
120 changes: 0 additions & 120 deletions Library/UIKit/UIKit+Migration.swift

This file was deleted.

2 changes: 1 addition & 1 deletion R.swift.Library.podspec
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Pod::Spec.new do |spec|

spec.name = "R.swift.Library"
spec.version = "3.0.2"
spec.version = "4.0.0.alpha.2"
spec.license = "MIT"

spec.summary = "Companion library for R.swift, featuring types used to type resources"
Loading
Oops, something went wrong.