This commit is contained in:
Isaac 2026-01-31 00:37:38 +08:00
commit ff7f75c946
7 changed files with 63 additions and 23 deletions

View file

@ -15699,6 +15699,7 @@ Error: %8$@";
"Gift.Craft.Info.Understood" = "Understood";
"Gift.Craft.Unavailable.Title" = "Try Later";
"Gift.Craft.Unavailable.Text" = "You will be able to craft this gift on %@.";
"Gift.Craft.Error.NotAvailable" = "One of the gifts is not available for crafting.";
"Gift.Craft.Select.Title" = "Select Gifts";
"Gift.Craft.Select.YourGifts" = "Your Gifts";

View file

@ -3409,6 +3409,7 @@ public enum CraftStarGiftError {
case generic
case tooEarly(Int32)
case craftFailed
case unavailable
}
func _internal_craftStarGift(account: Account, references: [StarGiftReference]) -> Signal<ProfileGiftsContext.State.StarGift, CraftStarGiftError> {
@ -3427,6 +3428,8 @@ func _internal_craftStarGift(account: Account, references: [StarGiftReference])
if let value = Int32(timeout) {
return .tooEarly(value)
}
} else if error.errorDescription == "STARGIFT_CRAFT_UNAVAILABLE" {
return .unavailable
}
return .generic
}

View file

