Various fixes

This commit is contained in:
Ilya Laktyushin 2024-12-28 19:56:24 +04:00
parent 5f44db6b7b
commit 27e6f83aa9
7 changed files with 59 additions and 13 deletions

View File

@ -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";

View File

@ -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 {
}
}
}

View File

@ -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

View File

@ -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 = ""

View File

@ -23,6 +23,7 @@ swift_library(
"//submodules/AccountContext",
"//submodules/Components/MultilineTextComponent",
"//submodules/Components/BundleIconComponent",
"//submodules/TelegramUI/Components/Gifts/GiftItemComponent",
],
visibility = [
"//visibility:public",

View File

@ -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<Empty>()
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 {

View File

@ -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))
}