Fix ad and contact buttons layout

This commit is contained in:
Ilya Laktyushin 2024-02-02 23:44:46 +04:00
parent 94835e8272
commit 011189e98f
2 changed files with 12 additions and 2 deletions

View File

@ -596,7 +596,12 @@ public final class ChatMessageAttachedContentNode: ASDisplayNode {
false
)
actionButtonMinWidthAndFinalizeLayout = (buttonWidth, continueLayout)
actualWidth = max(actualWidth, buttonWidth)
var buttonInset: CGFloat = 0.0
if let buttonIconImage {
buttonInset += buttonIconImage.size.width + 2.0
}
actualWidth = max(actualWidth, buttonWidth + buttonInset * 2.0)
} else {
actionButtonMinWidthAndFinalizeLayout = nil
}

View File

@ -321,6 +321,11 @@ public class ChatMessageContactBubbleContentNode: ChatMessageBubbleContentNode {
}
let (addButtonWidth, addContinueLayout) = makeAddButtonLayout(constrainedSize.width, 10.0, nil, false, addTitle.uppercased(), mainColor, false, false)
let showAddButton = !(!canAdd && canMessage)
let showMessageButton = canMessage
let buttonCount = (showAddButton ? 1 : 0) + (showMessageButton ? 1 : 0)
let maxButtonWidth = max(messageButtonWidth, addButtonWidth)
var maxContentWidth: CGFloat = avatarSize.width + 7.0
if let statusSuggestedWidthAndContinue = statusSuggestedWidthAndContinue {
@ -328,7 +333,7 @@ public class ChatMessageContactBubbleContentNode: ChatMessageBubbleContentNode {
}
maxContentWidth = max(maxContentWidth, 7.0 + avatarSize.width + 7.0 + titleLayout.size.width + 7.0)
maxContentWidth = max(maxContentWidth, 7.0 + avatarSize.width + 7.0 + textLayout.size.width + 7.0)
maxContentWidth = max(maxContentWidth, maxButtonWidth * 2.0)
maxContentWidth = max(maxContentWidth, maxButtonWidth * CGFloat(buttonCount))
maxContentWidth = max(maxContentWidth, 220.0)
let contentWidth = maxContentWidth + layoutConstants.text.bubbleInsets.right * 2.0