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
} }
} }
} }
@ -82,10 +86,10 @@ public func mediaContentKind(_ media: Media, message: Message? = nil, strings: P
switch media { switch media {
case let expiredMedia as TelegramMediaExpiredContent: case let expiredMedia as TelegramMediaExpiredContent:
switch expiredMedia.data { switch expiredMedia.data {
case .image: case .image:
return .expiredImage return .expiredImage
case .file: case .file:
return .expiredVideo return .expiredVideo
} }
case _ as TelegramMediaImage: case _ as TelegramMediaImage:
return .image return .image
@ -93,34 +97,34 @@ public func mediaContentKind(_ media: Media, message: Message? = nil, strings: P
var fileName: String = "" var fileName: String = ""
for attribute in file.attributes { for attribute in file.attributes {
switch attribute { switch attribute {
case let .Sticker(text, _, _): case let .Sticker(text, _, _):
return .sticker(text) return .sticker(text)
case let .FileName(name): case let .FileName(name):
fileName = name fileName = name
case let .Audio(isVoice, _, title, performer, _): case let .Audio(isVoice, _, title, performer, _):
if isVoice { if isVoice {
return .audioMessage return .audioMessage
} else {
if let title = title, let performer = performer, !title.isEmpty, !performer.isEmpty {
return .file(title + "" + performer)
} else if let title = title, !title.isEmpty {
return .file(title)
} else if let performer = performer, !performer.isEmpty {
return .file(performer)
}
}
case let .Video(_, _, flags):
if file.isAnimated {
return .animation
} else {
if flags.contains(.instantRoundVideo) {
return .videoMessage
} else { } else {
return .video if let title = title, let performer = performer, !title.isEmpty, !performer.isEmpty {
return .file(title + "" + performer)
} else if let title = title, !title.isEmpty {
return .file(title)
} else if let performer = performer, !performer.isEmpty {
return .file(performer)
}
} }
} case let .Video(_, _, flags):
default: if file.isAnimated {
break return .animation
} else {
if flags.contains(.instantRoundVideo) {
return .videoMessage
} else {
return .video
}
}
default:
break
} }
} }
return .file(fileName) return .file(fileName)
@ -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)
} }
} }