diff --git a/Telegram/Telegram-iOS/en.lproj/Localizable.strings b/Telegram/Telegram-iOS/en.lproj/Localizable.strings index 8a67272ca8..1ba52c6c05 100644 --- a/Telegram/Telegram-iOS/en.lproj/Localizable.strings +++ b/Telegram/Telegram-iOS/en.lproj/Localizable.strings @@ -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"; diff --git a/submodules/TelegramCore/Sources/TelegramEngine/Payments/StarGifts.swift b/submodules/TelegramCore/Sources/TelegramEngine/Payments/StarGifts.swift index f54b2155ba..b14662e5d6 100644 --- a/submodules/TelegramCore/Sources/TelegramEngine/Payments/StarGifts.swift +++ b/submodules/TelegramCore/Sources/TelegramEngine/Payments/StarGifts.swift @@ -3409,6 +3409,7 @@ public enum CraftStarGiftError { case generic case tooEarly(Int32) case craftFailed + case unavailable } func _internal_craftStarGift(account: Account, references: [StarGiftReference]) -> Signal { @@ -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 } diff --git a/submodules/TelegramUI/Components/Chat/ChatMessageGiftBubbleContentNode/Sources/ChatMessageGiftBubbleContentNode.swift b/submodules/TelegramUI/Components/Chat/ChatMessageGiftBubbleContentNode/Sources/ChatMessageGiftBubbleContentNode.swift index d3e7eb48db..006db046d3 100644 --- a/submodules/TelegramUI/Components/Chat/ChatMessageGiftBubbleContentNode/Sources/ChatMessageGiftBubbleContentNode.swift +++ b/submodules/TelegramUI/Components/Chat/ChatMessageGiftBubbleContentNode/Sources/ChatMessageGiftBubbleContentNode.swift @@ -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, _, _): diff --git a/submodules/TelegramUI/Components/Gifts/GiftCraftScreen/Sources/GiftCraftScreen.swift b/submodules/TelegramUI/Components/Gifts/GiftCraftScreen/Sources/GiftCraftScreen.swift index 82682af122..33ee134fa7 100644 --- a/submodules/TelegramUI/Components/Gifts/GiftCraftScreen/Sources/GiftCraftScreen.swift +++ b/submodules/TelegramUI/Components/Gifts/GiftCraftScreen/Sources/GiftCraftScreen.swift @@ -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)) } } diff --git a/submodules/TelegramUI/Components/Settings/ArchiveInfoScreen/BUILD b/submodules/TelegramUI/Components/Settings/ArchiveInfoScreen/BUILD index aa5718c1c1..4d6f471d37 100644 --- a/submodules/TelegramUI/Components/Settings/ArchiveInfoScreen/BUILD +++ b/submodules/TelegramUI/Components/Settings/ArchiveInfoScreen/BUILD @@ -28,6 +28,7 @@ swift_library( "//submodules/Components/BundleIconComponent", "//submodules/TelegramUI/Components/ButtonComponent", "//submodules/Markdown", + "//submodules/TelegramUI/Components/LottieComponent", ], visibility = [ "//visibility:public", diff --git a/submodules/TelegramUI/Components/Settings/ArchiveInfoScreen/Sources/ArchiveInfoScreen.swift b/submodules/TelegramUI/Components/Settings/ArchiveInfoScreen/Sources/ArchiveInfoScreen.swift index 5bc9281d03..fdefc69947 100644 --- a/submodules/TelegramUI/Components/Settings/ArchiveInfoScreen/Sources/ArchiveInfoScreen.swift +++ b/submodules/TelegramUI/Components/Settings/ArchiveInfoScreen/Sources/ArchiveInfoScreen.swift @@ -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() private let button = ComponentView() + fileprivate let playButtonAnimation = ActionSlot() + 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] = [] + 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 )), diff --git a/submodules/TelegramUI/Sources/ChatController.swift b/submodules/TelegramUI/Sources/ChatController.swift index ed63089326..f344f3ce9c 100644 --- a/submodules/TelegramUI/Sources/ChatController.swift +++ b/submodules/TelegramUI/Sources/ChatController.swift @@ -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))