Add channel proceeds info

This commit is contained in:
Ilya Laktyushin 2024-07-03 11:30:11 +04:00
parent 294f922e66
commit ed6081f34b
5 changed files with 67 additions and 20 deletions

View File

@ -12456,6 +12456,7 @@ Sorry for the inconvenience.";
"Monetization.StarsProceeds.Available" = "Available Balance"; "Monetization.StarsProceeds.Available" = "Available Balance";
"Monetization.StarsProceeds.Current" = "Total Balance"; "Monetization.StarsProceeds.Current" = "Total Balance";
"Monetization.StarsProceeds.Total" = "Lifetime Proceeds"; "Monetization.StarsProceeds.Total" = "Lifetime Proceeds";
"Monetization.StarsProceeds.Info" = "Funds from your total balance can be used for ads or withdrawn as rewards 21 days after they are earned.";
"Premium.MessageEffects" = "Message Effects"; "Premium.MessageEffects" = "Message Effects";
"Premium.MessageEffectsInfo" = "Add over 500 animated effects to private messages."; "Premium.MessageEffectsInfo" = "Add over 500 animated effects to private messages.";

View File

@ -153,9 +153,10 @@ class BarsComponentController: GeneralChartComponentController {
func verticalLimitsLabels(verticalRange: ClosedRange<CGFloat>, secondary: Bool) -> (ClosedRange<CGFloat>, [LinesChartLabel]) { func verticalLimitsLabels(verticalRange: ClosedRange<CGFloat>, secondary: Bool) -> (ClosedRange<CGFloat>, [LinesChartLabel]) {
var (range, labels) = super.verticalLimitsLabels(verticalRange: verticalRange) var (range, labels) = super.verticalLimitsLabels(verticalRange: verticalRange)
if secondary { if secondary {
let allowedChars = "0123456789\(self.verticalLimitsNumberFormatter.decimalSeparator ?? ".")"
var updatedLabels: [LinesChartLabel] = [] var updatedLabels: [LinesChartLabel] = []
for label in labels { for label in labels {
let convertedValue = (Double(label.text) ?? 0.0) * self.conversionRate let convertedValue = (Double(label.text.filter(allowedChars.contains)) ?? 0.0) * self.conversionRate
let text: String let text: String
if convertedValue > 1.0 { if convertedValue > 1.0 {
text = String(format: "%0.1f", convertedValue) text = String(format: "%0.1f", convertedValue)

View File

@ -238,8 +238,9 @@ private enum StatsEntry: ItemListNodeEntry {
case adsStarsRevenueGraph(PresentationTheme, PresentationStrings, PresentationDateTimeFormat, StatsGraph, ChartType, Double) case adsStarsRevenueGraph(PresentationTheme, PresentationStrings, PresentationDateTimeFormat, StatsGraph, ChartType, Double)
case adsProceedsTitle(PresentationTheme, String) case adsProceedsTitle(PresentationTheme, String)
case adsProceedsOverview(PresentationTheme, RevenueStats, StarsRevenueStats?) case adsProceedsOverview(PresentationTheme, RevenueStats?, StarsRevenueStats?)
case adsProceedsInfo(PresentationTheme, String)
case adsTonBalanceTitle(PresentationTheme, String) case adsTonBalanceTitle(PresentationTheme, String)
case adsTonBalance(PresentationTheme, RevenueStats, Bool, Bool) case adsTonBalance(PresentationTheme, RevenueStats, Bool, Bool)
case adsTonBalanceInfo(PresentationTheme, String) case adsTonBalanceInfo(PresentationTheme, String)
@ -307,7 +308,7 @@ private enum StatsEntry: ItemListNodeEntry {
return StatsSection.adsTonRevenue.rawValue return StatsSection.adsTonRevenue.rawValue
case .adsStarsRevenueTitle, .adsStarsRevenueGraph: case .adsStarsRevenueTitle, .adsStarsRevenueGraph:
return StatsSection.adsStarsRevenue.rawValue return StatsSection.adsStarsRevenue.rawValue
case .adsProceedsTitle, .adsProceedsOverview: case .adsProceedsTitle, .adsProceedsOverview, .adsProceedsInfo:
return StatsSection.adsProceeds.rawValue return StatsSection.adsProceeds.rawValue
case .adsTonBalanceTitle, .adsTonBalance, .adsTonBalanceInfo: case .adsTonBalanceTitle, .adsTonBalance, .adsTonBalanceInfo:
return StatsSection.adsTonBalance.rawValue return StatsSection.adsTonBalance.rawValue
@ -430,24 +431,26 @@ private enum StatsEntry: ItemListNodeEntry {
return 20007 return 20007
case .adsProceedsOverview: case .adsProceedsOverview:
return 20008 return 20008
case .adsTonBalanceTitle: case .adsProceedsInfo:
return 20009 return 20009
case .adsTonBalance: case .adsTonBalanceTitle:
return 20010 return 20010
case .adsTonBalanceInfo: case .adsTonBalance:
return 20011 return 20011
case .adsStarsBalanceTitle: case .adsTonBalanceInfo:
return 20012 return 20012
case .adsStarsBalance: case .adsStarsBalanceTitle:
return 20013 return 20013
case .adsStarsBalanceInfo: case .adsStarsBalance:
return 20014 return 20014
case .adsTransactionsTitle: case .adsStarsBalanceInfo:
return 20015 return 20015
case .adsTransactionsTabs: case .adsTransactionsTitle:
return 20016 return 20016
case .adsTransactionsTabs:
return 20017
case let .adsTransaction(index, _, _): case let .adsTransaction(index, _, _):
return 20017 + index return 20018 + index
case let .adsStarsTransaction(index, _, _): case let .adsStarsTransaction(index, _, _):
return 30017 + index return 30017 + index
case .adsTransactionsExpand: case .adsTransactionsExpand:
@ -785,6 +788,12 @@ private enum StatsEntry: ItemListNodeEntry {
} else { } else {
return false return false
} }
case let .adsProceedsInfo(lhsTheme, lhsText):
if case let .adsProceedsInfo(rhsTheme, rhsText) = rhs, lhsTheme === rhsTheme, lhsText == rhsText {
return true
} else {
return false
}
case let .adsTonBalanceTitle(lhsTheme, lhsText): case let .adsTonBalanceTitle(lhsTheme, lhsText):
if case let .adsTonBalanceTitle(rhsTheme, rhsText) = rhs, lhsTheme === rhsTheme, lhsText == rhsText { if case let .adsTonBalanceTitle(rhsTheme, rhsText) = rhs, lhsTheme === rhsTheme, lhsText == rhsText {
return true return true
@ -904,7 +913,8 @@ private enum StatsEntry: ItemListNodeEntry {
let .boostersInfo(_, text), let .boostersInfo(_, text),
let .boostLinkInfo(_, text), let .boostLinkInfo(_, text),
let .boostGiftsInfo(_, text), let .boostGiftsInfo(_, text),
let .adsCpmInfo(_, text): let .adsCpmInfo(_, text),
let .adsProceedsInfo(_, text):
return ItemListTextItem(presentationData: presentationData, text: .markdown(text), sectionId: self.section) return ItemListTextItem(presentationData: presentationData, text: .markdown(text), sectionId: self.section)
case let .overview(_, stats): case let .overview(_, stats):
return StatsOverviewItem(context: arguments.context, presentationData: presentationData, isGroup: false, stats: stats, sectionId: self.section, style: .blocks) return StatsOverviewItem(context: arguments.context, presentationData: presentationData, isGroup: false, stats: stats, sectionId: self.section, style: .blocks)
@ -1046,7 +1056,7 @@ private enum StatsEntry: ItemListNodeEntry {
arguments.openMonetizationIntro() arguments.openMonetizationIntro()
}) })
case let .adsProceedsOverview(_, stats, starsStats): case let .adsProceedsOverview(_, stats, starsStats):
return StatsOverviewItem(context: arguments.context, presentationData: presentationData, isGroup: false, stats: stats, additionalStats: starsStats, sectionId: self.section, style: .blocks) return StatsOverviewItem(context: arguments.context, presentationData: presentationData, isGroup: false, stats: stats ?? starsStats, additionalStats: stats != nil ? starsStats : nil, sectionId: self.section, style: .blocks)
case let .adsTonBalance(_, stats, canWithdraw, isEnabled): case let .adsTonBalance(_, stats, canWithdraw, isEnabled):
return MonetizationBalanceItem( return MonetizationBalanceItem(
context: arguments.context, context: arguments.context,
@ -1542,8 +1552,9 @@ private func monetizationEntries(
} }
} }
entries.append(.adsProceedsTitle(presentationData.theme, presentationData.strings.Monetization_OverviewTitle)) entries.append(.adsProceedsTitle(presentationData.theme, presentationData.strings.Monetization_StarsProceeds_Title))
entries.append(.adsProceedsOverview(presentationData.theme, data, starsData)) entries.append(.adsProceedsOverview(presentationData.theme, canViewRevenue ? data : nil, canViewStarsRevenue ? starsData : nil))
entries.append(.adsProceedsInfo(presentationData.theme, presentationData.strings.Monetization_StarsProceeds_Info))
var isCreator = false var isCreator = false
if let peer, case let .channel(channel) = peer, channel.flags.contains(.isCreator) { if let peer, case let .channel(channel) = peer, channel.flags.contains(.isCreator) {

View File

@ -160,7 +160,7 @@ private enum StatsEntry: ItemListNodeEntry {
let .publicForwardsTitle(_, text): let .publicForwardsTitle(_, text):
return ItemListSectionHeaderItem(presentationData: presentationData, text: text, sectionId: self.section) return ItemListSectionHeaderItem(presentationData: presentationData, text: text, sectionId: self.section)
case let .overview(_, stats, storyViews, publicShares): case let .overview(_, stats, storyViews, publicShares):
return StatsOverviewItem(context: arguments.context, presentationData: presentationData, isGroup: false, stats: stats as! Stats, storyViews: storyViews, publicShares: publicShares, sectionId: self.section, style: .blocks) return StatsOverviewItem(context: arguments.context, presentationData: presentationData, isGroup: false, stats: stats as? Stats, storyViews: storyViews, publicShares: publicShares, sectionId: self.section, style: .blocks)
case let .interactionsGraph(_, _, _, graph, type, noInitialZoom), let .reactionsGraph(_, _, _, graph, type, noInitialZoom): case let .interactionsGraph(_, _, _, graph, type, noInitialZoom), let .reactionsGraph(_, _, _, graph, type, noInitialZoom):
return StatsGraphItem(presentationData: presentationData, graph: graph, type: type, noInitialZoom: noInitialZoom, getDetailsData: { date, completion in return StatsGraphItem(presentationData: presentationData, graph: graph, type: type, noInitialZoom: noInitialZoom, getDetailsData: { date, completion in
let _ = arguments.loadDetailedGraph(graph, Int64(date.timeIntervalSince1970) * 1000).start(next: { graph in let _ = arguments.loadDetailedGraph(graph, Int64(date.timeIntervalSince1970) * 1000).start(next: { graph in

View File

@ -47,14 +47,14 @@ class StatsOverviewItem: ListViewItem, ItemListItem {
let context: AccountContext let context: AccountContext
let presentationData: ItemListPresentationData let presentationData: ItemListPresentationData
let isGroup: Bool let isGroup: Bool
let stats: Stats let stats: Stats?
let additionalStats: Stats? let additionalStats: Stats?
let storyViews: EngineStoryItem.Views? let storyViews: EngineStoryItem.Views?
let publicShares: Int32? let publicShares: Int32?
let sectionId: ItemListSectionId let sectionId: ItemListSectionId
let style: ItemListStyle let style: ItemListStyle
init(context: AccountContext, presentationData: ItemListPresentationData, isGroup: Bool, stats: Stats, additionalStats: Stats? = nil, storyViews: EngineStoryItem.Views? = nil, publicShares: Int32? = nil, sectionId: ItemListSectionId, style: ItemListStyle) { init(context: AccountContext, presentationData: ItemListPresentationData, isGroup: Bool, stats: Stats?, additionalStats: Stats? = nil, storyViews: EngineStoryItem.Views? = nil, publicShares: Int32? = nil, sectionId: ItemListSectionId, style: ItemListStyle) {
self.context = context self.context = context
self.presentationData = presentationData self.presentationData = presentationData
self.isGroup = isGroup self.isGroup = isGroup
@ -863,6 +863,40 @@ class StatsOverviewItemNode: ListViewItemNode {
height += topLeftItemLayoutAndApply!.0.height * 3.0 + verticalSpacing * 2.0 height += topLeftItemLayoutAndApply!.0.height * 3.0 + verticalSpacing * 2.0
} }
} else if let stats = item.stats as? StarsRevenueStats {
twoColumnLayout = false
topLeftItemLayoutAndApply = makeTopLeftItemLayout(
item.context,
params.width,
item.presentationData,
presentationStringsFormattedNumber(Int32(stats.balances.availableBalance), item.presentationData.dateTimeFormat.groupingSeparator),
item.presentationData.strings.Monetization_StarsProceeds_Available,
(stats.balances.availableBalance == 0 ? "" : "\(formatUsdValue(stats.balances.availableBalance, rate: stats.usdRate))", .generic),
.stars
)
topRightItemLayoutAndApply = makeTopRightItemLayout(
item.context,
params.width,
item.presentationData,
presentationStringsFormattedNumber(Int32(stats.balances.currentBalance), item.presentationData.dateTimeFormat.groupingSeparator),
item.presentationData.strings.Monetization_StarsProceeds_Current,
(stats.balances.currentBalance == 0 ? "" : "\(formatUsdValue(stats.balances.currentBalance, rate: stats.usdRate))", .generic),
.stars
)
middle1LeftItemLayoutAndApply = makeMiddle1LeftItemLayout(
item.context,
params.width,
item.presentationData,
presentationStringsFormattedNumber(Int32(stats.balances.overallRevenue), item.presentationData.dateTimeFormat.groupingSeparator),
item.presentationData.strings.Monetization_StarsProceeds_Total,
(stats.balances.overallRevenue == 0 ? "" : "\(formatUsdValue(stats.balances.overallRevenue, rate: stats.usdRate))", .generic),
.stars
)
height += topLeftItemLayoutAndApply!.0.height * 3.0 + verticalSpacing * 2.0
} }
let contentSize = CGSize(width: params.width, height: height) let contentSize = CGSize(width: params.width, height: height)