Skip to content

Commit 9c95be3

Browse files
committed
Various fixes
1 parent acae4de commit 9c95be3

File tree

7 files changed

+161
-35
lines changed

7 files changed

+161
-35
lines changed

Telegram/Telegram-iOS/en.lproj/Localizable.strings

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13578,10 +13578,14 @@ Sorry for the inconvenience.";
1357813578

1357913579
"Notification.StarGift.Subtitle.Other" = "%1$@ can turn this gift to a unique collectible.";
1358013580

13581+
"Notification.StarGift.Subtitle.Upgraded" = "This gift was upgraded.";
13582+
1358113583
"Stars.Transaction.GiftFrom" = "Gift From";
1358213584
"Stars.Transaction.GiftUpgrade" = "Gift Upgrade";
1358313585

1358413586
"Gift.View.KeepOrUpgradeDescription" = "Tap \"Unpack\" to turn this gift to a unique collectible.";
13587+
"Gift.View.UpgradedDescription" = "This gift was turned to a unique collectible.";
13588+
"Gift.View.ViewUpgraded" = "View Upgraded Gift";
1358513589

1358613590
"VideoChat.IncomingVideoQuality.AudioOnly" = "Audio Only";
1358713591
"VideoChat.IncomingVideoQuality.Title" = "Receive Video Quality";

submodules/TelegramUI/Components/Chat/ChatMessageGiftBubbleContentNode/Sources/ChatMessageGiftBubbleContentNode.swift

