Skip to content

Commit

Permalink
Add require and prioritize methods to Layout (#255)
Browse files Browse the repository at this point in the history
  • Loading branch information
tinder-cfuller authored Dec 13, 2023
1 parent 73a3332 commit b35c649
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions Sources/Layout/Layout.swift
Original file line number Diff line number Diff line change
Expand Up @@ -407,12 +407,6 @@ public final class Layout { // swiftlint:disable:this type_body_length
return self
}

@discardableResult
public func withPriority(_ priority: UILayoutPriority) -> Layout {
constraints.prioritize(priority)
return self
}

@discardableResult
public func activate() -> Layout {
constraints.activate()
Expand All @@ -425,6 +419,19 @@ public final class Layout { // swiftlint:disable:this type_body_length
return self
}

public func require() -> Layout {
withPriority(.required)
}

public func withPriority(_ priority: UILayoutPriority) -> Layout {
constraints.prioritize(priority)
return self
}

public func prioritize(_ priority: UILayoutPriority) {
constraints.forEach { $0.prioritize(priority) }
}

public func update() {
view?.setNeedsUpdateConstraints()
view?.updateConstraintsIfNeeded()
Expand Down

0 comments on commit b35c649

Please sign in to comment.