diff --git a/Telegram/Telegram-iOS/en.lproj/Localizable.strings b/Telegram/Telegram-iOS/en.lproj/Localizable.strings index 605f908a5a..1f055b2c9d 100644 --- a/Telegram/Telegram-iOS/en.lproj/Localizable.strings +++ b/Telegram/Telegram-iOS/en.lproj/Localizable.strings @@ -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"; diff --git a/submodules/TelegramStringFormatting/Sources/ServiceMessageStrings.swift b/submodules/TelegramStringFormatting/Sources/ServiceMessageStrings.swift index 9fffa987bd..a76d645a38 100644 --- a/submodules/TelegramStringFormatting/Sources/ServiceMessageStrings.swift +++ b/submodules/TelegramStringFormatting/Sources/ServiceMessageStrings.swift @@ -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) diff --git a/submodules/TelegramUI/Components/Chat/ChatChannelSubscriberInputPanelNode/Sources/ChatChannelSubscriberInputPanelNode.swift b/submodules/TelegramUI/Components/Chat/ChatChannelSubscriberInputPanelNode/Sources/ChatChannelSubscriberInputPanelNode.swift index f9edf5c465..bf18e4432b 100644 --- a/submodules/TelegramUI/Components/Chat/ChatChannelSubscriberInputPanelNode/Sources/ChatChannelSubscriberInputPanelNode.swift +++ b/submodules/TelegramUI/Components/Chat/ChatChannelSubscriberInputPanelNode/Sources/ChatChannelSubscriberInputPanelNode.swift @@ -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 diff --git a/submodules/TelegramUI/Components/Chat/ChatMessageGiftBubbleContentNode/Sources/ChatMessageGiftBubbleContentNode.swift b/submodules/TelegramUI/Components/Chat/ChatMessageGiftBubbleContentNode/Sources/ChatMessageGiftBubbleContentNode.swift index 2d0327ee7a..3de1f1658e 100644 --- a/submodules/TelegramUI/Components/Chat/ChatMessageGiftBubbleContentNode/Sources/ChatMessageGiftBubbleContentNode.swift +++ b/submodules/TelegramUI/Components/Chat/ChatMessageGiftBubbleContentNode/Sources/ChatMessageGiftBubbleContentNode.swift @@ -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