Skip to content

Commit

Permalink
Cherry-pick fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
laktyushin committed Nov 9, 2023
1 parent cb6af54 commit b77b6fb
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ + (SSignal *)renderUIImage:(UIImage *)image duration:(NSTimeInterval)duration ad
SAtomic *context = [[SAtomic alloc] initWithValue:[TGMediaVideoConversionContext contextWithQueue:queue subscriber:subscriber]];
NSURL *outputUrl = [NSURL fileURLWithPath:path];

NSString *path = TGComponentsPathForResource(@"blank", @"mp4");
NSString *path = TGComponentsPathForResource(@"BlankVideo", @"m4v");
AVAsset *avAsset = [[AVURLAsset alloc] initWithURL:[NSURL fileURLWithPath:path] options:nil];

NSArray *requiredKeys = @[ @"tracks", @"duration", @"playable" ];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -537,6 +537,7 @@ public class ChatMessageBubbleItemNode: ChatMessageItemView, ChatMessagePreviewI
private var nameNode: TextNode?
private var nameButtonNode: HighlightTrackingButtonNode?
private var nameHighlightNode: ASImageNode?
private var viaMeasureNode: TextNode?

private var adminBadgeNode: TextNode?
private var credibilityIconView: ComponentHostView<Empty>?
Expand Down Expand Up @@ -1242,6 +1243,7 @@ public class ChatMessageBubbleItemNode: ChatMessageItemView, ChatMessagePreviewI
}

let authorNameLayout = TextNode.asyncLayout(self.nameNode)
let viaMeasureLayout = TextNode.asyncLayout(self.viaMeasureNode)
let adminBadgeLayout = TextNode.asyncLayout(self.adminBadgeNode)
let threadInfoLayout = ChatMessageThreadInfoNode.asyncLayout(self.threadInfoNode)
let forwardInfoLayout = ChatMessageForwardInfoNode.asyncLayout(self.forwardInfoNode)
Expand All @@ -1265,6 +1267,7 @@ public class ChatMessageBubbleItemNode: ChatMessageItemView, ChatMessagePreviewI
return ChatMessageBubbleItemNode.beginLayout(selfReference: weakSelf, item, params, mergedTop, mergedBottom, dateHeaderAtBottom,
currentContentClassesPropertiesAndLayouts: currentContentClassesPropertiesAndLayouts,
authorNameLayout: authorNameLayout,
viaMeasureLayout: viaMeasureLayout,
adminBadgeLayout: adminBadgeLayout,
threadInfoLayout: threadInfoLayout,
forwardInfoLayout: forwardInfoLayout,
Expand All @@ -1283,6 +1286,7 @@ public class ChatMessageBubbleItemNode: ChatMessageItemView, ChatMessagePreviewI
private static func beginLayout(selfReference: Weak<ChatMessageBubbleItemNode>, _ item: ChatMessageItem, _ params: ListViewItemLayoutParams, _ mergedTop: ChatMessageMerge, _ mergedBottom: ChatMessageMerge, _ dateHeaderAtBottom: Bool,
currentContentClassesPropertiesAndLayouts: [(Message, AnyClass, Bool, (_ item: ChatMessageBubbleContentItem, _ layoutConstants: ChatMessageItemLayoutConstants, _ preparePosition: ChatMessageBubblePreparePosition, _ messageSelection: Bool?, _ constrainedSize: CGSize, _ avatarInset: CGFloat) -> (ChatMessageBubbleContentProperties, CGSize?, CGFloat, (CGSize, ChatMessageBubbleContentPosition) -> (CGFloat, (CGFloat) -> (CGSize, (ListViewItemUpdateAnimation, Bool, ListViewItemApply?) -> Void))))],
authorNameLayout: (TextNodeLayoutArguments) -> (TextNodeLayout, () -> TextNode),
viaMeasureLayout: (TextNodeLayoutArguments) -> (TextNodeLayout, () -> TextNode),
adminBadgeLayout: (TextNodeLayoutArguments) -> (TextNodeLayout, () -> TextNode),
threadInfoLayout: (ChatMessageThreadInfoNode.Arguments) -> (CGSize, (Bool) -> ChatMessageThreadInfoNode),
forwardInfoLayout: (AccountContext, ChatPresentationData, PresentationStrings, ChatMessageForwardInfoType, Peer?, String?, String?, ChatMessageForwardInfoNode.StoryData?, CGSize) -> (CGSize, (CGFloat) -> ChatMessageForwardInfoNode),
Expand Down Expand Up @@ -2097,6 +2101,7 @@ public class ChatMessageBubbleItemNode: ChatMessageItemView, ChatMessagePreviewI
var nameNodeOriginY: CGFloat = 0.0
var nameNodeSizeApply: (CGSize, () -> TextNode?) = (CGSize(), { nil })
var adminNodeSizeApply: (CGSize, () -> TextNode?) = (CGSize(), { nil })
var viaWidth: CGFloat = 0.0

var threadInfoOriginY: CGFloat = 0.0
var threadInfoSizeApply: (CGSize, (Bool) -> ChatMessageThreadInfoNode?) = (CGSize(), { _ in nil })
Expand Down Expand Up @@ -2135,13 +2140,16 @@ public class ChatMessageBubbleItemNode: ChatMessageItemView, ChatMessagePreviewI
} else if authorIsChannel, case .peer = item.chatLocation {
adminBadgeString = NSAttributedString(string: " \(item.presentationData.strings.Channel_Status)", font: inlineBotPrefixFont, textColor: messageTheme.secondaryTextColor)
}

var viaSuffix: NSAttributedString?
if let authorNameString = authorNameString, let authorNameColor = authorNameColor, let inlineBotNameString = inlineBotNameString {
let mutableString = NSMutableAttributedString(string: "\(authorNameString) ", attributes: [NSAttributedString.Key.font: nameFont, NSAttributedString.Key.foregroundColor: authorNameColor])
let bodyAttributes = MarkdownAttributeSet(font: nameFont, textColor: inlineBotNameColor)
let boldAttributes = MarkdownAttributeSet(font: inlineBotPrefixFont, textColor: inlineBotNameColor)
let botString = addAttributesToStringWithRanges(item.presentationData.strings.Conversation_MessageViaUser("@\(inlineBotNameString)")._tuple, body: bodyAttributes, argumentAttributes: [0: boldAttributes])
mutableString.append(botString)
attributedString = mutableString
viaSuffix = botString
} else if let authorNameString = authorNameString, let authorNameColor = authorNameColor {
attributedString = NSAttributedString(string: authorNameString, font: nameFont, textColor: authorNameColor)
} else if let inlineBotNameString = inlineBotNameString {
Expand Down Expand Up @@ -2176,6 +2184,11 @@ public class ChatMessageBubbleItemNode: ChatMessageItemView, ChatMessagePreviewI
return sizeAndApply.1()
})

