Skip to content

Commit 46cf5ea

Browse files
author
Luc Dion
committed
initial commit
1 parent 5f92ab4 commit 46cf5ea

File tree

11 files changed

+154
-45
lines changed

11 files changed

+154
-45
lines changed

.swiftlint.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ disabled_rules: # rule identifiers to exclude from running
1818
- type_body_length
1919
- cyclomatic_complexity
2020
- nimble_operator
21-
- variable_name
21+
- identifier_name
2222
- line_length
2323

2424
excluded: # paths to ignore during linting. overridden by `included`.

Example/.swiftlint.yml

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,25 @@
11
opt_in_rules: # some rules are only opt-in
2-
- attributes
32
- closure_end_indentation
43
- closure_spacing
5-
- empty_count
64
- explicit_init
75
- nimble_operator
8-
- number_separator
96
- operator_usage_whitespace
107
- overridden_super_call
118
- private_outlet
129
- prohibited_super_call
1310
- redundant_nil_coalescing
1411

1512
disabled_rules: # rule identifiers to exclude from running
16-
# - function_body_length
13+
- function_body_length
1714
- trailing_whitespace
1815
- force_cast
1916
- type_name
20-
# - todo
2117
- file_length
22-
# - type_body_length
23-
# - valid_docs
24-
# - cyclomatic_complexity
25-
# - nesting
26-
# - function_parameter_count
27-
# - large_tuple
28-
# - variable_name
29-
# - empty_parentheses_with_trailing_closure
18+
- type_body_length
19+
- cyclomatic_complexity
20+
- nimble_operator
21+
- identifier_name
3022
- line_length
3123

3224
excluded: # paths to ignore during linting. overridden by `included`.
3325
- Pods
34-

