Skip to content

Commit

Permalink
Fixed isEnabled did not work
Browse files Browse the repository at this point in the history
  • Loading branch information
kennic committed Sep 30, 2023
1 parent 6311d44 commit ccb3527
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 1 deletion.
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 = '7.0.2'
s.version = '7.0.3'
s.summary = 'FrameLayoutKit is a super fast and easy to use layout kit'
s.description = <<-DESC
FrameLayoutKit is a powerful Swift library designed to streamline the process of creating user interfaces. With its intuitive operator syntax and support for nested functions, developers can effortlessly construct complex UI layouts with minimal code. By leveraging the flexibility of operators, developers can easily position and arrange views within a container view, enabling precise control over the visual hierarchy. Additionally, the library offers a range of convenient functions for configuring view properties, such as setting dimensions, margins, and alignment. Whether you're building a simple screen or a complex interface, FrameLayoutKit simplifies the UI creation process, resulting in cleaner, more maintainable code.
Expand Down
3 changes: 3 additions & 0 deletions FrameLayoutKit/Classes/DoubleFrameLayout.swift
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,8 @@ open class DoubleFrameLayout: FrameLayout {
}

open override func sizeThatFits(_ size: CGSize, ignoreHiddenView: Bool) -> CGSize {
if !isEnabled { return .zero }

willSizeThatFitsBlock?(self, size)

var result: CGSize = size
Expand Down Expand Up @@ -619,6 +621,7 @@ open class DoubleFrameLayout: FrameLayout {

override open func layoutSubviews() {
super.layoutSubviews()
if !isEnabled { return }

defer {
didLayoutSubviewsBlock?(self)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,11 @@ extension ScrollStackView {
return self
}

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

@discardableResult public func willLayoutSubviews(_ block: @escaping (ScrollStackView) -> Void) -> Self {
willLayoutSubviewsBlock = block
return self
Expand Down
3 changes: 3 additions & 0 deletions FrameLayoutKit/Classes/FlowFrameLayout.swift
Original file line number Diff line number Diff line change
Expand Up @@ -356,12 +356,15 @@ open class FlowFrameLayout: FrameLayout {
}

override open func sizeThatFits(_ size: CGSize) -> CGSize {
if !isEnabled { return .zero }

willSizeThatFitsBlock?(self, size)
return calculateSize(fitSize: size).size.limitTo(minSize: minSize, maxSize: maxSize)
}

open override func layoutSubviews() {
super.layoutSubviews()
if !isEnabled { return }

defer {
didLayoutSubviewsBlock?(self)
Expand Down
2 changes: 2 additions & 0 deletions FrameLayoutKit/Classes/GridFrameLayout.swift
Original file line number Diff line number Diff line change
Expand Up @@ -494,6 +494,7 @@ open class GridFrameLayout: FrameLayout {
fileprivate var lastSize: CGSize = .zero
open override func layoutSubviews() {
super.layoutSubviews()
if !isEnabled { return }

if maxColumnWidth > 0, lastSize != bounds.size {
lastSize = bounds.size
Expand All @@ -506,6 +507,7 @@ open class GridFrameLayout: FrameLayout {
}

open override func sizeThatFits(_ size: CGSize) -> CGSize {
if !isEnabled { return .zero }
return stackLayout.sizeThatFits(size)
}

Expand Down
5 changes: 5 additions & 0 deletions FrameLayoutKit/Classes/ScrollStackView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,8 @@ open class ScrollStackView: UIView {
}
}

public var isEnabled = true

public var heightRatio: CGFloat {
get { frameLayout.heightRatio }
set {
Expand Down Expand Up @@ -428,11 +430,14 @@ open class ScrollStackView: UIView {
}

override open func sizeThatFits(_ size: CGSize) -> CGSize {
if !isEnabled { return .zero }
willSizeThatFitsBlock?(self, size)
return frameLayout.sizeThatFits(size)
}

override open func layoutSubviews() {
if !isEnabled { return }

willLayoutSubviewsBlock?(self)
super.layoutSubviews()

Expand Down
2 changes: 2 additions & 0 deletions FrameLayoutKit/Classes/StackFrameLayout.swift
Original file line number Diff line number Diff line change
Expand Up @@ -389,6 +389,7 @@ open class StackFrameLayout: FrameLayout {
// MARK: -

open override func sizeThatFits(_ size: CGSize, ignoreHiddenView: Bool) -> CGSize {
if !isEnabled { return .zero }
willSizeThatFitsBlock?(self, size)

var result: CGSize = size
Expand Down Expand Up @@ -579,6 +580,7 @@ open class StackFrameLayout: FrameLayout {

override open func layoutSubviews() {
super.layoutSubviews()
if !isEnabled { return }

defer {
didLayoutSubviewsBlock?(self)
Expand Down

0 comments on commit ccb3527

Please sign in to comment.