Skip to content

Commit 35e8835

Browse files
authored
Use << for ConstraintAttributes options (SnapKit#659)
* Use << for ConstraintAttributes options * iPhone 6s is not supported by the latest Xcode
1 parent dfe862d commit 35e8835

File tree

2 files changed

+43
-43
lines changed

2 files changed

+43
-43
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ osx_image: xcode11
33

44
env:
55
- ACTION=test PLATFORM=Mac DESTINATION='platform=macOS'
6-
- ACTION=test PLATFORM=iOS DESTINATION='platform=iOS Simulator,name=iPhone 6S'
6+
- ACTION=test PLATFORM=iOS DESTINATION='platform=iOS Simulator,name=iPhone 8'
77
- ACTION=test PLATFORM=tvOS DESTINATION='platform=tvOS Simulator,name=Apple TV 4K (at 1080p)'
88

99
script:

Source/ConstraintAttributes.swift

Lines changed: 42 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -56,65 +56,65 @@ internal struct ConstraintAttributes : OptionSet, ExpressibleByIntegerLiteral {
5656

5757
// normal
5858

59-
internal static var none: ConstraintAttributes { return 0 }
60-
internal static var left: ConstraintAttributes { return 1 }
61-
internal static var top: ConstraintAttributes { return 2 }
62-
internal static var right: ConstraintAttributes { return 4 }
63-
internal static var bottom: ConstraintAttributes { return 8 }
64-
internal static var leading: ConstraintAttributes { return 16 }
65-
internal static var trailing: ConstraintAttributes { return 32 }
66-
internal static var width: ConstraintAttributes { return 64 }
67-
internal static var height: ConstraintAttributes { return 128 }
68-
internal static var centerX: ConstraintAttributes { return 256 }
69-
internal static var centerY: ConstraintAttributes { return 512 }
70-
internal static var lastBaseline: ConstraintAttributes { return 1024 }
59+
internal static let none: ConstraintAttributes = 0
60+
internal static let left: ConstraintAttributes = ConstraintAttributes(UInt(1) << 0)
61+
internal static let top: ConstraintAttributes = ConstraintAttributes(UInt(1) << 1)
62+
internal static let right: ConstraintAttributes = ConstraintAttributes(UInt(1) << 2)
63+
internal static let bottom: ConstraintAttributes = ConstraintAttributes(UInt(1) << 3)
64+
internal static let leading: ConstraintAttributes = ConstraintAttributes(UInt(1) << 4)
65+
internal static let trailing: ConstraintAttributes = ConstraintAttributes(UInt(1) << 5)
66+
internal static let width: ConstraintAttributes = ConstraintAttributes(UInt(1) << 6)
67+
internal static let height: ConstraintAttributes = ConstraintAttributes(UInt(1) << 7)
68+
internal static let centerX: ConstraintAttributes = ConstraintAttributes(UInt(1) << 8)
69+
internal static let centerY: ConstraintAttributes = ConstraintAttributes(UInt(1) << 9)
70+
internal static let lastBaseline: ConstraintAttributes = ConstraintAttributes(UInt(1) << 10)
7171

7272
@available(iOS 8.0, OSX 10.11, *)
73-
internal static var firstBaseline: ConstraintAttributes { return 2048 }
74-
73+
internal static let firstBaseline: ConstraintAttributes = ConstraintAttributes(UInt(1) << 11)
74+
7575
@available(iOS 8.0, *)
76-
internal static var leftMargin: ConstraintAttributes { return 4096 }
77-
76+
internal static let leftMargin: ConstraintAttributes = ConstraintAttributes(UInt(1) << 12)
77+
7878
@available(iOS 8.0, *)
79-
internal static var rightMargin: ConstraintAttributes { return 8192 }
80-
79+
internal static let rightMargin: ConstraintAttributes = ConstraintAttributes(UInt(1) << 13)
80+
8181
@available(iOS 8.0, *)
82-
internal static var topMargin: ConstraintAttributes { return 16384 }
83-
82+
internal static let topMargin: ConstraintAttributes = ConstraintAttributes(UInt(1) << 14)
83+
8484
@available(iOS 8.0, *)
85-
internal static var bottomMargin: ConstraintAttributes { return 32768 }
86-
85+
internal static let bottomMargin: ConstraintAttributes = ConstraintAttributes(UInt(1) << 15)
86+
8787
@available(iOS 8.0, *)
88-
internal static var leadingMargin: ConstraintAttributes { return 65536 }
89-
88+
internal static let leadingMargin: ConstraintAttributes = ConstraintAttributes(UInt(1) << 16)
89+
9090
@available(iOS 8.0, *)
91-
internal static var trailingMargin: ConstraintAttributes { return 131072 }
92-
91+
internal static let trailingMargin: ConstraintAttributes = ConstraintAttributes(UInt(1) << 17)
92+
9393
@available(iOS 8.0, *)
94-
internal static var centerXWithinMargins: ConstraintAttributes { return 262144 }
95-
94+
internal static let centerXWithinMargins: ConstraintAttributes = ConstraintAttributes(UInt(1) << 18)
95+
9696
@available(iOS 8.0, *)
97-
internal static var centerYWithinMargins: ConstraintAttributes { return 524288 }
97+
internal static let centerYWithinMargins: ConstraintAttributes = ConstraintAttributes(UInt(1) << 19)
9898

9999
// aggregates
100100

101-
internal static var edges: ConstraintAttributes { return 15 }
102-
internal static var horizontalEdges: ConstraintAttributes { return 5 }
103-
internal static var verticalEdges: ConstraintAttributes { return 10 }
104-
internal static var directionalEdges: ConstraintAttributes { return 58 }
105-
internal static var directionalHorizontalEdges: ConstraintAttributes { return 48 }
106-
internal static var directionalVerticalEdges: ConstraintAttributes { return 10 }
107-
internal static var size: ConstraintAttributes { return 192 }
108-
internal static var center: ConstraintAttributes { return 768 }
109-
101+
internal static let edges: ConstraintAttributes = [.horizontalEdges, .verticalEdges]
102+
internal static let horizontalEdges: ConstraintAttributes = [.left, .right]
103+
internal static let verticalEdges: ConstraintAttributes = [.top, .bottom]
104+
internal static let directionalEdges: ConstraintAttributes = [.directionalHorizontalEdges, .directionalVerticalEdges]
105+
internal static let directionalHorizontalEdges: ConstraintAttributes = [.leading, .trailing]
106+
internal static let directionalVerticalEdges: ConstraintAttributes = [.top, .bottom]
107+
internal static let size: ConstraintAttributes = [.width, .height]
108+
internal static let center: ConstraintAttributes = [.centerX, .centerY]
109+
110110
@available(iOS 8.0, *)
111-
internal static var margins: ConstraintAttributes { return 61440 }
112-
111+
internal static let margins: ConstraintAttributes = [.leftMargin, .topMargin, .rightMargin, .bottomMargin]
112+
113113
@available(iOS 8.0, *)
114-
internal static var directionalMargins: ConstraintAttributes { return 245760 }
114+
internal static let directionalMargins: ConstraintAttributes = [.leadingMargin, .topMargin, .trailingMargin, .bottomMargin]
115115

116116
@available(iOS 8.0, *)
117-
internal static var centerWithinMargins: ConstraintAttributes { return 786432 }
117+
internal static let centerWithinMargins: ConstraintAttributes = [.centerXWithinMargins, .centerYWithinMargins]
118118

119119
internal var layoutAttributes:[LayoutAttribute] {
120120
var attrs = [LayoutAttribute]()

0 commit comments

Comments
 (0)