Example/PinLayoutSample.xcodeproj/project.pbxproj

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -409,7 +409,7 @@
409409
isa = PBXProject;
410410
attributes = {
411411
LastSwiftUpdateCheck = 0900;
412-
LastUpgradeCheck = 0820;
412+
LastUpgradeCheck = 0900;
413413
ORGANIZATIONNAME = Mirego;
414414
TargetAttributes = {
415415
249EFE3E1E64FAFE00165E39 = {
@@ -616,15 +616,21 @@
616616
CLANG_CXX_LIBRARY = "libc++";
617617
CLANG_ENABLE_MODULES = YES;
618618
CLANG_ENABLE_OBJC_ARC = YES;
619+
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
619620
CLANG_WARN_BOOL_CONVERSION = YES;
621+
CLANG_WARN_COMMA = YES;
620622
CLANG_WARN_CONSTANT_CONVERSION = YES;
621623
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
622624
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
623625
CLANG_WARN_EMPTY_BODY = YES;
624626
CLANG_WARN_ENUM_CONVERSION = YES;
625627
CLANG_WARN_INFINITE_RECURSION = YES;
626628
CLANG_WARN_INT_CONVERSION = YES;
629+
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
630+
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
627631
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
632+
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
633+
CLANG_WARN_STRICT_PROTOTYPES = YES;
628634
CLANG_WARN_SUSPICIOUS_MOVE = YES;
629635
CLANG_WARN_UNREACHABLE_CODE = YES;
630636
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
@@ -666,15 +672,21 @@
666672
CLANG_CXX_LIBRARY = "libc++";
667673
CLANG_ENABLE_MODULES = YES;
668674
CLANG_ENABLE_OBJC_ARC = YES;
675+
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
669676
CLANG_WARN_BOOL_CONVERSION = YES;
677+
CLANG_WARN_COMMA = YES;
670678
CLANG_WARN_CONSTANT_CONVERSION = YES;
671679
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
672680
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
673681
CLANG_WARN_EMPTY_BODY = YES;
674682
CLANG_WARN_ENUM_CONVERSION = YES;
675683
CLANG_WARN_INFINITE_RECURSION = YES;
676684
CLANG_WARN_INT_CONVERSION = YES;
685+
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
686+
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
677687
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
688+
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
689+
CLANG_WARN_STRICT_PROTOTYPES = YES;
678690
CLANG_WARN_SUSPICIOUS_MOVE = YES;
679691
CLANG_WARN_UNREACHABLE_CODE = YES;
680692
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;

Example/PinLayoutSample.xcodeproj/xcshareddata/xcschemes/PinLayoutSample.xcscheme

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<Scheme
3-
LastUpgradeVersion = "0830"
3+
LastUpgradeVersion = "0900"
44
version = "1.3">
55
<BuildAction
66
parallelizeBuildables = "YES"
@@ -26,6 +26,7 @@
2626
buildConfiguration = "Debug"
2727
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
2828
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
29+
language = ""
2930
shouldUseLaunchSchemeArgsEnv = "YES">
3031
<Testables>
3132
</Testables>
@@ -45,6 +46,7 @@
4546
buildConfiguration = "Debug"
4647
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
4748
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
49+
language = ""
4850
launchStyle = "0"
4951
useCustomWorkingDirectory = "NO"
5052
ignoresPersistentStateOnLaunch = "NO"

PinLayout.xcodeproj/project.pbxproj

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
242723731F008BF7006A5C3A /* MinMaxWidthHeightSpec.swift in Sources */ = {isa = PBXBuildFile; fileRef = 242723711F008B85006A5C3A /* MinMaxWidthHeightSpec.swift */; };
1515
242E8DC31EED5AB2005935FB /* RelativePositionMultipleViewsSpec.swift in Sources */ = {isa = PBXBuildFile; fileRef = 242E8DC11EED5982005935FB /* RelativePositionMultipleViewsSpec.swift */; };
1616
244C6E151E776A0C0074FC74 /* MarginsSpec.swift in Sources */ = {isa = PBXBuildFile; fileRef = 244C6E141E776A0C0074FC74 /* MarginsSpec.swift */; };
17-
244DF3031EF46F6C0090508B /* InfoTVOS.plist in Resources */ = {isa = PBXBuildFile; fileRef = 244DF3011EF46F670090508B /* InfoTVOS.plist */; };
1817
244DF3061EF46FC20090508B /* PinLayoutTVOS.h in Headers */ = {isa = PBXBuildFile; fileRef = 244DF3041EF46FB90090508B /* PinLayoutTVOS.h */; settings = {ATTRIBUTES = (Public, ); }; };
1918
245302071ED05FD000E13F29 /* AccurencyTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 245302061ED05FD000E13F29 /* AccurencyTests.swift */; };
2019
2469C4FC1E74855D00073BEE /* PinEdgeCoordinateSpec.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2469C4FB1E74855D00073BEE /* PinEdgeCoordinateSpec.swift */; };
@@ -32,7 +31,6 @@
3231
249EFE841E64FB4C00165E39 /* PinLayout.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 249EFE7A1E64FB4C00165E39 /* PinLayout.framework */; };
3332
249EFE891E64FB4C00165E39 /* PinLayoutTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 249EFE881E64FB4C00165E39 /* PinLayoutTests.swift */; };
3433
24A9782E1EE845BB002BD0F1 /* Coordinates.swift in Sources */ = {isa = PBXBuildFile; fileRef = 24A9782D1EE845BB002BD0F1 /* Coordinates.swift */; };
35-
24A978311EE845CD002BD0F1 /* Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = 24A9782F1EE845CD002BD0F1 /* Info.plist */; };
3634
24A978321EE845CD002BD0F1 /* PinLayout.h in Headers */ = {isa = PBXBuildFile; fileRef = 24A978301EE845CD002BD0F1 /* PinLayout.h */; settings = {ATTRIBUTES = (Public, ); }; };
3735
24B02B091F2A713000C18179 /* PinLayout+Filters.swift in Sources */ = {isa = PBXBuildFile; fileRef = 24949A2D1EF69474003643D3 /* PinLayout+Filters.swift */; };
3836
24B02B0A1F2A713300C18179 /* PinLayout.swift in Sources */ = {isa = PBXBuildFile; fileRef = DFC97CA61E8A8F2C001545D5 /* PinLayout.swift */; };
@@ -312,7 +310,6 @@
312310
249EFE751E64FB4C00165E39 /* Sources */,
313311
249EFE761E64FB4C00165E39 /* Frameworks */,
314312
249EFE771E64FB4C00165E39 /* Headers */,
315-
249EFE781E64FB4C00165E39 /* Resources */,
316313
);
317314
buildRules = (
318315
);
@@ -352,7 +349,7 @@
352349
isa = PBXProject;
353350
attributes = {
354351
LastSwiftUpdateCheck = 0820;
355-
LastUpgradeCheck = 0820;
352+
LastUpgradeCheck = 0900;
356353
ORGANIZATIONNAME = mcswiftlayyout.mirego.com;
357354
TargetAttributes = {
358355
244DF2F71EF46C500090508B = {
@@ -396,15 +393,6 @@
396393
isa = PBXResourcesBuildPhase;
397394
buildActionMask = 2147483647;
398395
files = (
399-
244DF3031EF46F6C0090508B /* InfoTVOS.plist in Resources */,
400-
);
401-
runOnlyForDeploymentPostprocessing = 0;
402-
};
403-
249EFE781E64FB4C00165E39 /* Resources */ = {
404-
isa = PBXResourcesBuildPhase;
405-
buildActionMask = 2147483647;
406-
files = (
407-
24A978311EE845CD002BD0F1 /* Info.plist in Resources */,
408396
);
409397
runOnlyForDeploymentPostprocessing = 0;
410398
};
@@ -606,15 +594,21 @@
606594
CLANG_CXX_LIBRARY = "libc++";
607595
CLANG_ENABLE_MODULES = YES;
608596
CLANG_ENABLE_OBJC_ARC = YES;
597+
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
609598
CLANG_WARN_BOOL_CONVERSION = YES;
599+
CLANG_WARN_COMMA = YES;
610600
CLANG_WARN_CONSTANT_CONVERSION = YES;
611601
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
612602
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
613603
CLANG_WARN_EMPTY_BODY = YES;
614604
CLANG_WARN_ENUM_CONVERSION = YES;
615605
CLANG_WARN_INFINITE_RECURSION = YES;
616606
CLANG_WARN_INT_CONVERSION = YES;
607+
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
608+
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
617609
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
610+
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
611+
CLANG_WARN_STRICT_PROTOTYPES = YES;
618612
CLANG_WARN_SUSPICIOUS_MOVE = YES;
619613
CLANG_WARN_UNREACHABLE_CODE = YES;
620614
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
@@ -661,15 +655,21 @@
661655
CLANG_CXX_LIBRARY = "libc++";
662656
CLANG_ENABLE_MODULES = YES;
663657
CLANG_ENABLE_OBJC_ARC = YES;
658+
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
664659
CLANG_WARN_BOOL_CONVERSION = YES;
660+
CLANG_WARN_COMMA = YES;
665661
CLANG_WARN_CONSTANT_CONVERSION = YES;
666662
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
667663
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
668664
CLANG_WARN_EMPTY_BODY = YES;
669665
CLANG_WARN_ENUM_CONVERSION = YES;
670666
CLANG_WARN_INFINITE_RECURSION = YES;
671667
CLANG_WARN_INT_CONVERSION = YES;
668+
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
669+
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
672670
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
671+
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
672+
CLANG_WARN_STRICT_PROTOTYPES = YES;
673673
CLANG_WARN_SUSPICIOUS_MOVE = YES;
674674
CLANG_WARN_UNREACHABLE_CODE = YES;
675675
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;

PinLayout.xcodeproj/xcshareddata/xcschemes/PinLayout.xcscheme

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<Scheme
3-
LastUpgradeVersion = "0820"
3+
LastUpgradeVersion = "0900"
44
version = "1.3">
55
<BuildAction
66
parallelizeBuildables = "YES"

PinLayout.xcodeproj/xcshareddata/xcschemes/PinLayoutTVOS.xcscheme

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<Scheme
3-
LastUpgradeVersion = "0830"
3+
LastUpgradeVersion = "0900"
44
version = "1.3">
55
<BuildAction
66
parallelizeBuildables = "YES"
@@ -26,6 +26,7 @@
2626
buildConfiguration = "Debug"
2727
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
2828
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
29+
language = ""
2930
shouldUseLaunchSchemeArgsEnv = "YES">
3031
<Testables>
3132
</Testables>
@@ -36,6 +37,7 @@
3637
buildConfiguration = "Debug"
3738
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
3839
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
40+
language = ""
3941
launchStyle = "0"
4042
useCustomWorkingDirectory = "NO"
4143
ignoresPersistentStateOnLaunch = "NO"

Sources/PinLayout.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,11 @@ public protocol PinLayout {
153153
@discardableResult func end(_ value: CGFloat) -> PinLayout
154154
@discardableResult func end(_ percent: Percent) -> PinLayout
155155

156+
// Pin multiple edges at once.
157+
@discardableResult func all() -> PinLayout
158+
@discardableResult func horizontally() -> PinLayout
159+
@discardableResult func vertically() -> PinLayout
160+
156161
//
157162
// MARK: Layout using edges
158163
//

Sources/PinLayoutImpl+Coordinates.swift

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@
2121
import UIKit
2222

2323
extension PinLayoutImpl {
24+
internal func top(_ context: Context) {
25+
setTop(0, context)
26+
}
27+
2428
internal func setTop(_ value: CGFloat, _ context: Context) {
2529
if let _bottom = _bottom, let height = height {
2630
warnConflict(context, ["bottom": _bottom, "height": height])
@@ -117,6 +121,20 @@ extension PinLayoutImpl {
117121
}
118122
}
119123

124+
@discardableResult
125+
internal func bottom(_ context: Context) -> PinLayout {
126+
guard let layoutSuperview = layoutSuperview(context) else { return self }
127+
setBottom(layoutSuperview.frame.height, context)
128+
return self
129+
}
130+
131+
@discardableResult
132+
internal func bottom(_ value: CGFloat, _ context: Context) -> PinLayout {
133+
guard let layoutSuperview = layoutSuperview(context) else { return self }
134+
setBottom(layoutSuperview.frame.height - value, context)
135+
return self
136+
}
137+
120138
internal func setBottom(_ value: CGFloat, _ context: Context) {
121139
if let _top = _top, let height = height {
122140
warnConflict(context, ["top": _top, "height": height])

Sources/PinLayoutImpl.swift

Lines changed: 29 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ class PinLayoutImpl: PinLayout {
7373
// top, left, bottom, right
7474
//
7575
@discardableResult func top() -> PinLayout {
76-
setTop(0, { return "top()" })
76+
top({ return "top()" })
7777
return self
7878
}
7979

@@ -125,25 +125,19 @@ class PinLayoutImpl: PinLayout {
125125
}
126126

127127
@discardableResult func bottom() -> PinLayout {
128-
func context() -> String { return "bottom()" }
129-
guard let layoutSuperview = layoutSuperview(context) else { return self }
130-
setBottom(layoutSuperview.frame.height, context)
131-
return self
128+
return bottom({ return "bottom()" })
132129
}
133130

134131
@discardableResult
135132
func bottom(_ value: CGFloat) -> PinLayout {
136-
func context() -> String { return "bottom(\(value))" }
137-
guard let layoutSuperview = layoutSuperview(context) else { return self }
138-
setBottom(layoutSuperview.frame.height - value, context)
139-
return self
133+
return bottom(value, { return "bottom(\(value))" })
140134
}
141135

142136
@discardableResult
143137
func bottom(_ percent: Percent) -> PinLayout {
144138
func context() -> String { return "bottom(\(percent))" }
145139
guard let layoutSuperview = layoutSuperview(context) else { return self }
146-
setBottom(layoutSuperview.frame.height - percent.of(layoutSuperview.frame.height), context)
140+
bottom(percent.of(layoutSuperview.frame.height), context)
147141
return self
148142
}
149143

@@ -225,6 +219,31 @@ class PinLayoutImpl: PinLayout {
225219
setVerticalCenter((layoutSuperview.frame.height / 2) + percent.of(layoutSuperview.frame.height), context)
226220
return self
227221
}
222+
223+
@discardableResult
224+
func all() -> PinLayout {
225+
func context() -> String { return "all()" }
226+
top(context)
227+
bottom(context)
228+
right(context)
229+
left(context)
230+
return self
231+
}
232+
233+
@discardableResult
234+
func horizontally() -> PinLayout {
235+
func context() -> String { return "horizontally()" }
236+
right(context)
237+
left(context)
238+
return self
239+
}
240+
@discardableResult
241+
func vertically() -> PinLayout {
242+
func context() -> String { return "vertically()" }
243+
top(context)
244+
bottom(context)
245+
return self
246+
}
228247

229248
//
230249
// top, left, bottom, right

0 commit comments

Comments
 (0)