mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-23 06:35:51 +00:00
Various improvements
This commit is contained in:
@@ -322,10 +322,15 @@ final class ChatPinnedMessageTitlePanelNode: ChatTitleAccessoryPanelNode {
|
||||
messageUpdated = true
|
||||
}
|
||||
|
||||
var isStarsPayment = false
|
||||
if let message = interfaceState.pinnedMessage, !message.message.isRestricted(platform: "ios", contentSettings: self.context.currentContentSettings.with { $0 }) {
|
||||
for attribute in message.message.attributes {
|
||||
if let attribute = attribute as? ReplyMarkupMessageAttribute, attribute.flags.contains(.inline), attribute.rows.count == 1, attribute.rows[0].buttons.count == 1 {
|
||||
actionTitle = attribute.rows[0].buttons[0].title
|
||||
let title = attribute.rows[0].buttons[0].title
|
||||
actionTitle = title
|
||||
if case .payment = attribute.rows[0].buttons[0].action, title.contains("⭐️") {
|
||||
isStarsPayment = true
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@@ -430,7 +435,20 @@ final class ChatPinnedMessageTitlePanelNode: ChatTitleAccessoryPanelNode {
|
||||
self.actionButtonBackgroundNode.isHidden = false
|
||||
self.actionButtonTitleNode.isHidden = false
|
||||
|
||||
self.actionButtonTitleNode.attributedText = NSAttributedString(string: actionTitle, font: Font.with(size: 15.0, design: .round, weight: .semibold, traits: [.monospacedNumbers]), textColor: interfaceState.theme.list.itemCheckColors.foregroundColor)
|
||||
let attributedTitle: NSAttributedString
|
||||
if isStarsPayment {
|
||||
let updatedTitle = actionTitle.replacingOccurrences(of: "⭐️", with: " # ")
|
||||
let buttonAttributedString = NSMutableAttributedString(string: updatedTitle, font: Font.with(size: 15.0, design: .round, weight: .semibold, traits: [.monospacedNumbers]), textColor: interfaceState.theme.list.itemCheckColors.foregroundColor)
|
||||
if let range = buttonAttributedString.string.range(of: "#"), let starImage = UIImage(bundleImageName: "Item List/PremiumIcon") {
|
||||
buttonAttributedString.addAttribute(.attachment, value: starImage, range: NSRange(range, in: buttonAttributedString.string))
|
||||
buttonAttributedString.addAttribute(.foregroundColor, value: interfaceState.theme.list.itemCheckColors.foregroundColor, range: NSRange(range, in: buttonAttributedString.string))
|
||||
buttonAttributedString.addAttribute(.baselineOffset, value: 1.0, range: NSRange(range, in: buttonAttributedString.string))
|
||||
}
|
||||
attributedTitle = buttonAttributedString
|
||||
} else {
|
||||
attributedTitle = NSAttributedString(string: actionTitle, font: Font.with(size: 15.0, design: .round, weight: .semibold, traits: [.monospacedNumbers]), textColor: interfaceState.theme.list.itemCheckColors.foregroundColor)
|
||||
}
|
||||
self.actionButtonTitleNode.attributedText = attributedTitle
|
||||
|
||||
let actionButtonTitleSize = self.actionButtonTitleNode.updateLayout(CGSize(width: 150.0, height: .greatestFiniteMagnitude))
|
||||
let actionButtonSize = CGSize(width: max(actionButtonTitleSize.width + 20.0, 40.0), height: 28.0)
|
||||
|
||||
Reference in New Issue
Block a user