From fd9b25b527ec171f2b7641da21bce74095960fa5 Mon Sep 17 00:00:00 2001 From: Ilya Laktyushin Date: Sat, 19 Jul 2025 15:53:00 +0100 Subject: [PATCH] Various fixes --- .../Sources/PeerInfoGiftsPaneNode.swift | 24 +++-- .../Sources/StarsTransactionsScreen.swift | 99 +++++++++---------- 2 files changed, 65 insertions(+), 58 deletions(-) diff --git a/submodules/TelegramUI/Components/PeerInfo/PeerInfoVisualMediaPaneNode/Sources/PeerInfoGiftsPaneNode.swift b/submodules/TelegramUI/Components/PeerInfo/PeerInfoVisualMediaPaneNode/Sources/PeerInfoGiftsPaneNode.swift index 8919270716..5e91ca0b04 100644 --- a/submodules/TelegramUI/Components/PeerInfo/PeerInfoVisualMediaPaneNode/Sources/PeerInfoGiftsPaneNode.swift +++ b/submodules/TelegramUI/Components/PeerInfo/PeerInfoVisualMediaPaneNode/Sources/PeerInfoGiftsPaneNode.swift @@ -359,12 +359,12 @@ public final class PeerInfoGiftsPaneNode: ASDisplayNode, PeerInfoPaneNode, UIScr switch collection { case let .collection(id): profileGifts = self.profileGiftsCollections.giftsContextForCollection(id: id) - if case .ready = profileGifts.currentState?.dataState { - profileGifts.reload() - } default: profileGifts = self.profileGifts } + if case .ready = profileGifts.currentState?.dataState { + profileGifts.reload() + } self.giftsListView = GiftsListView(context: self.context, peerId: self.peerId, profileGifts: profileGifts, giftsCollections: self.profileGiftsCollections, canSelect: false) self.giftsListView.addToCollection = { [weak self] in @@ -862,6 +862,14 @@ public final class PeerInfoGiftsPaneNode: ASDisplayNode, PeerInfoPaneNode, UIScr canReorder = true } + let profileGifts: ProfileGiftsContext + switch self.currentCollection { + case let .collection(id): + profileGifts = self.profileGiftsCollections.giftsContextForCollection(id: id) + default: + profileGifts = self.profileGifts + } + var items: [ContextMenuItem] = [] if canManage { items.append(.action(ContextMenuActionItem(text: "Add to Collection", textLayout: .twoLinesMax, icon: { theme in generateTintedImage(image: UIImage(bundleImageName: "Peer Info/Gifts/AddToCollection"), color: theme.contextMenu.primaryColor) }, action: { [weak self] c, f in @@ -943,7 +951,7 @@ public final class PeerInfoGiftsPaneNode: ASDisplayNode, PeerInfoPaneNode, UIScr return } - self.profileGifts.updateStarGiftPinnedToTop(reference: reference, pinnedToTop: pinnedToTop) + profileGifts.updateStarGiftPinnedToTop(reference: reference, pinnedToTop: pinnedToTop) let toastTitle: String? let toastText: String @@ -1114,7 +1122,7 @@ public final class PeerInfoGiftsPaneNode: ASDisplayNode, PeerInfoPaneNode, UIScr } if let reference = gift.reference { let added = !gift.savedToProfile - self.profileGifts.updateStarGiftAddedToProfile(reference: reference, added: added) + profileGifts.updateStarGiftAddedToProfile(reference: reference, added: added) var animationFile: TelegramMediaFile? switch gift.gift { @@ -1169,8 +1177,8 @@ public final class PeerInfoGiftsPaneNode: ASDisplayNode, PeerInfoPaneNode, UIScr showSelf = true } let transferStars = gift.transferStars ?? 0 - let controller = context.sharedContext.makePremiumGiftController(context: context, source: .starGiftTransfer(birthdays, reference, uniqueGift, transferStars, gift.canExportDate, showSelf), completion: { [weak self] peerIds in - guard let self, let peerId = peerIds.first else { + let controller = context.sharedContext.makePremiumGiftController(context: context, source: .starGiftTransfer(birthdays, reference, uniqueGift, transferStars, gift.canExportDate, showSelf), completion: { peerIds in + guard let peerId = peerIds.first else { return .complete() } Queue.mainQueue().after(1.5, { @@ -1178,7 +1186,7 @@ public final class PeerInfoGiftsPaneNode: ASDisplayNode, PeerInfoPaneNode, UIScr context.starsContext?.load(force: true) } }) - return self.profileGifts.transferStarGift(prepaid: transferStars == 0, reference: reference, peerId: peerId) + return profileGifts.transferStarGift(prepaid: transferStars == 0, reference: reference, peerId: peerId) }) self.parentController?.push(controller) }) diff --git a/submodules/TelegramUI/Components/Stars/StarsTransactionsScreen/Sources/StarsTransactionsScreen.swift b/submodules/TelegramUI/Components/Stars/StarsTransactionsScreen/Sources/StarsTransactionsScreen.swift index 3b587d8402..46ccd0e59d 100644 --- a/submodules/TelegramUI/Components/Stars/StarsTransactionsScreen/Sources/StarsTransactionsScreen.swift +++ b/submodules/TelegramUI/Components/Stars/StarsTransactionsScreen/Sources/StarsTransactionsScreen.swift @@ -540,8 +540,7 @@ final class StarsTransactionsScreenComponent: Component { let descriptionString: String if component.starsContext.ton { titleString = environment.strings.Stars_Ton_Title - descriptionString = "Use TON to submit post suggestions in channels or buy gifts." - //descriptionString = environment.strings.Stars_Ton_Description + descriptionString = environment.strings.Stars_Ton_Description } else { titleString = environment.strings.Stars_Intro_Title descriptionString = environment.strings.Stars_Intro_Description @@ -672,52 +671,52 @@ final class StarsTransactionsScreenComponent: Component { let withdrawAvailable = (self.revenueState?.balances.overallRevenue.amount.value ?? 0) > 0 - if component.starsContext.ton { - //TODO:localize - let proceedsSize = self.proceedsView.update( - transition: .immediate, - component: AnyComponent(ListSectionComponent( - theme: environment.theme, - header: AnyComponent(MultilineTextComponent( - text: .plain(NSAttributedString( - string: "Proceeds Overview".uppercased(), - font: Font.regular(presentationData.listsFontSize.itemListBaseHeaderFontSize), - textColor: environment.theme.list.freeTextColor - )), - maximumNumberOfLines: 0 - )), - footer: nil, - items: [ - AnyComponentWithIdentity(id: 0, component: AnyComponent(StarsOverviewItemComponent( - theme: environment.theme, - dateTimeFormat: environment.dateTimeFormat, - title: "Balance Available to Withdraw", - value: self.revenueState?.balances.availableBalance ?? CurrencyAmount(amount: .zero, currency: .stars), - rate: self.revenueState?.usdRate ?? 0.0 - ))), - AnyComponentWithIdentity(id: 1, component: AnyComponent(StarsOverviewItemComponent( - theme: environment.theme, - dateTimeFormat: environment.dateTimeFormat, - title: "Total Lifetime Proceeds", - value: self.revenueState?.balances.overallRevenue ?? CurrencyAmount(amount: .zero, currency: .stars), - rate: self.revenueState?.usdRate ?? 0.0 - ))) - ], - displaySeparators: false - )), - environment: {}, - containerSize: CGSize(width: availableSize.width - sideInsets, height: availableSize.height) - ) - let proceedsFrame = CGRect(origin: CGPoint(x: floorToScreenPixels((availableSize.width - proceedsSize.width) / 2.0), y: contentHeight), size: proceedsSize) - if let proceedsView = self.proceedsView.view { - if proceedsView.superview == nil { - self.scrollView.addSubview(proceedsView) - } - transition.setFrame(view: proceedsView, frame: proceedsFrame) - } - contentHeight += proceedsSize.height - contentHeight += 31.0 - } +// if component.starsContext.ton { +// //TODO:localize +// let proceedsSize = self.proceedsView.update( +// transition: .immediate, +// component: AnyComponent(ListSectionComponent( +// theme: environment.theme, +// header: AnyComponent(MultilineTextComponent( +// text: .plain(NSAttributedString( +// string: "Proceeds Overview".uppercased(), +// font: Font.regular(presentationData.listsFontSize.itemListBaseHeaderFontSize), +// textColor: environment.theme.list.freeTextColor +// )), +// maximumNumberOfLines: 0 +// )), +// footer: nil, +// items: [ +// AnyComponentWithIdentity(id: 0, component: AnyComponent(StarsOverviewItemComponent( +// theme: environment.theme, +// dateTimeFormat: environment.dateTimeFormat, +// title: "Balance Available to Withdraw", +// value: self.revenueState?.balances.availableBalance ?? CurrencyAmount(amount: .zero, currency: .stars), +// rate: self.revenueState?.usdRate ?? 0.0 +// ))), +// AnyComponentWithIdentity(id: 1, component: AnyComponent(StarsOverviewItemComponent( +// theme: environment.theme, +// dateTimeFormat: environment.dateTimeFormat, +// title: "Total Lifetime Proceeds", +// value: self.revenueState?.balances.overallRevenue ?? CurrencyAmount(amount: .zero, currency: .stars), +// rate: self.revenueState?.usdRate ?? 0.0 +// ))) +// ], +// displaySeparators: false +// )), +// environment: {}, +// containerSize: CGSize(width: availableSize.width - sideInsets, height: availableSize.height) +// ) +// let proceedsFrame = CGRect(origin: CGPoint(x: floorToScreenPixels((availableSize.width - proceedsSize.width) / 2.0), y: contentHeight), size: proceedsSize) +// if let proceedsView = self.proceedsView.view { +// if proceedsView.superview == nil { +// self.scrollView.addSubview(proceedsView) +// } +// transition.setFrame(view: proceedsView, frame: proceedsFrame) +// } +// contentHeight += proceedsSize.height +// contentHeight += 31.0 +// } let termsFont = Font.regular(13.0) let termsTextColor = environment.theme.list.freeTextColor @@ -740,7 +739,7 @@ final class StarsTransactionsScreenComponent: Component { component: AnyComponent(ListSectionComponent( theme: environment.theme, header: nil, - footer: component.starsContext.ton ? AnyComponent(MultilineTextComponent( + footer: component.starsContext.ton && !"".isEmpty ? AnyComponent(MultilineTextComponent( text: .plain(balanceInfoString), maximumNumberOfLines: 0, highlightColor: environment.theme.list.itemAccentColor.withAlphaComponent(0.1), @@ -767,7 +766,7 @@ final class StarsTransactionsScreenComponent: Component { currency: component.starsContext.ton ? .ton : .stars, rate: nil, actionTitle: component.starsContext.ton ? "Withdraw via Fragment" : (withdrawAvailable ? environment.strings.Stars_Intro_BuyShort : environment.strings.Stars_Intro_Buy), - actionAvailable: (!premiumConfiguration.areStarsDisabled && !premiumConfiguration.isPremiumDisabled), + actionAvailable: (!component.starsContext.ton && !premiumConfiguration.areStarsDisabled && !premiumConfiguration.isPremiumDisabled), actionIsEnabled: true, actionIcon: component.starsContext.ton ? nil : PresentationResourcesItemList.itemListRoundTopupIcon(environment.theme), action: { [weak self] in