mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-08-08 08:31:13 +00:00
Stars
This commit is contained in:
parent
adae44e26f
commit
d27741e5d9
@ -342,7 +342,7 @@ final class StarsTransactionItemNode: ListViewItemNode, ItemListItemNode {
|
|||||||
contentInsets: UIEdgeInsets(top: 9.0, left: 0.0, bottom: 8.0, right: 0.0),
|
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),
|
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,
|
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
|
action: { [weak self] _ in
|
||||||
guard let self, let item = self.item else {
|
guard let self, let item = self.item else {
|
||||||
return
|
return
|
||||||
|
@ -1074,7 +1074,7 @@ public final class StarsContext {
|
|||||||
return peerId!
|
return peerId!
|
||||||
}
|
}
|
||||||
|
|
||||||
let ton: Bool
|
public let ton: Bool
|
||||||
|
|
||||||
public var currentState: StarsContext.State? {
|
public var currentState: StarsContext.State? {
|
||||||
var state: StarsContext.State?
|
var state: StarsContext.State?
|
||||||
|
@ -17,7 +17,7 @@ final class StarsBalanceComponent: Component {
|
|||||||
let strings: PresentationStrings
|
let strings: PresentationStrings
|
||||||
let dateTimeFormat: PresentationDateTimeFormat
|
let dateTimeFormat: PresentationDateTimeFormat
|
||||||
let count: StarsAmount
|
let count: StarsAmount
|
||||||
let isTon: Bool
|
let currency: CurrencyAmount.Currency
|
||||||
let rate: Double?
|
let rate: Double?
|
||||||
let actionTitle: String
|
let actionTitle: String
|
||||||
let actionAvailable: Bool
|
let actionAvailable: Bool
|
||||||
@ -36,7 +36,7 @@ final class StarsBalanceComponent: Component {
|
|||||||
strings: PresentationStrings,
|
strings: PresentationStrings,
|
||||||
dateTimeFormat: PresentationDateTimeFormat,
|
dateTimeFormat: PresentationDateTimeFormat,
|
||||||
count: StarsAmount,
|
count: StarsAmount,
|
||||||
isTon: Bool = false,
|
currency: CurrencyAmount.Currency,
|
||||||
rate: Double?,
|
rate: Double?,
|
||||||
actionTitle: String,
|
actionTitle: String,
|
||||||
actionAvailable: Bool,
|
actionAvailable: Bool,
|
||||||
@ -54,7 +54,7 @@ final class StarsBalanceComponent: Component {
|
|||||||
self.strings = strings
|
self.strings = strings
|
||||||
self.dateTimeFormat = dateTimeFormat
|
self.dateTimeFormat = dateTimeFormat
|
||||||
self.count = count
|
self.count = count
|
||||||
self.isTon = isTon
|
self.currency = currency
|
||||||
self.rate = rate
|
self.rate = rate
|
||||||
self.actionTitle = actionTitle
|
self.actionTitle = actionTitle
|
||||||
self.actionAvailable = actionAvailable
|
self.actionAvailable = actionAvailable
|
||||||
@ -100,7 +100,7 @@ final class StarsBalanceComponent: Component {
|
|||||||
if lhs.count != rhs.count {
|
if lhs.count != rhs.count {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
if lhs.isTon != rhs.isTon {
|
if lhs.currency != rhs.currency {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
if lhs.rate != rhs.rate {
|
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 {
|
func update(component: StarsBalanceComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment<Empty>, transition: ComponentTransition) -> CGSize {
|
||||||
if self.component == nil {
|
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)
|
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")
|
self.icon.image = UIImage(bundleImageName: "Premium/Stars/BalanceStar")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -177,9 +178,10 @@ final class StarsBalanceComponent: Component {
|
|||||||
var contentHeight: CGFloat = sideInset
|
var contentHeight: CGFloat = sideInset
|
||||||
|
|
||||||
let formattedLabel: String
|
let formattedLabel: String
|
||||||
if component.isTon {
|
switch component.currency {
|
||||||
|
case .ton:
|
||||||
formattedLabel = formatTonAmountText(component.count.value, dateTimeFormat: component.dateTimeFormat)
|
formattedLabel = formatTonAmountText(component.count.value, dateTimeFormat: component.dateTimeFormat)
|
||||||
} else {
|
case .stars:
|
||||||
formattedLabel = formatStarsAmountText(component.count, dateTimeFormat: component.dateTimeFormat)
|
formattedLabel = formatStarsAmountText(component.count, dateTimeFormat: component.dateTimeFormat)
|
||||||
}
|
}
|
||||||
let labelFont: UIFont
|
let labelFont: UIFont
|
||||||
|
@ -579,8 +579,8 @@ final class StarsStatisticsScreenComponent: Component {
|
|||||||
theme: environment.theme,
|
theme: environment.theme,
|
||||||
strings: strings,
|
strings: strings,
|
||||||
dateTimeFormat: environment.dateTimeFormat,
|
dateTimeFormat: environment.dateTimeFormat,
|
||||||
currency: .stars,
|
|
||||||
count: self.starsState?.balances.availableBalance ?? StarsAmount.zero,
|
count: self.starsState?.balances.availableBalance ?? StarsAmount.zero,
|
||||||
|
currency: .stars,
|
||||||
rate: self.starsState?.usdRate ?? 0,
|
rate: self.starsState?.usdRate ?? 0,
|
||||||
actionTitle: strings.Stars_Intro_BuyShort,
|
actionTitle: strings.Stars_Intro_BuyShort,
|
||||||
actionAvailable: true,
|
actionAvailable: true,
|
||||||
@ -623,8 +623,8 @@ final class StarsStatisticsScreenComponent: Component {
|
|||||||
theme: environment.theme,
|
theme: environment.theme,
|
||||||
strings: strings,
|
strings: strings,
|
||||||
dateTimeFormat: environment.dateTimeFormat,
|
dateTimeFormat: environment.dateTimeFormat,
|
||||||
currency: .stars,
|
|
||||||
count: self.starsState?.balances.availableBalance ?? StarsAmount.zero,
|
count: self.starsState?.balances.availableBalance ?? StarsAmount.zero,
|
||||||
|
currency: .stars,
|
||||||
rate: self.starsState?.usdRate ?? 0,
|
rate: self.starsState?.usdRate ?? 0,
|
||||||
actionTitle: strings.Stars_BotRevenue_Withdraw_WithdrawShort,
|
actionTitle: strings.Stars_BotRevenue_Withdraw_WithdrawShort,
|
||||||
actionAvailable: true,
|
actionAvailable: true,
|
||||||
|
@ -671,8 +671,8 @@ final class StarsTransactionsScreenComponent: Component {
|
|||||||
theme: environment.theme,
|
theme: environment.theme,
|
||||||
strings: environment.strings,
|
strings: environment.strings,
|
||||||
dateTimeFormat: environment.dateTimeFormat,
|
dateTimeFormat: environment.dateTimeFormat,
|
||||||
currency: component.starsContext.ton ? .ton : .stars,
|
|
||||||
count: self.starsState?.balance ?? StarsAmount.zero,
|
count: self.starsState?.balance ?? StarsAmount.zero,
|
||||||
|
currency: component.starsContext.ton ? .ton : .stars,
|
||||||
rate: nil,
|
rate: nil,
|
||||||
actionTitle: withdrawAvailable ? environment.strings.Stars_Intro_BuyShort : environment.strings.Stars_Intro_Buy,
|
actionTitle: withdrawAvailable ? environment.strings.Stars_Intro_BuyShort : environment.strings.Stars_Intro_Buy,
|
||||||
actionAvailable: !premiumConfiguration.areStarsDisabled && !premiumConfiguration.isPremiumDisabled,
|
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 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)
|
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(
|
subscriptionsItems.append(AnyComponentWithIdentity(
|
||||||
|
@ -585,7 +585,7 @@ final class TonTransactionsScreenComponent: Component {
|
|||||||
strings: environment.strings,
|
strings: environment.strings,
|
||||||
dateTimeFormat: environment.dateTimeFormat,
|
dateTimeFormat: environment.dateTimeFormat,
|
||||||
count: self.starsState?.balance ?? StarsAmount.zero,
|
count: self.starsState?.balance ?? StarsAmount.zero,
|
||||||
isTon: true,
|
currency: .ton,
|
||||||
rate: 2.99 * 1e-9,
|
rate: 2.99 * 1e-9,
|
||||||
actionTitle: "Withdraw via Fragment",
|
actionTitle: "Withdraw via Fragment",
|
||||||
actionAvailable: withdrawAvailable,
|
actionAvailable: withdrawAvailable,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user