mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-10-09 03:20:48 +00:00
Merge branch 'master' of gitlab.com:peter-iakovlev/telegram-ios
This commit is contained in:
commit
9f58b7e39f
@ -727,8 +727,8 @@ public func createPollController(context: AccountContext, peer: Peer, isQuiz: Bo
|
||||
} else {
|
||||
kind = .poll(multipleAnswers: state.isMultipleChoice)
|
||||
}
|
||||
completion(.message(text: "", attributes: [], mediaReference: .standalone(media: TelegramMediaPoll(pollId: MediaId(namespace: Namespaces.Media.LocalPoll, id: arc4random64()), publicity: publicity, kind: kind, text: processPollText(state.text), options: options, correctAnswers: correctAnswers, results: TelegramMediaPollResults(voters: nil, totalVoters: nil, recentVoters: []), isClosed: false)), replyToMessageId: nil, localGroupingKey: nil))
|
||||
dismissImpl?()
|
||||
completion(.message(text: "", attributes: [], mediaReference: .standalone(media: TelegramMediaPoll(pollId: MediaId(namespace: Namespaces.Media.LocalPoll, id: arc4random64()), publicity: publicity, kind: kind, text: processPollText(state.text), options: options, correctAnswers: correctAnswers, results: TelegramMediaPollResults(voters: nil, totalVoters: nil, recentVoters: []), isClosed: false)), replyToMessageId: nil, localGroupingKey: nil))
|
||||
})
|
||||
|
||||
let leftNavigationButton = ItemListNavigationButton(content: .text(presentationData.strings.Common_Cancel), style: .regular, enabled: true, action: {
|
||||
@ -777,7 +777,6 @@ public func createPollController(context: AccountContext, peer: Peer, isQuiz: Bo
|
||||
controller?.present(c, in: .window(.root), with: a)
|
||||
}
|
||||
dismissImpl = { [weak controller] in
|
||||
//controller?.view.endEditing(true)
|
||||
controller?.dismiss()
|
||||
}
|
||||
ensureTextVisibleImpl = { [weak controller] in
|
||||
|
@ -1247,6 +1247,7 @@ public class ItemListPeerItemNode: ItemListRevealOptionsItemNode, ItemListItemNo
|
||||
public final class ItemListPeerItemHeader: ListViewItemHeader {
|
||||
public let id: Int64
|
||||
public let text: String
|
||||
public let additionalText: String
|
||||
public let stickDirection: ListViewItemHeaderStickDirection = .topEdge
|
||||
public let theme: PresentationTheme
|
||||
public let strings: PresentationStrings
|
||||
@ -1255,8 +1256,9 @@ public final class ItemListPeerItemHeader: ListViewItemHeader {
|
||||
|
||||
public let height: CGFloat = 28.0
|
||||
|
||||
public init(theme: PresentationTheme, strings: PresentationStrings, text: String, actionTitle: String? = nil, id: Int64, action: (() -> Void)? = nil) {
|
||||
public init(theme: PresentationTheme, strings: PresentationStrings, text: String, additionalText: String, actionTitle: String? = nil, id: Int64, action: (() -> Void)? = nil) {
|
||||
self.text = text
|
||||
self.additionalText = additionalText
|
||||
self.id = id
|
||||
self.theme = theme
|
||||
self.strings = strings
|
||||
@ -1265,11 +1267,11 @@ public final class ItemListPeerItemHeader: ListViewItemHeader {
|
||||
}
|
||||
|
||||
public func node() -> ListViewItemHeaderNode {
|
||||
return ItemListPeerItemHeaderNode(theme: self.theme, strings: self.strings, text: self.text, actionTitle: self.actionTitle, action: self.action)
|
||||
return ItemListPeerItemHeaderNode(theme: self.theme, strings: self.strings, text: self.text, additionalText: self.additionalText, actionTitle: self.actionTitle, action: self.action)
|
||||
}
|
||||
|
||||
public func updateNode(_ node: ListViewItemHeaderNode, previous: ListViewItemHeader?, next: ListViewItemHeader?) {
|
||||
(node as? ItemListPeerItemHeaderNode)?.update(text: self.text, actionTitle: self.actionTitle, action: self.action)
|
||||
(node as? ItemListPeerItemHeaderNode)?.update(text: self.text, additionalText: self.additionalText, actionTitle: self.actionTitle, action: self.action)
|
||||
}
|
||||
}
|
||||
|
||||
@ -1285,12 +1287,13 @@ public final class ItemListPeerItemHeaderNode: ListViewItemHeaderNode {
|
||||
private let snappedBackgroundNode: ASDisplayNode
|
||||
private let separatorNode: ASDisplayNode
|
||||
private let textNode: ImmediateTextNode
|
||||
private let additionalTextNode: ImmediateTextNode
|
||||
private let actionTextNode: ImmediateTextNode
|
||||
private let actionButton: HighlightableButtonNode
|
||||
|
||||
private var stickDistanceFactor: CGFloat?
|
||||
|
||||
public init(theme: PresentationTheme, strings: PresentationStrings, text: String, actionTitle: String?, action: (() -> Void)?) {
|
||||
public init(theme: PresentationTheme, strings: PresentationStrings, text: String, additionalText: String, actionTitle: String?, action: (() -> Void)?) {
|
||||
self.theme = theme
|
||||
self.strings = strings
|
||||
self.actionTitle = actionTitle
|
||||
@ -1312,9 +1315,13 @@ public final class ItemListPeerItemHeaderNode: ListViewItemHeaderNode {
|
||||
self.textNode = ImmediateTextNode()
|
||||
self.textNode.displaysAsynchronously = false
|
||||
self.textNode.maximumNumberOfLines = 1
|
||||
self.textNode.truncationType = .middle
|
||||
self.textNode.attributedText = NSAttributedString(string: text, font: titleFont, textColor: theme.list.sectionHeaderTextColor)
|
||||
|
||||
self.additionalTextNode = ImmediateTextNode()
|
||||
self.additionalTextNode.displaysAsynchronously = false
|
||||
self.additionalTextNode.maximumNumberOfLines = 1
|
||||
self.additionalTextNode.attributedText = NSAttributedString(string: additionalText, font: titleFont, textColor: theme.list.sectionHeaderTextColor)
|
||||
|
||||
self.actionTextNode = ImmediateTextNode()
|
||||
self.actionTextNode.displaysAsynchronously = false
|
||||
self.actionTextNode.maximumNumberOfLines = 1
|
||||
@ -1329,6 +1336,7 @@ public final class ItemListPeerItemHeaderNode: ListViewItemHeaderNode {
|
||||
self.addSubnode(self.snappedBackgroundNode)
|
||||
self.addSubnode(self.separatorNode)
|
||||
self.addSubnode(self.textNode)
|
||||
self.addSubnode(self.additionalTextNode)
|
||||
self.addSubnode(self.actionTextNode)
|
||||
self.addSubnode(self.actionButton)
|
||||
|
||||
@ -1356,14 +1364,16 @@ public final class ItemListPeerItemHeaderNode: ListViewItemHeaderNode {
|
||||
let titleFont = Font.regular(13.0)
|
||||
|
||||
self.textNode.attributedText = NSAttributedString(string: self.textNode.attributedText?.string ?? "", font: titleFont, textColor: theme.list.sectionHeaderTextColor)
|
||||
self.additionalTextNode.attributedText = NSAttributedString(string: self.additionalTextNode.attributedText?.string ?? "", font: titleFont, textColor: theme.list.sectionHeaderTextColor)
|
||||
self.actionTextNode.attributedText = NSAttributedString(string: self.actionTextNode.attributedText?.string ?? "", font: titleFont, textColor: theme.list.sectionHeaderTextColor)
|
||||
}
|
||||
|
||||
public func update(text: String, actionTitle: String?, action: (() -> Void)?) {
|
||||
public func update(text: String, additionalText: String, actionTitle: String?, action: (() -> Void)?) {
|
||||
self.actionTitle = actionTitle
|
||||
self.action = action
|
||||
let titleFont = Font.regular(13.0)
|
||||
self.textNode.attributedText = NSAttributedString(string: text, font: titleFont, textColor: theme.list.sectionHeaderTextColor)
|
||||
self.additionalTextNode.attributedText = NSAttributedString(string: additionalText, font: titleFont, textColor: theme.list.sectionHeaderTextColor)
|
||||
self.actionTextNode.attributedText = NSAttributedString(string: actionTitle ?? "", font: titleFont, textColor: action == nil ? theme.list.sectionHeaderTextColor : theme.list.itemAccentColor)
|
||||
self.actionButton.isUserInteractionEnabled = self.action != nil
|
||||
if let (size, leftInset, rightInset) = self.validLayout {
|
||||
@ -1380,9 +1390,12 @@ public final class ItemListPeerItemHeaderNode: ListViewItemHeaderNode {
|
||||
let sideInset: CGFloat = 15.0 + leftInset
|
||||
|
||||
let actionTextSize = self.actionTextNode.updateLayout(CGSize(width: size.width - sideInset * 2.0, height: size.height))
|
||||
let textSize = self.textNode.updateLayout(CGSize(width: size.width - sideInset * 2.0 - actionTextSize.width - 8.0, height: size.height))
|
||||
let additionalTextSize = self.additionalTextNode.updateLayout(CGSize(width: size.width - sideInset * 2.0 - actionTextSize.width - 8.0, height: size.height))
|
||||
let textSize = self.textNode.updateLayout(CGSize(width: max(1.0, size.width - sideInset * 2.0 - actionTextSize.width - 8.0 - additionalTextSize.width), height: size.height))
|
||||
|
||||
self.textNode.frame = CGRect(origin: CGPoint(x: sideInset, y: 7.0), size: textSize)
|
||||
let textFrame = CGRect(origin: CGPoint(x: sideInset, y: 7.0), size: textSize)
|
||||
self.textNode.frame = textFrame
|
||||
self.additionalTextNode.frame = CGRect(origin: CGPoint(x: textFrame.maxX, y: 7.0), size: additionalTextSize)
|
||||
self.actionTextNode.frame = CGRect(origin: CGPoint(x: size.width - sideInset - actionTextSize.width, y: 7.0), size: actionTextSize)
|
||||
self.actionButton.frame = CGRect(origin: CGPoint(x: size.width - sideInset - actionTextSize.width, y: 0.0), size: CGSize(width: actionTextSize.width, height: size.height))
|
||||
}
|
||||
|
@ -301,8 +301,6 @@ public func legacyAttachmentMenu(context: AccountContext, peer: Peer, editMediaO
|
||||
peerSupportsPolls = true
|
||||
} else if let user = peer as? TelegramUser, let _ = user.botInfo {
|
||||
peerSupportsPolls = true
|
||||
} else if peer.id == context.account.peerId {
|
||||
peerSupportsPolls = true
|
||||
}
|
||||
if peerSupportsPolls && canSendMessagesToPeer(peer) && canSendPolls {
|
||||
let pollItem = TGMenuSheetButtonItemView(title: presentationData.strings.AttachmentMenu_Poll, type: TGMenuSheetButtonTypeDefault, fontSize: fontSize, action: { [weak controller] in
|
||||
|
@ -217,13 +217,17 @@ public final class TelegramMediaPoll: Media, Equatable {
|
||||
if min {
|
||||
if let currentVoters = self.results.voters, let updatedVoters = results.voters {
|
||||
var selectedOpaqueIdentifiers = Set<Data>()
|
||||
var correctOpaqueIdentifiers = Set<Data>()
|
||||
for voters in currentVoters {
|
||||
if voters.selected {
|
||||
selectedOpaqueIdentifiers.insert(voters.opaqueIdentifier)
|
||||
}
|
||||
if voters.isCorrect {
|
||||
correctOpaqueIdentifiers.insert(voters.opaqueIdentifier)
|
||||
}
|
||||
}
|
||||
updatedResults = TelegramMediaPollResults(voters: updatedVoters.map({ voters in
|
||||
return TelegramMediaPollOptionVoters(selected: selectedOpaqueIdentifiers.contains(voters.opaqueIdentifier), opaqueIdentifier: voters.opaqueIdentifier, count: voters.count, isCorrect: voters.isCorrect)
|
||||
return TelegramMediaPollOptionVoters(selected: selectedOpaqueIdentifiers.contains(voters.opaqueIdentifier), opaqueIdentifier: voters.opaqueIdentifier, count: voters.count, isCorrect: correctOpaqueIdentifiers.contains(voters.opaqueIdentifier))
|
||||
}), totalVoters: results.totalVoters, recentVoters: results.recentVoters)
|
||||
} else {
|
||||
updatedResults = TelegramMediaPollResults(voters: self.results.voters, totalVoters: results.totalVoters, recentVoters: results.recentVoters)
|
||||
|
@ -21,42 +21,58 @@ public func requestMessageSelectPollOption(account: Account, messageId: MessageI
|
||||
return .generic
|
||||
}
|
||||
|> mapToSignal { result -> Signal<TelegramMediaPoll?, RequestMessageSelectPollOptionError> in
|
||||
var resultPoll: TelegramMediaPoll?
|
||||
switch result {
|
||||
case let .updates(updates, _, _, _, _):
|
||||
for update in updates {
|
||||
switch update {
|
||||
case let .updateMessagePoll(_, pollId, poll, results):
|
||||
if let poll = poll {
|
||||
switch poll {
|
||||
case let .poll(id, flags, question, answers):
|
||||
let publicity: TelegramMediaPollPublicity
|
||||
if (flags & (1 << 1)) != 0 {
|
||||
publicity = .public
|
||||
} else {
|
||||
publicity = .anonymous
|
||||
return account.postbox.transaction { transaction -> TelegramMediaPoll? in
|
||||
var resultPoll: TelegramMediaPoll?
|
||||
switch result {
|
||||
case let .updates(updates, _, _, _, _):
|
||||
for update in updates {
|
||||
switch update {
|
||||
case let .updateMessagePoll(_, id, poll, results):
|
||||
let pollId = MediaId(namespace: Namespaces.Media.CloudPoll, id: id)
|
||||
resultPoll = transaction.getMedia(pollId) as? TelegramMediaPoll
|
||||
if let poll = poll {
|
||||
switch poll {
|
||||
case let .poll(id, flags, question, answers):
|
||||
let publicity: TelegramMediaPollPublicity
|
||||
if (flags & (1 << 1)) != 0 {
|
||||
publicity = .public
|
||||
} else {
|
||||
publicity = .anonymous
|
||||
}
|
||||
let kind: TelegramMediaPollKind
|
||||
if (flags & (1 << 3)) != 0 {
|
||||
kind = .quiz
|
||||
} else {
|
||||
kind = .poll(multipleAnswers: (flags & (1 << 2)) != 0)
|
||||
}
|
||||
resultPoll = TelegramMediaPoll(pollId: pollId, publicity: publicity, kind: kind, text: question, options: answers.map(TelegramMediaPollOption.init(apiOption:)), correctAnswers: nil, results: TelegramMediaPollResults(apiResults: results), isClosed: (flags & (1 << 0)) != 0)
|
||||
default:
|
||||
break
|
||||
}
|
||||
let kind: TelegramMediaPollKind
|
||||
if (flags & (1 << 3)) != 0 {
|
||||
kind = .quiz
|
||||
} else {
|
||||
kind = .poll(multipleAnswers: (flags & (1 << 2)) != 0)
|
||||
}
|
||||
resultPoll = TelegramMediaPoll(pollId: MediaId(namespace: Namespaces.Media.CloudPoll, id: id), publicity: publicity, kind: kind, text: question, options: answers.map(TelegramMediaPollOption.init(apiOption:)), correctAnswers: nil, results: TelegramMediaPollResults(apiResults: results), isClosed: (flags & (1 << 0)) != 0)
|
||||
default:
|
||||
break
|
||||
}
|
||||
|
||||
let resultsMin: Bool
|
||||
switch results {
|
||||
case let .pollResults(pollResults):
|
||||
resultsMin = (pollResults.flags & (1 << 0)) != 0
|
||||
}
|
||||
resultPoll = resultPoll?.withUpdatedResults(TelegramMediaPollResults(apiResults: results), min: resultsMin)
|
||||
|
||||
if let resultPoll = resultPoll {
|
||||
updateMessageMedia(transaction: transaction, id: pollId, media: resultPoll)
|
||||
}
|
||||
default:
|
||||
break
|
||||
}
|
||||
default:
|
||||
break
|
||||
}
|
||||
break
|
||||
default:
|
||||
break
|
||||
}
|
||||
break
|
||||
default:
|
||||
break
|
||||
account.stateManager.addUpdates(result)
|
||||
return resultPoll
|
||||
}
|
||||
account.stateManager.addUpdates(result)
|
||||
return .single(resultPoll)
|
||||
|> castError(RequestMessageSelectPollOptionError.self)
|
||||
}
|
||||
} else {
|
||||
return .single(nil)
|
||||
|
@ -1636,7 +1636,10 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
|
||||
return
|
||||
}
|
||||
if controllerInteraction.pollActionState.pollMessageIdsInProgress.removeValue(forKey: id) != nil {
|
||||
strongSelf.chatDisplayNode.historyNode.requestMessageUpdate(id)
|
||||
Queue.mainQueue().after(1.0, {
|
||||
|
||||
strongSelf.chatDisplayNode.historyNode.requestMessageUpdate(id)
|
||||
})
|
||||
}
|
||||
}), forKey: id)
|
||||
}
|
||||
|
@ -2909,6 +2909,14 @@ class ChatMessageBubbleItemNode: ChatMessageItemView, ChatMessagePrevewItemNode
|
||||
}
|
||||
|
||||
func animateQuizInvalidOptionSelected() {
|
||||
if let supernode = self.supernode, let subnodes = supernode.subnodes {
|
||||
for i in 0 ..< subnodes.count {
|
||||
if subnodes[i] === self {
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let duration: Double = 0.5
|
||||
let minScale: CGFloat = -0.03
|
||||
let scaleAnimation0 = self.layer.makeAnimation(from: 0.0 as NSNumber, to: minScale as NSNumber, keyPath: "transform.scale", timingFunction: CAMediaTimingFunctionName.linear.rawValue, duration: duration / 2.0, removeOnCompletion: false, additive: true, completion: { [weak self] _ in
|
||||
|
@ -1361,7 +1361,7 @@ class ChatMessagePollBubbleContentNode: ChatMessageBubbleContentNode {
|
||||
if optionNode.frame.contains(point), case .tap = gesture {
|
||||
if optionNode.isUserInteractionEnabled {
|
||||
return .ignore
|
||||
} else if let result = optionNode.currentResult, let item = self.item, let poll = self.poll, let option = optionNode.option {
|
||||
} else if let result = optionNode.currentResult, let item = self.item, !Namespaces.Message.allScheduled.contains(item.message.id.namespace), let poll = self.poll, let option = optionNode.option {
|
||||
switch poll.publicity {
|
||||
case .anonymous:
|
||||
let string: String
|
||||
|
@ -13,6 +13,23 @@ import StickerResources
|
||||
import PhotoResources
|
||||
import TelegramStringFormatting
|
||||
|
||||
private func foldLineBreaks(_ text: String) -> String {
|
||||
var lines = text.split { $0.isNewline }
|
||||
var startedBothLines = false
|
||||
var result = ""
|
||||
for line in lines {
|
||||
if line.isEmpty {
|
||||
continue
|
||||
}
|
||||
if result.isEmpty {
|
||||
result += line
|
||||
} else {
|
||||
result += " " + line
|
||||
}
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
final class ChatPinnedMessageTitlePanelNode: ChatTitleAccessoryPanelNode {
|
||||
private let context: AccountContext
|
||||
private let tapButton: HighlightTrackingButtonNode
|
||||
@ -238,7 +255,7 @@ final class ChatPinnedMessageTitlePanelNode: ChatTitleAccessoryPanelNode {
|
||||
|
||||
let (titleLayout, titleApply) = makeTitleLayout(TextNodeLayoutArguments(attributedString: NSAttributedString(string: titleString, font: Font.medium(15.0), textColor: theme.chat.inputPanel.panelControlAccentColor), backgroundColor: nil, maximumNumberOfLines: 1, truncationType: .end, constrainedSize: CGSize(width: width - textLineInset - contentLeftInset - rightInset - textRightInset, height: CGFloat.greatestFiniteMagnitude), alignment: .natural, cutout: nil, insets: UIEdgeInsets(top: 2.0, left: 0.0, bottom: 2.0, right: 0.0)))
|
||||
|
||||
let (textLayout, textApply) = makeTextLayout(TextNodeLayoutArguments(attributedString: NSAttributedString(string: descriptionStringForMessage(contentSettings: context.currentContentSettings.with { $0 }, message: message, strings: strings, nameDisplayOrder: nameDisplayOrder, accountPeerId: accountPeerId).0, font: Font.regular(15.0), textColor: message.media.isEmpty || message.media.first is TelegramMediaWebpage ? theme.chat.inputPanel.primaryTextColor : theme.chat.inputPanel.secondaryTextColor), backgroundColor: nil, maximumNumberOfLines: 1, truncationType: .end, constrainedSize: CGSize(width: width - textLineInset - contentLeftInset - rightInset - textRightInset, height: CGFloat.greatestFiniteMagnitude), alignment: .natural, cutout: nil, insets: UIEdgeInsets(top: 2.0, left: 0.0, bottom: 2.0, right: 0.0)))
|
||||
let (textLayout, textApply) = makeTextLayout(TextNodeLayoutArguments(attributedString: NSAttributedString(string: foldLineBreaks(descriptionStringForMessage(contentSettings: context.currentContentSettings.with { $0 }, message: message, strings: strings, nameDisplayOrder: nameDisplayOrder, accountPeerId: accountPeerId).0), font: Font.regular(15.0), textColor: message.media.isEmpty || message.media.first is TelegramMediaWebpage ? theme.chat.inputPanel.primaryTextColor : theme.chat.inputPanel.secondaryTextColor), backgroundColor: nil, maximumNumberOfLines: 1, truncationType: .end, constrainedSize: CGSize(width: width - textLineInset - contentLeftInset - rightInset - textRightInset, height: CGFloat.greatestFiniteMagnitude), alignment: .natural, cutout: nil, insets: UIEdgeInsets(top: 2.0, left: 0.0, bottom: 2.0, right: 0.0)))
|
||||
|
||||
Queue.mainQueue().async {
|
||||
if let strongSelf = self {
|
||||
|
@ -61,7 +61,7 @@ private enum PollResultsItemTag: ItemListItemTag, Equatable {
|
||||
|
||||
private enum PollResultsEntry: ItemListNodeEntry {
|
||||
case text(String)
|
||||
case optionPeer(optionId: Int, index: Int, peer: RenderedPeer, optionText: String, optionCount: Int32, optionExpanded: Bool, opaqueIdentifier: Data, shimmeringAlternation: Int?, isFirstInOption: Bool)
|
||||
case optionPeer(optionId: Int, index: Int, peer: RenderedPeer, optionText: String, optionAdditionalText: String, optionCount: Int32, optionExpanded: Bool, opaqueIdentifier: Data, shimmeringAlternation: Int?, isFirstInOption: Bool)
|
||||
case optionExpand(optionId: Int, opaqueIdentifier: Data, text: String, enabled: Bool)
|
||||
|
||||
var section: ItemListSectionId {
|
||||
@ -137,8 +137,8 @@ private enum PollResultsEntry: ItemListNodeEntry {
|
||||
switch self {
|
||||
case let .text(text):
|
||||
return ItemListTextItem(presentationData: presentationData, text: .large(text), sectionId: self.section)
|
||||
case let .optionPeer(optionId, _, peer, optionText, optionCount, optionExpanded, opaqueIdentifier, shimmeringAlternation, isFirstInOption):
|
||||
let header = ItemListPeerItemHeader(theme: presentationData.theme, strings: presentationData.strings, text: optionText, actionTitle: optionExpanded ? presentationData.strings.PollResults_Collapse : presentationData.strings.MessagePoll_VotedCount(optionCount), id: Int64(optionId), action: optionExpanded ? {
|
||||
case let .optionPeer(optionId, _, peer, optionText, optionAdditionalText, optionCount, optionExpanded, opaqueIdentifier, shimmeringAlternation, isFirstInOption):
|
||||
let header = ItemListPeerItemHeader(theme: presentationData.theme, strings: presentationData.strings, text: optionText, additionalText: optionAdditionalText, actionTitle: optionExpanded ? presentationData.strings.PollResults_Collapse : presentationData.strings.MessagePoll_VotedCount(optionCount), id: Int64(optionId), action: optionExpanded ? {
|
||||
arguments.collapseOption(opaqueIdentifier)
|
||||
} : nil)
|
||||
return ItemListPeerItem(presentationData: presentationData, dateTimeFormat: PresentationDateTimeFormat(timeFormat: .regular, dateFormat: .dayFirst, dateSeparator: ".", decimalSeparator: ".", groupingSeparator: ""), nameDisplayOrder: .firstLast, context: arguments.context, peer: peer.peers[peer.peerId]!, presence: nil, text: .none, label: .none, editing: ItemListPeerItemEditing(editable: false, editing: false, revealed: false), switchValue: nil, enabled: true, selectable: shimmeringAlternation == nil, sectionId: self.section, action: {
|
||||
@ -193,7 +193,8 @@ private func pollResultsControllerEntries(presentationData: PresentationData, po
|
||||
for i in 0 ..< poll.options.count {
|
||||
let percentage = optionPercentage.count > i ? optionPercentage[i] : 0
|
||||
let option = poll.options[i]
|
||||
let optionTextHeader = option.text.uppercased() + " — \(percentage)%"
|
||||
let optionTextHeader = option.text.uppercased()
|
||||
let optionAdditionalTextHeader = " — \(percentage)%"
|
||||
if isEmpty {
|
||||
if let voterCount = optionVoterCount[i], voterCount != 0 {
|
||||
let displayCount: Int
|
||||
@ -205,7 +206,7 @@ private func pollResultsControllerEntries(presentationData: PresentationData, po
|
||||
for peerIndex in 0 ..< displayCount {
|
||||
let fakeUser = TelegramUser(id: PeerId(namespace: -1, id: 0), accessHash: nil, firstName: "", lastName: "", username: nil, phone: nil, photo: [], botInfo: nil, restrictionInfo: nil, flags: [])
|
||||
let peer = RenderedPeer(peer: fakeUser)
|
||||
entries.append(.optionPeer(optionId: i, index: peerIndex, peer: peer, optionText: optionTextHeader, optionCount: voterCount, optionExpanded: false, opaqueIdentifier: option.opaqueIdentifier, shimmeringAlternation: peerIndex % 2, isFirstInOption: peerIndex == 0))
|
||||
entries.append(.optionPeer(optionId: i, index: peerIndex, peer: peer, optionText: optionTextHeader, optionAdditionalText: optionAdditionalTextHeader, optionCount: voterCount, optionExpanded: false, opaqueIdentifier: option.opaqueIdentifier, shimmeringAlternation: peerIndex % 2, isFirstInOption: peerIndex == 0))
|
||||
}
|
||||
if displayCount < Int(voterCount) {
|
||||
let remainingCount = Int(voterCount) - displayCount
|
||||
@ -248,7 +249,7 @@ private func pollResultsControllerEntries(presentationData: PresentationData, po
|
||||
if peerIndex >= displayCount {
|
||||
break inner
|
||||
}
|
||||
entries.append(.optionPeer(optionId: i, index: peerIndex, peer: peer, optionText: optionTextHeader, optionCount: Int32(count), optionExpanded: optionExpandedAtCount != nil, opaqueIdentifier: option.opaqueIdentifier, shimmeringAlternation: nil, isFirstInOption: peerIndex == 0))
|
||||
entries.append(.optionPeer(optionId: i, index: peerIndex, peer: peer, optionText: optionTextHeader, optionAdditionalText: optionAdditionalTextHeader, optionCount: Int32(count), optionExpanded: optionExpandedAtCount != nil, opaqueIdentifier: option.opaqueIdentifier, shimmeringAlternation: nil, isFirstInOption: peerIndex == 0))
|
||||
peerIndex += 1
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user