Fix poll option percentages getting cut off

Closes #120
This commit is contained in:
Shadowfacts 2021-05-22 11:44:50 -04:00
parent e745d78d67
commit b51c1c03cb
Signed by untrusted user: shadowfacts
GPG Key ID: 94A5AB95422746E5
1 changed files with 5 additions and 1 deletions

View File

@ -30,6 +30,7 @@ class PollOptionView: UIView {
let label = EmojiLabel()
label.translatesAutoresizingMaskIntoConstraints = false
label.numberOfLines = 0
label.font = .preferredFont(forTextStyle: .callout)
label.text = option.title
label.setEmojis(poll.emojis, identifier: poll.id)
addSubview(label)
@ -37,7 +38,10 @@ class PollOptionView: UIView {
let percentLabel = UILabel()
percentLabel.translatesAutoresizingMaskIntoConstraints = false
percentLabel.text = "100%"
percentLabel.font = label.font
percentLabel.isHidden = true
percentLabel.setContentCompressionResistancePriority(.required, for: .horizontal)
percentLabel.setContentHuggingPriority(.required, for: .horizontal)
addSubview(percentLabel)
if (poll.voted ?? false) || poll.effectiveExpired,
@ -76,7 +80,7 @@ class PollOptionView: UIView {
label.topAnchor.constraint(equalTo: topAnchor),
label.bottomAnchor.constraint(equalTo: bottomAnchor),
label.leadingAnchor.constraint(equalTo: checkbox.trailingAnchor, constant: 8),
label.trailingAnchor.constraint(equalTo: percentLabel.leadingAnchor),
label.trailingAnchor.constraint(equalTo: percentLabel.leadingAnchor, constant: -4),
percentLabel.topAnchor.constraint(equalTo: topAnchor),
percentLabel.bottomAnchor.constraint(equalTo: bottomAnchor),