mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-22 14:20:20 +00:00
Various fixes
This commit is contained in:
@@ -313,12 +313,10 @@ public class ChatMessageFactCheckBubbleContentNode: ChatMessageBubbleContentNode
|
||||
let titleBadgeString = NSAttributedString(string: item.presentationData.strings.Message_FactCheck_WhatIsThis, font: badgeFont, textColor: mainColor)
|
||||
let (titleBadgeLayout, titleBadgeApply) = titleBadgeLayout(TextNodeLayoutArguments(attributedString: titleBadgeString, maximumNumberOfLines: 1, truncationType: .end, constrainedSize: textConstrainedSize))
|
||||
|
||||
var finalAttributedText = attributedText
|
||||
if "".isEmpty {
|
||||
finalAttributedText = stringWithAppliedEntities(rawText + "\u{00A0}\u{00A0}\u{00A0}", entities: rawEntities, baseColor: messageTheme.primaryTextColor, linkColor: messageTheme.linkTextColor, baseFont: textFont, linkFont: textFont, boldFont: textBoldFont, italicFont: textItalicFont, boldItalicFont: textBoldItalicFont, fixedFont: textFixedFont, blockQuoteFont: textBlockQuoteFont, message: nil)
|
||||
}
|
||||
let finalAttributedText = stringWithAppliedEntities(rawText, entities: rawEntities, baseColor: messageTheme.primaryTextColor, linkColor: messageTheme.linkTextColor, baseFont: textFont, linkFont: textFont, boldFont: textBoldFont, italicFont: textItalicFont, boldItalicFont: textBoldItalicFont, fixedFont: textFixedFont, blockQuoteFont: textBlockQuoteFont, message: nil) as! NSMutableAttributedString
|
||||
finalAttributedText.append(NSAttributedString(string: "__", font: textFont, textColor: .clear))
|
||||
|
||||
let (textLayout, textApply) = textLayout(TextNodeLayoutArguments(attributedString: finalAttributedText, backgroundColor: nil, maximumNumberOfLines: 0, truncationType: .end, constrainedSize: textConstrainedSize, alignment: .natural, cutout: nil, insets: textInsets, lineColor: messageTheme.accentControlColor, customTruncationToken: NSAttributedString(string: "", font: textFont, textColor: .clear)))
|
||||
let (textLayout, textApply) = textLayout(TextNodeLayoutArguments(attributedString: finalAttributedText, backgroundColor: nil, maximumNumberOfLines: 0, truncationType: .end, constrainedSize: textConstrainedSize, alignment: .natural, cutout: nil, insets: textInsets, lineColor: messageTheme.accentControlColor))
|
||||
|
||||
var canExpand = false
|
||||
var clippedTextHeight: CGFloat = textLayout.size.height
|
||||
@@ -336,6 +334,7 @@ public class ChatMessageFactCheckBubbleContentNode: ChatMessageBubbleContentNode
|
||||
var titleFrameWithoutInsets = CGRect(origin: CGPoint(x: titleFrame.origin.x + textInsets.left, y: titleFrame.origin.y + textInsets.top), size: CGSize(width: titleFrame.width - textInsets.left - textInsets.right, height: titleFrame.height - textInsets.top - textInsets.bottom))
|
||||
titleFrameWithoutInsets = titleFrameWithoutInsets.offsetBy(dx: layoutConstants.text.bubbleInsets.left, dy: layoutConstants.text.bubbleInsets.top)
|
||||
|
||||
let topInset: CGFloat = 5.0
|
||||
let textSpacing: CGFloat = 3.0
|
||||
|
||||
let textFrame = CGRect(origin: CGPoint(x: titleFrame.origin.x, y: -textInsets.top + titleFrameWithoutInsets.height + textSpacing), size: textLayout.size)
|
||||
@@ -386,7 +385,7 @@ public class ChatMessageFactCheckBubbleContentNode: ChatMessageBubbleContentNode
|
||||
|
||||
let statusSizeAndApply = statusSuggestedWidthAndContinue?.1(boundingWidth - layoutConstants.text.bubbleInsets.left - layoutConstants.text.bubbleInsets.right)
|
||||
|
||||
boundingSize = CGSize(width: boundingWidth, height: titleFrameWithoutInsets.height + textFrameWithoutInsets.size.height + textSpacing)
|
||||
boundingSize = CGSize(width: boundingWidth, height: topInset + titleFrameWithoutInsets.height + textFrameWithoutInsets.size.height + textSpacing)
|
||||
if let statusSizeAndApply = statusSizeAndApply {
|
||||
boundingSize.height += statusSizeAndApply.0.height
|
||||
}
|
||||
@@ -460,13 +459,13 @@ public class ChatMessageFactCheckBubbleContentNode: ChatMessageBubbleContentNode
|
||||
}
|
||||
|
||||
let _ = titleApply()
|
||||
strongSelf.titleNode.frame = titleFrame
|
||||
strongSelf.titleNode.frame = titleFrame.offsetBy(dx: 0.0, dy: topInset)
|
||||
let _ = titleBadgeApply()
|
||||
|
||||
let _ = textApply()
|
||||
strongSelf.textNode.frame = CGRect(origin: .zero, size: textFrame.size)
|
||||
|
||||
var clippingTextFrame = textFrame
|
||||
var clippingTextFrame = textFrame.offsetBy(dx: 0.0, dy: topInset)
|
||||
clippingTextFrame.size.height = clippedTextHeight - 3.0
|
||||
|
||||
if canExpand {
|
||||
@@ -523,7 +522,7 @@ public class ChatMessageFactCheckBubbleContentNode: ChatMessageBubbleContentNode
|
||||
titleLineWidth = titleFrame.width
|
||||
}
|
||||
|
||||
let titleBadgeFrame = CGRect(origin: CGPoint(x: titleFrame.minX + titleLineWidth + titleBadgeSpacing + titleBadgePadding, y: floorToScreenPixels(titleFrame.midY - titleBadgeLayout.size.height / 2.0) - 1.0), size: titleBadgeLayout.size)
|
||||
let titleBadgeFrame = CGRect(origin: CGPoint(x: titleFrame.minX + titleLineWidth + titleBadgeSpacing + titleBadgePadding, y: topInset + floorToScreenPixels(titleFrame.midY - titleBadgeLayout.size.height / 2.0) - 1.0), size: titleBadgeLayout.size)
|
||||
let badgeBackgroundFrame = titleBadgeFrame.insetBy(dx: -titleBadgePadding, dy: -1.0 + UIScreenPixel)
|
||||
|
||||
strongSelf.titleBadgeLabel.frame = titleBadgeFrame
|
||||
@@ -560,7 +559,7 @@ public class ChatMessageFactCheckBubbleContentNode: ChatMessageBubbleContentNode
|
||||
titleBadgeButton.setBackgroundImage(generateFilledCircleImage(diameter: badgeBackgroundFrame.height, color: mainColor.withMultipliedAlpha(0.1))?.stretchableImage(withLeftCapWidth: Int(badgeBackgroundFrame.height / 2), topCapHeight: Int(badgeBackgroundFrame.height / 2)), for: .normal)
|
||||
}
|
||||
|
||||
let backgroundFrame = CGRect(origin: CGPoint(x: backgroundInsets.left, y: backgroundInsets.top), size: CGSize(width: boundingWidth - backgroundInsets.left - backgroundInsets.right, height: titleFrameWithoutInsets.height + textSpacing + textFrameWithoutInsets.height + textSpacing))
|
||||
let backgroundFrame = CGRect(origin: CGPoint(x: backgroundInsets.left, y: backgroundInsets.top + topInset), size: CGSize(width: boundingWidth - backgroundInsets.left - backgroundInsets.right, height: titleFrameWithoutInsets.height + textSpacing + textFrameWithoutInsets.height + textSpacing))
|
||||
|
||||
if isFirstTime {
|
||||
strongSelf.textClippingNode.frame = clippingTextFrame
|
||||
@@ -595,7 +594,7 @@ public class ChatMessageFactCheckBubbleContentNode: ChatMessageBubbleContentNode
|
||||
item.controllerInteraction.openMessageReactionContextMenu(item.topMessage, sourceNode, gesture, value)
|
||||
}
|
||||
|
||||
let statusFrame = CGRect(origin: CGPoint(x: boundingWidth - layoutConstants.text.bubbleInsets.right - statusSizeAndApply.0.width, y: textFrameWithoutInsets.maxY), size: statusSizeAndApply.0)
|
||||
let statusFrame = CGRect(origin: CGPoint(x: boundingWidth - layoutConstants.text.bubbleInsets.right - statusSizeAndApply.0.width, y: topInset + textFrameWithoutInsets.maxY), size: statusSizeAndApply.0)
|
||||
if isFirstTime {
|
||||
strongSelf.statusNode.frame = statusFrame
|
||||
} else {
|
||||
|
||||
@@ -62,7 +62,7 @@ public final class ChatMessageInvoiceBubbleContentNode: ChatMessageBubbleContent
|
||||
if let image = invoice.photo {
|
||||
automaticDownloadSettings = MediaAutoDownloadSettings.defaultSettings
|
||||
mediaAndFlags = ([image], [.preferMediaBeforeText])
|
||||
} else {
|
||||
} else if invoice.currency != "XTR" {
|
||||
let invoiceLabel = item.presentationData.strings.Message_InvoiceLabel
|
||||
var invoiceText = "\(formatCurrencyAmount(invoice.totalAmount, currency: invoice.currency)) "
|
||||
invoiceText += invoiceLabel
|
||||
|
||||
@@ -20,6 +20,7 @@ private final class FactCheckAlertContentNode: AlertContentNode {
|
||||
private var presentationTheme: PresentationTheme
|
||||
private let strings: PresentationStrings
|
||||
private let text: String
|
||||
private let initialValue: String
|
||||
|
||||
private let titleView = ComponentView<Empty>()
|
||||
|
||||
@@ -58,6 +59,7 @@ private final class FactCheckAlertContentNode: AlertContentNode {
|
||||
self.presentationTheme = presentationTheme
|
||||
self.strings = strings
|
||||
self.text = text
|
||||
self.initialValue = value
|
||||
|
||||
if !value.isEmpty {
|
||||
self.inputFieldExternalState.initialText = chatInputStateStringWithAppliedEntities(value, entities: entities)
|
||||
@@ -271,7 +273,23 @@ private final class FactCheckAlertContentNode: AlertContentNode {
|
||||
}
|
||||
|
||||
if let lastActionNode = self.actionNodes.last {
|
||||
lastActionNode.actionEnabled = self.inputFieldExternalState.hasText
|
||||
if self.initialValue.isEmpty {
|
||||
lastActionNode.actionEnabled = self.inputFieldExternalState.hasText
|
||||
} else {
|
||||
if self.inputFieldExternalState.hasText {
|
||||
lastActionNode.action = TextAlertAction(
|
||||
type: .defaultAction,
|
||||
title: self.strings.Common_Done,
|
||||
action: lastActionNode.action.action
|
||||
)
|
||||
} else {
|
||||
lastActionNode.action = TextAlertAction(
|
||||
type: .defaultDestructiveAction,
|
||||
title: self.strings.FactCheck_Remove,
|
||||
action: lastActionNode.action.action
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let resultSize = CGSize(width: resultWidth, height: titleSize.height + spacing + inputFieldSize.height + 17.0 + actionsHeight + insets.top + insets.bottom)
|
||||
|
||||
Reference in New Issue
Block a user