Skip to content

Commit

Permalink
added debug chainnable syntax to ScrollStackView, and disable warning…
Browse files Browse the repository at this point in the history
… debug message on default
  • Loading branch information
kennic committed Feb 3, 2023
1 parent aceb57f commit 8794b2a
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 35 deletions.
Binary file not shown.
2 changes: 1 addition & 1 deletion FrameLayoutKit.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = 'FrameLayoutKit'
s.version = '6.5.0'
s.version = '6.5.2'
s.summary = 'FrameLayoutKit is a super fast and easy to use layout kit'
s.description = <<-DESC
An auto layout kit helps you to layout your UI easier, faster and more effective
Expand Down
12 changes: 3 additions & 9 deletions FrameLayoutKit/Classes/DoubleFrameLayout.swift
Original file line number Diff line number Diff line change
Expand Up @@ -118,15 +118,11 @@ open class DoubleFrameLayout: FrameLayout {
}

override open var frame: CGRect {
didSet {
setNeedsLayout()
}
didSet { setNeedsLayout() }
}

override open var bounds: CGRect {
didSet {
setNeedsLayout()
}
didSet { setNeedsLayout() }
}

override open var description: String {
Expand Down Expand Up @@ -172,9 +168,7 @@ open class DoubleFrameLayout: FrameLayout {
}

public var isOverlapped: Bool = false {
didSet {
setNeedsLayout()
}
didSet { setNeedsLayout() }
}

// MARK: -
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,4 +175,9 @@ extension ScrollStackView {
return self
}

@discardableResult public func debug(_ value: Bool) -> Self {
debug = value
return self
}

}
3 changes: 3 additions & 0 deletions FrameLayoutKit/Classes/FrameLayout.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ public enum NKContentHorizontalAlignment {
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.
*/
open class FrameLayout: UIView {
/// Show warnings on debug console when adding a UIControl without `isUserInteractionEnabled` turned on, which will make that control untouchabe
public static var showDebugWarnings = false

/// Target view that handled by this frameLayout
public var targetView: UIView?
/// Additional views that will have their frames binding to `targetView`'s frame
Expand Down
8 changes: 2 additions & 6 deletions FrameLayoutKit/Classes/ScrollStackView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,11 @@ open class ScrollStackView: UIView {
}

override open var frame: CGRect {
didSet {
setNeedsLayout()
}
didSet { setNeedsLayout() }
}

override open var bounds: CGRect {
didSet {
setNeedsLayout()
}
didSet { setNeedsLayout() }
}

public var axis: NKLayoutAxis {
Expand Down
28 changes: 9 additions & 19 deletions FrameLayoutKit/Classes/StackFrameLayout.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,21 +20,15 @@ open class StackFrameLayout: FrameLayout {
}

public var isOverlapped: Bool = false {
didSet {
setNeedsLayout()
}
didSet { setNeedsLayout() }
}

public var isJustified: Bool = false {
didSet {
setNeedsLayout()
}
didSet { setNeedsLayout() }
}

public var justifyThreshold: CGFloat = 0.0 {
didSet {
setNeedsLayout()
}
didSet { setNeedsLayout() }
}

override open var ignoreHiddenView: Bool {
Expand Down Expand Up @@ -105,15 +99,11 @@ open class StackFrameLayout: FrameLayout {
}

override open var frame: CGRect {
didSet {
setNeedsLayout()
}
didSet { setNeedsLayout() }
}

override open var bounds: CGRect {
didSet {
setNeedsLayout()
}
didSet { setNeedsLayout() }
}

override open var clipsToBounds: Bool {
Expand Down Expand Up @@ -188,18 +178,17 @@ open class StackFrameLayout: FrameLayout {
}
else {
if let view = view, view.superview == nil {
/*
#if DEBUG
if !isUserInteractionEnabled, view is UIControl {
if FrameLayout.showDebugWarnings, !isUserInteractionEnabled, view is UIControl {
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.")
}
#endif
*/
addSubview(view)
}

let frameLayout = FrameLayout(targetView: view)
frameLayout.debug = debug
frameLayout.debugColor = debugColor
frameLayout.ignoreHiddenView = ignoreHiddenView
frameLayout.fixedContentSize = fixedItemSize
frameLayout.minContentSize = minItemSize
Expand All @@ -220,7 +209,7 @@ open class StackFrameLayout: FrameLayout {
else {
if let view = view, view.superview == nil {
#if DEBUG
if !isUserInteractionEnabled, view is UIControl {
if FrameLayout.showDebugWarnings, !isUserInteractionEnabled, view is UIControl {
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.")
}
#endif
Expand All @@ -229,6 +218,7 @@ open class StackFrameLayout: FrameLayout {

let frameLayout = FrameLayout(targetView: view)
frameLayout.debug = debug
frameLayout.debugColor = debugColor
frameLayout.ignoreHiddenView = ignoreHiddenView
frameLayout.fixedContentSize = fixedItemSize
frameLayout.minContentSize = minItemSize
Expand Down

0 comments on commit 8794b2a

Please sign in to comment.