From 004ebd58ad619a95e12b580be2271687c440eb20 Mon Sep 17 00:00:00 2001 From: Ilya Laktyushin Date: Tue, 28 Jan 2025 01:51:45 +0400 Subject: [PATCH] Various improvements --- .../Sources/GiftViewScreen.swift | 88 ++++++++++--------- .../Sources/SharedAccountContext.swift | 36 +++++--- 2 files changed, 70 insertions(+), 54 deletions(-) diff --git a/submodules/TelegramUI/Components/Gifts/GiftViewScreen/Sources/GiftViewScreen.swift b/submodules/TelegramUI/Components/Gifts/GiftViewScreen/Sources/GiftViewScreen.swift index 08c2b6e8e5..746955b19a 100644 --- a/submodules/TelegramUI/Components/Gifts/GiftViewScreen/Sources/GiftViewScreen.swift +++ b/submodules/TelegramUI/Components/Gifts/GiftViewScreen/Sources/GiftViewScreen.swift @@ -1743,54 +1743,56 @@ private final class GiftViewSheetContent: CombinedComponent { canConvert = false } } - let valueComponent: AnyComponent if let convertStars, incoming && !converted && canConvert { - valueComponent = AnyComponent( - HStack([ - AnyComponentWithIdentity( - id: AnyHashable(0), - component: AnyComponent(MultilineTextWithEntitiesComponent( - context: component.context, - animationCache: component.context.animationCache, - animationRenderer: component.context.animationRenderer, - placeholderColor: theme.list.mediaPlaceholderColor, - text: .plain(valueAttributedString), - maximumNumberOfLines: 0 - )) - ), - AnyComponentWithIdentity( - id: AnyHashable(1), - component: AnyComponent(Button( - content: AnyComponent(ButtonContentComponent( + tableItems.append(.init( + id: "value_convert", + title: strings.Gift_View_Value, + component: AnyComponent( + HStack([ + AnyComponentWithIdentity( + id: AnyHashable(0), + component: AnyComponent(MultilineTextWithEntitiesComponent( context: component.context, - text: strings.Gift_View_Sale(strings.Gift_View_Sale_Stars(Int32(convertStars))).string, - color: theme.list.itemAccentColor - )), - action: { - component.convertToStars() - } - )) - ) - ], spacing: 4.0) - ) + animationCache: component.context.animationCache, + animationRenderer: component.context.animationRenderer, + placeholderColor: theme.list.mediaPlaceholderColor, + text: .plain(valueAttributedString), + maximumNumberOfLines: 0 + )) + ), + AnyComponentWithIdentity( + id: AnyHashable(1), + component: AnyComponent(Button( + content: AnyComponent(ButtonContentComponent( + context: component.context, + text: strings.Gift_View_Sale(strings.Gift_View_Sale_Stars(Int32(convertStars))).string, + color: theme.list.itemAccentColor + )), + action: { + component.convertToStars() + } + )) + ) + ], spacing: 4.0) + ), + insets: UIEdgeInsets(top: 0.0, left: 10.0, bottom: 0.0, right: 12.0) + )) } else { - valueComponent = AnyComponent(MultilineTextWithEntitiesComponent( - context: component.context, - animationCache: component.context.animationCache, - animationRenderer: component.context.animationRenderer, - placeholderColor: theme.list.mediaPlaceholderColor, - text: .plain(valueAttributedString), - maximumNumberOfLines: 0 + tableItems.append(.init( + id: "value", + title: strings.Gift_View_Value, + component: AnyComponent(MultilineTextWithEntitiesComponent( + context: component.context, + animationCache: component.context.animationCache, + animationRenderer: component.context.animationRenderer, + placeholderColor: theme.list.mediaPlaceholderColor, + text: .plain(valueAttributedString), + maximumNumberOfLines: 0 + )), + insets: UIEdgeInsets(top: 0.0, left: 10.0, bottom: 0.0, right: 12.0) )) } - - tableItems.append(.init( - id: "value", - title: strings.Gift_View_Value, - component: valueComponent, - insets: UIEdgeInsets(top: 0.0, left: 10.0, bottom: 0.0, right: 12.0) - )) - + if let limitTotal { var remains: Int32 = 0 if let gift = state.starGiftsMap[giftId], let availability = gift.availability { diff --git a/submodules/TelegramUI/Sources/SharedAccountContext.swift b/submodules/TelegramUI/Sources/SharedAccountContext.swift index 0bced54179..5cc2644511 100644 --- a/submodules/TelegramUI/Sources/SharedAccountContext.swift +++ b/submodules/TelegramUI/Sources/SharedAccountContext.swift @@ -2659,21 +2659,35 @@ public final class SharedAccountContextImpl: SharedAccountContext { controllers = controllers.filter { !($0 is ContactSelectionController) } if !isChannelGift { - var foundController = false - for controller in controllers.reversed() { - if let chatController = controller as? ChatController, case .peer(id: peer.id) = chatController.chatLocation { + if peer.id.namespace == Namespaces.Peer.CloudChannel { + if let controller = context.sharedContext.makePeerInfoController( + context: context, + updatedPresentationData: nil, + peer: peer._asPeer(), + mode: .gifts, + avatarInitiallyExpanded: false, + fromChat: false, + requestsContext: nil + ) { + controllers.append(controller) + } + } else { + var foundController = false + for controller in controllers.reversed() { + if let chatController = controller as? ChatController, case .peer(id: peer.id) = chatController.chatLocation { + chatController.hintPlayNextOutgoingGift() + foundController = true + break + } + } + if !foundController { + let chatController = context.sharedContext.makeChatController(context: context, chatLocation: .peer(id: peer.id), subject: nil, botStart: nil, mode: .standard(.default), params: nil) chatController.hintPlayNextOutgoingGift() - foundController = true - break + controllers.append(chatController) } } - if !foundController { - let chatController = context.sharedContext.makeChatController(context: context, chatLocation: .peer(id: peer.id), subject: nil, botStart: nil, mode: .standard(.default), params: nil) - chatController.hintPlayNextOutgoingGift() - controllers.append(chatController) - } - navigationController.setViewControllers(controllers, animated: true) } + navigationController.setViewControllers(controllers, animated: true) Queue.mainQueue().after(0.3) { let tooltipController = UndoOverlayController(