Skip to content

Commit fa02c41

Browse files
authored
Merge pull request #38 from HotCocoaTouch/shorten-component-name-in-examples
Standardize on com. instead of component.
2 parents eea6e85 + 0cf4642 commit fa02c41

7 files changed

+162
-162
lines changed

Example/DeclarativeLayout/MenuViewController.swift

+3-3
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,9 @@ class MenuViewController: UIViewController, UITableViewDelegate, UITableViewData
6060
}
6161

6262
private func layoutAllViews() {
63-
viewLayout.updateLayoutTo { (component) in
64-
component.view(tableView) { (component) in
65-
component.layout {[
63+
viewLayout.updateLayoutTo { (com) in
64+
com.view(tableView) { (com) in
65+
com.layout {[
6666
$0.topAnchor.constraint(equalTo: $1.topAnchor),
6767
$0.leadingAnchor.constraint(equalTo: $1.leadingAnchor),
6868
$0.trailingAnchor.constraint(equalTo: $1.trailingAnchor),

Example/DeclarativeLayout/READMEExample/READMEExample.swift

+11-11
Original file line numberDiff line numberDiff line change
@@ -39,24 +39,24 @@ class READMEExample: UIViewController {
3939
blueView,
4040
purpleView]
4141

42-
viewLayout.updateLayoutTo { (component) in
43-
component.stackView(self.stackView) { (component) in
44-
component.constraints(
45-
component.ownedView.leadingAnchor.constraint(equalTo: component.superview.leadingAnchor),
46-
component.ownedView.trailingAnchor.constraint(equalTo: component.superview.trailingAnchor),
47-
component.ownedView.topAnchor.constraint(equalTo: component.superview.safeAreaLayoutGuide.topAnchor,
42+
viewLayout.updateLayoutTo { (com) in
43+
com.stackView(self.stackView) { (com) in
44+
com.constraints(
45+
com.ownedView.leadingAnchor.constraint(equalTo: com.superview.leadingAnchor),
46+
com.ownedView.trailingAnchor.constraint(equalTo: com.superview.trailingAnchor),
47+
com.ownedView.topAnchor.constraint(equalTo: com.superview.safeAreaLayoutGuide.topAnchor,
4848
constant: 35)
4949
)
5050

51-
component.ownedView.axis = .vertical
51+
com.ownedView.axis = .vertical
5252
for view in views.shuffled() {
53-
component.arrangedView(view) { (component) in
53+
com.arrangedView(view) { (com) in
5454
let random = CGFloat(Int.random(in: 20..<100))
55-
component.constraints(
56-
component.ownedView.heightAnchor.constraint(equalToConstant: random)
55+
com.constraints(
56+
com.ownedView.heightAnchor.constraint(equalToConstant: random)
5757
)
5858
}
59-
component.space(CGFloat(Int.random(in: 0..<50)))
59+
com.space(CGFloat(Int.random(in: 0..<50)))
6060
}
6161
}
6262
}

Example/DeclarativeLayout/WithFramework/RegistrationExampleWithFrameworkViewController.swift

+23-23
Original file line numberDiff line numberDiff line change
@@ -51,22 +51,22 @@ class RegistrationExampleWithFrameworkViewController: UIViewController {
5151

5252
private func layoutAllViews() {
5353

54-
viewLayout.updateLayoutTo { (component) in
55-
component.stackView(self.stackView) { (component) in
56-
component.ownedView.axis = .vertical
57-
component.layout {[ // $0 is component's view, $1 is its superview
54+
viewLayout.updateLayoutTo { (com) in
55+
com.stackView(self.stackView) { (com) in
56+
com.ownedView.axis = .vertical
57+
com.layout {[ // $0 is component's view, $1 is its superview
5858
$0.topAnchor.constraint(equalTo: $1.safeAreaLayoutGuide.topAnchor, constant: 35),
5959
$0.leadingAnchor.constraint(equalTo: $1.leadingAnchor, constant: 20),
6060
$0.trailingAnchor.constraint(equalTo: $1.trailingAnchor, constant: -20),
6161
]}
6262

63-
component.arrangedView(self.registerOrSignInSegmentedControl)
64-
component.space(30)
65-
component.arrangedView(self.headerLabel)
66-
component.space(20)
67-
component.arrangedView { (component) in
68-
component.view(self.emailLabel) { (component) in
69-
component.layout {[
63+
com.arrangedView(self.registerOrSignInSegmentedControl)
64+
com.space(30)
65+
com.arrangedView(self.headerLabel)
66+
com.space(20)
67+
com.arrangedView { (com) in
68+
com.view(self.emailLabel) { (com) in
69+
com.layout {[
7070
$0.topAnchor.constraint(greaterThanOrEqualTo: $1.topAnchor),
7171
$0.leadingAnchor.constraint(equalTo: $1.leadingAnchor),
7272
$0.trailingAnchor.constraint(equalTo: self.emailTextField.leadingAnchor, constant: -20),
@@ -75,8 +75,8 @@ class RegistrationExampleWithFrameworkViewController: UIViewController {
7575
]}
7676
}
7777

78-
component.view(self.emailTextField) { (component) in
79-
component.layout {[
78+
com.view(self.emailTextField) { (com) in
79+
com.layout {[
8080
$0.topAnchor.constraint(greaterThanOrEqualTo: $1.topAnchor),
8181
$0.trailingAnchor.constraint(equalTo: $1.trailingAnchor),
8282
$0.bottomAnchor.constraint(lessThanOrEqualTo: $1.bottomAnchor),
@@ -85,10 +85,10 @@ class RegistrationExampleWithFrameworkViewController: UIViewController {
8585
}
8686
}
8787

88-
component.space(40)
89-
component.arrangedView { (component) in
90-
component.view(self.passwordLabel) { (component) in
91-
component.layout {[
88+
com.space(40)
89+
com.arrangedView { (com) in
90+
com.view(self.passwordLabel) { (com) in
91+
com.layout {[
9292
$0.topAnchor.constraint(greaterThanOrEqualTo: $1.topAnchor),
9393
$0.leadingAnchor.constraint(equalTo: $1.leadingAnchor),
9494
$0.trailingAnchor.constraint(equalTo: self.passwordTextField.leadingAnchor, constant: -20),
@@ -97,8 +97,8 @@ class RegistrationExampleWithFrameworkViewController: UIViewController {
9797
]}
9898
}
9999

100-
component.view(self.passwordTextField) { (component) in
101-
component.layout {[
100+
com.view(self.passwordTextField) { (com) in
101+
com.layout {[
102102
$0.topAnchor.constraint(greaterThanOrEqualTo: $1.topAnchor),
103103
$0.trailingAnchor.constraint(equalTo: $1.trailingAnchor),
104104
$0.bottomAnchor.constraint(lessThanOrEqualTo: $1.bottomAnchor),
@@ -108,12 +108,12 @@ class RegistrationExampleWithFrameworkViewController: UIViewController {
108108
}
109109
}
110110

111-
component.space(40)
112-
component.arrangedView(self.submitButton)
111+
com.space(40)
112+
com.arrangedView(self.submitButton)
113113
}
114114

115-
component.view(self.forgotMyPasswordButton) { (component) in
116-
component.layout {[
115+
com.view(self.forgotMyPasswordButton) { (com) in
116+
com.layout {[
117117
$0.topAnchor.constraint(equalTo: self.stackView.bottomAnchor, constant: 20),
118118
$0.centerXAnchor.constraint(equalTo: $1.centerXAnchor),
119119
]}

Example/DeclarativeLayout/WithFrameworkAndAnchorage/RegistrationExampleWithFrameworkAndAnchorageViewController.swift

+23-23
Original file line numberDiff line numberDiff line change
@@ -66,22 +66,22 @@ class RegistrationExampleWithFrameworkAndAnchorageViewController: UIViewControll
6666

6767
private func layoutAllViews() {
6868

69-
viewLayout.updateLayoutTo { (component) in
70-
component.stackView(self.stackView) { (component) in
71-
component.ownedView.axis = .vertical
72-
component.layout { // $0 is component's view, $1 is superview
69+
viewLayout.updateLayoutTo { (com) in
70+
com.stackView(self.stackView) { (com) in
71+
com.ownedView.axis = .vertical
72+
com.layout { // $0 is component's view, $1 is superview
7373
$0.topAnchor == $1.safeAreaLayoutGuide.topAnchor + 35
7474
$0.leadingAnchor == $1.leadingAnchor + 20
7575
$0.trailingAnchor == $1.trailingAnchor - 20
7676
}
7777

78-
component.arrangedView(self.registerOrSignInSegmentedControl)
79-
component.space(30)
80-
component.arrangedView(self.headerLabel)
81-
component.space(20)
82-
component.arrangedView { (component) in
83-
component.view(self.emailLabel) { (component) in
84-
component.layout {
78+
com.arrangedView(self.registerOrSignInSegmentedControl)
79+
com.space(30)
80+
com.arrangedView(self.headerLabel)
81+
com.space(20)
82+
com.arrangedView { (com) in
83+
com.view(self.emailLabel) { (com) in
84+
com.layout {
8585
$0.topAnchor >= $1.topAnchor
8686
$0.leadingAnchor == $1.leadingAnchor
8787
$0.trailingAnchor == self.emailTextField.leadingAnchor - 20
@@ -90,8 +90,8 @@ class RegistrationExampleWithFrameworkAndAnchorageViewController: UIViewControll
9090
}
9191
}
9292

93-
component.view(self.emailTextField) { (component) in
94-
component.layout {
93+
com.view(self.emailTextField) { (com) in
94+
com.layout {
9595
$0.topAnchor >= $1.topAnchor
9696
$0.trailingAnchor == $1.trailingAnchor
9797
$0.bottomAnchor <= $1.bottomAnchor
@@ -100,10 +100,10 @@ class RegistrationExampleWithFrameworkAndAnchorageViewController: UIViewControll
100100
}
101101
}
102102

103-
component.space(40)
104-
component.arrangedView { (component) in
105-
component.view(self.passwordLabel) { (component) in
106-
component.layout {
103+
com.space(40)
104+
com.arrangedView { (com) in
105+
com.view(self.passwordLabel) { (com) in
106+
com.layout {
107107
$0.topAnchor >= $1.topAnchor
108108
$0.leadingAnchor == $1.leadingAnchor
109109
$0.trailingAnchor == self.passwordTextField.leadingAnchor - 20
@@ -112,8 +112,8 @@ class RegistrationExampleWithFrameworkAndAnchorageViewController: UIViewControll
112112
}
113113
}
114114

115-
component.view(self.passwordTextField) { (component) in
116-
component.layout {
115+
com.view(self.passwordTextField) { (com) in
116+
com.layout {
117117
$0.topAnchor >= $1.topAnchor
118118
$0.trailingAnchor == $1.trailingAnchor
119119
$0.bottomAnchor <= $1.bottomAnchor
@@ -123,12 +123,12 @@ class RegistrationExampleWithFrameworkAndAnchorageViewController: UIViewControll
123123
}
124124
}
125125

126-
component.space(40)
127-
component.arrangedView(self.submitButton)
126+
com.space(40)
127+
com.arrangedView(self.submitButton)
128128
}
129129

130-
component.view(self.forgotMyPasswordButton) { (component) in
131-
component.layout {
130+
com.view(self.forgotMyPasswordButton) { (com) in
131+
com.layout {
132132
$0.topAnchor == self.stackView.bottomAnchor + 20
133133
$0.centerXAnchor == $1.centerXAnchor
134134
}

Example/DeclarativeLayout/WithFrameworkAndSnapKit/RegistrationExampleWithFrameworkAndSnapKitViewController.swift

+23-23
Original file line numberDiff line numberDiff line change
@@ -71,22 +71,22 @@ class RegistrationExampleWithFrameworkAndSnapKitViewController: UIViewController
7171

7272
private func layoutAllViews() {
7373

74-
viewLayout.updateLayoutTo { (component) in
75-
component.stackView(self.stackView) { (component) in
76-
component.ownedView.axis = .vertical
77-
component.layout { // $0 is ConstraintMaker, $1 is superview
74+
viewLayout.updateLayoutTo { (com) in
75+
com.stackView(self.stackView) { (com) in
76+
com.ownedView.axis = .vertical
77+
com.layout { // $0 is ConstraintMaker, $1 is superview
7878
$0.top.equalTo($1.safeAreaLayoutGuide).offset(35)
7979
$0.leading.equalTo($1).offset(20)
8080
$0.trailing.equalTo($1).offset(-20)
8181
}
8282

83-
component.arrangedView(self.registerOrSignInSegmentedControl)
84-
component.space(30)
85-
component.arrangedView(self.headerLabel)
86-
component.space(20)
87-
component.arrangedView { (component) in
88-
component.view(self.emailLabel) { (component) in
89-
component.layout {
83+
com.arrangedView(self.registerOrSignInSegmentedControl)
84+
com.space(30)
85+
com.arrangedView(self.headerLabel)
86+
com.space(20)
87+
com.arrangedView { (com) in
88+
com.view(self.emailLabel) { (com) in
89+
com.layout {
9090
$0.top.greaterThanOrEqualTo($1)
9191
$0.leading.equalTo($1)
9292
$0.trailing.equalTo(self.emailTextField.snp.leading).offset(-20)
@@ -95,8 +95,8 @@ class RegistrationExampleWithFrameworkAndSnapKitViewController: UIViewController
9595
}
9696
}
9797

98-
component.view(self.emailTextField) { (component) in
99-
component.layout {
98+
com.view(self.emailTextField) { (com) in
99+
com.layout {
100100
$0.top.greaterThanOrEqualTo($1)
101101
$0.trailing.equalTo($1)
102102
$0.bottom.lessThanOrEqualTo($1)
@@ -105,10 +105,10 @@ class RegistrationExampleWithFrameworkAndSnapKitViewController: UIViewController
105105
}
106106
}
107107

108-
component.space(40)
109-
component.arrangedView { (component) in
110-
component.view(self.passwordLabel) { (component) in
111-
component.layout {
108+
com.space(40)
109+
com.arrangedView { (com) in
110+
com.view(self.passwordLabel) { (com) in
111+
com.layout {
112112
$0.top.greaterThanOrEqualTo($1)
113113
$0.leading.equalTo($1)
114114
$0.trailing.equalTo(self.passwordTextField.snp.leading).offset(-20)
@@ -117,8 +117,8 @@ class RegistrationExampleWithFrameworkAndSnapKitViewController: UIViewController
117117
}
118118
}
119119

120-
component.view(self.passwordTextField) { (component) in
121-
component.layout {
120+
com.view(self.passwordTextField) { (com) in
121+
com.layout {
122122
$0.top.greaterThanOrEqualTo($1)
123123
$0.trailing.equalTo($1)
124124
$0.bottom.lessThanOrEqualTo($1)
@@ -128,12 +128,12 @@ class RegistrationExampleWithFrameworkAndSnapKitViewController: UIViewController
128128
}
129129
}
130130

131-
component.space(40)
132-
component.arrangedView(self.submitButton)
131+
com.space(40)
132+
com.arrangedView(self.submitButton)
133133
}
134134

135-
component.view(self.forgotMyPasswordButton) { (component) in
136-
component.layout {
135+
com.view(self.forgotMyPasswordButton) { (com) in
136+
com.layout {
137137
$0.top.equalTo(self.stackView.snp.bottom).offset(20)
138138
$0.centerX.equalTo($1)
139139
}

0 commit comments

Comments
 (0)