Skip to content

Commit 8794b2a

Browse files
committed
added debug chainnable syntax to ScrollStackView, and disable warning debug message on default
1 parent aceb57f commit 8794b2a

7 files changed

Lines changed: 23 additions & 35 deletions

File tree

Binary file not shown.

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.5.0'
3+
s.version = '6.5.2'
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/DoubleFrameLayout.swift

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -118,15 +118,11 @@ open class DoubleFrameLayout: FrameLayout {
118118
}
119119

120120
override open var frame: CGRect {
121-
didSet {
122-
setNeedsLayout()
123-
}
121+
didSet { setNeedsLayout() }
124122
}
125123

126124
override open var bounds: CGRect {
127-
didSet {
128-
setNeedsLayout()
129-
}
125+
didSet { setNeedsLayout() }
130126
}
131127

132128
override open var description: String {
@@ -172,9 +168,7 @@ open class DoubleFrameLayout: FrameLayout {
172168
}
173169

174170
public var isOverlapped: Bool = false {
175-
didSet {
176-
setNeedsLayout()
177-
}
171+
didSet { setNeedsLayout() }
178172
}
179173

180174
// MARK: -

FrameLayoutKit/Classes/Extensions/ScrollStackView+Chainable.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,4 +175,9 @@ extension ScrollStackView {
175175
return self
176176
}
177177

178+
@discardableResult public func debug(_ value: Bool) -> Self {
179+
debug = value
180+
return self
181+
}
182+
178183
}

FrameLayoutKit/Classes/FrameLayout.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ public enum NKContentHorizontalAlignment {
2828
FrameLayout is the fundamental component of the kit. This class will automatically adjust the size and position of the view assigned to it based on the size and position of the frameLayout itself, and the specified alignment value.
2929
*/
3030
open class FrameLayout: UIView {
31+
/// Show warnings on debug console when adding a UIControl without `isUserInteractionEnabled` turned on, which will make that control untouchabe
32+
public static var showDebugWarnings = false
33+
3134
/// Target view that handled by this frameLayout
3235
public var targetView: UIView?
3336
/// Additional views that will have their frames binding to `targetView`'s frame

FrameLayoutKit/Classes/ScrollStackView.swift

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,15 +46,11 @@ open class ScrollStackView: UIView {
4646
}
4747

4848
override open var frame: CGRect {
49-
didSet {
50-
setNeedsLayout()
51-
}
49+
didSet { setNeedsLayout() }
5250
}
5351

5452
override open var bounds: CGRect {
55-
didSet {
56-
setNeedsLayout()
57-
}
53+
didSet { setNeedsLayout() }
5854
}
5955

6056
public var axis: NKLayoutAxis {

FrameLayoutKit/Classes/StackFrameLayout.swift

Lines changed: 9 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -20,21 +20,15 @@ open class StackFrameLayout: FrameLayout {
2020
}
2121

2222
public var isOverlapped: Bool = false {
23-
didSet {
24-
setNeedsLayout()
25-
}
23+
didSet { setNeedsLayout() }
2624
}
2725

2826
public var isJustified: Bool = false {
29-
didSet {
30-
setNeedsLayout()
31-
}
27+
didSet { setNeedsLayout() }
3228
}
3329

3430
public var justifyThreshold: CGFloat = 0.0 {
35-
didSet {
36-
setNeedsLayout()
37-
}
31+
didSet { setNeedsLayout() }
3832
}
3933

4034
override open var ignoreHiddenView: Bool {
@@ -105,15 +99,11 @@ open class StackFrameLayout: FrameLayout {
10599
}
106100

107101
override open var frame: CGRect {
108-
didSet {
109-
setNeedsLayout()
110-
}
102+
didSet { setNeedsLayout() }
111103
}
112104

113105
override open var bounds: CGRect {
114-
didSet {
115-
setNeedsLayout()
116-
}
106+
didSet { setNeedsLayout() }
117107
}
118108

119109
override open var clipsToBounds: Bool {
@@ -188,18 +178,17 @@ open class StackFrameLayout: FrameLayout {
188178
}
189179
else {
190180
if let view = view, view.superview == nil {
191-
/*
192181
#if DEBUG
193-
if !isUserInteractionEnabled, view is UIControl {
182+
if FrameLayout.showDebugWarnings, !isUserInteractionEnabled, view is UIControl {
194183
print("⚠️ [FrameLayoutKit] \(view) was automatically added to StackFrameLayout \(self) which was disabled user interation. This could make your control unable to interact. You can either set isUserInteractionEnabled = true for this FrameLayout or addSubview(your control) before adding to frameLayout.")
195184
}
196185
#endif
197-
*/
198186
addSubview(view)
199187
}
200188

201189
let frameLayout = FrameLayout(targetView: view)
202190
frameLayout.debug = debug
191+
frameLayout.debugColor = debugColor
203192
frameLayout.ignoreHiddenView = ignoreHiddenView
204193
frameLayout.fixedContentSize = fixedItemSize
205194
frameLayout.minContentSize = minItemSize
@@ -220,7 +209,7 @@ open class StackFrameLayout: FrameLayout {
220209
else {
221210
if let view = view, view.superview == nil {
222211
#if DEBUG
223-
if !isUserInteractionEnabled, view is UIControl {
212+
if FrameLayout.showDebugWarnings, !isUserInteractionEnabled, view is UIControl {
224213
print("⚠️ [FrameLayoutKit] \(view) was automatically added to StackFrameLayout \(self) which was disabled user interation. This could make your control unable to interact. You can either set isUserInteractionEnabled = true for this FrameLayout or addSubview(your control) before adding to frameLayout.")
225214
}
226215
#endif
@@ -229,6 +218,7 @@ open class StackFrameLayout: FrameLayout {
229218

230219
let frameLayout = FrameLayout(targetView: view)
231220
frameLayout.debug = debug
221+
frameLayout.debugColor = debugColor
232222
frameLayout.ignoreHiddenView = ignoreHiddenView
233223
frameLayout.fixedContentSize = fixedItemSize
234224
frameLayout.minContentSize = minItemSize

0 commit comments

Comments
 (0)