@ -725,16 +725,18 @@ public class ChatMessageGiftBubbleContentNode: ChatMessageBubbleContentNode {
} else {
ribbonTitle = isStoryEntity ? "" : item.presentationData.strings.Notification_StarGift_Gift
}
if uniqueGift.flags.contains(.isBurned) {
ribbonTitle = item.presentationData.strings.Notification_StarGift_Burned
}
buttonTitle = isStoryEntity ? "" : item.presentationData.strings.Notification_StarGift_View
modelTitle = item.presentationData.strings.Notification_StarGift_Model
backdropTitle = item.presentationData.strings.Notification_StarGift_Backdrop
symbolTitle = item.presentationData.strings.Notification_StarGift_Symbol
if uniqueGift.flags.contains(.isBurned) {
ribbonTitle = item.presentationData.strings.Notification_StarGift_Burned
customRibbonColors = [UIColor(rgb: 0xd9433a), UIColor(rgb: 0xff645b)]
buttonTitle = ""
}
for attribute in uniqueGift.attributes {
switch attribute {
case let .model(name, file, _, _):

View file

@ -1763,8 +1763,15 @@ private final class SheetContainerComponent: CombinedComponent {
}
default:
if let navigationController = controller()?.navigationController {
var text: String = strings.Login_UnknownError
switch error {
case .unavailable:
text = strings.Gift_Craft_Error_NotAvailable
default:
break
}
dismiss(true)
let alertController = textAlertController(context: component.context, title: nil, text: strings.Login_UnknownError, actions: [TextAlertAction(type: .defaultAction, title: strings.Common_OK, action: {})])
let alertController = textAlertController(context: component.context, title: nil, text: text, actions: [TextAlertAction(type: .defaultAction, title: strings.Common_OK, action: {})])
(navigationController.topViewController as? ViewController)?.present(alertController, in: .window(.root))
}
}

View file

@ -28,6 +28,7 @@ swift_library(
"//submodules/Components/BundleIconComponent",
"//submodules/TelegramUI/Components/ButtonComponent",
"//submodules/Markdown",
"//submodules/TelegramUI/Components/LottieComponent",
],
visibility = [
"//visibility:public",

View file

@ -2,11 +2,12 @@ import Foundation
import UIKit
import Display
import ComponentFlow
import TelegramCore
import ViewControllerComponent
import AccountContext
import SheetComponent
import ButtonComponent
import TelegramCore
import LottieComponent
private final class ArchiveInfoSheetContentComponent: Component {
typealias EnvironmentType = ViewControllerComponentContainer.Environment
@ -36,6 +37,9 @@ private final class ArchiveInfoSheetContentComponent: Component {
private let content = ComponentView<Empty>()
private let button = ComponentView<Empty>()
fileprivate let playButtonAnimation = ActionSlot<Void>()
private var didPlayAnimation = false
private var component: ArchiveInfoSheetContentComponent?
override init(frame: CGRect) {
@ -76,16 +80,34 @@ private final class ArchiveInfoSheetContentComponent: Component {
contentHeight += contentSize.height
contentHeight += 30.0
var buttonTitle: [AnyComponentWithIdentity<Empty>] = []
buttonTitle.append(AnyComponentWithIdentity(id: 0, component: AnyComponent(LottieComponent(
content: LottieComponent.AppBundleContent(name: "anim_ok"),
color: environment.theme.list.itemCheckColors.foregroundColor,
startingPosition: .begin,
size: CGSize(width: 28.0, height: 28.0),
playOnce: playButtonAnimation
))))
buttonTitle.append(AnyComponentWithIdentity(id: 1, component: AnyComponent(ButtonTextContentComponent(
text: environment.strings.ArchiveInfo_CloseAction,
badge: 0,
textColor: environment.theme.list.itemCheckColors.foregroundColor,
badgeBackground: environment.theme.list.itemCheckColors.foregroundColor,
badgeForeground: environment.theme.list.itemCheckColors.fillColor
))))
let buttonInsets = ContainerViewLayout.concentricInsets(bottomInset: environment.safeInsets.bottom, innerDiameter: 52.0, sideInset: 30.0)
let buttonSize = self.button.update(
transition: transition,
component: AnyComponent(ButtonComponent(
background: ButtonComponent.Background(
style: .glass,
color: environment.theme.list.itemCheckColors.fillColor,
foreground: environment.theme.list.itemCheckColors.foregroundColor,
pressedColor: environment.theme.list.itemCheckColors.fillColor.withMultipliedAlpha(0.8)
),
content: AnyComponentWithIdentity(id: AnyHashable(0 as Int), component: AnyComponent(
Text(text: environment.strings.ArchiveInfo_CloseAction, font: Font.semibold(17.0), color: environment.theme.list.itemCheckColors.foregroundColor)
content: AnyComponentWithIdentity(id: "ok", component: AnyComponent(
HStack(buttonTitle, spacing: 2.0)
)),
isEnabled: true,
displaysProgress: false,
@ -97,20 +119,19 @@ private final class ArchiveInfoSheetContentComponent: Component {
}
)),
environment: {},
containerSize: CGSize(width: availableSize.width - sideInset * 2.0, height: 50.0)
containerSize: CGSize(width: availableSize.width - buttonInsets.left - buttonInsets.right, height: 52.0)
)
let buttonFrame = CGRect(origin: CGPoint(x: sideInset, y: contentHeight), size: buttonSize)
let buttonFrame = CGRect(origin: CGPoint(x: buttonInsets.left, y: contentHeight), size: buttonSize)
if let buttonView = self.button.view {
if buttonView.superview == nil {
self.addSubview(buttonView)
self.playButtonAnimation.invoke(Void())
}
transition.setFrame(view: buttonView, frame: buttonFrame)
}
contentHeight += buttonSize.height
let bottomPanelPadding: CGFloat = 12.0
let bottomInset: CGFloat = environment.safeInsets.bottom > 0.0 ? environment.safeInsets.bottom + 5.0 : bottomPanelPadding
contentHeight += bottomInset
contentHeight += buttonInsets.bottom
return CGSize(width: availableSize.width, height: contentHeight)
}
@ -224,6 +245,7 @@ private final class ArchiveInfoScreenComponent: Component {
})
}
)),
style: .glass,
backgroundColor: .color(environment.theme.actionSheet.opaqueItemBackgroundColor),
animateOut: self.sheetAnimateOut
)),

View file

@ -1204,15 +1204,19 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
self.push(controller)
return true
case .starGift, .starGiftUnique:
let controller = self.context.sharedContext.makeGiftViewScreen(context: self.context, message: EngineMessage(message), shareStory: { [weak self] uniqueGift in
Queue.mainQueue().after(0.15) {
if let self {
let controller = self.context.sharedContext.makeStorySharingScreen(context: self.context, subject: .gift(uniqueGift), parentController: self)
self.push(controller)
if case let .starGiftUnique(gift, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _) = action.action, case let .unique(uniqueGift) = gift, uniqueGift.flags.contains(.isBurned) {
self.present(textAlertController(context: context, updatedPresentationData: updatedPresentationData, title: nil, text: self.presentationData.strings.Resolve_GiftErrorBurned, actions: [TextAlertAction(type: .defaultAction, title: self.presentationData.strings.Common_OK, action: {})]), in: .window(.root))
} else {
let controller = self.context.sharedContext.makeGiftViewScreen(context: self.context, message: EngineMessage(message), shareStory: { [weak self] uniqueGift in
Queue.mainQueue().after(0.15) {
if let self {
let controller = self.context.sharedContext.makeStorySharingScreen(context: self.context, subject: .gift(uniqueGift), parentController: self)
self.push(controller)
}
}
}
})
self.push(controller)
})
self.push(controller)
}
return true
case .giftStars:
let controller = self.context.sharedContext.makeStarsGiftScreen(context: self.context, message: EngineMessage(message))