Skip to content

Commit 9f603d1

Browse files
authored
Merge pull request #177 from layoutBox/update
Minor changes
2 parents 12e1a9e + edb552d commit 9f603d1

33 files changed

+173
-134
lines changed

.gitignore

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,8 @@ fastlane/report.xml
1414
fastlane/test_output
1515

1616
TestProjects/cocoapods/ios/PinLayout-iOS.xcworkspace/
17-
TestProjects/cocoapods/ios/Podfile.lock
1817
TestProjects/cocoapods/macos/PinLayout-macOS.xcworkspace/
19-
TestProjects/cocoapods/macos/Podfile.lock
2018
TestProjects/cocoapods/tvos/PinLayout-tvOS.xcworkspace/
21-
TestProjects/cocoapods/tvos/Podfile.lock
2219

2320
TestProjects/carthage/ios/Cartfile.resolved
2421
TestProjects/carthage/ios/Carthage/

.swiftlint.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@ disabled_rules: # rule identifiers to exclude from running
2121
- identifier_name
2222
- line_length
2323
- empty_count
24+
- todo
25+
- private_over_fileprivate
2426

2527
excluded: # paths to ignore during linting. overridden by `included`.
2628
- Pods
29+
- Example/PinLayoutExampleMacOS
30+
- TestProjects

Example/PinLayoutSample.xcodeproj/project.pbxproj

Lines changed: 5 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@
99
/* Begin PBXBuildFile section */
1010
241637741F8E4BC200EE703A /* IntroObjectiveCViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 241637711F8E4BC200EE703A /* IntroObjectiveCViewController.m */; };
1111
241637771F8E4F9100EE703A /* IntroObjectiveCView.m in Sources */ = {isa = PBXBuildFile; fileRef = 241637761F8E4F9100EE703A /* IntroObjectiveCView.m */; };
12-
2439CC281E6658C3003326FB /* PinLayout.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 2439CC241E665858003326FB /* PinLayout.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
13-
2439CC2B1E6658CC003326FB /* PinLayout.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 2439CC241E665858003326FB /* PinLayout.framework */; };
1412
2439CC351E665BF6003326FB /* MenuView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2439CC331E665BF6003326FB /* MenuView.swift */; };
1513
2439CC361E665BF6003326FB /* MenuViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2439CC341E665BF6003326FB /* MenuViewController.swift */; };
1614
2439CC4B1E665C6B003326FB /* BasicView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2439CC381E665C6B003326FB /* BasicView.swift */; };
@@ -114,30 +112,6 @@
114112
};
115113
/* End PBXContainerItemProxy section */
116114

