Skip to content

Commit ec5145b

Browse files
isaacclaude
andcommitted
fix(chat): render instant-page preview icons in the edit accessory panel
Render instant-page preview icons in the message-edit accessory panel text (renderInstantPagePreviewIcons), with text render insets so the glyphs aren't clipped and a matching frame offset. Nudge the self-destruct timer icon's vertical inset. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent d6a001c commit ec5145b

2 files changed

Lines changed: 7 additions & 3 deletions

File tree

‎submodules/TelegramUI/Components/Chat/ChatInputMessageAccessoryPanel/Sources/ChatInputMessageAccessoryPanel.swift‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -588,6 +588,7 @@ public final class ChatInputMessageAccessoryPanel: Component {
588588
titleStringValue = environment.strings.Conversation_EditingMessagePanelTitle
589589
}
590590
titleText = [.text(NSAttributedString(string: titleStringValue, font: Font.medium(14.0), textColor: environment.theme.chat.inputPanel.panelControlAccentColor))]
591+
textString = renderInstantPagePreviewIcons(textString, font: Font.regular(14.0), textColor: environment.theme.chat.inputPanel.primaryTextColor)
591592
case let .reply(reply):
592593
if let peer = self.messages.first?.peers[reply.id.peerId] as? TelegramChannel, case .broadcast = peer.info {
593594
let icon: UIImage?
@@ -923,10 +924,12 @@ public final class ChatInputMessageAccessoryPanel: Component {
923924
self.titleNode.components = titleText
924925
let titleSize = self.titleNode.update(constrainedSize: CGSize(width: availableSize.width - lineFrame.maxX - textInsets.left - textInsets.right, height: 100.0))
925926

927+
let textRenderInsets = UIEdgeInsets(top: 2.0, left: 2.0, bottom: 2.0, right: 2.0)
926928
let textSize = self.text.update(
927929
transition: .immediate,
928930
component: AnyComponent(MultilineTextComponent(
929931
text: .plain(textString),
932+
insets: textRenderInsets
930933
)),
931934
environment: {},
932935
containerSize: CGSize(width: availableSize.width - lineFrame.maxX - textInsets.left - textInsets.right, height: 100.0)
@@ -945,7 +948,7 @@ public final class ChatInputMessageAccessoryPanel: Component {
945948
let titleTextSpacing: CGFloat = 1.0
946949

947950
let titleFrame = CGRect(origin: CGPoint(x: lineFrame.maxX + textInsets.left, y: textInsets.top), size: titleSize)
948-
let textFrame = CGRect(origin: CGPoint(x: lineFrame.maxX + textInsets.left, y: titleFrame.maxY + titleTextSpacing), size: textSize)
951+
let textFrame = CGRect(origin: CGPoint(x: lineFrame.maxX + textInsets.left - textRenderInsets.left, y: titleFrame.maxY + titleTextSpacing - textRenderInsets.top), size: textSize)
949952

950953
transition.setFrame(view: self.titleNode.view, frame: titleFrame)
951954

‎submodules/TelegramUI/Components/Chat/ChatTextInputPanelNode/Sources/AccessoryItemIconButton.swift‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ final class AccessoryItemIconButton: HighlightTrackingButton, GlassBackgroundVie
165165
if let timeout = timeout {
166166
return (nil, shortTimeIntervalString(strings: strings, value: timeout), strings.VoiceOver_SelfDestructTimerOn(timeIntervalString(strings: strings, value: timeout)).string, 1.0, UIEdgeInsets())
167167
} else {
168-
return (PresentationResourcesChat.chatInputTextFieldTimerImage(theme), nil, strings.VoiceOver_SelfDestructTimerOff, 1.0, UIEdgeInsets(top: 0.0, left: 0.0, bottom: 0.0, right: 0.0))
168+
return (PresentationResourcesChat.chatInputTextFieldTimerImage(theme), nil, strings.VoiceOver_SelfDestructTimerOff, 1.0, UIEdgeInsets(top: 1.0, left: 0.0, bottom: -1.0, right: 0.0))
169169
}
170170
case .scheduledMessages:
171171
return (PresentationResourcesChat.chatInputTextFieldScheduleImage(theme), nil, strings.VoiceOver_ScheduledMessages, 1.0, UIEdgeInsets())
@@ -192,13 +192,14 @@ final class AccessoryItemIconButton: HighlightTrackingButton, GlassBackgroundVie
192192
let previousItem = self.item
193193
self.item = item
194194

195-
let (updatedImage, text, _, _, _) = AccessoryItemIconButton.imageAndInsets(item: item, theme: self.theme, strings: self.strings)
195+
let (updatedImage, text, _, _, insets) = AccessoryItemIconButton.imageAndInsets(item: item, theme: self.theme, strings: self.strings)
196196

197197
if let image = self.iconImageView.image {
198198
self.iconImageView.image = updatedImage
199199

200200
let bottomInset: CGFloat = 0.0
201201
var imageFrame = CGRect(origin: CGPoint(x: floor((size.width - image.size.width) / 2.0), y: floor((size.height - image.size.height) / 2.0) - bottomInset), size: image.size)
202+
imageFrame.origin.y += insets.top
202203
if case .scheduledMessages = item {
203204
imageFrame.origin.y += 1.0
204205
}

0 commit comments

Comments
 (0)