Fix ambiguous constraints in poll view

This commit is contained in:
Shadowfacts 2023-05-27 15:11:53 -07:00
parent 13a807ba4f
commit d9a6bb0fd2
2 changed files with 5 additions and 2 deletions

View File

@ -32,10 +32,12 @@ class PollVoteButton: UIView {
button.translatesAutoresizingMaskIntoConstraints = false
button.setTitleColor(.secondaryLabel, for: .disabled)
button.contentHorizontalAlignment = .trailing
embedSubview(button)
#if targetEnvironment(macCatalyst)
label.textColor = .secondaryLabel
label.translatesAutoresizingMaskIntoConstraints = false
label.textAlignment = .right
embedSubview(label)
#endif

View File

@ -67,6 +67,7 @@ class StatusPollView: UIView, StatusContentPollView {
voteButton.translatesAutoresizingMaskIntoConstraints = false
voteButton.addTarget(self, action: #selector(votePressed))
voteButton.setFont(infoLabel.font)
voteButton.setContentCompressionResistancePriority(.defaultHigh, for: .horizontal)
addSubview(voteButton)
NSLayoutConstraint.activate([
@ -77,7 +78,7 @@ class StatusPollView: UIView, StatusContentPollView {
infoLabel.leadingAnchor.constraint(equalTo: leadingAnchor),
infoLabel.topAnchor.constraint(equalTo: optionsView.bottomAnchor),
infoLabel.bottomAnchor.constraint(equalTo: bottomAnchor),
infoLabel.trailingAnchor.constraint(lessThanOrEqualTo: voteButton.leadingAnchor, constant: -8),
infoLabel.trailingAnchor.constraint(equalTo: voteButton.leadingAnchor, constant: -8),
voteButton.widthAnchor.constraint(greaterThanOrEqualToConstant: 44),
voteButton.trailingAnchor.constraint(equalTo: trailingAnchor),
@ -141,7 +142,7 @@ class StatusPollView: UIView, StatusContentPollView {
}
func estimateHeight(effectiveWidth: CGFloat) -> CGFloat {
guard let poll else { return 0 }
guard poll != nil else { return 0 }
return optionsView.estimateHeight(effectiveWidth: effectiveWidth) + infoLabel.sizeThatFits(UIView.layoutFittingExpandedSize).height
}