mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-10-09 03:20:48 +00:00
Merge commit 'c7949efcc2088d808ca49014dcc66a88f16974dc'
This commit is contained in:
commit
0280cdbaec
@ -73,7 +73,7 @@ func confirmRevenueWithdrawalController(context: AccountContext, updatedPresenta
|
||||
}
|
||||
|
||||
|
||||
func revenueWithdrawalController(context: AccountContext, updatedPresentationData: (initial: PresentationData, signal: Signal<PresentationData, NoError>)? = nil, peerId: EnginePeer.Id, initialError: RequestStarsRevenueWithdrawalError, present: @escaping (ViewController, Any?) -> Void, completion: @escaping (String) -> Void) -> ViewController {
|
||||
public func revenueWithdrawalController(context: AccountContext, updatedPresentationData: (initial: PresentationData, signal: Signal<PresentationData, NoError>)? = nil, peerId: EnginePeer.Id, initialError: RequestStarsRevenueWithdrawalError, present: @escaping (ViewController, Any?) -> Void, completion: @escaping (String) -> Void) -> ViewController {
|
||||
let presentationData = updatedPresentationData?.initial ?? context.sharedContext.currentPresentationData.with { $0 }
|
||||
let theme = AlertControllerTheme(presentationData: presentationData)
|
||||
|
||||
|
@ -109,12 +109,12 @@ public func formatStarsAmountText(_ amount: StarsAmount, dateTimeFormat: Present
|
||||
return balanceText
|
||||
}
|
||||
|
||||
public func formatCurrencyAmountText(_ amount: CurrencyAmount, dateTimeFormat: PresentationDateTimeFormat, showPlus: Bool = false) -> String {
|
||||
public func formatCurrencyAmountText(_ amount: CurrencyAmount, dateTimeFormat: PresentationDateTimeFormat, showPlus: Bool = false, maxDecimalPositions: Int? = 2) -> String {
|
||||
switch amount.currency {
|
||||
case .stars:
|
||||
return formatStarsAmountText(amount.amount, dateTimeFormat: dateTimeFormat, showPlus: showPlus)
|
||||
case .ton:
|
||||
return formatTonAmountText(amount.amount.value, dateTimeFormat: dateTimeFormat, showPlus: showPlus)
|
||||
return formatTonAmountText(amount.amount.value, dateTimeFormat: dateTimeFormat, showPlus: showPlus, maxDecimalPositions: maxDecimalPositions)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1031,7 +1031,8 @@ public class ChatMessageGiftBubbleContentNode: ChatMessageBubbleContentNode {
|
||||
creatorButtonBackgroundNode.removeFromSupernode()
|
||||
}
|
||||
}
|
||||
strongSelf.creatorButtonTitleNode.frame = CGRect(origin: CGPoint(x: 9.0, y: 1.0), size: creatorButtonTitleLayout.size)
|
||||
let creatorButtonTitleNodeFrame = CGRect(origin: CGPoint(x: 9.0, y: 1.0 + UIScreenPixel), size: creatorButtonTitleLayout.size)
|
||||
strongSelf.creatorButtonTitleNode.frame = creatorButtonTitleNodeFrame
|
||||
|
||||
animation.animator.updateFrame(layer: strongSelf.creatorButtonNode.layer, frame: creatorButtonFrame, completion: nil)
|
||||
|
||||
|
@ -3595,10 +3595,10 @@ private final class GiftViewSheetContent: CombinedComponent {
|
||||
buttonAttributedString.addAttribute(.kern, value: 2.0, range: NSRange(range, in: buttonAttributedString.string))
|
||||
}
|
||||
if let buttonAttributedSubtitleString, let range = buttonAttributedSubtitleString.string.range(of: "#"), let starImage = state.cachedSubtitleStarImage?.0 {
|
||||
buttonAttributedSubtitleString.addAttribute(.attachment, value: starImage, range: NSRange(range, in: buttonAttributedString.string))
|
||||
buttonAttributedSubtitleString.addAttribute(.foregroundColor, value: theme.list.itemCheckColors.foregroundColor.withAlphaComponent(0.7), range: NSRange(range, in: buttonAttributedString.string))
|
||||
buttonAttributedSubtitleString.addAttribute(.baselineOffset, value: 1.5, range: NSRange(range, in: buttonAttributedString.string))
|
||||
buttonAttributedSubtitleString.addAttribute(.kern, value: 2.0, range: NSRange(range, in: buttonAttributedString.string))
|
||||
buttonAttributedSubtitleString.addAttribute(.attachment, value: starImage, range: NSRange(range, in: buttonAttributedSubtitleString.string))
|
||||
buttonAttributedSubtitleString.addAttribute(.foregroundColor, value: theme.list.itemCheckColors.foregroundColor.withAlphaComponent(0.7), range: NSRange(range, in: buttonAttributedSubtitleString.string))
|
||||
buttonAttributedSubtitleString.addAttribute(.baselineOffset, value: 1.5, range: NSRange(range, in: buttonAttributedSubtitleString.string))
|
||||
buttonAttributedSubtitleString.addAttribute(.kern, value: 2.0, range: NSRange(range, in: buttonAttributedSubtitleString.string))
|
||||
}
|
||||
|
||||
var items: [AnyComponentWithIdentity<Empty>] = [
|
||||
|
@ -89,8 +89,8 @@ final class StarsOverviewItemComponent: Component {
|
||||
valueOffset += icon.size.width
|
||||
}
|
||||
|
||||
let valueString = formatStarsAmountText(component.value.amount, dateTimeFormat: component.dateTimeFormat)
|
||||
let usdValueString = formatTonUsdValue(component.value.amount.value, divide: false, rate: component.rate, dateTimeFormat: component.dateTimeFormat)
|
||||
let valueString = formatCurrencyAmountText(component.value, dateTimeFormat: component.dateTimeFormat, maxDecimalPositions: nil)
|
||||
let usdValueString = formatTonUsdValue(component.value.amount.value, divide: component.value.currency == .ton, rate: component.rate, dateTimeFormat: component.dateTimeFormat)
|
||||
|
||||
let valueSize = self.value.update(
|
||||
transition: .immediate,
|
||||
|
@ -582,20 +582,12 @@ final class StarsStatisticsScreenComponent: Component {
|
||||
count: self.starsState?.balances.availableBalance.amount ?? StarsAmount.zero,
|
||||
currency: .stars,
|
||||
rate: self.starsState?.usdRate ?? 0,
|
||||
actionTitle: strings.Stars_Intro_BuyShort,
|
||||
actionAvailable: true,
|
||||
actionTitle: strings.Stars_Intro_Withdraw,
|
||||
actionAvailable: withdrawEnabled,
|
||||
actionIsEnabled: true,
|
||||
actionIcon: PresentationResourcesItemList.itemListRoundTopupIcon(environment.theme),
|
||||
actionCooldownUntilTimestamp: self.starsState?.balances.nextWithdrawalTimestamp,
|
||||
actionIcon: PresentationResourcesItemList.itemListRoundWithdrawIcon(environment.theme),
|
||||
action: { [weak self] in
|
||||
guard let self, let component = self.component else {
|
||||
return
|
||||
}
|
||||
component.buy()
|
||||
},
|
||||
secondaryActionTitle: withdrawEnabled ? strings.Stars_Intro_Withdraw : nil,
|
||||
secondaryActionIcon: PresentationResourcesItemList.itemListRoundWithdrawIcon(environment.theme),
|
||||
secondaryActionCooldownUntilTimestamp: self.starsState?.balances.nextWithdrawalTimestamp,
|
||||
secondaryAction: { [weak self] in
|
||||
guard let self, let component = self.component else {
|
||||
return
|
||||
}
|
||||
|
@ -25,6 +25,7 @@ import ListItemComponentAdaptor
|
||||
import ItemListUI
|
||||
import StarsWithdrawalScreen
|
||||
import PremiumDiamondComponent
|
||||
import StatisticsUI
|
||||
|
||||
private let initialSubscriptionsDisplayedLimit: Int32 = 3
|
||||
|
||||
@ -671,52 +672,52 @@ final class StarsTransactionsScreenComponent: Component {
|
||||
|
||||
let withdrawAvailable = (self.revenueState?.balances.overallRevenue.amount.value ?? 0) > 0
|
||||
|
||||
// if component.starsContext.ton {
|
||||
// //TODO:localize
|
||||
// let proceedsSize = self.proceedsView.update(
|
||||
// transition: .immediate,
|
||||
// component: AnyComponent(ListSectionComponent(
|
||||
// theme: environment.theme,
|
||||
// header: AnyComponent(MultilineTextComponent(
|
||||
// text: .plain(NSAttributedString(
|
||||
// string: "Proceeds Overview".uppercased(),
|
||||
// font: Font.regular(presentationData.listsFontSize.itemListBaseHeaderFontSize),
|
||||
// textColor: environment.theme.list.freeTextColor
|
||||
// )),
|
||||
// maximumNumberOfLines: 0
|
||||
// )),
|
||||
// footer: nil,
|
||||
// items: [
|
||||
// AnyComponentWithIdentity(id: 0, component: AnyComponent(StarsOverviewItemComponent(
|
||||
// theme: environment.theme,
|
||||
// dateTimeFormat: environment.dateTimeFormat,
|
||||
// title: "Balance Available to Withdraw",
|
||||
// value: self.revenueState?.balances.availableBalance ?? CurrencyAmount(amount: .zero, currency: .stars),
|
||||
// rate: self.revenueState?.usdRate ?? 0.0
|
||||
// ))),
|
||||
// AnyComponentWithIdentity(id: 1, component: AnyComponent(StarsOverviewItemComponent(
|
||||
// theme: environment.theme,
|
||||
// dateTimeFormat: environment.dateTimeFormat,
|
||||
// title: "Total Lifetime Proceeds",
|
||||
// value: self.revenueState?.balances.overallRevenue ?? CurrencyAmount(amount: .zero, currency: .stars),
|
||||
// rate: self.revenueState?.usdRate ?? 0.0
|
||||
// )))
|
||||
// ],
|
||||
// displaySeparators: false
|
||||
// )),
|
||||
// environment: {},
|
||||
// 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)
|
||||
// if let proceedsView = self.proceedsView.view {
|
||||
// if proceedsView.superview == nil {
|
||||
// self.scrollView.addSubview(proceedsView)
|
||||
// }
|
||||
// transition.setFrame(view: proceedsView, frame: proceedsFrame)
|
||||
// }
|
||||
// contentHeight += proceedsSize.height
|
||||
// contentHeight += 31.0
|
||||
// }
|
||||
if component.starsContext.ton {
|
||||
//TODO:localize
|
||||
let proceedsSize = self.proceedsView.update(
|
||||
transition: .immediate,
|
||||
component: AnyComponent(ListSectionComponent(
|
||||
theme: environment.theme,
|
||||
header: AnyComponent(MultilineTextComponent(
|
||||
text: .plain(NSAttributedString(
|
||||
string: "Proceeds Overview".uppercased(),
|
||||
font: Font.regular(presentationData.listsFontSize.itemListBaseHeaderFontSize),
|
||||
textColor: environment.theme.list.freeTextColor
|
||||
)),
|
||||
maximumNumberOfLines: 0
|
||||
)),
|
||||
footer: nil,
|
||||
items: [
|
||||
AnyComponentWithIdentity(id: 0, component: AnyComponent(StarsOverviewItemComponent(
|
||||
theme: environment.theme,
|
||||
dateTimeFormat: environment.dateTimeFormat,
|
||||
title: "Balance Available to Withdraw",
|
||||
value: self.revenueState?.balances.availableBalance ?? CurrencyAmount(amount: .zero, currency: .ton),
|
||||
rate: self.revenueState?.usdRate ?? 0.0
|
||||
))),
|
||||
AnyComponentWithIdentity(id: 1, component: AnyComponent(StarsOverviewItemComponent(
|
||||
theme: environment.theme,
|
||||
dateTimeFormat: environment.dateTimeFormat,
|
||||
title: "Total Lifetime Proceeds",
|
||||
value: self.revenueState?.balances.overallRevenue ?? CurrencyAmount(amount: .zero, currency: .ton),
|
||||
rate: self.revenueState?.usdRate ?? 0.0
|
||||
)))
|
||||
],
|
||||
displaySeparators: false
|
||||
)),
|
||||
environment: {},
|
||||
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)
|
||||
if let proceedsView = self.proceedsView.view {
|
||||
if proceedsView.superview == nil {
|
||||
self.scrollView.addSubview(proceedsView)
|
||||
}
|
||||
transition.setFrame(view: proceedsView, frame: proceedsFrame)
|
||||
}
|
||||
contentHeight += proceedsSize.height
|
||||
contentHeight += 31.0
|
||||
}
|
||||
|
||||
let termsFont = Font.regular(13.0)
|
||||
let termsTextColor = environment.theme.list.freeTextColor
|
||||
@ -739,7 +740,7 @@ final class StarsTransactionsScreenComponent: Component {
|
||||
component: AnyComponent(ListSectionComponent(
|
||||
theme: environment.theme,
|
||||
header: nil,
|
||||
footer: component.starsContext.ton && !"".isEmpty ? AnyComponent(MultilineTextComponent(
|
||||
footer: component.starsContext.ton ? AnyComponent(MultilineTextComponent(
|
||||
text: .plain(balanceInfoString),
|
||||
maximumNumberOfLines: 0,
|
||||
highlightColor: environment.theme.list.itemAccentColor.withAlphaComponent(0.1),
|
||||
@ -766,7 +767,7 @@ final class StarsTransactionsScreenComponent: Component {
|
||||
currency: component.starsContext.ton ? .ton : .stars,
|
||||
rate: nil,
|
||||
actionTitle: component.starsContext.ton ? "Withdraw via Fragment" : (withdrawAvailable ? environment.strings.Stars_Intro_BuyShort : environment.strings.Stars_Intro_Buy),
|
||||
actionAvailable: (!component.starsContext.ton && !premiumConfiguration.areStarsDisabled && !premiumConfiguration.isPremiumDisabled),
|
||||
actionAvailable: (!premiumConfiguration.areStarsDisabled && !premiumConfiguration.isPremiumDisabled),
|
||||
actionIsEnabled: true,
|
||||
actionIcon: component.starsContext.ton ? nil : PresentationResourcesItemList.itemListRoundTopupIcon(environment.theme),
|
||||
action: { [weak self] in
|
||||
@ -1219,7 +1220,7 @@ public final class StarsTransactionsScreen: ViewControllerComponentContainer {
|
||||
self.context = context
|
||||
self.starsContext = starsContext
|
||||
|
||||
self.starsRevenueStatsContext = context.engine.payments.peerStarsRevenueContext(peerId: context.account.peerId, ton: false)
|
||||
self.starsRevenueStatsContext = context.engine.payments.peerStarsRevenueContext(peerId: context.account.peerId, ton: starsContext.ton)
|
||||
if !starsContext.ton {
|
||||
self.subscriptionsContext = context.engine.payments.peerStarsSubscriptionsContext(starsContext: starsContext)
|
||||
} else {
|
||||
@ -1358,42 +1359,13 @@ public final class StarsTransactionsScreen: ViewControllerComponentContainer {
|
||||
guard let self else {
|
||||
return
|
||||
}
|
||||
switch error {
|
||||
case .serverProvided:
|
||||
return
|
||||
case .requestPassword:
|
||||
let _ = (self.starsRevenueStatsContext.state
|
||||
|> take(1)
|
||||
|> deliverOnMainQueue).start(next: { [weak self] state in
|
||||
guard let self, let stats = state.stats else {
|
||||
return
|
||||
}
|
||||
let controller = self.context.sharedContext.makeStarsWithdrawalScreen(context: context, stats: stats, completion: { [weak self] amount in
|
||||
guard let self else {
|
||||
return
|
||||
}
|
||||
let controller = confirmStarsRevenueWithdrawalController(context: context, peerId: context.account.peerId, amount: amount, present: { [weak self] c, a in
|
||||
self?.present(c, in: .window(.root))
|
||||
}, completion: { [weak self] url in
|
||||
let presentationData = context.sharedContext.currentPresentationData.with { $0 }
|
||||
context.sharedContext.openExternalUrl(context: context, urlContext: .generic, url: url, forceExternal: true, presentationData: presentationData, navigationController: nil, dismissInput: {})
|
||||
|
||||
Queue.mainQueue().after(2.0) {
|
||||
self?.starsRevenueStatsContext.reload()
|
||||
}
|
||||
})
|
||||
self.present(controller, in: .window(.root))
|
||||
})
|
||||
self.push(controller)
|
||||
})
|
||||
default:
|
||||
let controller = starsRevenueWithdrawalController(context: context, peerId: context.account.peerId, amount: 0, initialError: error, present: { [weak self] c, a in
|
||||
self?.present(c, in: .window(.root))
|
||||
}, completion: { _ in
|
||||
|
||||
})
|
||||
self.present(controller, in: .window(.root))
|
||||
}
|
||||
let controller = revenueWithdrawalController(context: context, peerId: context.account.peerId, initialError: error, present: { [weak self] c, _ in
|
||||
self?.present(c, in: .window(.root))
|
||||
}, completion: { url in
|
||||
let presentationData = context.sharedContext.currentPresentationData.with { $0 }
|
||||
context.sharedContext.openExternalUrl(context: context, urlContext: .generic, url: url, forceExternal: true, presentationData: presentationData, navigationController: nil, dismissInput: {})
|
||||
})
|
||||
self.present(controller, in: .window(.root))
|
||||
})
|
||||
} else {
|
||||
let controller = self.context.sharedContext.makeStarsStatisticsScreen(context: context, peerId: context.account.peerId, revenueContext: self.starsRevenueStatsContext)
|
||||
|
Loading…
x
Reference in New Issue
Block a user