mirror of https://github.com/SnapKit/SnapKit
Merge branch 'develop' of github.com:SnapKit/SnapKit into develop
This commit is contained in:
commit
ee34ec542f
|
@ -21,7 +21,7 @@
|
||||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
// THE SOFTWARE.
|
// THE SOFTWARE.
|
||||||
|
|
||||||
#if os(iOS)
|
#if os(iOS) || os(tvOS)
|
||||||
import UIKit
|
import UIKit
|
||||||
#else
|
#else
|
||||||
import AppKit
|
import AppKit
|
||||||
|
@ -119,7 +119,7 @@ internal class ConcreteConstraint: Constraint {
|
||||||
self.updatePriority(Float(750.0))
|
self.updatePriority(Float(750.0))
|
||||||
}
|
}
|
||||||
internal override func updatePriorityMedium() -> Void {
|
internal override func updatePriorityMedium() -> Void {
|
||||||
#if os(iOS)
|
#if os(iOS) || os(tvOS)
|
||||||
self.updatePriority(Float(500.0))
|
self.updatePriority(Float(500.0))
|
||||||
#else
|
#else
|
||||||
self.updatePriority(Float(501.0))
|
self.updatePriority(Float(501.0))
|
||||||
|
@ -251,7 +251,7 @@ internal class ConcreteConstraint: Constraint {
|
||||||
let layoutConstant: CGFloat = layoutToAttribute.snp_constantForValue(self.constant)
|
let layoutConstant: CGFloat = layoutToAttribute.snp_constantForValue(self.constant)
|
||||||
|
|
||||||
// get layout to
|
// get layout to
|
||||||
#if os(iOS)
|
#if os(iOS) || os(tvOS)
|
||||||
var layoutTo: AnyObject? = self.toItem.view ?? self.toItem.layoutSupport
|
var layoutTo: AnyObject? = self.toItem.view ?? self.toItem.layoutSupport
|
||||||
#else
|
#else
|
||||||
var layoutTo: AnyObject? = self.toItem.view
|
var layoutTo: AnyObject? = self.toItem.view
|
||||||
|
@ -397,7 +397,7 @@ private extension NSLayoutAttribute {
|
||||||
}
|
}
|
||||||
// CGPoint
|
// CGPoint
|
||||||
else if let point = value as? CGPoint {
|
else if let point = value as? CGPoint {
|
||||||
#if os(iOS)
|
#if os(iOS) || os(tvOS)
|
||||||
switch self {
|
switch self {
|
||||||
case .Left, .CenterX, .LeftMargin, .CenterXWithinMargins: return point.x
|
case .Left, .CenterX, .LeftMargin, .CenterXWithinMargins: return point.x
|
||||||
case .Top, .CenterY, .TopMargin, .CenterYWithinMargins, .Baseline, .FirstBaseline: return point.y
|
case .Top, .CenterY, .TopMargin, .CenterYWithinMargins, .Baseline, .FirstBaseline: return point.y
|
||||||
|
@ -422,7 +422,7 @@ private extension NSLayoutAttribute {
|
||||||
}
|
}
|
||||||
// EdgeInsets
|
// EdgeInsets
|
||||||
else if let insets = value as? EdgeInsets {
|
else if let insets = value as? EdgeInsets {
|
||||||
#if os(iOS)
|
#if os(iOS) || os(tvOS)
|
||||||
switch self {
|
switch self {
|
||||||
case .Left, .CenterX, .LeftMargin, .CenterXWithinMargins: return insets.left
|
case .Left, .CenterX, .LeftMargin, .CenterXWithinMargins: return insets.left
|
||||||
case .Top, .CenterY, .TopMargin, .CenterYWithinMargins, .Baseline, .FirstBaseline: return insets.top
|
case .Top, .CenterY, .TopMargin, .CenterYWithinMargins, .Baseline, .FirstBaseline: return insets.top
|
||||||
|
|
|
@ -21,7 +21,7 @@
|
||||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
// THE SOFTWARE.
|
// THE SOFTWARE.
|
||||||
|
|
||||||
#if os(iOS)
|
#if os(iOS) || os(tvOS)
|
||||||
import UIKit
|
import UIKit
|
||||||
#else
|
#else
|
||||||
import AppKit
|
import AppKit
|
||||||
|
@ -133,7 +133,7 @@ internal struct ConstraintAttributes: OptionSetType, BooleanType {
|
||||||
attrs.append(.Baseline)
|
attrs.append(.Baseline)
|
||||||
}
|
}
|
||||||
|
|
||||||
#if os(iOS)
|
#if os(iOS) || os(tvOS)
|
||||||
#if SNAPKIT_DEPLOYMENT_LEGACY
|
#if SNAPKIT_DEPLOYMENT_LEGACY
|
||||||
guard #available(iOS 8.0, *) else {
|
guard #available(iOS 8.0, *) else {
|
||||||
return attrs
|
return attrs
|
||||||
|
|
|
@ -21,7 +21,7 @@
|
||||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
// THE SOFTWARE.
|
// THE SOFTWARE.
|
||||||
|
|
||||||
#if os(iOS)
|
#if os(iOS) || os(tvOS)
|
||||||
import UIKit
|
import UIKit
|
||||||
#else
|
#else
|
||||||
import AppKit
|
import AppKit
|
||||||
|
@ -95,6 +95,8 @@ public protocol ConstraintDescriptionRelatable: class {
|
||||||
func equalTo(other: View) -> ConstraintDescriptionEditable
|
func equalTo(other: View) -> ConstraintDescriptionEditable
|
||||||
@available(iOS 7.0, *)
|
@available(iOS 7.0, *)
|
||||||
func equalTo(other: LayoutSupport) -> ConstraintDescriptionEditable
|
func equalTo(other: LayoutSupport) -> ConstraintDescriptionEditable
|
||||||
|
@available(iOS 9.0, *)
|
||||||
|
func equalTo(other: NSLayoutAnchor) -> ConstraintDescriptionEditable
|
||||||
func equalTo(other: Float) -> ConstraintDescriptionEditable
|
func equalTo(other: Float) -> ConstraintDescriptionEditable
|
||||||
func equalTo(other: Double) -> ConstraintDescriptionEditable
|
func equalTo(other: Double) -> ConstraintDescriptionEditable
|
||||||
func equalTo(other: CGFloat) -> ConstraintDescriptionEditable
|
func equalTo(other: CGFloat) -> ConstraintDescriptionEditable
|
||||||
|
@ -108,6 +110,8 @@ public protocol ConstraintDescriptionRelatable: class {
|
||||||
func lessThanOrEqualTo(other: View) -> ConstraintDescriptionEditable
|
func lessThanOrEqualTo(other: View) -> ConstraintDescriptionEditable
|
||||||
@available(iOS 7.0, *)
|
@available(iOS 7.0, *)
|
||||||
func lessThanOrEqualTo(other: LayoutSupport) -> ConstraintDescriptionEditable
|
func lessThanOrEqualTo(other: LayoutSupport) -> ConstraintDescriptionEditable
|
||||||
|
@available(iOS 9.0, *)
|
||||||
|
func lessThanOrEqualTo(other: NSLayoutAnchor) -> ConstraintDescriptionEditable
|
||||||
func lessThanOrEqualTo(other: Float) -> ConstraintDescriptionEditable
|
func lessThanOrEqualTo(other: Float) -> ConstraintDescriptionEditable
|
||||||
func lessThanOrEqualTo(other: Double) -> ConstraintDescriptionEditable
|
func lessThanOrEqualTo(other: Double) -> ConstraintDescriptionEditable
|
||||||
func lessThanOrEqualTo(other: CGFloat) -> ConstraintDescriptionEditable
|
func lessThanOrEqualTo(other: CGFloat) -> ConstraintDescriptionEditable
|
||||||
|
@ -121,6 +125,8 @@ public protocol ConstraintDescriptionRelatable: class {
|
||||||
func greaterThanOrEqualTo(other: View) -> ConstraintDescriptionEditable
|
func greaterThanOrEqualTo(other: View) -> ConstraintDescriptionEditable
|
||||||
@available(iOS 7.0, *)
|
@available(iOS 7.0, *)
|
||||||
func greaterThanOrEqualTo(other: LayoutSupport) -> ConstraintDescriptionEditable
|
func greaterThanOrEqualTo(other: LayoutSupport) -> ConstraintDescriptionEditable
|
||||||
|
@available(iOS 9.0, *)
|
||||||
|
func greaterThanOrEqualTo(other: NSLayoutAnchor) -> ConstraintDescriptionEditable
|
||||||
func greaterThanOrEqualTo(other: Float) -> ConstraintDescriptionEditable
|
func greaterThanOrEqualTo(other: Float) -> ConstraintDescriptionEditable
|
||||||
func greaterThanOrEqualTo(other: Double) -> ConstraintDescriptionEditable
|
func greaterThanOrEqualTo(other: Double) -> ConstraintDescriptionEditable
|
||||||
func greaterThanOrEqualTo(other: CGFloat) -> ConstraintDescriptionEditable
|
func greaterThanOrEqualTo(other: CGFloat) -> ConstraintDescriptionEditable
|
||||||
|
@ -224,6 +230,10 @@ internal class ConstraintDescription: ConstraintDescriptionExtendable, Constrain
|
||||||
internal func equalTo(other: LayoutSupport) -> ConstraintDescriptionEditable {
|
internal func equalTo(other: LayoutSupport) -> ConstraintDescriptionEditable {
|
||||||
return self.constrainTo(other, relation: .Equal)
|
return self.constrainTo(other, relation: .Equal)
|
||||||
}
|
}
|
||||||
|
@available(iOS 9.0, *)
|
||||||
|
internal func equalTo(other: NSLayoutAnchor) -> ConstraintDescriptionEditable {
|
||||||
|
return self.constrainTo(other, relation: .Equal)
|
||||||
|
}
|
||||||
internal func equalTo(other: Float) -> ConstraintDescriptionEditable {
|
internal func equalTo(other: Float) -> ConstraintDescriptionEditable {
|
||||||
return self.constrainTo(other, relation: .Equal)
|
return self.constrainTo(other, relation: .Equal)
|
||||||
}
|
}
|
||||||
|
@ -261,6 +271,10 @@ internal class ConstraintDescription: ConstraintDescriptionExtendable, Constrain
|
||||||
internal func lessThanOrEqualTo(other: LayoutSupport) -> ConstraintDescriptionEditable {
|
internal func lessThanOrEqualTo(other: LayoutSupport) -> ConstraintDescriptionEditable {
|
||||||
return self.constrainTo(other, relation: .LessThanOrEqualTo)
|
return self.constrainTo(other, relation: .LessThanOrEqualTo)
|
||||||
}
|
}
|
||||||
|
@available(iOS 9.0, *)
|
||||||
|
internal func lessThanOrEqualTo(other: NSLayoutAnchor) -> ConstraintDescriptionEditable {
|
||||||
|
return self.constrainTo(other, relation: .LessThanOrEqualTo)
|
||||||
|
}
|
||||||
internal func lessThanOrEqualTo(other: Float) -> ConstraintDescriptionEditable {
|
internal func lessThanOrEqualTo(other: Float) -> ConstraintDescriptionEditable {
|
||||||
return self.constrainTo(other, relation: .LessThanOrEqualTo)
|
return self.constrainTo(other, relation: .LessThanOrEqualTo)
|
||||||
}
|
}
|
||||||
|
@ -298,6 +312,10 @@ internal class ConstraintDescription: ConstraintDescriptionExtendable, Constrain
|
||||||
internal func greaterThanOrEqualTo(other: LayoutSupport) -> ConstraintDescriptionEditable {
|
internal func greaterThanOrEqualTo(other: LayoutSupport) -> ConstraintDescriptionEditable {
|
||||||
return self.constrainTo(other, relation: .GreaterThanOrEqualTo)
|
return self.constrainTo(other, relation: .GreaterThanOrEqualTo)
|
||||||
}
|
}
|
||||||
|
@available(iOS 9.0, *)
|
||||||
|
internal func greaterThanOrEqualTo(other: NSLayoutAnchor) -> ConstraintDescriptionEditable {
|
||||||
|
return self.constrainTo(other, relation: .LessThanOrEqualTo)
|
||||||
|
}
|
||||||
internal func greaterThanOrEqualTo(other: Float) -> ConstraintDescriptionEditable {
|
internal func greaterThanOrEqualTo(other: Float) -> ConstraintDescriptionEditable {
|
||||||
return self.constrainTo(other, relation: .GreaterThanOrEqualTo)
|
return self.constrainTo(other, relation: .GreaterThanOrEqualTo)
|
||||||
}
|
}
|
||||||
|
@ -446,7 +464,7 @@ internal class ConstraintDescription: ConstraintDescriptionExtendable, Constrain
|
||||||
return self.priority(750.0)
|
return self.priority(750.0)
|
||||||
}
|
}
|
||||||
internal func priorityMedium() -> ConstraintDescriptionFinalizable {
|
internal func priorityMedium() -> ConstraintDescriptionFinalizable {
|
||||||
#if os(iOS)
|
#if os(iOS) || os(tvOS)
|
||||||
return self.priority(500.0)
|
return self.priority(500.0)
|
||||||
#else
|
#else
|
||||||
return self.priority(501.0)
|
return self.priority(501.0)
|
||||||
|
@ -547,6 +565,11 @@ internal class ConstraintDescription: ConstraintDescriptionExtendable, Constrain
|
||||||
return constrainTo(ConstraintItem(object: other, attributes: ConstraintAttributes.None), relation: relation)
|
return constrainTo(ConstraintItem(object: other, attributes: ConstraintAttributes.None), relation: relation)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@available(iOS 9.0, *)
|
||||||
|
private func constrainTo(other: NSLayoutAnchor, relation: ConstraintRelation) -> ConstraintDescription {
|
||||||
|
return constrainTo(ConstraintItem(object: other, attributes: ConstraintAttributes.None), relation: relation)
|
||||||
|
}
|
||||||
|
|
||||||
private func constrainTo(other: Float, relation: ConstraintRelation) -> ConstraintDescription {
|
private func constrainTo(other: Float, relation: ConstraintRelation) -> ConstraintDescription {
|
||||||
self.constant = other
|
self.constant = other
|
||||||
return constrainTo(ConstraintItem(object: nil, attributes: ConstraintAttributes.None), relation: relation)
|
return constrainTo(ConstraintItem(object: nil, attributes: ConstraintAttributes.None), relation: relation)
|
||||||
|
|
|
@ -21,7 +21,7 @@
|
||||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
// THE SOFTWARE.
|
// THE SOFTWARE.
|
||||||
|
|
||||||
#if os(iOS)
|
#if os(iOS) || os(tvOS)
|
||||||
import UIKit
|
import UIKit
|
||||||
#else
|
#else
|
||||||
import AppKit
|
import AppKit
|
||||||
|
|
|
@ -21,7 +21,7 @@
|
||||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
// THE SOFTWARE.
|
// THE SOFTWARE.
|
||||||
|
|
||||||
#if os(iOS)
|
#if os(iOS) || os(tvOS)
|
||||||
import UIKit
|
import UIKit
|
||||||
#else
|
#else
|
||||||
import AppKit
|
import AppKit
|
||||||
|
|
|
@ -21,7 +21,7 @@
|
||||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
// THE SOFTWARE.
|
// THE SOFTWARE.
|
||||||
|
|
||||||
#if os(iOS)
|
#if os(iOS) || os(tvOS)
|
||||||
import UIKit
|
import UIKit
|
||||||
#else
|
#else
|
||||||
import AppKit
|
import AppKit
|
||||||
|
|
|
@ -21,7 +21,7 @@
|
||||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
// THE SOFTWARE.
|
// THE SOFTWARE.
|
||||||
|
|
||||||
#if os(iOS)
|
#if os(iOS) || os(tvOS)
|
||||||
import UIKit
|
import UIKit
|
||||||
#else
|
#else
|
||||||
import AppKit
|
import AppKit
|
||||||
|
@ -149,7 +149,7 @@ private extension NSLayoutRelation {
|
||||||
private extension NSLayoutAttribute {
|
private extension NSLayoutAttribute {
|
||||||
|
|
||||||
private var snp_description: String {
|
private var snp_description: String {
|
||||||
#if os(iOS)
|
#if os(iOS) || os(tvOS)
|
||||||
switch self {
|
switch self {
|
||||||
case .NotAnAttribute: return "notAnAttribute"
|
case .NotAnAttribute: return "notAnAttribute"
|
||||||
case .Top: return "top"
|
case .Top: return "top"
|
||||||
|
|
|
@ -21,7 +21,7 @@
|
||||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
// THE SOFTWARE.
|
// THE SOFTWARE.
|
||||||
|
|
||||||
#if os(iOS)
|
#if os(iOS) || os(tvOS)
|
||||||
import UIKit
|
import UIKit
|
||||||
public typealias EdgeInsets = UIEdgeInsets
|
public typealias EdgeInsets = UIEdgeInsets
|
||||||
public func EdgeInsetsMake(top: CGFloat, left: CGFloat, bottom: CGFloat, right: CGFloat) -> EdgeInsets {
|
public func EdgeInsetsMake(top: CGFloat, left: CGFloat, bottom: CGFloat, right: CGFloat) -> EdgeInsets {
|
||||||
|
|
|
@ -21,7 +21,7 @@
|
||||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
// THE SOFTWARE.
|
// THE SOFTWARE.
|
||||||
|
|
||||||
#if os(iOS)
|
#if os(iOS) || os(tvOS)
|
||||||
import UIKit
|
import UIKit
|
||||||
#else
|
#else
|
||||||
import AppKit
|
import AppKit
|
||||||
|
|
|
@ -21,7 +21,7 @@
|
||||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
// THE SOFTWARE.
|
// THE SOFTWARE.
|
||||||
|
|
||||||
#if os(iOS)
|
#if os(iOS) || os(tvOS)
|
||||||
import UIKit
|
import UIKit
|
||||||
public typealias InterfaceLayoutDirection = UIUserInterfaceLayoutDirection
|
public typealias InterfaceLayoutDirection = UIUserInterfaceLayoutDirection
|
||||||
public typealias LayoutSupport = UILayoutSupport
|
public typealias LayoutSupport = UILayoutSupport
|
||||||
|
|
|
@ -21,7 +21,7 @@
|
||||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
// THE SOFTWARE.
|
// THE SOFTWARE.
|
||||||
|
|
||||||
#if os(iOS)
|
#if os(iOS) || os(tvOS)
|
||||||
import UIKit
|
import UIKit
|
||||||
public typealias View = UIView
|
public typealias View = UIView
|
||||||
#else
|
#else
|
||||||
|
|
|
@ -21,7 +21,7 @@
|
||||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
// THE SOFTWARE.
|
// THE SOFTWARE.
|
||||||
|
|
||||||
#if os(iOS)
|
#if os(iOS) || os(tvOS)
|
||||||
import UIKit
|
import UIKit
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
#if os(iOS)
|
#if os(iOS) || os(tvOS)
|
||||||
import UIKit
|
import UIKit
|
||||||
typealias View = UIView
|
typealias View = UIView
|
||||||
extension View {
|
extension View {
|
||||||
|
@ -30,7 +30,7 @@ class SnapKitTests: XCTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
func testLayoutGuideConstraints() {
|
func testLayoutGuideConstraints() {
|
||||||
#if os(iOS)
|
#if os(iOS) || os(tvOS)
|
||||||
let vc = UIViewController()
|
let vc = UIViewController()
|
||||||
vc.view = UIView(frame: CGRectMake(0, 0, 300, 300))
|
vc.view = UIView(frame: CGRectMake(0, 0, 300, 300))
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue