Fix action button layout

This commit is contained in:
Isaac 2025-06-24 15:28:44 +02:00
parent 119db20d25
commit 183db2a8e4
3 changed files with 9 additions and 7 deletions

View File

@ -1286,10 +1286,12 @@ public class ChatMessageAnimatedStickerItemNode: ChatMessageItemView {
needsForwardBackground = true
}
let baseWidth = params.width - params.leftInset - params.rightInset
var maxContentWidth = imageSize.width
var actionButtonsFinalize: ((CGFloat) -> (CGSize, (_ animation: ListViewItemUpdateAnimation) -> ChatMessageActionButtonsNode))?
if let replyMarkup = replyMarkup {
let (minWidth, buttonsLayout) = actionButtonsLayout(item.context, item.presentationData.theme, item.presentationData.chatBubbleCorners, item.presentationData.strings, item.controllerInteraction.presentationContext.backgroundNode, replyMarkup, [:], item.message, maxContentWidth)
let (minWidth, buttonsLayout) = actionButtonsLayout(item.context, item.presentationData.theme, item.presentationData.chatBubbleCorners, item.presentationData.strings, item.controllerInteraction.presentationContext.backgroundNode, replyMarkup, [:], item.message, baseWidth)
maxContentWidth = max(maxContentWidth, minWidth)
actionButtonsFinalize = buttonsLayout
} else if incoming, let attribute = item.message.attributes.first(where: { $0 is SuggestedPostMessageAttribute }) as? SuggestedPostMessageAttribute, attribute.state == nil {
@ -1325,7 +1327,7 @@ public class ChatMessageAnimatedStickerItemNode: ChatMessageItemView {
],
flags: [],
placeholder: nil
), customIcons, item.message, maxContentWidth)
), customIcons, item.message, baseWidth)
maxContentWidth = max(maxContentWidth, minWidth)
actionButtonsFinalize = buttonsLayout
}
@ -1377,7 +1379,6 @@ public class ChatMessageAnimatedStickerItemNode: ChatMessageItemView {
layoutSize.height += 4.0 + reactionButtonsSizeAndApply.0.height
}
let baseWidth = params.width - params.leftInset - params.rightInset
var suggestedPostInfoNodeLayout: (CGSize, () -> ChatMessageSuggestedPostInfoNode)?
for attribute in item.message.attributes {
if let _ = attribute as? SuggestedPostMessageAttribute {

View File

@ -2838,7 +2838,7 @@ public class ChatMessageBubbleItemNode: ChatMessageItemView, ChatMessagePreviewI
],
flags: [],
placeholder: nil
), customIcons, item.message, maximumNodeWidth)
), customIcons, item.message, baseWidth)
maxContentWidth = max(maxContentWidth, minWidth)
actionButtonsFinalize = buttonsLayout

View File

@ -847,10 +847,12 @@ public class ChatMessageStickerItemNode: ChatMessageItemView {
needsForwardBackground = true
}
let baseWidth = params.width - params.leftInset - params.rightInset
var maxContentWidth = imageSize.width
var actionButtonsFinalize: ((CGFloat) -> (CGSize, (_ animation: ListViewItemUpdateAnimation) -> ChatMessageActionButtonsNode))?
if let replyMarkup = replyMarkup {
let (minWidth, buttonsLayout) = actionButtonsLayout(item.context, item.presentationData.theme, item.presentationData.chatBubbleCorners, item.presentationData.strings, item.controllerInteraction.presentationContext.backgroundNode, replyMarkup, [:], item.message, maxContentWidth)
let (minWidth, buttonsLayout) = actionButtonsLayout(item.context, item.presentationData.theme, item.presentationData.chatBubbleCorners, item.presentationData.strings, item.controllerInteraction.presentationContext.backgroundNode, replyMarkup, [:], item.message, baseWidth)
maxContentWidth = max(maxContentWidth, minWidth)
actionButtonsFinalize = buttonsLayout
} else if incoming, let attribute = item.message.attributes.first(where: { $0 is SuggestedPostMessageAttribute }) as? SuggestedPostMessageAttribute, attribute.state == nil {
@ -886,7 +888,7 @@ public class ChatMessageStickerItemNode: ChatMessageItemView {
],
flags: [],
placeholder: nil
), customIcons, item.message, maxContentWidth)
), customIcons, item.message, baseWidth)
maxContentWidth = max(maxContentWidth, minWidth)
actionButtonsFinalize = buttonsLayout
}
@ -942,7 +944,6 @@ public class ChatMessageStickerItemNode: ChatMessageItemView {
layoutSize.height += actionButtonsSizeAndApply.0.height
}
let baseWidth = params.width - params.leftInset - params.rightInset
var suggestedPostInfoNodeLayout: (CGSize, () -> ChatMessageSuggestedPostInfoNode)?
for attribute in item.message.attributes {
if let _ = attribute as? SuggestedPostMessageAttribute {