diff --git a/Telegram/Telegram-iOS/en.lproj/Localizable.strings b/Telegram/Telegram-iOS/en.lproj/Localizable.strings index d141dd5f34..b11c70abfb 100644 --- a/Telegram/Telegram-iOS/en.lproj/Localizable.strings +++ b/Telegram/Telegram-iOS/en.lproj/Localizable.strings @@ -13532,6 +13532,8 @@ Sorry for the inconvenience."; "Gift.Transfer.Confirmation.Transfer" = "Transfer for"; "Gift.Transfer.Confirmation.TransferFree" = "Transfer"; +"Gift.Transfer.Success" = "You have successfully gifter **%1$@** to **%2$@**."; + "Gift.View.UpgradeForFree" = "Upgrade for Free"; "Gift.View.KeepUpgradeOrConvertDescription" = "You can keep this gift, upgrade it, or sell it for %@. [More About Stars >]()"; @@ -13576,14 +13578,17 @@ Sorry for the inconvenience."; "Notification.StarGift.Subtitle.Refunded" = "This gift cannot be converted to Stars because the payment related to it was refunded."; "Notification.StarGift.Subtitle.Downgraded" = "This gift was downgraded because a request to refund the payment related to this gift was made, and the money was returned."; -"Notification.StarGift.Subtitle.Other" = "%1$@ can turn this gift to a unique collectible."; +"Notification.StarGift.Subtitle.Upgrade" = "Tap \"Unpack\" to turn this gift to a unique collectible."; +"Notification.StarGift.Subtitle.Upgrade.Other" = "%1$@ can turn this gift to a unique collectible."; "Notification.StarGift.Subtitle.Upgraded" = "This gift was upgraded."; "Stars.Transaction.GiftFrom" = "Gift From"; "Stars.Transaction.GiftUpgrade" = "Gift Upgrade"; -"Gift.View.KeepOrUpgradeDescription" = "Tap \"Unpack\" to turn this gift to a unique collectible."; +"Gift.View.FreeUpgradeDescription" = "Upgrade this gift for free to turn it to a unique collectible."; +"Gift.View.FreeUpgradeOtherDescription" = "%1$@ can turn this gift to a unique collectible."; + "Gift.View.UpgradedDescription" = "This gift was turned to a unique collectible."; "Gift.View.ViewUpgraded" = "View Upgraded Gift"; diff --git a/submodules/TelegramUI/Components/Chat/ChatMessageGiftBubbleContentNode/Sources/ChatMessageGiftBubbleContentNode.swift b/submodules/TelegramUI/Components/Chat/ChatMessageGiftBubbleContentNode/Sources/ChatMessageGiftBubbleContentNode.swift index d6b164a927..6f724e93a9 100644 --- a/submodules/TelegramUI/Components/Chat/ChatMessageGiftBubbleContentNode/Sources/ChatMessageGiftBubbleContentNode.swift +++ b/submodules/TelegramUI/Components/Chat/ChatMessageGiftBubbleContentNode/Sources/ChatMessageGiftBubbleContentNode.swift @@ -478,6 +478,8 @@ public class ChatMessageGiftBubbleContentNode: ChatMessageBubbleContentNode { } else if incoming { if converted { text = item.presentationData.strings.Notification_StarGift_Subtitle_Converted(item.presentationData.strings.Notification_StarGift_Subtitle_Converted_Stars(Int32(convertStars ?? 0))).string + } else if upgradeStars != nil { + text = item.presentationData.strings.Notification_StarGift_Subtitle_Upgrade } else if savedToProfile { if let convertStars { text = item.presentationData.strings.Notification_StarGift_Subtitle_Displaying(item.presentationData.strings.Notification_StarGift_Subtitle_Displaying_Stars(Int32(convertStars))).string @@ -503,14 +505,14 @@ public class ChatMessageGiftBubbleContentNode: ChatMessageBubbleContentNode { text = item.presentationData.strings.Notification_StarGift_Bot_Subtitle } } else { - if let convertStars, convertStars > 0 { + if upgradeStars != nil { + text = item.presentationData.strings.Notification_StarGift_Subtitle_Upgrade_Other(peerName).string + } else if let convertStars, convertStars > 0 { let formattedString = item.presentationData.strings.Notification_StarGift_Subtitle_Other(peerName, item.presentationData.strings.Notification_StarGift_Subtitle_Other_Stars(Int32(convertStars))) text = formattedString.string if let starsRange = formattedString.ranges.last { entities.append(MessageTextEntity(range: starsRange.range.lowerBound ..< starsRange.range.upperBound, type: .Bold)) } - } else { - } } } diff --git a/submodules/TelegramUI/Components/Gifts/GiftItemComponent/Sources/GiftItemComponent.swift b/submodules/TelegramUI/Components/Gifts/GiftItemComponent/Sources/GiftItemComponent.swift index ac21727aac..95712eb17f 100644 --- a/submodules/TelegramUI/Components/Gifts/GiftItemComponent/Sources/GiftItemComponent.swift +++ b/submodules/TelegramUI/Components/Gifts/GiftItemComponent/Sources/GiftItemComponent.swift @@ -224,9 +224,9 @@ public final class GiftItemComponent: Component { iconSize = CGSize(width: 88.0, height: 88.0) cornerRadius = 10.0 case .thumbnail: - size = CGSize(width: 60.0, height: 60.0) - iconSize = CGSize(width: 42.0, height: 42.0) - cornerRadius = 12.0 + size = CGSize(width: availableSize.width, height: availableSize.width) + iconSize = CGSize(width: floor(size.width * 0.7), height: floor(size.width * 0.7)) + cornerRadius = floor(availableSize.width * 0.2) } self.backgroundLayer.cornerRadius = cornerRadius diff --git a/submodules/TelegramUI/Components/Gifts/GiftViewScreen/Sources/GiftViewScreen.swift b/submodules/TelegramUI/Components/Gifts/GiftViewScreen/Sources/GiftViewScreen.swift index f6a9f8f845..d3c1037d7f 100644 --- a/submodules/TelegramUI/Components/Gifts/GiftViewScreen/Sources/GiftViewScreen.swift +++ b/submodules/TelegramUI/Components/Gifts/GiftViewScreen/Sources/GiftViewScreen.swift @@ -708,7 +708,9 @@ private final class GiftViewSheetContent: CombinedComponent { } else if upgraded { descriptionText = strings.Gift_View_UpgradedDescription } else if incoming { - if let convertStars, !upgraded { + if let _ = upgradeStars { + descriptionText = strings.Gift_View_FreeUpgradeDescription + } else if let convertStars, !upgraded { if !converted { if canUpgrade || upgradeStars != nil { descriptionText = strings.Gift_View_KeepUpgradeOrConvertDescription(strings.Gift_View_KeepOrConvertDescription_Stars(Int32(convertStars))).string @@ -718,13 +720,13 @@ private final class GiftViewSheetContent: CombinedComponent { } else { descriptionText = strings.Gift_View_ConvertedDescription(strings.Gift_View_ConvertedDescription_Stars(Int32(convertStars))).string } - } else if (canUpgrade || upgradeStars != nil) && !upgraded { - descriptionText = strings.Gift_View_KeepOrUpgradeDescription } else { descriptionText = strings.Gift_View_BotDescription } } else if let peerId = subject.arguments?.peerId, let peer = state.peerMap[peerId] { - if case .message = subject, let convertStars { + if let _ = upgradeStars { + descriptionText = strings.Gift_View_FreeUpgradeOtherDescription(peer.compactDisplayTitle).string + } else if case .message = subject, let convertStars { descriptionText = strings.Gift_View_OtherDescription(peer.compactDisplayTitle, strings.Gift_View_OtherDescription_Stars(Int32(convertStars))).string } else { descriptionText = "" diff --git a/submodules/TelegramUI/Components/Stars/StarsAvatarComponent/BUILD b/submodules/TelegramUI/Components/Stars/StarsAvatarComponent/BUILD index 4eabbf93fc..8e587337b5 100644 --- a/submodules/TelegramUI/Components/Stars/StarsAvatarComponent/BUILD +++ b/submodules/TelegramUI/Components/Stars/StarsAvatarComponent/BUILD @@ -23,6 +23,7 @@ swift_library( "//submodules/AccountContext", "//submodules/Components/MultilineTextComponent", "//submodules/Components/BundleIconComponent", + "//submodules/TelegramUI/Components/Gifts/GiftItemComponent", ], visibility = [ "//visibility:public", diff --git a/submodules/TelegramUI/Components/Stars/StarsAvatarComponent/Sources/StarsAvatarComponent.swift b/submodules/TelegramUI/Components/Stars/StarsAvatarComponent/Sources/StarsAvatarComponent.swift index ee90ffd29f..6b3a895a7d 100644 --- a/submodules/TelegramUI/Components/Stars/StarsAvatarComponent/Sources/StarsAvatarComponent.swift +++ b/submodules/TelegramUI/Components/Stars/StarsAvatarComponent/Sources/StarsAvatarComponent.swift @@ -11,6 +11,7 @@ import AvatarNode import AccountContext import BundleIconComponent import MultilineTextComponent +import GiftItemComponent public final class StarsAvatarComponent: Component { let context: AccountContext @@ -77,6 +78,7 @@ public final class StarsAvatarComponent: Component { private var imageNode: TransformImageNode? private var imageFrameNode: UIView? private var secondImageNode: TransformImageNode? + private let giftView = ComponentView() private let fetchDisposable = DisposableSet() @@ -114,7 +116,29 @@ public final class StarsAvatarComponent: Component { var dimensions = size var didSetup = false - if !component.media.isEmpty { + if let gift = component.uniqueGift { + let giftFrame = CGRect(origin: .zero, size: size) + let _ = self.giftView.update( + transition: .immediate, + component: AnyComponent( + GiftItemComponent( + context: component.context, + theme: component.theme, + peer: nil, + subject: .uniqueGift(gift: gift), + mode: .thumbnail + ) + ), + environment: {}, + containerSize: giftFrame.size + ) + if let view = self.giftView.view { + if view.superview == nil { + self.addSubview(view) + } + view.frame = giftFrame + } + } else if !component.media.isEmpty { let imageNode: TransformImageNode var isFirstTime = false if let current = self.imageNode { diff --git a/submodules/TelegramUI/Sources/SharedAccountContext.swift b/submodules/TelegramUI/Sources/SharedAccountContext.swift index a18a74c999..51a1999b14 100644 --- a/submodules/TelegramUI/Sources/SharedAccountContext.swift +++ b/submodules/TelegramUI/Sources/SharedAccountContext.swift @@ -2497,6 +2497,18 @@ public final class SharedAccountContextImpl: SharedAccountContext { controllers.append(chatController) } navigationController.setViewControllers(controllers, animated: true) + + Queue.mainQueue().after(0.3) { + let tooltipController = UndoOverlayController( + presentationData: presentationData, + content: .forward(savedMessages: false, text: presentationData.strings.Gift_Transfer_Success("\(gift) #\(gift.number)", peer.displayTitle(strings: presentationData.strings, displayOrder: presentationData.nameDisplayOrder)).string), + elevatedLayout: false, + action: { _ in return true } + ) + if let lastController = controllers.last as? ViewController { + lastController.present(tooltipController, in: .window(.root)) + } + } }) controller.present(alertController, in: .window(.root)) }