Lines changed: 24 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public class ChatMessageGiftBubbleContentNode: ChatMessageBubbleContentNode {
6060
private let buttonNode: HighlightTrackingButtonNode
6161
private let buttonStarsNode: PremiumStarsNode
6262
private let buttonTitleNode: TextNode
63-
private let buttonIconNode: ASImageNode
63+
private var buttonIconNode: DefaultAnimatedStickerNodeImpl?
6464

6565
private let moreTextNode: TextNode
6666

@@ -165,11 +165,7 @@ public class ChatMessageGiftBubbleContentNode: ChatMessageBubbleContentNode {
165165
self.buttonTitleNode = TextNode()
166166
self.buttonTitleNode.isUserInteractionEnabled = false
167167
self.buttonTitleNode.displaysAsynchronously = false
168-
169-
self.buttonIconNode = ASImageNode()
170-
self.buttonIconNode.displaysAsynchronously = false
171-
self.buttonIconNode.isUserInteractionEnabled = false
172-
168+
173169
self.ribbonBackgroundNode = ASImageNode()
174170
self.ribbonBackgroundNode.displaysAsynchronously = false
175171

@@ -195,7 +191,6 @@ public class ChatMessageGiftBubbleContentNode: ChatMessageBubbleContentNode {
195191
self.addSubnode(self.buttonNode)
196192
self.buttonNode.addSubnode(self.buttonStarsNode)
197193
self.buttonNode.addSubnode(self.buttonTitleNode)
198-
self.buttonNode.addSubnode(self.buttonIconNode)
199194

200195
self.addSubnode(self.ribbonBackgroundNode)
201196
self.addSubnode(self.ribbonTextNode)
@@ -478,6 +473,8 @@ public class ChatMessageGiftBubbleContentNode: ChatMessageBubbleContentNode {
478473
} else {
479474
if isRefunded {
480475
text = item.presentationData.strings.Notification_StarGift_Subtitle_Refunded
476+
} else if upgraded {
477+
text = item.presentationData.strings.Notification_StarGift_Subtitle_Upgraded
481478
} else if incoming {
482479
if converted {
483480
text = item.presentationData.strings.Notification_StarGift_Subtitle_Converted(item.presentationData.strings.Notification_StarGift_Subtitle_Converted_Stars(Int32(convertStars ?? 0))).string
@@ -530,7 +527,7 @@ public class ChatMessageGiftBubbleContentNode: ChatMessageBubbleContentNode {
530527
}
531528
if incoming || item.presentationData.isPreview, let upgradeStars, upgradeStars > 0, !upgraded {
532529
buttonTitle = item.presentationData.strings.Notification_StarGift_Unpack
533-
buttonIcon = "Premium/GiftUnpack"
530+
buttonIcon = "GiftUnpack"
534531
} else {
535532
buttonTitle = item.presentationData.strings.Notification_StarGift_View
536533
}
@@ -754,7 +751,6 @@ public class ChatMessageGiftBubbleContentNode: ChatMessageBubbleContentNode {
754751

755752
strongSelf.buttonNode.isHidden = buttonTitle.isEmpty
756753
strongSelf.buttonTitleNode.isHidden = buttonTitle.isEmpty
757-
strongSelf.buttonIconNode.isHidden = buttonIcon == nil
758754

759755
if strongSelf.item == nil {
760756
strongSelf.animationNode.started = { [weak self] in
@@ -930,15 +926,28 @@ public class ChatMessageGiftBubbleContentNode: ChatMessageBubbleContentNode {
930926
if modelTitleLayoutAndApply != nil {
931927
buttonOriginY = clippingTextFrame.maxY + 80.0
932928
}
929+
strongSelf.buttonTitleNode.frame = CGRect(origin: CGPoint(x: 19.0, y: 8.0), size: buttonTitleLayout.size)
930+
933931
if let buttonIcon {
934932
buttonSize.width += 15.0
935-
if strongSelf.buttonIconNode.image == nil {
936-
strongSelf.buttonIconNode.image = generateTintedImage(image: UIImage(bundleImageName: buttonIcon), color: .white)
933+
934+
let buttonIconNode: DefaultAnimatedStickerNodeImpl
935+
if let current = strongSelf.buttonIconNode {
936+
buttonIconNode = current
937+
} else {
938+
buttonIconNode = DefaultAnimatedStickerNodeImpl()
939+
buttonIconNode.setup(source: AnimatedStickerNodeLocalFileSource(name: buttonIcon), width: 60, height: 60, playbackMode: .loop, mode: .direct(cachePathPrefix: nil))
940+
strongSelf.buttonNode.addSubnode(buttonIconNode)
941+
strongSelf.buttonIconNode = buttonIconNode
942+
buttonIconNode.playLoop()
937943
}
944+
let iconSize = CGSize(width: 20.0, height: 20.0)
945+
buttonIconNode.frame = CGRect(origin: CGPoint(x: buttonSize.width - iconSize.width - 13.0, y: 7.0), size: iconSize)
946+
buttonIconNode.updateLayout(size: iconSize)
947+
buttonIconNode.visibility = strongSelf.visibilityStatus == true
948+
buttonIconNode.dynamicColor = primaryTextColor
938949
}
939-
strongSelf.buttonTitleNode.frame = CGRect(origin: CGPoint(x: 19.0, y: 8.0), size: buttonTitleLayout.size)
940-
strongSelf.buttonIconNode.frame = CGRect(origin: CGPoint(x: buttonSize.width - 30.0, y: 9.0), size: CGSize(width: 14.0, height: 14.0))
941-
950+
942951
animation.animator.updateFrame(layer: strongSelf.buttonNode.layer, frame: CGRect(origin: CGPoint(x: mediaBackgroundFrame.minX + floorToScreenPixels((mediaBackgroundFrame.width - buttonSize.width) / 2.0), y: buttonOriginY), size: buttonSize), completion: nil)
943952
strongSelf.buttonStarsNode.frame = CGRect(origin: .zero, size: buttonSize)
944953

@@ -1236,6 +1245,7 @@ public class ChatMessageGiftBubbleContentNode: ChatMessageBubbleContentNode {
12361245
self.isPlaying = isPlaying
12371246
self.animationNode.visibility = isPlaying
12381247
}
1248+
self.buttonIconNode?.visibility = isPlaying
12391249

12401250
if isPlaying && self.setupTimestamp == nil {
12411251
self.setupTimestamp = CACurrentMediaTime()

0 commit comments

Comments
 (0)