Fix selection layout on grouped voice messages

This commit is contained in:
Ilya Laktyushin 2021-02-20 20:57:24 +04:00
parent 4e4f479b57
commit bc5e40f924

View File

@ -708,7 +708,15 @@ final class ChatMessageInteractiveFileNode: ASDisplayNode {
selectionNode.frame = selectionFrame selectionNode.frame = selectionFrame
selectionNode.updateSelected(selection, animated: isAnimated) selectionNode.updateSelected(selection, animated: isAnimated)
} else { } else {
let selectionNode = FileMessageSelectionNode(theme: presentationData.theme.theme, incoming: incoming, noPreview: file.isMusic || file.previewRepresentations.isEmpty, toggle: { [weak self] value in let type: FileMessageSelectionNode.NodeType
if file.isVoice {
type = .voice
} else if file.isMusic || file.previewRepresentations.isEmpty {
type = .file
} else {
type = .media
}
let selectionNode = FileMessageSelectionNode(theme: presentationData.theme.theme, incoming: incoming, type: type, toggle: { [weak self] value in
self?.toggleSelection(value) self?.toggleSelection(value)
}) })
strongSelf.selectionNode = selectionNode strongSelf.selectionNode = selectionNode
@ -999,7 +1007,10 @@ final class ChatMessageInteractiveFileNode: ASDisplayNode {
} }
} }
let cutoutFrame = streamingCacheStatusFrame.insetBy(dx: -(1.0 + UIScreenPixel), dy: -(1.0 + UIScreenPixel)).offsetBy(dx: progressFrame.minX - 6.0, dy: progressFrame.minY) var cutoutFrame = streamingCacheStatusFrame.insetBy(dx: -(1.0 + UIScreenPixel), dy: -(1.0 + UIScreenPixel)).offsetBy(dx: progressFrame.minX - 6.0, dy: progressFrame.minY)
if file.isVoice {
cutoutFrame.origin.y += 6.0
}
if streamingState == .none && self.selectionNode == nil { if streamingState == .none && self.selectionNode == nil {
self.statusNode?.setCutout(nil, animated: animated) self.statusNode?.setCutout(nil, animated: animated)
@ -1119,16 +1130,21 @@ final class ChatMessageInteractiveFileNode: ASDisplayNode {
final class FileMessageSelectionNode: ASDisplayNode { final class FileMessageSelectionNode: ASDisplayNode {
enum NodeType {
case media
case file
case voice
}
private let toggle: (Bool) -> Void private let toggle: (Bool) -> Void
private var selected = false private var selected = false
private let checkNode: CheckNode private let checkNode: CheckNode
private let noPreview: Bool private let type: NodeType
public init(theme: PresentationTheme, incoming: Bool, noPreview: Bool, toggle: @escaping (Bool) -> Void) { public init(theme: PresentationTheme, incoming: Bool, type: NodeType, toggle: @escaping (Bool) -> Void) {
self.noPreview = noPreview self.type = type
self.toggle = toggle self.toggle = toggle
self.checkNode = CheckNode(theme: noPreview ? CheckNodeTheme(backgroundColor: theme.list.itemCheckColors.fillColor, strokeColor: theme.list.itemCheckColors.foregroundColor, borderColor: incoming ? theme.chat.message.incoming.mediaPlaceholderColor : theme.chat.message.outgoing.mediaPlaceholderColor, overlayBorder: false, hasInset: false, hasShadow: false) : CheckNodeTheme(theme: theme, style: .overlay)) self.checkNode = CheckNode(theme: type != .media ? CheckNodeTheme(backgroundColor: theme.list.itemCheckColors.fillColor, strokeColor: theme.list.itemCheckColors.foregroundColor, borderColor: incoming ? theme.chat.message.incoming.mediaPlaceholderColor : theme.chat.message.outgoing.mediaPlaceholderColor, overlayBorder: false, hasInset: false, hasShadow: false) : CheckNodeTheme(theme: theme, style: .overlay))
self.checkNode.isUserInteractionEnabled = false self.checkNode.isUserInteractionEnabled = false
super.init() super.init()
@ -1172,12 +1188,16 @@ final class FileMessageSelectionNode: ASDisplayNode {
let checkSize: CGSize let checkSize: CGSize
let checkOrigin: CGPoint let checkOrigin: CGPoint
if self.noPreview { switch self.type {
checkSize = CGSize(width: 20.0, height: 20.0) case .media:
checkOrigin = CGPoint(x: 29.0, y: 26.0) checkSize = CGSize(width: 28.0, height: 28.0)
} else { checkOrigin = CGPoint(x: 41.0, y: -3.0)
checkSize = CGSize(width: 28.0, height: 28.0) case .file:
checkOrigin = CGPoint(x: 41.0, y: -3.0) checkSize = CGSize(width: 20.0, height: 20.0)
checkOrigin = CGPoint(x: 29.0, y: 26.0)
case .voice:
checkSize = CGSize(width: 20.0, height: 20.0)
checkOrigin = CGPoint(x: 29.0, y: 23.0)
} }
self.checkNode.frame = CGRect(origin: checkOrigin, size: checkSize) self.checkNode.frame = CGRect(origin: checkOrigin, size: checkSize)
} }