Skip to content

Commit

Permalink
Swift 5 (#23)
Browse files Browse the repository at this point in the history
  • Loading branch information
pedrommcarrasco authored Mar 28, 2019
1 parent 12826d1 commit 0d9984d
Show file tree
Hide file tree
Showing 34 changed files with 645 additions and 652 deletions.
4 changes: 2 additions & 2 deletions Constrictor.podspec
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Pod::Spec.new do |s|
s.swift_version = "4.2"
s.swift_version = "5.0"
s.name = "Constrictor"
s.version = "5.0.1"
s.version = "6.0.0"
s.summary = "🐍 Constrict your layout in Swift"

s.description = "Constrict your Auto Layout code with Constrictor, your chainable sugar."
Expand Down
11 changes: 5 additions & 6 deletions Constrictor/Constrictor.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -517,7 +517,7 @@
};
53D8198620B57C0B00E62D1E = {
CreatedOnToolsVersion = 9.3;
LastSwiftMigration = 0930;
LastSwiftMigration = 1020;
};
};
};
Expand All @@ -526,7 +526,6 @@
developmentRegion = en;
hasScannedForEncodings = 0;
knownRegions = (
en,
);
mainGroup = 53CDE3B420B3201E007E4AE0;
productRefGroup = 53CDE3BF20B3201E007E4AE0 /* Products */;
Expand Down Expand Up @@ -823,7 +822,7 @@
PROVISIONING_PROFILE_SPECIFIER = "";
SKIP_INSTALL = YES;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 4.2;
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Debug;
Expand Down Expand Up @@ -851,7 +850,7 @@
PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)";
PROVISIONING_PROFILE_SPECIFIER = "";
SKIP_INSTALL = YES;
SWIFT_VERSION = 4.2;
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Release;
Expand All @@ -872,7 +871,7 @@
PRODUCT_BUNDLE_IDENTIFIER = pedrommcarrasco.ConstrictorTests;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 4.2;
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Debug;
Expand All @@ -892,7 +891,7 @@
);
PRODUCT_BUNDLE_IDENTIFIER = pedrommcarrasco.ConstrictorTests;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 4.2;
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Release;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1000"
LastUpgradeVersion = "1020"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
286 changes: 143 additions & 143 deletions Constrictor/Constrictor/Core/Constrictor+Simple.swift

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions Constrictor/Constrictor/Modifiers/LayoutPriority.swift
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,11 @@ extension LayoutPriority {
// MARK: - Operators
public extension LayoutPriority {

public static func +(lhs: LayoutPriority, rhs: Float) -> LayoutPriority {
static func +(lhs: LayoutPriority, rhs: Float) -> LayoutPriority {
return LayoutPriority(lhs.value + rhs)
}

public static func -(lhs: LayoutPriority, rhs: Float) -> LayoutPriority {
static func -(lhs: LayoutPriority, rhs: Float) -> LayoutPriority {
return LayoutPriority(lhs.value - rhs)
}
}
4 changes: 2 additions & 2 deletions Constrictor/Constrictor/Modifiers/LayoutState.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@ extension LayoutState {
// MARK: - NSLayoutConstraint's Sugar
public extension NSLayoutConstraint {

public func enable() {
func enable() {
isActive = true
}

public func disable() {
func disable() {
isActive = false
}
}
18 changes: 9 additions & 9 deletions Constrictor/Constrictor/Sugar/Center/CenterConstant.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,27 +10,27 @@ import UIKit

// MARK: - CenterConstant
public struct CenterConstant: Equatable {

let centerX: CGFloat
let centerY: CGFloat
}

// MARK: - Modifiers
extension CenterConstant {

public static func centerX(_ value: CGFloat) -> CenterConstant {
public extension CenterConstant {
static func centerX(_ value: CGFloat) -> CenterConstant {
return CenterConstant(centerX: value, centerY: 0)
}

public static func centerY(_ value: CGFloat) -> CenterConstant {
static func centerY(_ value: CGFloat) -> CenterConstant {
return CenterConstant(centerX: 0, centerY: value)
}
}

// MARK: - Operator
extension CenterConstant {

public static func & (lhs: CenterConstant, rhs: CenterConstant) -> CenterConstant {
public extension CenterConstant {
static func & (lhs: CenterConstant, rhs: CenterConstant) -> CenterConstant {
return .init(centerX: lhs.centerX + rhs.centerX, centerY: lhs.centerY + rhs.centerY)
}
}
6 changes: 3 additions & 3 deletions Constrictor/Constrictor/Sugar/Center/Constrictor+Center.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
import UIKit

// MARK: - Center
extension Constrictor {
public extension Constrictor {

@discardableResult
public func center(as relation: LayoutRelation = .equal,
func center(as relation: LayoutRelation = .equal,
in item: Anchorable,
with constant: CenterConstant,
prioritizeAs priority: LayoutPriority = .required,
Expand All @@ -27,7 +27,7 @@ extension Constrictor {
}

@discardableResult
public func center(as relation: LayoutRelation = .equal,
func center(as relation: LayoutRelation = .equal,
in item: Anchorable,
with constant: CGFloat = 0,
prioritizeAs priority: LayoutPriority = .required,
Expand Down
46 changes: 23 additions & 23 deletions Constrictor/Constrictor/Sugar/Edge/Constrictor+Edge.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,26 +9,26 @@
import UIKit

// MARK: - Edge
extension Constrictor {
public extension Constrictor {

@discardableResult
public func edge(as relation: LayoutRelation = .equal,
to item: Anchorable,
with constant: CGFloat,
prioritizeAs priority: LayoutPriority = .required,
is state: LayoutState = .enabled) -> Self {
func edge(as relation: LayoutRelation = .equal,
to item: Anchorable,
with constant: CGFloat,
prioritizeAs priority: LayoutPriority = .required,
is state: LayoutState = .enabled) -> Self {

edge(as: relation, to: item, with: .all(constant), prioritizeAs: priority, is: state)

return self
}

@discardableResult
public func edge(as relation: LayoutRelation = .equal,
to item: Anchorable,
with constant: EdgeConstant = .zero,
prioritizeAs priority: LayoutPriority = .required,
is state: LayoutState = .enabled) -> Self {
func edge(as relation: LayoutRelation = .equal,
to item: Anchorable,
with constant: EdgeConstant = .zero,
prioritizeAs priority: LayoutPriority = .required,
is state: LayoutState = .enabled) -> Self {

top(as: relation, to: item, .top, with: constant.top, prioritizeAs: priority, is: state)
bottom(as: relation, to: item, .bottom, with: constant.bottom, prioritizeAs: priority, is: state)
Expand All @@ -39,12 +39,12 @@ extension Constrictor {
}

@discardableResult
public func edge(as relation: LayoutRelation = .equal,
to item: Anchorable,
_ attributes: EdgeAnchor ...,
with constant: CGFloat,
prioritizeAs priority: LayoutPriority = .required,
is state: LayoutState = .enabled) -> Self {
func edge(as relation: LayoutRelation = .equal,
to item: Anchorable,
_ attributes: EdgeAnchor ...,
with constant: CGFloat,
prioritizeAs priority: LayoutPriority = .required,
is state: LayoutState = .enabled) -> Self {

internalVariadicEdge(as: relation, to: item, attributes, with: .all(constant),
prioritizeAs: priority, is: state)
Expand All @@ -53,12 +53,12 @@ extension Constrictor {
}

@discardableResult
public func edge(as relation: LayoutRelation = .equal,
to item: Anchorable,
_ attributes: EdgeAnchor ...,
with constant: EdgeConstant = .zero,
prioritizeAs priority: LayoutPriority = .required,
is state: LayoutState = .enabled) -> Self {
func edge(as relation: LayoutRelation = .equal,
to item: Anchorable,
_ attributes: EdgeAnchor ...,
with constant: EdgeConstant = .zero,
prioritizeAs priority: LayoutPriority = .required,
is state: LayoutState = .enabled) -> Self {

internalVariadicEdge(as: relation, to: item, attributes, with: constant,
prioritizeAs: priority, is: state)
Expand Down
20 changes: 10 additions & 10 deletions Constrictor/Constrictor/Sugar/Edge/EdgeConstant.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,33 +18,33 @@ public struct EdgeConstant: Equatable {
}

// MARK: - Modifiers
extension EdgeConstant {
public extension EdgeConstant {

public static var zero: EdgeConstant {
static var zero: EdgeConstant {
return EdgeConstant(top: 0, bottom: 0, leading: 0, trailing: 0)
}

public static func top(_ value: CGFloat) -> EdgeConstant {
static func top(_ value: CGFloat) -> EdgeConstant {
return EdgeConstant(top: value, bottom: 0, leading: 0, trailing: 0)
}

public static func bottom(_ value: CGFloat) -> EdgeConstant {
static func bottom(_ value: CGFloat) -> EdgeConstant {
return EdgeConstant(top: 0, bottom: -value, leading: 0, trailing: 0)
}

public static func leading(_ value: CGFloat) -> EdgeConstant {
static func leading(_ value: CGFloat) -> EdgeConstant {
return EdgeConstant(top: 0, bottom: 0, leading: value, trailing: 0)
}

public static func trailing(_ value: CGFloat) -> EdgeConstant {
static func trailing(_ value: CGFloat) -> EdgeConstant {
return EdgeConstant(top: 0, bottom: 0, leading: 0, trailing: -value)
}

public static func vertical(_ value: CGFloat) -> EdgeConstant {
static func vertical(_ value: CGFloat) -> EdgeConstant {
return EdgeConstant(top: value, bottom: -value, leading: 0, trailing: 0)
}

public static func horizontal(_ value: CGFloat) -> EdgeConstant {
static func horizontal(_ value: CGFloat) -> EdgeConstant {
return EdgeConstant(top: 0, bottom: 0, leading: value, trailing: -value)
}

Expand All @@ -54,9 +54,9 @@ extension EdgeConstant {
}

// MARK: - Operator
extension EdgeConstant {
public extension EdgeConstant {

public static func & (lhs: EdgeConstant, rhs: EdgeConstant) -> EdgeConstant {
static func & (lhs: EdgeConstant, rhs: EdgeConstant) -> EdgeConstant {
return .init(top: lhs.top + rhs.top,
bottom: lhs.bottom + rhs.bottom,
leading: lhs.leading + rhs.leading,
Expand Down
42 changes: 21 additions & 21 deletions Constrictor/Constrictor/Sugar/Size/Constrictor+Size.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@
import UIKit

// MARK: - Size
extension Constrictor {
public extension Constrictor {

@discardableResult
public func size(as relation: LayoutRelation = .equal,
to item: Anchorable,
with constant: SizeConstant,
multiplyBy multiplier: CGFloat = 1,
prioritizeAs priority: LayoutPriority = .required,
is state: LayoutState = .enabled) -> Self {
func size(as relation: LayoutRelation = .equal,
to item: Anchorable,
with constant: SizeConstant,
multiplyBy multiplier: CGFloat = 1,
prioritizeAs priority: LayoutPriority = .required,
is state: LayoutState = .enabled) -> Self {

width(as: relation, to: item, .width, with: constant.width,
multiplyBy: multiplier, prioritizeAs: priority, is: state)
Expand All @@ -28,12 +28,12 @@ extension Constrictor {
}

@discardableResult
public func size(as relation: LayoutRelation = .equal,
to item: Anchorable,
with constant: CGFloat = 0,
multiplyBy multiplier: CGFloat = 1,
prioritizeAs priority: LayoutPriority = .required,
is state: LayoutState = .enabled) -> Self {
func size(as relation: LayoutRelation = .equal,
to item: Anchorable,
with constant: CGFloat = 0,
multiplyBy multiplier: CGFloat = 1,
prioritizeAs priority: LayoutPriority = .required,
is state: LayoutState = .enabled) -> Self {

width(as: relation, to: item, .width, with: constant,
multiplyBy: multiplier, prioritizeAs: priority, is: state)
Expand All @@ -44,10 +44,10 @@ extension Constrictor {
}

@discardableResult
public func size(as relation: LayoutRelation = .equal,
to constant: CGFloat,
prioritizeAs priority: LayoutPriority = .required,
is state: LayoutState = .enabled) -> Self {
func size(as relation: LayoutRelation = .equal,
to constant: CGFloat,
prioritizeAs priority: LayoutPriority = .required,
is state: LayoutState = .enabled) -> Self {

width(as: relation, to: constant, prioritizeAs: priority, is: state)
height(as: relation, to: constant, prioritizeAs: priority, is: state)
Expand All @@ -56,10 +56,10 @@ extension Constrictor {
}

@discardableResult
public func size(as relation: LayoutRelation = .equal,
to constant: SizeConstant,
prioritizeAs priority: LayoutPriority = .required,
is state: LayoutState = .enabled) -> Self {
func size(as relation: LayoutRelation = .equal,
to constant: SizeConstant,
prioritizeAs priority: LayoutPriority = .required,
is state: LayoutState = .enabled) -> Self {

width(as: relation, to: constant.width, prioritizeAs: priority, is: state)
height(as: relation, to: constant.height, prioritizeAs: priority, is: state)
Expand Down
Loading

0 comments on commit 0d9984d

Please sign in to comment.