Skip to content

Commit 27e6f83

Browse files
committed
Various fixes
1 parent 5f44db6 commit 27e6f83

File tree

7 files changed

+59
-13
lines changed

7 files changed

+59
-13
lines changed

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

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13532,6 +13532,8 @@ Sorry for the inconvenience.";
1353213532
"Gift.Transfer.Confirmation.Transfer" = "Transfer for";
1353313533
"Gift.Transfer.Confirmation.TransferFree" = "Transfer";
1353413534

13535+
"Gift.Transfer.Success" = "You have successfully gifter **%1$@** to **%2$@**.";
13536+
1353513537
"Gift.View.UpgradeForFree" = "Upgrade for Free";
1353613538
"Gift.View.KeepUpgradeOrConvertDescription" = "You can keep this gift, upgrade it, or sell it for %@. [More About Stars >]()";
1353713539

@@ -13576,14 +13578,17 @@ Sorry for the inconvenience.";
1357613578
"Notification.StarGift.Subtitle.Refunded" = "This gift cannot be converted to Stars because the payment related to it was refunded.";
1357713579
"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.";
1357813580

13579-
"Notification.StarGift.Subtitle.Other" = "%1$@ can turn this gift to a unique collectible.";
13581+
"Notification.StarGift.Subtitle.Upgrade" = "Tap \"Unpack\" to turn this gift to a unique collectible.";
13582+
"Notification.StarGift.Subtitle.Upgrade.Other" = "%1$@ can turn this gift to a unique collectible.";
1358013583

1358113584
"Notification.StarGift.Subtitle.Upgraded" = "This gift was upgraded.";
1358213585

1358313586
"Stars.Transaction.GiftFrom" = "Gift From";
1358413587
"Stars.Transaction.GiftUpgrade" = "Gift Upgrade";
1358513588

