[WIP] Stars [skip ci]

This commit is contained in:
Isaac
2025-06-24 00:16:00 +02:00
parent 9a14b076c6
commit 51a16c7110
10 changed files with 123 additions and 50 deletions

View File

@@ -1444,27 +1444,25 @@ public func universalServiceMessageString(presentationData: (PresentationTheme,
}
attributedString = NSAttributedString(string: string, font: titleFont, textColor: primaryTextColor)
case let .giftTon(currency, amount, _, _, _):
let _ = currency
let _ = amount
attributedString = nil
// if !forAdditionalServiceMessage {
// attributedString = NSAttributedString(string: strings.Notification_Gift, font: titleFont, textColor: primaryTextColor)
// } else {
// let price = formatCurrencyAmount(amount, currency: currency)
// if message.author?.id == accountPeerId {
// attributedString = addAttributesToStringWithRanges(strings.Notification_StarsGift_SentYou(price)._tuple, body: bodyAttributes, argumentAttributes: [0: boldAttributes])
// } else {
// var authorName = compactAuthorName
// var peerIds: [(Int, EnginePeer.Id?)] = [(0, message.author?.id)]
// if message.id.peerId.namespace == Namespaces.Peer.CloudUser && message.id.peerId.id._internalGetInt64Value() == 777000 {
// authorName = strings.Notification_StarsGift_UnknownUser
// peerIds = []
// }
// var attributes = peerMentionsAttributes(primaryTextColor: primaryTextColor, peerIds: peerIds)
// attributes[1] = boldAttributes
// attributedString = addAttributesToStringWithRanges(strings.Notification_StarsGift_Sent(authorName, price)._tuple, body: bodyAttributes, argumentAttributes: attributes)
// }
// }
if !forAdditionalServiceMessage {
attributedString = NSAttributedString(string: strings.Notification_Gift, font: titleFont, textColor: primaryTextColor)
} else {
let price = formatCurrencyAmount(amount, currency: currency)
if message.author?.id == accountPeerId {
attributedString = addAttributesToStringWithRanges(strings.Notification_StarsGift_SentYou(price)._tuple, body: bodyAttributes, argumentAttributes: [0: boldAttributes])
} else {
var authorName = compactAuthorName
var peerIds: [(Int, EnginePeer.Id?)] = [(0, message.author?.id)]
if message.id.peerId.namespace == Namespaces.Peer.CloudUser && message.id.peerId.id._internalGetInt64Value() == 777000 {
authorName = strings.Notification_StarsGift_UnknownUser
peerIds = []
}
var attributes = peerMentionsAttributes(primaryTextColor: primaryTextColor, peerIds: peerIds)
attributes[1] = boldAttributes
attributedString = addAttributesToStringWithRanges(strings.Notification_StarsGift_Sent(authorName, price)._tuple, body: bodyAttributes, argumentAttributes: attributes)
}
}
case .unknown:
attributedString = nil
}