Skip to content

Commit aceb57f

Browse files
committed
Remove 'with' protocol, some syntaxes updated
1 parent 4eb31e2 commit aceb57f

16 files changed

Lines changed: 75 additions & 47 deletions

Example/FrameLayoutKit/CardView.swift

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,11 @@ class CardView: UIView {
1717
let dateLabel = UILabel()
1818
let messageLabel = UILabel()
1919
let expandButton = UIButton(type: .contactAdd)
20-
let frameLayout = StackFrameLayout(axis: .horizontal)
20+
let frameLayout = HStackLayout() {
21+
$0.spacing = 15.0
22+
$0.padding(top: 15, left: 15, bottom: 15, right: 15)
23+
$0.debug = true
24+
}
2125
let blueView = UIView()
2226
let redView = UIView()
2327
var messageFrameLayout: FrameLayout!
@@ -61,7 +65,7 @@ class CardView: UIView {
6165
$0.textColor = .black
6266
}
6367

64-
[blueView, redView, earthImageView, rocketImageView, nameLabel, titleLabel, dateLabel, messageLabel, expandButton].forEach { addSubview($0) }
68+
[blueView, redView, earthImageView, rocketImageView, nameLabel, titleLabel, dateLabel, messageLabel, expandButton, frameLayout].forEach { addSubview($0) }
6569

6670
// Standard syntax:
6771

@@ -107,12 +111,7 @@ class CardView: UIView {
107111
$0.spacing = 10
108112

109113
($0 + [Label(.yellow), Label(.green), Label(.brown), Label(.systemPink), Label(.blue)]).forEach {
110-
$0.willSizeThatFitsBlock = { (sender, size) in
111-
if let label = sender.targetView as? UILabel {
112-
label.text = "\(size.width) x \(size.height)"
113-
}
114-
}
115-
$0.willLayoutSubviewsBlock = { sender in
114+
$0.didLayoutSubviewsBlock = { sender in
116115
if let label = sender.targetView as? UILabel {
117116
let size = sender.frame.size
118117
label.text = "\(size.width) x \(size.height)"
@@ -126,10 +125,7 @@ class CardView: UIView {
126125
$0.spacing = 5.0
127126
}
128127

129-
frameLayout.spacing = 15.0
130-
frameLayout.padding(top: 15, left: 15, bottom: 15, right: 15)
131-
frameLayout.debug = true
132-
addSubview(frameLayout)
128+
133129
}
134130

135131
func Label(_ color: UIColor) -> UILabel {

Example/FrameLayoutKit/NumberPadView.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ class NumberPadView: UIView {
3030
button.setTitle(title, for: .normal)
3131
button.backgroundColor = color(index: i)
3232
button.showsTouchWhenHighlighted = true
33+
button.titleLabel?.font = .systemFont(ofSize: 24, weight: .medium)
3334
i += 1
3435
return button
3536
}

Example/FrameLayoutKit/TagListView.swift

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ class TagListView: UIView {
1313
let flowLayout = FlowFrameLayout(axis: .horizontal)
1414
let addButton = UIButton()
1515
let removeButton = UIButton()
16-
let frameLayout = StackFrameLayout(axis: .vertical)
16+
let frameLayout = VStackLayout().spacing(4.0)
1717
let colors: [UIColor] = [.red, .green, .blue, .brown, .yellow, .magenta, .black, .orange, .purple, .systemPink]
1818

1919
var onChanged: ((TagListView) -> Void)?
@@ -23,10 +23,11 @@ class TagListView: UIView {
2323

2424
backgroundColor = .gray
2525

26-
flowLayout.interItemSpacing = 4
27-
flowLayout.lineSpacing = 4
28-
flowLayout.padding(top: 4, left: 4, bottom: 4, right: 4)
29-
flowLayout.distribution = .left
26+
flowLayout
27+
.interitemSpacing(4)
28+
.lineSpacing(4)
29+
.padding(top: 4, left: 4, bottom: 4, right: 4)
30+
.distribution(.left)
3031

3132
addButton.setTitle("Add Item", for: .normal)
3233
addButton.backgroundColor = .systemBlue
@@ -53,11 +54,10 @@ class TagListView: UIView {
5354
frameLayout + flowLayout
5455
frameLayout + HStackLayout {
5556
$0 + [removeButton, addButton]
56-
$0.distribution = .equal
57-
$0.fixedSize = CGSize(width: 0, height: 50)
57+
58+
$0.distribution(.equal)
59+
.fixedSize(CGSize(width: 0, height: 50))
5860
}
59-
60-
frameLayout.spacing = 4
6161
}
6262

6363
required init?(coder: NSCoder) {

Example/FrameLayoutKit/ViewController.swift

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,11 @@ class ViewController: UIViewController {
3535
scrollStackView + NumberPadView()
3636
scrollStackView + tagListView
3737

38-
scrollStackView.spacing = 20
39-
scrollStackView.edgeInsets = UIEdgeInsets(top: 50, left: 50, bottom: 50, right: 50)
40-
scrollStackView.distribution = .center
38+
scrollStackView
39+
.spacing(20)
40+
.padding(top: 50, left: 50, bottom: 50, right: 50)
41+
.distribution(.center)
42+
4143
view.addSubview(scrollStackView)
4244
}
4345

FrameLayoutKit.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Pod::Spec.new do |s|
22
s.name = 'FrameLayoutKit'
3-
s.version = '6.4.1'
3+
s.version = '6.5.0'
44
s.summary = 'FrameLayoutKit is a super fast and easy to use layout kit'
55
s.description = <<-DESC
66
An auto layout kit helps you to layout your UI easier, faster and more effective

FrameLayoutKit/Classes/Extensions/DoubleFrameLayout+Chainable.swift

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,14 @@ extension DoubleFrameLayout {
3030
return self
3131
}
3232

33+
@discardableResult public func leftView(_ view: UIView?) -> Self {
34+
setLeft(view)
35+
return self
36+
}
37+
38+
@discardableResult public func rightView(_ view: UIView?) -> Self {
39+
setRight(view)
40+
return self
41+
}
42+
3343
}

FrameLayoutKit/Classes/Extensions/FrameLayout+Chainable.swift

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,11 @@ import UIKit
1111
/**
1212
Supports chaining syntax:
1313

14-
frameLayout.flexible().align(vertical: .center, horizontal: .left).padding(top: 10, bottom: 20).minHeight(100)
14+
frameLayout
15+
.flexible()
16+
.align(vertical: .center, horizontal: .left)
17+
.padding(top: 10, bottom: 20)
18+
.minHeight(100)
1519
*/
1620

1721
extension FrameLayout {

FrameLayoutKit/Classes/Extensions/ScrollStackView+Chainable.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,8 +165,8 @@ extension ScrollStackView {
165165
return self
166166
}
167167

168-
@discardableResult public func fixItemSize(_ value: CGSize) -> Self {
169-
fixItemSize = value
168+
@discardableResult public func fixedItemSize(_ value: CGSize) -> Self {
169+
fixedItemSize = value
170170
return self
171171
}
172172

FrameLayoutKit/Classes/Extensions/StackFrameLayout+Chainable.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@ extension StackFrameLayout {
5050
return self
5151
}
5252

53-
@discardableResult public func fixItemSize(_ value: CGSize) -> Self {
54-
fixItemSize = value
53+
@discardableResult public func fixedItemSize(_ value: CGSize) -> Self {
54+
fixedItemSize = value
5555
return self
5656
}
5757

0 commit comments

Comments
 (0)