condensing
This commit is contained in:
parent
a0f9470c27
commit
5b5a03b869
@ -257,13 +257,11 @@ public class MoleculeStackView: ViewConstrainingView {
|
|||||||
view.alignHorizontal?(horizontalAlignment)
|
view.alignHorizontal?(horizontalAlignment)
|
||||||
view.alignVertical?(verticalAlignment)
|
view.alignVertical?(verticalAlignment)
|
||||||
}
|
}
|
||||||
let first = items.first(where: { (stackItem) -> Bool in
|
let first = items.first { !$0.gone } == nil
|
||||||
return !stackItem.gone
|
|
||||||
}) == nil
|
|
||||||
if axis == .vertical {
|
if axis == .vertical {
|
||||||
if first {
|
if first {
|
||||||
pinView(view, toView: contentView, attribute: .top, relation: .equal, priority: .required, constant: useStackSpacingBeforeFirstItem ? spacing : stackItem.spacing ?? 0)
|
pinView(view, toView: contentView, attribute: .top, relation: .equal, priority: .required, constant: useStackSpacingBeforeFirstItem ? spacing : stackItem.spacing ?? 0)
|
||||||
} else if let previousView = items.last(where: { (stackItem) -> Bool in
|
} else if let previousView = items.last(where: { stackItem in
|
||||||
return !stackItem.gone
|
return !stackItem.gone
|
||||||
})?.view {
|
})?.view {
|
||||||
_ = NSLayoutConstraint(pinFirstView: previousView, toSecondView: view, withConstant: spacing, directionVertical: true)
|
_ = NSLayoutConstraint(pinFirstView: previousView, toSecondView: view, withConstant: spacing, directionVertical: true)
|
||||||
@ -280,7 +278,7 @@ public class MoleculeStackView: ViewConstrainingView {
|
|||||||
if first {
|
if first {
|
||||||
// First horizontal item has no spacing by default unless told otherwise.
|
// First horizontal item has no spacing by default unless told otherwise.
|
||||||
pinView(view, toView: contentView, attribute: .leading, relation: .equal, priority: .required, constant: useStackSpacingBeforeFirstItem ? spacing : stackItem.spacing ?? 0)
|
pinView(view, toView: contentView, attribute: .leading, relation: .equal, priority: .required, constant: useStackSpacingBeforeFirstItem ? spacing : stackItem.spacing ?? 0)
|
||||||
} else if let previousView = items.last(where: { (stackItem) -> Bool in
|
} else if let previousView = items.last(where: { stackItem in
|
||||||
return !stackItem.gone
|
return !stackItem.gone
|
||||||
})?.view {
|
})?.view {
|
||||||
_ = NSLayoutConstraint(pinFirstView: previousView, toSecondView: view, withConstant: spacing, directionVertical: false)
|
_ = NSLayoutConstraint(pinFirstView: previousView, toSecondView: view, withConstant: spacing, directionVertical: false)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user