Skip to content

Commit

Permalink
Add warning if sizeOffset is set when it should not
Browse files Browse the repository at this point in the history
  • Loading branch information
eonist committed Jun 29, 2023
1 parent 6a4a5ec commit f5f15f9
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
3 changes: 2 additions & 1 deletion Sources/Spatial/view/View+Access.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,10 @@ extension View {
*/
public func anchorAndSize(to: View, sizeTo: View? = nil, width: CGFloat? = nil, height: CGFloat? = nil, align: Alignment = .topLeft, alignTo: Alignment = .topLeft, multiplier: CGSize = .init(width: 1, height: 1), offset: CGPoint = .zero, sizeOffset: CGSize = .zero, useMargin: Bool = false) {

Check failure on line 25 in Sources/Spatial/view/View+Access.swift

View workflow job for this annotation

GitHub Actions / SwiftLint

Line Length Violation: Line should be 200 characters or less; currently it has 295 characters (line_length)
self.activateAnchorAndSize { _ in
let anchor = Constraint.anchor(self, to: to, align: align, alignTo: alignTo, offset: offset, useMargin: useMargin)
let anchor: AnchorConstraint = Constraint.anchor(self, to: to, align: align, alignTo: alignTo, offset: offset, useMargin: useMargin)
let size: SizeConstraint = {
if let width = width, let height = height { // This method exists when you have size, but don't want to set size based on another view
if sizeOffset != .zero { Swift.print("⚠️️ sizeOffset does not affect constraints when width and height are predfined, set offset to the width and height directly") }
return Constraint.size(self, size: .init(width: width, height: height), multiplier: multiplier)
} else {
return Constraint.size(self, to: sizeTo ?? to, width: width, height: height, offset: sizeOffset, multiplier: multiplier)
Expand Down
2 changes: 1 addition & 1 deletion Sources/Spatial/view/View+Size.swift
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ extension Constraint {
}
/**
* Creates a size constraint
* - Fixme: ⚠️️ This doesn't have offset, maybe it should, for now I guess you can always inset the size
* - Fixme: ⚠️️ This doesn't have offset, maybe it should, for now I guess you can always inset the size, or add etc
* ## Examples:
* let sizeConstraint = Constraint.size(square, size: .init(width: 100, height: 100))
* - Parameters:
Expand Down

0 comments on commit f5f15f9

Please sign in to comment.