Various improvements

This commit is contained in:
Ilya Laktyushin 2025-01-22 21:33:47 +04:00
parent 103b244216
commit 8164009fdb
4 changed files with 34 additions and 7 deletions

View File

@ -13782,3 +13782,9 @@ Sorry for the inconvenience.";
"AvatarUpload.StatusUploading" = "Your photo is uploading.";
"AvatarUpload.StatusDone" = "Your photo is now set.";
"AvatarUpload.ViewAction" = "View";
"Notification.StarGift.TitleShort" = "Gift";
"Notification.StarsGift.SentSomeone" = "Someone sent you a gift";
"Notification.StarsGift.UpgradeChannel" = "A gift was turned into a unique collectible";

View File

@ -1086,7 +1086,9 @@ public func universalServiceMessageString(presentationData: (PresentationTheme,
authorName = strings.Notification_StarsGift_UnknownUser
peerIds = []
}
if message.id.peerId == accountPeerId {
if message.id.peerId.isTelegramNotifications && senderId == nil {
attributedString = NSAttributedString(string: strings.Notification_StarsGift_SentSomeone, font: titleFont, textColor: primaryTextColor)
} else if message.id.peerId == accountPeerId {
attributedString = addAttributesToStringWithRanges(strings.Notification_StarsGift_Self_Bought(starsPrice)._tuple, body: bodyAttributes, argumentAttributes: [0: boldAttributes])
} else if message.author?.id == accountPeerId {
attributedString = addAttributesToStringWithRanges(strings.Notification_StarsGift_SentYou(starsPrice)._tuple, body: bodyAttributes, argumentAttributes: [0: boldAttributes])
@ -1111,15 +1113,17 @@ public func universalServiceMessageString(presentationData: (PresentationTheme,
attributedString = addAttributesToStringWithRanges(strings.Notification_StarsGift_Sent(authorName, starsPrice)._tuple, body: bodyAttributes, argumentAttributes: attributes)
}
}
case let .starGiftUnique(gift, isUpgrade, _, _, _, _, _, _, _, _):
case let .starGiftUnique(gift, isUpgrade, _, _, _, _, _, _, senderId, _):
if case let .unique(gift) = gift {
if !forAdditionalServiceMessage && !"".isEmpty {
attributedString = NSAttributedString(string: "\(gift.title) #\(gift.number)", font: titleFont, textColor: primaryTextColor)
} else if let messagePeer = message.peers[message.id.peerId] {
let peerName = EnginePeer(messagePeer).compactDisplayTitle
let peerIds: [(Int, EnginePeer.Id?)] = [(0, messagePeer.id)]
var peerName = EnginePeer(messagePeer).compactDisplayTitle
var peerIds: [(Int, EnginePeer.Id?)] = [(0, messagePeer.id)]
if isUpgrade {
if message.id.peerId == accountPeerId {
if message.id.peerId.isTelegramNotifications {
attributedString = NSAttributedString(string: strings.Notification_StarsGift_UpgradeChannel, font: titleFont, textColor: primaryTextColor)
} else if message.id.peerId == accountPeerId {
attributedString = NSAttributedString(string: strings.Notification_StarsGift_UpgradeSelf, font: titleFont, textColor: primaryTextColor)
} else if message.author?.id == accountPeerId {
let attributes = peerMentionsAttributes(primaryTextColor: primaryTextColor, peerIds: peerIds)
@ -1129,8 +1133,15 @@ public func universalServiceMessageString(presentationData: (PresentationTheme,
attributedString = addAttributesToStringWithRanges(strings.Notification_StarsGift_Upgrade(peerName)._tuple, body: bodyAttributes, argumentAttributes: attributes)
}
} else {
if message.author?.id == accountPeerId {
if message.id.peerId.isTelegramNotifications && senderId == nil {
attributedString = NSAttributedString(string: strings.Notification_StarsGift_SentSomeone, font: titleFont, textColor: primaryTextColor)
} else if message.author?.id == accountPeerId {
attributedString = NSAttributedString(string: strings.Notification_StarsGift_TransferYou, font: titleFont, textColor: primaryTextColor)
} else if let senderId, let peer = message.peers[senderId] {
peerName = EnginePeer(peer).compactDisplayTitle
peerIds = [(0, senderId)]
let attributes = peerMentionsAttributes(primaryTextColor: primaryTextColor, peerIds: peerIds)
attributedString = addAttributesToStringWithRanges(strings.Notification_StarsGift_Transfer(peerName)._tuple, body: bodyAttributes, argumentAttributes: attributes)
} else {
let attributes = peerMentionsAttributes(primaryTextColor: primaryTextColor, peerIds: peerIds)
attributedString = addAttributesToStringWithRanges(strings.Notification_StarsGift_Transfer(peerName)._tuple, body: bodyAttributes, argumentAttributes: attributes)

View File

@ -359,6 +359,7 @@ public final class ChatChannelSubscriberInputPanelNode: ChatInputPanelNode {
}
private func updateLayout(width: CGFloat, leftInset: CGFloat, rightInset: CGFloat, bottomInset: CGFloat, additionalSideInsets: UIEdgeInsets, maxHeight: CGFloat, isSecondary: Bool, transition: ContainedViewLayoutTransition, interfaceState: ChatPresentationInterfaceState, metrics: LayoutMetrics, force: Bool) -> CGFloat {
let isFirstTime = self.layoutData == nil
self.layoutData = (width, leftInset, rightInset, bottomInset, additionalSideInsets, maxHeight, isSecondary, metrics)
if self.presentationInterfaceState != interfaceState || force {
@ -416,6 +417,11 @@ public final class ChatChannelSubscriberInputPanelNode: ChatInputPanelNode {
if let peer = interfaceState.renderedPeer?.peer as? TelegramChannel {
if case .broadcast = peer.info, interfaceState.starGiftsAvailable {
if self.giftButton.isHidden && !isFirstTime {
self.giftButton.layer.animateAlpha(from: 0.0, to: 1.0, duration: 0.2)
self.giftButton.layer.animateScale(from: 0.01, to: 1.0, duration: 0.2)
}
self.giftButton.isHidden = false
self.helpButton.isHidden = true

View File

@ -570,7 +570,11 @@ public class ChatMessageGiftBubbleContentNode: ChatMessageBubbleContentNode {
} else {
authorName = item.message.author.flatMap { EnginePeer($0) }?.compactDisplayTitle ?? ""
}
title = isStoryEntity ? uniqueGift.title : item.presentationData.strings.Notification_StarGift_Title(authorName).string
if item.message.id.peerId.isTelegramNotifications {
title = item.presentationData.strings.Notification_StarGift_TitleShort
} else {
title = isStoryEntity ? uniqueGift.title : item.presentationData.strings.Notification_StarGift_Title(authorName).string
}
text = isStoryEntity ? "**Collectible #\(uniqueGift.number)**" : "**\(uniqueGift.title) #\(uniqueGift.number)**"
ribbonTitle = isStoryEntity ? "" : item.presentationData.strings.Notification_StarGift_Gift
buttonTitle = isStoryEntity ? "" : item.presentationData.strings.Notification_StarGift_View