diff --git a/submodules/StatisticsUI/Sources/StarsTransactionItem.swift b/submodules/StatisticsUI/Sources/StarsTransactionItem.swift index b706c235b1..426c3b0db8 100644 --- a/submodules/StatisticsUI/Sources/StarsTransactionItem.swift +++ b/submodules/StatisticsUI/Sources/StarsTransactionItem.swift @@ -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 diff --git a/submodules/TelegramCore/Sources/TelegramEngine/Payments/Stars.swift b/submodules/TelegramCore/Sources/TelegramEngine/Payments/Stars.swift index afd57ea134..c80f535da0 100644 --- a/submodules/TelegramCore/Sources/TelegramEngine/Payments/Stars.swift +++ b/submodules/TelegramCore/Sources/TelegramEngine/Payments/Stars.swift @@ -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? diff --git a/submodules/TelegramUI/Components/Stars/StarsTransactionsScreen/Sources/StarsBalanceComponent.swift b/submodules/TelegramUI/Components/Stars/StarsTransactionsScreen/Sources/StarsBalanceComponent.swift index 8753da0912..015c4cf330 100644 --- a/submodules/TelegramUI/Components/Stars/StarsTransactionsScreen/Sources/StarsBalanceComponent.swift +++ b/submodules/TelegramUI/Components/Stars/StarsTransactionsScreen/Sources/StarsBalanceComponent.swift @@ -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, 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 diff --git a/submodules/TelegramUI/Components/Stars/StarsTransactionsScreen/Sources/StarsStatisticsScreen.swift b/submodules/TelegramUI/Components/Stars/StarsTransactionsScreen/Sources/StarsStatisticsScreen.swift index e29f5a3506..1c16a1db28 100644 --- a/submodules/TelegramUI/Components/Stars/StarsTransactionsScreen/Sources/StarsStatisticsScreen.swift +++ b/submodules/TelegramUI/Components/Stars/StarsTransactionsScreen/Sources/StarsStatisticsScreen.swift @@ -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, diff --git a/submodules/TelegramUI/Components/Stars/StarsTransactionsScreen/Sources/StarsTransactionsScreen.swift b/submodules/TelegramUI/Components/Stars/StarsTransactionsScreen/Sources/StarsTransactionsScreen.swift index ee4289cdd4..a693c1cc02 100644 --- a/submodules/TelegramUI/Components/Stars/StarsTransactionsScreen/Sources/StarsTransactionsScreen.swift +++ b/submodules/TelegramUI/Components/Stars/StarsTransactionsScreen/Sources/StarsTransactionsScreen.swift @@ -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( diff --git a/submodules/TelegramUI/Components/Stars/StarsTransactionsScreen/Sources/TonTransactionsScreen.swift b/submodules/TelegramUI/Components/Stars/StarsTransactionsScreen/Sources/TonTransactionsScreen.swift index c2da4898b0..d556a49edf 100644 --- a/submodules/TelegramUI/Components/Stars/StarsTransactionsScreen/Sources/TonTransactionsScreen.swift +++ b/submodules/TelegramUI/Components/Stars/StarsTransactionsScreen/Sources/TonTransactionsScreen.swift @@ -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,