Various fixes

This commit is contained in:
Ilya Laktyushin 2025-07-19 15:53:00 +01:00
parent eeaf5d4ac9
commit fd9b25b527
2 changed files with 65 additions and 58 deletions

View File

@ -359,12 +359,12 @@ public final class PeerInfoGiftsPaneNode: ASDisplayNode, PeerInfoPaneNode, UIScr
switch collection { switch collection {
case let .collection(id): case let .collection(id):
profileGifts = self.profileGiftsCollections.giftsContextForCollection(id: id) profileGifts = self.profileGiftsCollections.giftsContextForCollection(id: id)
if case .ready = profileGifts.currentState?.dataState {
profileGifts.reload()
}
default: default:
profileGifts = self.profileGifts 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 = GiftsListView(context: self.context, peerId: self.peerId, profileGifts: profileGifts, giftsCollections: self.profileGiftsCollections, canSelect: false)
self.giftsListView.addToCollection = { [weak self] in self.giftsListView.addToCollection = { [weak self] in
@ -862,6 +862,14 @@ public final class PeerInfoGiftsPaneNode: ASDisplayNode, PeerInfoPaneNode, UIScr
canReorder = true 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] = [] var items: [ContextMenuItem] = []
if canManage { 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 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 return
} }
self.profileGifts.updateStarGiftPinnedToTop(reference: reference, pinnedToTop: pinnedToTop) profileGifts.updateStarGiftPinnedToTop(reference: reference, pinnedToTop: pinnedToTop)
let toastTitle: String? let toastTitle: String?
let toastText: String let toastText: String
@ -1114,7 +1122,7 @@ public final class PeerInfoGiftsPaneNode: ASDisplayNode, PeerInfoPaneNode, UIScr
} }
if let reference = gift.reference { if let reference = gift.reference {
let added = !gift.savedToProfile let added = !gift.savedToProfile
self.profileGifts.updateStarGiftAddedToProfile(reference: reference, added: added) profileGifts.updateStarGiftAddedToProfile(reference: reference, added: added)
var animationFile: TelegramMediaFile? var animationFile: TelegramMediaFile?
switch gift.gift { switch gift.gift {
@ -1169,8 +1177,8 @@ public final class PeerInfoGiftsPaneNode: ASDisplayNode, PeerInfoPaneNode, UIScr
showSelf = true showSelf = true
} }
let transferStars = gift.transferStars ?? 0 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 let controller = context.sharedContext.makePremiumGiftController(context: context, source: .starGiftTransfer(birthdays, reference, uniqueGift, transferStars, gift.canExportDate, showSelf), completion: { peerIds in
guard let self, let peerId = peerIds.first else { guard let peerId = peerIds.first else {
return .complete() return .complete()
} }
Queue.mainQueue().after(1.5, { Queue.mainQueue().after(1.5, {
@ -1178,7 +1186,7 @@ public final class PeerInfoGiftsPaneNode: ASDisplayNode, PeerInfoPaneNode, UIScr
context.starsContext?.load(force: true) 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) self.parentController?.push(controller)
}) })

View File

@ -540,8 +540,7 @@ final class StarsTransactionsScreenComponent: Component {
let descriptionString: String let descriptionString: String
if component.starsContext.ton { if component.starsContext.ton {
titleString = environment.strings.Stars_Ton_Title 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 { } else {
titleString = environment.strings.Stars_Intro_Title titleString = environment.strings.Stars_Intro_Title
descriptionString = environment.strings.Stars_Intro_Description descriptionString = environment.strings.Stars_Intro_Description
@ -672,52 +671,52 @@ final class StarsTransactionsScreenComponent: Component {
let withdrawAvailable = (self.revenueState?.balances.overallRevenue.amount.value ?? 0) > 0 let withdrawAvailable = (self.revenueState?.balances.overallRevenue.amount.value ?? 0) > 0
if component.starsContext.ton { // if component.starsContext.ton {
//TODO:localize // //TODO:localize
let proceedsSize = self.proceedsView.update( // let proceedsSize = self.proceedsView.update(
transition: .immediate, // transition: .immediate,
component: AnyComponent(ListSectionComponent( // component: AnyComponent(ListSectionComponent(
theme: environment.theme, // theme: environment.theme,
header: AnyComponent(MultilineTextComponent( // header: AnyComponent(MultilineTextComponent(
text: .plain(NSAttributedString( // text: .plain(NSAttributedString(
string: "Proceeds Overview".uppercased(), // string: "Proceeds Overview".uppercased(),
font: Font.regular(presentationData.listsFontSize.itemListBaseHeaderFontSize), // font: Font.regular(presentationData.listsFontSize.itemListBaseHeaderFontSize),
textColor: environment.theme.list.freeTextColor // textColor: environment.theme.list.freeTextColor
)), // )),
maximumNumberOfLines: 0 // maximumNumberOfLines: 0
)), // )),
footer: nil, // footer: nil,
items: [ // items: [
AnyComponentWithIdentity(id: 0, component: AnyComponent(StarsOverviewItemComponent( // AnyComponentWithIdentity(id: 0, component: AnyComponent(StarsOverviewItemComponent(
theme: environment.theme, // theme: environment.theme,
dateTimeFormat: environment.dateTimeFormat, // dateTimeFormat: environment.dateTimeFormat,
title: "Balance Available to Withdraw", // title: "Balance Available to Withdraw",
value: self.revenueState?.balances.availableBalance ?? CurrencyAmount(amount: .zero, currency: .stars), // value: self.revenueState?.balances.availableBalance ?? CurrencyAmount(amount: .zero, currency: .stars),
rate: self.revenueState?.usdRate ?? 0.0 // rate: self.revenueState?.usdRate ?? 0.0
))), // ))),
AnyComponentWithIdentity(id: 1, component: AnyComponent(StarsOverviewItemComponent( // AnyComponentWithIdentity(id: 1, component: AnyComponent(StarsOverviewItemComponent(
theme: environment.theme, // theme: environment.theme,
dateTimeFormat: environment.dateTimeFormat, // dateTimeFormat: environment.dateTimeFormat,
title: "Total Lifetime Proceeds", // title: "Total Lifetime Proceeds",
value: self.revenueState?.balances.overallRevenue ?? CurrencyAmount(amount: .zero, currency: .stars), // value: self.revenueState?.balances.overallRevenue ?? CurrencyAmount(amount: .zero, currency: .stars),
rate: self.revenueState?.usdRate ?? 0.0 // rate: self.revenueState?.usdRate ?? 0.0
))) // )))
], // ],
displaySeparators: false // displaySeparators: false
)), // )),
environment: {}, // environment: {},
containerSize: CGSize(width: availableSize.width - sideInsets, height: availableSize.height) // 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) // let proceedsFrame = CGRect(origin: CGPoint(x: floorToScreenPixels((availableSize.width - proceedsSize.width) / 2.0), y: contentHeight), size: proceedsSize)
if let proceedsView = self.proceedsView.view { // if let proceedsView = self.proceedsView.view {
if proceedsView.superview == nil { // if proceedsView.superview == nil {
self.scrollView.addSubview(proceedsView) // self.scrollView.addSubview(proceedsView)
} // }
transition.setFrame(view: proceedsView, frame: proceedsFrame) // transition.setFrame(view: proceedsView, frame: proceedsFrame)
} // }
contentHeight += proceedsSize.height // contentHeight += proceedsSize.height
contentHeight += 31.0 // contentHeight += 31.0
} // }
let termsFont = Font.regular(13.0) let termsFont = Font.regular(13.0)
let termsTextColor = environment.theme.list.freeTextColor let termsTextColor = environment.theme.list.freeTextColor
@ -740,7 +739,7 @@ final class StarsTransactionsScreenComponent: Component {
component: AnyComponent(ListSectionComponent( component: AnyComponent(ListSectionComponent(
theme: environment.theme, theme: environment.theme,
header: nil, header: nil,
footer: component.starsContext.ton ? AnyComponent(MultilineTextComponent( footer: component.starsContext.ton && !"".isEmpty ? AnyComponent(MultilineTextComponent(
text: .plain(balanceInfoString), text: .plain(balanceInfoString),
maximumNumberOfLines: 0, maximumNumberOfLines: 0,
highlightColor: environment.theme.list.itemAccentColor.withAlphaComponent(0.1), highlightColor: environment.theme.list.itemAccentColor.withAlphaComponent(0.1),
@ -767,7 +766,7 @@ final class StarsTransactionsScreenComponent: Component {
currency: component.starsContext.ton ? .ton : .stars, currency: component.starsContext.ton ? .ton : .stars,
rate: nil, rate: nil,
actionTitle: component.starsContext.ton ? "Withdraw via Fragment" : (withdrawAvailable ? environment.strings.Stars_Intro_BuyShort : environment.strings.Stars_Intro_Buy), 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, actionIsEnabled: true,
actionIcon: component.starsContext.ton ? nil : PresentationResourcesItemList.itemListRoundTopupIcon(environment.theme), actionIcon: component.starsContext.ton ? nil : PresentationResourcesItemList.itemListRoundTopupIcon(environment.theme),
action: { [weak self] in action: { [weak self] in