From cf112917d6d3727823e3316c0ff3a27553ed8799 Mon Sep 17 00:00:00 2001 From: Isaac <> Date: Tue, 3 Jun 2025 00:23:10 +0800 Subject: [PATCH] Fix layout --- .../Sources/Node/ChatListItem.swift | 63 ++++++++++--------- 1 file changed, 34 insertions(+), 29 deletions(-) diff --git a/submodules/ChatListUI/Sources/Node/ChatListItem.swift b/submodules/ChatListUI/Sources/Node/ChatListItem.swift index 25e7fce3b7..9261614586 100644 --- a/submodules/ChatListUI/Sources/Node/ChatListItem.swift +++ b/submodules/ChatListUI/Sources/Node/ChatListItem.swift @@ -4267,35 +4267,6 @@ public class ChatListItemNode: ItemListRevealOptionsItemNode { let titleFrame = CGRect(origin: CGPoint(x: contentRect.origin.x + titleOffset, y: contentRect.origin.y + UIScreenPixel), size: titleLayout.size) strongSelf.titleNode.frame = titleFrame - if let (titleBadgeLayout, titleBadgeApply) = titleBadgeLayoutAndApply { - let titleBadgeNode = titleBadgeApply() - let backgroundView: UIImageView - if let current = strongSelf.titleBadge { - backgroundView = current.backgroundView - } else { - backgroundView = UIImageView(image: generateStretchableFilledCircleImage(radius: 4.0, color: .white)?.withRenderingMode(.alwaysTemplate)) - strongSelf.titleBadge = (backgroundView, titleBadgeNode) - - strongSelf.mainContentContainerNode.view.addSubview(backgroundView) - strongSelf.mainContentContainerNode.addSubnode(titleBadgeNode) - } - let titleBadgeFrame = CGRect(origin: CGPoint(x: titleFrame.maxX + titleIconsWidth + 10.0, y: titleFrame.minY + floor((titleFrame.height - titleBadgeLayout.size.height) * 0.5)), size: titleBadgeLayout.size) - titleBadgeNode.frame = titleBadgeFrame - - var titleBadgeBackgroundFrame = titleBadgeFrame.insetBy(dx: -4.0, dy: -2.0) - titleBadgeBackgroundFrame.size.height -= 1.0 - backgroundView.frame = titleBadgeBackgroundFrame - if item.presentationData.theme.overallDarkAppearance { - backgroundView.tintColor = theme.titleColor.withMultipliedAlpha(0.1) - } else { - backgroundView.tintColor = theme.titleColor.withMultipliedAlpha(0.05) - } - } else if let titleBadge = strongSelf.titleBadge { - strongSelf.titleBadge = nil - titleBadge.backgroundView.removeFromSuperview() - titleBadge.textNode.removeFromSupernode() - } - let authorNodeFrame = CGRect(origin: CGPoint(x: contentRect.origin.x - 1.0, y: contentRect.minY + titleLayout.size.height), size: authorLayout) strongSelf.authorNode.frame = authorNodeFrame let textNodeFrame = CGRect(origin: CGPoint(x: contentRect.origin.x - 1.0, y: contentRect.minY + titleLayout.size.height - 1.0 + UIScreenPixel + (authorLayout.height.isZero ? 0.0 : (authorLayout.height - 3.0))), size: textLayout.size) @@ -4867,6 +4838,40 @@ public class ChatListItemNode: ItemListRevealOptionsItemNode { strongSelf.mutedIconNode.isHidden = true } + if let (titleBadgeLayout, titleBadgeApply) = titleBadgeLayoutAndApply { + let titleBadgeNode = titleBadgeApply() + let backgroundView: UIImageView + if let current = strongSelf.titleBadge { + backgroundView = current.backgroundView + } else { + backgroundView = UIImageView(image: generateStretchableFilledCircleImage(radius: 4.0, color: .white)?.withRenderingMode(.alwaysTemplate)) + strongSelf.titleBadge = (backgroundView, titleBadgeNode) + + strongSelf.mainContentContainerNode.view.addSubview(backgroundView) + strongSelf.mainContentContainerNode.addSubnode(titleBadgeNode) + } + if currentMutedIconImage != nil { + nextTitleIconOrigin -= 7.0 + } + nextTitleIconOrigin += 7.0 + let titleBadgeFrame = CGRect(origin: CGPoint(x: nextTitleIconOrigin, y: titleFrame.minY + floor((titleFrame.height - titleBadgeLayout.size.height) * 0.5)), size: titleBadgeLayout.size) + nextTitleIconOrigin += titleBadgeLayout.size.width + 4.0 + titleBadgeNode.frame = titleBadgeFrame + + var titleBadgeBackgroundFrame = titleBadgeFrame.insetBy(dx: -4.0, dy: -2.0) + titleBadgeBackgroundFrame.size.height -= 1.0 + backgroundView.frame = titleBadgeBackgroundFrame + if item.presentationData.theme.overallDarkAppearance { + backgroundView.tintColor = theme.titleColor.withMultipliedAlpha(0.1) + } else { + backgroundView.tintColor = theme.titleColor.withMultipliedAlpha(0.05) + } + } else if let titleBadge = strongSelf.titleBadge { + strongSelf.titleBadge = nil + titleBadge.backgroundView.removeFromSuperview() + titleBadge.textNode.removeFromSupernode() + } + let separatorInset: CGFloat if case let .groupReference(groupReferenceData) = item.content, groupReferenceData.hiddenByDefault { separatorInset = 0.0