117-
/* Begin PBXCopyFilesBuildPhase section */
118-
2460ACCE1E64FD9D000BCAC5 /* Embed Frameworks */ = {
119-
isa = PBXCopyFilesBuildPhase;
120-
buildActionMask = 2147483647;
121-
dstPath = "";
122-
dstSubfolderSpec = 10;
123-
files = (
124-
2439CC281E6658C3003326FB /* PinLayout.framework in Embed Frameworks */,
125-
);
126-
name = "Embed Frameworks";
127-
runOnlyForDeploymentPostprocessing = 0;
128-
};
129-
2468130D1F8D013600462E53 /* Embed App Extensions */ = {
130-
isa = PBXCopyFilesBuildPhase;
131-
buildActionMask = 2147483647;
132-
dstPath = "";
133-
dstSubfolderSpec = 13;
134-
files = (
135-
);
136-
name = "Embed App Extensions";
137-
runOnlyForDeploymentPostprocessing = 0;
138-
};
139-
/* End PBXCopyFilesBuildPhase section */
140-
141115
/* Begin PBXFileReference section */
142116
241637701F8E4BC200EE703A /* IntroObjectiveCViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = IntroObjectiveCViewController.h; sourceTree = "<group>"; };
143117
241637711F8E4BC200EE703A /* IntroObjectiveCViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = IntroObjectiveCViewController.m; sourceTree = "<group>"; };
@@ -206,7 +180,6 @@
206180
isa = PBXFrameworksBuildPhase;
207181
buildActionMask = 2147483647;
208182
files = (
209-
2439CC2B1E6658CC003326FB /* PinLayout.framework in Frameworks */,
210183
DE6C3D736B571B80E207DF6A /* Pods_PinLayoutSample.framework in Frameworks */,
211184
);
212185
runOnlyForDeploymentPostprocessing = 0;
@@ -520,10 +493,8 @@
520493
249EFE3B1E64FAFE00165E39 /* Sources */,
521494
249EFE3C1E64FAFE00165E39 /* Frameworks */,
522495
249EFE3D1E64FAFE00165E39 /* Resources */,
523-
2460ACCE1E64FD9D000BCAC5 /* Embed Frameworks */,
524-
5D3C4568AFC08267110D9971 /* [CP] Embed Pods Frameworks */,
525496
24E6547E1E68F88D00A72A8B /* Run Swiftlint */,
526-
2468130D1F8D013600462E53 /* Embed App Extensions */,
497+
A57F7C48B21998F5C851B138 /* [CP] Embed Pods Frameworks */,
527498
);
528499
buildRules = (
529500
);
@@ -647,15 +618,15 @@
647618
shellPath = /bin/sh;
648619
shellScript = ../Pods/SwiftLint/swiftlint;
649620
};
650-
5D3C4568AFC08267110D9971 /* [CP] Embed Pods Frameworks */ = {
621+
A57F7C48B21998F5C851B138 /* [CP] Embed Pods Frameworks */ = {
651622
isa = PBXShellScriptBuildPhase;
652623
buildActionMask = 2147483647;
653624
files = (
654625
);
655626
inputPaths = (
656627
"${SRCROOT}/../Pods/Target Support Files/Pods-PinLayoutSample/Pods-PinLayoutSample-frameworks.sh",
657628
"${BUILT_PRODUCTS_DIR}/PinLayout/PinLayout.framework",
658-
"${PODS_ROOT}/Reveal-SDK/RevealServer-17/iOS/RevealServer.framework",
629+
"${PODS_ROOT}/Reveal-SDK/RevealServer-18/iOS/RevealServer.framework",
659630
);
660631
name = "[CP] Embed Pods Frameworks";
661632
outputPaths = (
@@ -879,7 +850,7 @@
879850
isa = XCBuildConfiguration;
880851
baseConfigurationReference = A35A00E6536E49A548E763E6 /* Pods-PinLayoutSample.debug.xcconfig */;
881852
buildSettings = {
882-
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
853+
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = "$(inherited)";
883854
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
884855
CODE_SIGN_IDENTITY = "iPhone Developer";
885856
DEVELOPMENT_TEAM = "";
@@ -897,7 +868,7 @@
897868
isa = XCBuildConfiguration;
898869
baseConfigurationReference = C589624E868FCB20F7C10918 /* Pods-PinLayoutSample.release.xcconfig */;
899870
buildSettings = {
900-
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
871+
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = "$(inherited)";
901872
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
902873
CODE_SIGN_IDENTITY = "iPhone Developer";
903874
DEVELOPMENT_TEAM = "";

Example/PinLayoutSample/UI/Common/BaseFormView.swift

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,10 @@ import PinLayout
2222

2323
class BaseFormView: UIView {
2424
let formScrollView = UIScrollView()
25-
25+
2626
init() {
2727
super.init(frame: .zero)
28-
28+
2929
formScrollView.showsVerticalScrollIndicator = false
3030
formScrollView.keyboardDismissMode = .onDrag
3131

@@ -35,7 +35,7 @@ class BaseFormView: UIView {
3535
NotificationCenter.default.addObserver(self, selector: #selector(keyboardWillShow), name: .UIKeyboardWillShow, object: nil)
3636
NotificationCenter.default.addObserver(self, selector: #selector(keyboardWillHide), name: .UIKeyboardWillHide, object: nil)
3737
}
38-
38+
3939
required init(coder aDecoder: NSCoder) {
4040
fatalError("init(coder:) has not been implemented")
4141
}
@@ -46,7 +46,7 @@ class BaseFormView: UIView {
4646

4747
override func layoutSubviews() {
4848
super.layoutSubviews()
49-
49+
5050
formScrollView.pin.all()
5151
}
5252

@@ -55,23 +55,23 @@ class BaseFormView: UIView {
5555
guard let sizeValue = notification.userInfo?[UIKeyboardFrameEndUserInfoKey] as? NSValue else { return }
5656
setFormScrollView(bottomInset: sizeValue.cgRectValue.height)
5757
}
58-
58+
5959
@objc
6060
internal func keyboardWillHide(notification: Notification) {
6161
resetScrollOffset()
6262
}
63-
63+
6464
@objc
6565
internal func didTapScrollView() {
6666
endEditing(true)
6767
resetScrollOffset()
6868
}
69-
69+
7070
private func resetScrollOffset() {
7171
guard formScrollView.contentInset != .zero else { return }
7272
setFormScrollView(bottomInset: 0)
7373
}
74-
74+
7575
private func setFormScrollView(bottomInset: CGFloat) {
7676
formScrollView.contentInset = UIEdgeInsets(top: formScrollView.contentInset.top, left: 0,
7777
bottom: bottomInset, right: 0)

Example/PinLayoutSample/UI/Common/BasicView.swift

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,14 @@ import UIKit
2121

2222
class BasicView: UIView {
2323
private let label = UILabel()
24-
24+
2525
init(text: String? = nil, color: UIColor) {
2626
super.init(frame: .zero)
2727

2828
backgroundColor = color
2929
layer.borderWidth = 1
3030
layer.borderColor = UIColor.lightGray.cgColor
31-
31+
3232
label.text = text
3333
label.font = .systemFont(ofSize: 7)
3434
label.textColor = .white
@@ -39,16 +39,16 @@ class BasicView: UIView {
3939
required init?(coder aDecoder: NSCoder) {
4040
fatalError("init(coder:) has not been implemented")
4141
}
42-
42+
4343
override func layoutSubviews() {
4444
super.layoutSubviews()
45-
45+
4646
label.pin.top().horizontally().margin(4).sizeToFit(.width)
4747
}
48-
48+
4949
var sizeThatFitsExpectedArea: CGFloat = 40 * 40
5050
var sizeThatFitSizeOffset: CGFloat = 0
51-
51+
5252
override func sizeThatFits(_ size: CGSize) -> CGSize {
5353
var newSize = CGSize()
5454
if size.width != CGFloat.greatestFiniteMagnitude {
@@ -61,7 +61,7 @@ class BasicView: UIView {
6161
newSize.width = 40
6262
newSize.height = sizeThatFitsExpectedArea / newSize.width
6363
}
64-
64+
6565
return newSize
6666
}
6767

Example/PinLayoutSample/UI/Common/Stylesheet.swift

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,11 @@
2020
import UIKit
2121

2222
extension UIColor {
23-
class var pinLayoutColor: UIColor { return UIColor(red: 90.0 / 255.0, green: 171.0 / 255.0, blue: 243.0 / 255.0, alpha: 1.0) }
24-
class var lightColor: UIColor { return UIColor(red: 230.0 / 255.0, green: 240.0 / 255.0, blue: 255.0 / 255.0, alpha: 1.0) }
23+
class var pinLayoutColor: UIColor {
24+
return UIColor(red: 90.0 / 255.0, green: 171.0 / 255.0, blue: 243.0 / 255.0, alpha: 1.0)
25+
}
26+
27+
class var lightColor: UIColor {
28+
return UIColor(red: 230.0 / 255.0, green: 240.0 / 255.0, blue: 255.0 / 255.0, alpha: 1.0)
29+
}
2530
}

Example/PinLayoutSample/UI/Examples/AdjustToContainer/AdjustToContainerView.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ class AdjustToContainerView: UIView {
4040

4141
override func layoutSubviews() {
4242
super.layoutSubviews()
43-
43+
4444
languageSelectorView.pin.top(pin.safeArea).horizontally(pin.safeArea).sizeToFit(.width)
4545
swiftOpinionSelector.pin.below(of: languageSelectorView).horizontally(pin.safeArea).marginTop(10).sizeToFit(.width)
4646
swiftUsageSelector.pin.below(of: swiftOpinionSelector).horizontally(pin.safeArea).marginTop(10).sizeToFit(.width)

Example/PinLayoutSample/UI/Examples/AdjustToContainer/AdjustToContainerViewController.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,14 @@ class AdjustToContainerViewController: UIViewController {
2626

2727
init(pageType: PageType) {
2828
super.init(nibName: nil, bundle: nil)
29-
29+
3030
title = pageType.title
3131
}
32-
32+
3333
required init?(coder aDecoder: NSCoder) {
3434
super.init(coder: aDecoder)
3535
}
36-
36+
3737
override func loadView() {
3838
view = AdjustToContainerView()
3939
}

Example/PinLayoutSample/UI/Examples/AdjustToContainer/Subviews/ChoiceSelectorView.swift

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class ChoiceSelectorView: UIView {
2424

2525
private let textLabel = UILabel()
2626
private let segmentedControl = UISegmentedControl()
27-
27+
2828
init(text: String, choices: [String]) {
2929
super.init(frame: .zero)
3030

@@ -33,33 +33,33 @@ class ChoiceSelectorView: UIView {
3333
textLabel.numberOfLines = 0
3434
textLabel.lineBreakMode = .byWordWrapping
3535
addSubview(textLabel)
36-
36+
3737
choices.forEach({ segmentedControl.insertSegment(withTitle: $0, at: segmentedControl.numberOfSegments, animated: false) })
3838
segmentedControl.tintColor = .pinLayoutColor
3939
segmentedControl.sizeToFit()
4040
addSubview(segmentedControl)
4141
}
42-
42+
4343
required init?(coder aDecoder: NSCoder) {
4444
fatalError("init(coder:) has not been implemented")
4545
}
46-
46+
4747
override func layoutSubviews() {
4848
super.layoutSubviews()
4949
_ = layout()
5050
}
51-
51+
5252
override func sizeThatFits(_ size: CGSize) -> CGSize {
5353
// 1) Set the width to the specified width
5454
self.pin.width(size.width)
55-
55+
5656
// 2) Layout the contentView's controls
5757
return layout()
5858
}
59-
59+
6060
private func layout() -> CGSize {
6161
let margin: CGFloat = 12
62-
62+
6363
if frame.width > 500 {
6464
// The UISegmentedControl is at the top-right corner and the label takes the remaining horizontal space.
6565
segmentedControl.pin.top().right().margin(margin)
@@ -69,7 +69,7 @@ class ChoiceSelectorView: UIView {
6969
textLabel.pin.top().horizontally().margin(margin).sizeToFit(.width)
7070
segmentedControl.pin.below(of: textLabel).right().margin(margin)
7171
}
72-
72+
7373
return CGSize(width: frame.width, height: max(textLabel.frame.maxY, segmentedControl.frame.maxY) + margin)
7474
}
7575
}

Example/PinLayoutSample/UI/Examples/Form/FormView.swift

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -34,16 +34,16 @@ class FormView: BaseFormView {
3434
override init() {
3535
super.init()
3636
backgroundColor = .white
37-
37+
3838
formContainerView.backgroundColor = UIColor.pinLayoutColor.withAlphaComponent(0.3)
3939
formContainerView.layer.cornerRadius = 5
4040
formScrollView.addSubview(formContainerView)
41-
41+
4242
formTitleLabel.text = "Simple Form Example"
4343
formTitleLabel.font = .boldSystemFont(ofSize: 14)
4444
formTitleLabel.sizeToFit()
4545
formContainerView.addSubview(formTitleLabel)
46-
46+
4747
nameField.placeholder = "Name"
4848
nameField.layer.borderColor = UIColor.gray.cgColor
4949
nameField.layer.borderWidth = 1
@@ -52,31 +52,31 @@ class FormView: BaseFormView {
5252
ageSwitch.tintColor = .lightGray
5353
ageSwitch.addTarget(self, action: #selector(didChangeAgeSwitch), for: .valueChanged)
5454
formContainerView.addSubview(ageSwitch)
55-
55+
5656
ageField.placeholder = "Age"
5757
ageField.alpha = 0
5858
ageField.layer.borderColor = UIColor.gray.cgColor
5959
ageField.layer.borderWidth = 1
6060
formContainerView.addSubview(ageField)
61-
61+
6262
addressField.placeholder = "Address"
6363
addressField.layer.borderColor = UIColor.gray.cgColor
6464
addressField.layer.borderWidth = 1
6565
formContainerView.addSubview(addressField)
6666
}
67-
67+
6868
required init(coder aDecoder: NSCoder) {
6969
fatalError("init(coder:) has not been implemented")
7070
}
71-
71+
7272
override func layoutSubviews() {
7373
super.layoutSubviews()
7474
layoutFormFields()
7575
}
76-
76+
7777
private func layoutFormFields() {
7878
let margin: CGFloat = 12
79-
79+
8080
// Layout the formContainerView using the view's safeArea.
8181
formContainerView.pin.top().hCenter().width(100%).maxWidth(400).pinEdges().margin(margin)
8282

@@ -86,13 +86,13 @@ class FormView: BaseFormView {
8686

8787
ageSwitch.pin.below(of: nameField, aligned: .left).marginTop(margin).sizeToFit()
8888
ageField.pin.below(of: ageSwitch).horizontally().height(40).margin(margin)
89-
89+
9090
// Layout the Address UITextField below the last visible view, either ageSwitch or ageField.
9191
addressField.pin.below(of: visible([ageSwitch, ageField])).horizontally().height(40).margin(margin)
92-
92+
9393
// Adjust the form container bottom to contains all its childrens
9494
formContainerView.pin.wrapContent(.vertically, padding: margin)
95-
95+
9696
// Adjust UIScrollView contentSize
9797
formScrollView.contentSize = formContainerView.frame.size
9898
}

0 commit comments

Comments
 (0)