mirror of
https://github.com/Dimillian/IceCubesApp.git
synced 2025-01-27 12:59:17 +01:00
Poll: Support hidden votesCount close #1354
This commit is contained in:
parent
ab5c6643b3
commit
2601764b28
@ -16,7 +16,7 @@ public struct Poll: Codable, Equatable, Hashable {
|
|||||||
|
|
||||||
public var id = UUID().uuidString
|
public var id = UUID().uuidString
|
||||||
public let title: String
|
public let title: String
|
||||||
public let votesCount: Int
|
public let votesCount: Int?
|
||||||
}
|
}
|
||||||
|
|
||||||
public let id: String
|
public let id: String
|
||||||
|
@ -33,8 +33,8 @@ public struct StatusPollView: View {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private func ratioForOption(option: Poll.Option) -> CGFloat {
|
private func ratioForOption(option: Poll.Option) -> CGFloat {
|
||||||
if viewModel.poll.safeVotersCount != 0 {
|
if let votesCount = option.votesCount, viewModel.poll.safeVotersCount != 0 {
|
||||||
return CGFloat(option.votesCount) / CGFloat(viewModel.poll.safeVotersCount)
|
return CGFloat(votesCount) / CGFloat(viewModel.poll.safeVotersCount)
|
||||||
} else {
|
} else {
|
||||||
return 0.0
|
return 0.0
|
||||||
}
|
}
|
||||||
|
@ -335,8 +335,8 @@ private struct CombinedAccessibilityLabel {
|
|||||||
return poll.options.enumerated().reduce(into: Text(title)) { text, pair in
|
return poll.options.enumerated().reduce(into: Text(title)) { text, pair in
|
||||||
let (index, option) = pair
|
let (index, option) = pair
|
||||||
let selected = poll.ownVotes?.contains(index) ?? false
|
let selected = poll.ownVotes?.contains(index) ?? false
|
||||||
let percentage = poll.safeVotersCount > 0
|
let percentage = poll.safeVotersCount > 0 && option.votesCount != nil
|
||||||
? Int(round(Double(option.votesCount) / Double(poll.safeVotersCount) * 100))
|
? Int(round(Double(option.votesCount!) / Double(poll.safeVotersCount) * 100))
|
||||||
: 0
|
: 0
|
||||||
|
|
||||||
text = text +
|
text = text +
|
||||||
|
Loading…
x
Reference in New Issue
Block a user