Fix poll percentage wrapping with larger font sizes (#1182)

This commit is contained in:
Sami Samhuri 2023-03-05 22:07:59 -08:00 committed by GitHub
parent b0ee77caed
commit 796f451f3a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -77,9 +77,15 @@ public struct StatusPollView: View {
.disabled(viewModel.poll.expired || (viewModel.poll.voted ?? false))
if viewModel.showResults || status.account.id == currentAccount.account?.id {
Spacer()
Text("\(percentForOption(option: option))%")
.font(.scaledSubheadline)
.frame(width: 40)
// Make sure they're all the same width using a ZStack with 100% hiding behind the
// real percentage.
ZStack(alignment: .trailing) {
Text("100%")
.hidden()
Text("\(percentForOption(option: option))%")
.font(.scaledSubheadline)
}
}
}
}