This commit is contained in:
Isaac 2025-06-24 13:19:36 +02:00
parent adae44e26f
commit d27741e5d9
6 changed files with 17 additions and 15 deletions

View File

@ -342,7 +342,7 @@ final class StarsTransactionItemNode: ListViewItemNode, ItemListItemNode {
contentInsets: UIEdgeInsets(top: 9.0, left: 0.0, bottom: 8.0, right: 0.0),
leftIcon: .custom(AnyComponentWithIdentity(id: "avatar", component: AnyComponent(StarsAvatarComponent(context: item.context, theme: item.presentationData.theme, peer: item.transaction.peer, photo: nil, media: [], uniqueGift: nil, backgroundColor: item.presentationData.theme.list.itemBlocksBackgroundColor))), false),
icon: nil,
accessory: .custom(ListActionItemComponent.CustomAccessory(component: AnyComponentWithIdentity(id: "label", component: AnyComponent(StarsLabelComponent(theme: item.presentationData.theme, currency: item.transaction.currency, textColor: itemLabelColor, text: itemLabel))), insets: UIEdgeInsets(top: 0, left: 0, bottom: 0, right: 16.0))),
accessory: .custom(ListActionItemComponent.CustomAccessory(component: AnyComponentWithIdentity(id: "label", component: AnyComponent(StarsLabelComponent(text: itemLabel))), insets: UIEdgeInsets(top: 0, left: 0, bottom: 0, right: 16.0))),
action: { [weak self] _ in
guard let self, let item = self.item else {
return

View File

@ -1074,7 +1074,7 @@ public final class StarsContext {
return peerId!
}
let ton: Bool
public let ton: Bool
public var currentState: StarsContext.State? {
var state: StarsContext.State?

View File

@ -17,7 +17,7 @@ final class StarsBalanceComponent: Component {
let strings: PresentationStrings
let dateTimeFormat: PresentationDateTimeFormat
let count: StarsAmount
let isTon: Bool
let currency: CurrencyAmount.Currency
let rate: Double?
let actionTitle: String
let actionAvailable: Bool
@ -36,7 +36,7 @@ final class StarsBalanceComponent: Component {
strings: PresentationStrings,
dateTimeFormat: PresentationDateTimeFormat,
count: StarsAmount,
isTon: Bool = false,
currency: CurrencyAmount.Currency,
rate: Double?,
actionTitle: String,
actionAvailable: Bool,
@ -54,7 +54,7 @@ final class StarsBalanceComponent: Component {
self.strings = strings
self.dateTimeFormat = dateTimeFormat
self.count = count
self.isTon = isTon
self.currency = currency
self.rate = rate
self.actionTitle = actionTitle
self.actionAvailable = actionAvailable
@ -100,7 +100,7 @@ final class StarsBalanceComponent: Component {
if lhs.count != rhs.count {
return false
}
if lhs.isTon != rhs.isTon {
if lhs.currency != rhs.currency {
return false
}
if lhs.rate != rhs.rate {
@ -135,9 +135,10 @@ final class StarsBalanceComponent: Component {
func update(component: StarsBalanceComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment<Empty>, transition: ComponentTransition) -> CGSize {
if self.component == nil {
if component.isTon {
switch component.currency {
case .ton:
self.icon.image = generateTintedImage(image: UIImage(bundleImageName: "Ads/TonBig"), color: component.theme.list.itemAccentColor)
} else {
case .stars:
self.icon.image = UIImage(bundleImageName: "Premium/Stars/BalanceStar")
}
}
@ -177,9 +178,10 @@ final class StarsBalanceComponent: Component {
var contentHeight: CGFloat = sideInset
let formattedLabel: String
if component.isTon {
switch component.currency {
case .ton:
formattedLabel = formatTonAmountText(component.count.value, dateTimeFormat: component.dateTimeFormat)
} else {
case .stars:
formattedLabel = formatStarsAmountText(component.count, dateTimeFormat: component.dateTimeFormat)
}
let labelFont: UIFont

View File

@ -579,8 +579,8 @@ final class StarsStatisticsScreenComponent: Component {
theme: environment.theme,
strings: strings,
dateTimeFormat: environment.dateTimeFormat,
currency: .stars,
count: self.starsState?.balances.availableBalance ?? StarsAmount.zero,
currency: .stars,
rate: self.starsState?.usdRate ?? 0,
actionTitle: strings.Stars_Intro_BuyShort,
actionAvailable: true,
@ -623,8 +623,8 @@ final class StarsStatisticsScreenComponent: Component {
theme: environment.theme,
strings: strings,
dateTimeFormat: environment.dateTimeFormat,
currency: .stars,
count: self.starsState?.balances.availableBalance ?? StarsAmount.zero,
currency: .stars,
rate: self.starsState?.usdRate ?? 0,
actionTitle: strings.Stars_BotRevenue_Withdraw_WithdrawShort,
actionAvailable: true,

View File

@ -671,8 +671,8 @@ final class StarsTransactionsScreenComponent: Component {
theme: environment.theme,
strings: environment.strings,
dateTimeFormat: environment.dateTimeFormat,
currency: component.starsContext.ton ? .ton : .stars,
count: self.starsState?.balance ?? StarsAmount.zero,
currency: component.starsContext.ton ? .ton : .stars,
rate: nil,
actionTitle: withdrawAvailable ? environment.strings.Stars_Intro_BuyShort : environment.strings.Stars_Intro_Buy,
actionAvailable: !premiumConfiguration.areStarsDisabled && !premiumConfiguration.isPremiumDisabled,
@ -863,7 +863,7 @@ final class StarsTransactionsScreenComponent: Component {
let itemLabel = NSAttributedString(string: "\(subscription.pricing.amount)", font: Font.medium(fontBaseDisplaySize), textColor: itemLabelColor)
let itemSublabel = NSAttributedString(string: environment.strings.Stars_Intro_Subscriptions_PerMonth, font: Font.regular(floor(fontBaseDisplaySize * 13.0 / 17.0)), textColor: environment.theme.list.itemSecondaryTextColor)
labelComponent = AnyComponentWithIdentity(id: "label", component: AnyComponent(StarsLabelComponent(theme: environment.theme, currency: component.starsContext.ton ? .ton : .stars, textColor: itemLabelColor, text: itemLabel, subtext: itemSublabel)))
labelComponent = AnyComponentWithIdentity(id: "label", component: AnyComponent(StarsLabelComponent(text: itemLabel, subtext: itemSublabel)))
}
subscriptionsItems.append(AnyComponentWithIdentity(

View File

@ -585,7 +585,7 @@ final class TonTransactionsScreenComponent: Component {
strings: environment.strings,
dateTimeFormat: environment.dateTimeFormat,
count: self.starsState?.balance ?? StarsAmount.zero,
isTon: true,
currency: .ton,
rate: 2.99 * 1e-9,
actionTitle: "Withdraw via Fragment",
actionAvailable: withdrawAvailable,