if let viaSuffix {
let (viaLayout, _) = viaMeasureLayout(TextNodeLayoutArguments(attributedString: viaSuffix, backgroundColor: nil, maximumNumberOfLines: 1, truncationType: .end, constrainedSize: CGSize(width: max(0, maximumNodeWidth - layoutConstants.text.bubbleInsets.left - layoutConstants.text.bubbleInsets.right - credibilityIconWidth - adminBadgeSizeAndApply.0.size.width - closeButtonWidth), height: CGFloat.greatestFiniteMagnitude), alignment: .natural, cutout: nil, insets: UIEdgeInsets()))
viaWidth = viaLayout.size.width + 3.0
}

nameNodeOriginY = headerSize.height
headerSize.width = max(headerSize.width, nameNodeSizeApply.0.width + adminBadgeSizeAndApply.0.size.width + credibilityIconWidth + closeButtonWidth + bubbleWidthInsets)
headerSize.height += nameNodeSizeApply.0.height
Expand Down Expand Up @@ -2761,6 +2774,7 @@ public class ChatMessageBubbleItemNode: ChatMessageItemView, ChatMessagePreviewI
backgroundFrame: backgroundFrame,
deliveryFailedInset: deliveryFailedInset,
nameNodeSizeApply: nameNodeSizeApply,
viaWidth: viaWidth,
contentOrigin: contentOrigin,
nameNodeOriginY: nameNodeOriginY,
authorNameColor: authorNameColor,
Expand Down Expand Up @@ -2813,6 +2827,7 @@ public class ChatMessageBubbleItemNode: ChatMessageItemView, ChatMessagePreviewI
backgroundFrame: CGRect,
deliveryFailedInset: CGFloat,
nameNodeSizeApply: (CGSize, () -> TextNode?),
viaWidth: CGFloat,
contentOrigin: CGPoint,
nameNodeOriginY: CGFloat,
authorNameColor: UIColor?,
Expand Down Expand Up @@ -2989,8 +3004,10 @@ public class ChatMessageBubbleItemNode: ChatMessageItemView, ChatMessagePreviewI
strongSelf.clippingNode.addSubnode(nameButtonNode)
strongSelf.nameButtonNode = nameButtonNode
}
nameHighlightNode.frame = nameNodeFrame.insetBy(dx: -2.0, dy: -1.0)
nameButtonNode.frame = nameNodeFrame.insetBy(dx: -2.0, dy: -3.0)
var nameHiglightFrame = nameNodeFrame
nameHiglightFrame.size.width -= viaWidth
nameHighlightNode.frame = nameHiglightFrame.insetBy(dx: -2.0, dy: -1.0)
nameButtonNode.frame = nameHiglightFrame.insetBy(dx: -2.0, dy: -3.0)

let nameColor = authorNameColor ?? item.presentationData.theme.theme.chat.message.outgoing.accentTextColor
if themeUpdated {
Expand Down
2 changes: 1 addition & 1 deletion versions.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"app": "10.2.5",
"app": "10.2.6",
"bazel": "6.4.0",
"xcode": "15.0"
}

0 comments on commit b77b6fb

Please sign in to comment.