diff --git a/Tusker/Views/Status/StatusContentContainer.swift b/Tusker/Views/Status/StatusContentContainer.swift index 5ae4652e..64dce514 100644 --- a/Tusker/Views/Status/StatusContentContainer.swift +++ b/Tusker/Views/Status/StatusContentContainer.swift @@ -42,6 +42,8 @@ class StatusContentContainer: UIView { private var verticalConstraints: [NSLayoutConstraint] = [] private var lastSubviewBottomConstraint: NSLayoutConstraint? private var zeroHeightConstraint: NSLayoutConstraint! + + private var isCollapsed = false override init(frame: CGRect) { super.init(frame: frame) @@ -97,13 +99,20 @@ class StatusContentContainer: UIView { lastSubviewBottomConstraint?.isActive = false // this constraint needs to have low priority so that during the collapse/expand animation, the content container is the view that shrinks/expands lastSubviewBottomConstraint = subviews.last(where: { !$0.isHidden })!.bottomAnchor.constraint(equalTo: bottomAnchor) - lastSubviewBottomConstraint!.isActive = true + lastSubviewBottomConstraint!.isActive = !isCollapsed lastSubviewBottomConstraint!.priority = .defaultLow + zeroHeightConstraint.isActive = isCollapsed + super.updateConstraints() } func setCollapsed(_ collapsed: Bool) { + guard collapsed != isCollapsed else { + return + } + isCollapsed = collapsed + // ensure that we have a lastSubviewBottomConstraint updateConstraintsIfNeeded() // force unwrap because the content container should always have at least one view