13586-
"Gift.View.KeepOrUpgradeDescription" = "Tap \"Unpack\" to turn this gift to a unique collectible.";
13589+
"Gift.View.FreeUpgradeDescription" = "Upgrade this gift for free to turn it to a unique collectible.";
13590+
"Gift.View.FreeUpgradeOtherDescription" = "%1$@ can turn this gift to a unique collectible.";
13591+
1358713592
"Gift.View.UpgradedDescription" = "This gift was turned to a unique collectible.";
1358813593
"Gift.View.ViewUpgraded" = "View Upgraded Gift";
1358913594

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

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -478,6 +478,8 @@ public class ChatMessageGiftBubbleContentNode: ChatMessageBubbleContentNode {
478478
} else if incoming {
479479
if converted {
480480
text = item.presentationData.strings.Notification_StarGift_Subtitle_Converted(item.presentationData.strings.Notification_StarGift_Subtitle_Converted_Stars(Int32(convertStars ?? 0))).string
481+
} else if upgradeStars != nil {
482+
text = item.presentationData.strings.Notification_StarGift_Subtitle_Upgrade
481483
} else if savedToProfile {
482484
if let convertStars {
483485
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 {
503505
text = item.presentationData.strings.Notification_StarGift_Bot_Subtitle
504506
}
505507
} else {
506-
if let convertStars, convertStars > 0 {
508+
if upgradeStars != nil {
509+
text = item.presentationData.strings.Notification_StarGift_Subtitle_Upgrade_Other(peerName).string
510+
} else if let convertStars, convertStars > 0 {
507511
let formattedString = item.presentationData.strings.Notification_StarGift_Subtitle_Other(peerName, item.presentationData.strings.Notification_StarGift_Subtitle_Other_Stars(Int32(convertStars)))
508512
text = formattedString.string
509513
if let starsRange = formattedString.ranges.last {
510514
entities.append(MessageTextEntity(range: starsRange.range.lowerBound ..< starsRange.range.upperBound, type: .Bold))
511515
}
512-
} else {
513-
514516
}
515517
}
516518
}

submodules/TelegramUI/Components/Gifts/GiftItemComponent/Sources/GiftItemComponent.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -224,9 +224,9 @@ public final class GiftItemComponent: Component {
224224
iconSize = CGSize(width: 88.0, height: 88.0)
225225
cornerRadius = 10.0
226226
case .thumbnail:
227-
size = CGSize(width: 60.0, height: 60.0)
228-
iconSize = CGSize(width: 42.0, height: 42.0)
229-
cornerRadius = 12.0
227+
size = CGSize(width: availableSize.width, height: availableSize.width)
228+
iconSize = CGSize(width: floor(size.width * 0.7), height: floor(size.width * 0.7))
229+
cornerRadius = floor(availableSize.width * 0.2)
230230
}
231231

232232
self.backgroundLayer.cornerRadius = cornerRadius

submodules/TelegramUI/Components/Gifts/GiftViewScreen/Sources/GiftViewScreen.swift

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -708,7 +708,9 @@ private final class GiftViewSheetContent: CombinedComponent {
708708
} else if upgraded {
709709
descriptionText = strings.Gift_View_UpgradedDescription
710710
} else if incoming {
711-
if let convertStars, !upgraded {
711+
if let _ = upgradeStars {
712+
descriptionText = strings.Gift_View_FreeUpgradeDescription
713+
} else if let convertStars, !upgraded {
712714
if !converted {
713715
if canUpgrade || upgradeStars != nil {
714716
descriptionText = strings.Gift_View_KeepUpgradeOrConvertDescription(strings.Gift_View_KeepOrConvertDescription_Stars(Int32(convertStars))).string
@@ -718,13 +720,13 @@ private final class GiftViewSheetContent: CombinedComponent {
718720
} else {
719721
descriptionText = strings.Gift_View_ConvertedDescription(strings.Gift_View_ConvertedDescription_Stars(Int32(convertStars))).string
720722
}
721-
} else if (canUpgrade || upgradeStars != nil) && !upgraded {
722-
descriptionText = strings.Gift_View_KeepOrUpgradeDescription
723723
} else {
724724
descriptionText = strings.Gift_View_BotDescription
725725
}
726726
} else if let peerId = subject.arguments?.peerId, let peer = state.peerMap[peerId] {
727-
if case .message = subject, let convertStars {
727+
if let _ = upgradeStars {
728+
descriptionText = strings.Gift_View_FreeUpgradeOtherDescription(peer.compactDisplayTitle).string
729+
} else if case .message = subject, let convertStars {
728730
descriptionText = strings.Gift_View_OtherDescription(peer.compactDisplayTitle, strings.Gift_View_OtherDescription_Stars(Int32(convertStars))).string
729731
} else {
730732
descriptionText = ""

submodules/TelegramUI/Components/Stars/StarsAvatarComponent/BUILD

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ swift_library(
2323
"//submodules/AccountContext",
2424
"//submodules/Components/MultilineTextComponent",
2525
"//submodules/Components/BundleIconComponent",
26+
"//submodules/TelegramUI/Components/Gifts/GiftItemComponent",
2627
],
2728
visibility = [
2829
"//visibility:public",

submodules/TelegramUI/Components/Stars/StarsAvatarComponent/Sources/StarsAvatarComponent.swift

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import AvatarNode
1111
import AccountContext
1212
import BundleIconComponent
1313
import MultilineTextComponent
14+
import GiftItemComponent
1415

1516
public final class StarsAvatarComponent: Component {
1617
let context: AccountContext
@@ -77,6 +78,7 @@ public final class StarsAvatarComponent: Component {
7778
private var imageNode: TransformImageNode?
7879
private var imageFrameNode: UIView?
7980
private var secondImageNode: TransformImageNode?
81+
private let giftView = ComponentView<Empty>()
8082

8183
private let fetchDisposable = DisposableSet()
8284

@@ -114,7 +116,29 @@ public final class StarsAvatarComponent: Component {
114116
var dimensions = size
115117

116118
var didSetup = false
117-
if !component.media.isEmpty {
119+
if let gift = component.uniqueGift {
120+
let giftFrame = CGRect(origin: .zero, size: size)
121+
let _ = self.giftView.update(
122+
transition: .immediate,
123+
component: AnyComponent(
124+
GiftItemComponent(
125+
context: component.context,
126+
theme: component.theme,
127+
peer: nil,
128+
subject: .uniqueGift(gift: gift),
129+
mode: .thumbnail
130+
)
131+
),
132+
environment: {},
133+
containerSize: giftFrame.size
134+
)
135+
if let view = self.giftView.view {
136+
if view.superview == nil {
137+
self.addSubview(view)
138+
}
139+
view.frame = giftFrame
140+
}
141+
} else if !component.media.isEmpty {
118142
let imageNode: TransformImageNode
119143
var isFirstTime = false
120144
if let current = self.imageNode {

submodules/TelegramUI/Sources/SharedAccountContext.swift

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2497,6 +2497,18 @@ public final class SharedAccountContextImpl: SharedAccountContext {
24972497
controllers.append(chatController)
24982498
}
24992499
navigationController.setViewControllers(controllers, animated: true)
2500+
2501+
Queue.mainQueue().after(0.3) {
2502+
let tooltipController = UndoOverlayController(
2503+
presentationData: presentationData,
2504+
content: .forward(savedMessages: false, text: presentationData.strings.Gift_Transfer_Success("\(gift) #\(gift.number)", peer.displayTitle(strings: presentationData.strings, displayOrder: presentationData.nameDisplayOrder)).string),
2505+
elevatedLayout: false,
2506+
action: { _ in return true }
2507+
)
2508+
if let lastController = controllers.last as? ViewController {
2509+
lastController.present(tooltipController, in: .window(.root))
2510+
}
2511+
}
25002512
})
25012513
controller.present(alertController, in: .window(.root))
25022514
}

0 commit comments

Comments
 (0)