forked from shadowfacts/Tusker
Don't update constraints in StatusContentContainer.setCollapsed unless the state actually changes
This commit is contained in:
parent
6501343f24
commit
97c7104dbc
|
@ -43,6 +43,8 @@ class StatusContentContainer: UIView {
|
|||
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
|
||||
|
|
Loading…
Reference in New Issue