Fix close poll appearance

This commit is contained in:
Peter 2018-12-19 00:31:43 +03:00
parent 9f2c27072c
commit 49d76ffce7
3 changed files with 40 additions and 34 deletions

View File

@ -614,7 +614,7 @@ class ChatMessagePollBubbleContentNode: ChatMessageBubbleContentNode {
} }
} }
totalVoterCount = totalVoters totalVoterCount = totalVoters
if didVote { if didVote || poll.isClosed {
for i in 0 ..< poll.options.count { for i in 0 ..< poll.options.count {
inner: for optionVoters in voters { inner: for optionVoters in voters {
if optionVoters.opaqueIdentifier == poll.options[i].opaqueIdentifier { if optionVoters.opaqueIdentifier == poll.options[i].opaqueIdentifier {

View File

@ -348,12 +348,12 @@ class CreatePollOptionItemNode: ItemListRevealOptionsItemNode, ItemListItemNode,
let editableControlFrame = CGRect(origin: CGPoint(x: params.leftInset + 6.0 + revealOffset, y: 0.0), size: controlSizeAndApply.0) let editableControlFrame = CGRect(origin: CGPoint(x: params.leftInset + 6.0 + revealOffset, y: 0.0), size: controlSizeAndApply.0)
strongSelf.editableControlNode.frame = editableControlFrame strongSelf.editableControlNode.frame = editableControlFrame
let _ = reorderSizeAndApply.1(displayTextLimit) let _ = reorderSizeAndApply.1(displayTextLimit && layout.contentSize.height <= 44.0)
let reorderControlFrame = CGRect(origin: CGPoint(x: params.width + revealOffset - params.rightInset - reorderSizeAndApply.0.width, y: 0.0), size: reorderSizeAndApply.0) let reorderControlFrame = CGRect(origin: CGPoint(x: params.width + revealOffset - params.rightInset - reorderSizeAndApply.0.width, y: 0.0), size: reorderSizeAndApply.0)
strongSelf.reorderControlNode.frame = reorderControlFrame strongSelf.reorderControlNode.frame = reorderControlFrame
let _ = textLimitApply() let _ = textLimitApply()
strongSelf.textLimitNode.frame = CGRect(origin: CGPoint(x: reorderControlFrame.minX + floor((reorderControlFrame.width - textLimitLayout.size.width) / 2.0) - 4.0 - UIScreenPixel, y: floor(reorderControlFrame.midY + 2.0)), size: textLimitLayout.size) strongSelf.textLimitNode.frame = CGRect(origin: CGPoint(x: reorderControlFrame.minX + floor((reorderControlFrame.width - textLimitLayout.size.width) / 2.0) - 4.0 - UIScreenPixel, y: max(floor(reorderControlFrame.midY + 2.0), layout.contentSize.height - 15.0 - textLimitLayout.size.height)), size: textLimitLayout.size)
strongSelf.textLimitNode.isHidden = !displayTextLimit strongSelf.textLimitNode.isHidden = !displayTextLimit
strongSelf.updateLayout(size: layout.contentSize, leftInset: params.leftInset, rightInset: params.rightInset) strongSelf.updateLayout(size: layout.contentSize, leftInset: params.leftInset, rightInset: params.rightInset)

View File

@ -17,6 +17,7 @@ public enum MessageContentKindKey {
case liveLocation case liveLocation
case expiredImage case expiredImage
case expiredVideo case expiredVideo
case poll
} }
public enum MessageContentKind: Equatable { public enum MessageContentKind: Equatable {
@ -34,6 +35,7 @@ public enum MessageContentKind: Equatable {
case liveLocation case liveLocation
case expiredImage case expiredImage
case expiredVideo case expiredVideo
case poll(String)
public var key: MessageContentKindKey { public var key: MessageContentKindKey {
switch self { switch self {
@ -65,6 +67,8 @@ public enum MessageContentKind: Equatable {
return .expiredImage return .expiredImage
case .expiredVideo: case .expiredVideo:
return .expiredVideo return .expiredVideo
case .poll:
return .poll
} }
} }
} }
@ -141,7 +145,7 @@ public func mediaContentKind(_ media: Media, message: Message? = nil, strings: P
return nil return nil
} }
case let poll as TelegramMediaPoll: case let poll as TelegramMediaPoll:
return .text(poll.text) return .poll(poll.text)
default: default:
return nil return nil
} }
@ -185,6 +189,8 @@ func stringForMediaKind(_ kind: MessageContentKind, strings: PresentationStrings
return (strings.Message_ImageExpired, true) return (strings.Message_ImageExpired, true)
case .expiredVideo: case .expiredVideo:
return (strings.Message_VideoExpired, true) return (strings.Message_VideoExpired, true)
case let .poll(text):
return ("📊 \(text)", false)
} }
} }