diff --git a/submodules/TelegramCore/Sources/TelegramEngine/Payments/Stars.swift b/submodules/TelegramCore/Sources/TelegramEngine/Payments/Stars.swift index 1c5b0a7074..17adf1a612 100644 --- a/submodules/TelegramCore/Sources/TelegramEngine/Payments/Stars.swift +++ b/submodules/TelegramCore/Sources/TelegramEngine/Payments/Stars.swift @@ -204,6 +204,13 @@ private final class StarsContextImpl { self.updateState(StarsContext.State(flags: [.isPendingBalance], balance: state.balance + balance, transactions: transactions, canLoadMore: state.canLoadMore, isLoading: state.isLoading)) } + fileprivate func updateBalance(_ balance: Int64) { + guard let state = self._state else { + return + } + self.updateState(StarsContext.State(flags: [], balance: balance, transactions: state.transactions, canLoadMore: state.canLoadMore, isLoading: state.isLoading)) + } + func loadMore() { assert(Queue.mainQueue().isCurrent()) @@ -393,6 +400,13 @@ public final class StarsContext { } } + fileprivate func updateBalance(_ balance: Int64) { + self.impl.with { + $0.updateBalance(balance) + } + } + + public func load(force: Bool) { self.impl.with { $0.load(force: force) @@ -414,6 +428,7 @@ public final class StarsContext { private final class StarsTransactionsContextImpl { private let account: Account + private weak var starsContext: StarsContext? private let peerId: EnginePeer.Id private let subject: StarsTransactionsContext.Subject @@ -431,6 +446,7 @@ private final class StarsTransactionsContextImpl { assert(Queue.mainQueue().isCurrent()) self.account = account + self.starsContext = starsContext self.peerId = starsContext.peerId self.subject = subject @@ -518,6 +534,8 @@ private final class StarsTransactionsContextImpl { updatedState.isLoading = false updatedState.canLoadMore = self.nextOffset != nil self.updateState(updatedState) + + self.starsContext?.updateBalance(status.balance) })) } diff --git a/submodules/TelegramUI/Components/PeerInfo/PeerInfoScreen/Sources/PeerInfoScreen.swift b/submodules/TelegramUI/Components/PeerInfo/PeerInfoScreen/Sources/PeerInfoScreen.swift index 2e0e110acd..e078eb2647 100644 --- a/submodules/TelegramUI/Components/PeerInfo/PeerInfoScreen/Sources/PeerInfoScreen.swift +++ b/submodules/TelegramUI/Components/PeerInfo/PeerInfoScreen/Sources/PeerInfoScreen.swift @@ -11930,8 +11930,9 @@ public final class PeerInfoScreenImpl: ViewController, PeerInfoScreen, KeyShortc self.chatLocation = .peer(id: peerId) } - if isSettings { - self.starsContext = context.starsContext + if isSettings, let starsContext = context.starsContext { + self.starsContext = starsContext + starsContext.load() } else { self.starsContext = nil } diff --git a/submodules/TelegramUI/Components/Stars/StarsPurchaseScreen/Sources/StarsPurchaseScreen.swift b/submodules/TelegramUI/Components/Stars/StarsPurchaseScreen/Sources/StarsPurchaseScreen.swift index b73c62a6f4..56175544ac 100644 --- a/submodules/TelegramUI/Components/Stars/StarsPurchaseScreen/Sources/StarsPurchaseScreen.swift +++ b/submodules/TelegramUI/Components/Stars/StarsPurchaseScreen/Sources/StarsPurchaseScreen.swift @@ -166,7 +166,7 @@ private final class StarsPurchaseScreenContentComponent: CombinedComponent { } static var body: Body { - let overscroll = Child(Rectangle.self) +// let overscroll = Child(Rectangle.self) // let fade = Child(RoundedRectangle.self) let text = Child(BalancedTextComponent.self) let list = Child(VStack.self) @@ -188,21 +188,21 @@ private final class StarsPurchaseScreenContentComponent: CombinedComponent { let sideInsets = sideInset * 2.0 + environment.safeInsets.left + environment.safeInsets.right var size = CGSize(width: context.availableSize.width, height: 0.0) - var topBackgroundColor = theme.list.plainBackgroundColor - let bottomBackgroundColor = theme.list.blocksBackgroundColor - if theme.overallDarkAppearance { - topBackgroundColor = bottomBackgroundColor - } - - let overscroll = overscroll.update( - component: Rectangle(color: topBackgroundColor), - availableSize: CGSize(width: context.availableSize.width, height: 1000), - transition: context.transition - ) - context.add(overscroll - .position(CGPoint(x: overscroll.size.width / 2.0, y: -overscroll.size.height / 2.0)) - ) - +// var topBackgroundColor = theme.list.plainBackgroundColor +// let bottomBackgroundColor = theme.list.blocksBackgroundColor +// if theme.overallDarkAppearance { +// topBackgroundColor = bottomBackgroundColor +// } +// +// let overscroll = overscroll.update( +// component: Rectangle(color: topBackgroundColor), +// availableSize: CGSize(width: context.availableSize.width, height: 1000), +// transition: context.transition +// ) +// context.add(overscroll +// .position(CGPoint(x: overscroll.size.width / 2.0, y: -overscroll.size.height / 2.0)) +// ) +// // let fade = fade.update( // component: RoundedRectangle( // colors: [ diff --git a/submodules/TelegramUI/Components/Stars/StarsTransactionsScreen/Sources/StarsBalanceComponent.swift b/submodules/TelegramUI/Components/Stars/StarsTransactionsScreen/Sources/StarsBalanceComponent.swift index 99a24124f1..66546529ef 100644 --- a/submodules/TelegramUI/Components/Stars/StarsTransactionsScreen/Sources/StarsBalanceComponent.swift +++ b/submodules/TelegramUI/Components/Stars/StarsTransactionsScreen/Sources/StarsBalanceComponent.swift @@ -8,11 +8,11 @@ import MultilineTextComponent import TelegramPresentationData import PresentationDataUtils import SolidRoundedButtonComponent -import AnimatedTextComponent final class StarsBalanceComponent: Component { let theme: PresentationTheme let strings: PresentationStrings + let dateTimeFormat: PresentationDateTimeFormat let count: Int64 let purchaseAvailable: Bool let buy: () -> Void @@ -20,12 +20,14 @@ final class StarsBalanceComponent: Component { init( theme: PresentationTheme, strings: PresentationStrings, + dateTimeFormat: PresentationDateTimeFormat, count: Int64, purchaseAvailable: Bool, buy: @escaping () -> Void ) { self.theme = theme self.strings = strings + self.dateTimeFormat = dateTimeFormat self.count = count self.purchaseAvailable = purchaseAvailable self.buy = buy @@ -38,6 +40,9 @@ final class StarsBalanceComponent: Component { if lhs.strings !== rhs.strings { return false } + if lhs.dateTimeFormat != rhs.dateTimeFormat { + return false + } if lhs.purchaseAvailable != rhs.purchaseAvailable { return false } @@ -68,26 +73,17 @@ final class StarsBalanceComponent: Component { } func update(component: StarsBalanceComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { - let isFirstTime = self.component == nil self.component = component let sideInset: CGFloat = 16.0 var contentHeight: CGFloat = sideInset - var animatedTextItems: [AnimatedTextComponent.Item] = [] - animatedTextItems.append(AnimatedTextComponent.Item( - id: 1, - isUnbreakable: true, - content: .number(Int(component.count), minDigits: 1) - )) - + let balanceString = presentationStringsFormattedNumber(Int32(component.count), component.dateTimeFormat.groupingSeparator) let titleSize = self.title.update( - transition: isFirstTime ? .immediate : .easeInOut(duration: 0.2), + transition: .immediate, component: AnyComponent( - AnimatedTextComponent( - font: Font.with(size: 48.0, design: .round, weight: .semibold), - color: component.theme.list.itemPrimaryTextColor, - items: animatedTextItems + MultilineTextComponent( + text: .plain(NSAttributedString(string: balanceString, font: Font.with(size: 48.0, design: .round, weight: .semibold), textColor: component.theme.list.itemPrimaryTextColor)) ) ), environment: {}, diff --git a/submodules/TelegramUI/Components/Stars/StarsTransactionsScreen/Sources/StarsTransactionScreen.swift b/submodules/TelegramUI/Components/Stars/StarsTransactionsScreen/Sources/StarsTransactionScreen.swift index e441c8e595..d29f80c281 100644 --- a/submodules/TelegramUI/Components/Stars/StarsTransactionsScreen/Sources/StarsTransactionScreen.swift +++ b/submodules/TelegramUI/Components/Stars/StarsTransactionsScreen/Sources/StarsTransactionScreen.swift @@ -260,6 +260,8 @@ private final class StarsTransactionSheetContent: CombinedComponent { imageSubject = .photo(photo) } else if let transactionPeer { imageSubject = .transactionPeer(transactionPeer) + } else if let toPeer { + imageSubject = .transactionPeer(.peer(toPeer)) } else { imageSubject = .none } diff --git a/submodules/TelegramUI/Components/Stars/StarsTransactionsScreen/Sources/StarsTransactionsListPanelComponent.swift b/submodules/TelegramUI/Components/Stars/StarsTransactionsScreen/Sources/StarsTransactionsListPanelComponent.swift index 4f2f37720d..2efc927a33 100644 --- a/submodules/TelegramUI/Components/Stars/StarsTransactionsScreen/Sources/StarsTransactionsListPanelComponent.swift +++ b/submodules/TelegramUI/Components/Stars/StarsTransactionsScreen/Sources/StarsTransactionsListPanelComponent.swift @@ -546,7 +546,7 @@ private final class AvatarComponent: Component { imageNode = current } else { imageNode = TransformImageNode() - imageNode.contentAnimations = [.firstUpdate, .subsequentUpdates] + imageNode.contentAnimations = [.subsequentUpdates] self.addSubview(imageNode.view) self.imageNode = imageNode diff --git a/submodules/TelegramUI/Components/Stars/StarsTransactionsScreen/Sources/StarsTransactionsScreen.swift b/submodules/TelegramUI/Components/Stars/StarsTransactionsScreen/Sources/StarsTransactionsScreen.swift index fd926aae93..2659ac2f52 100644 --- a/submodules/TelegramUI/Components/Stars/StarsTransactionsScreen/Sources/StarsTransactionsScreen.swift +++ b/submodules/TelegramUI/Components/Stars/StarsTransactionsScreen/Sources/StarsTransactionsScreen.swift @@ -504,7 +504,7 @@ final class StarsTransactionsScreenComponent: Component { environment: {}, containerSize: CGSize(width: availableSize.width - sideInsets - 8.0, height: 240.0) ) - let descriptionFrame = CGRect(origin: CGPoint(x: floorToScreenPixels((availableSize.width - descriptionSize.width) / 2.0), y: contentHeight), size: descriptionSize) + let descriptionFrame = CGRect(origin: CGPoint(x: floorToScreenPixels((availableSize.width - descriptionSize.width) / 2.0), y: contentHeight + 20.0 - floor(descriptionSize.height / 2.0)), size: descriptionSize) if let descriptionView = self.descriptionView.view { if descriptionView.superview == nil { self.scrollView.addSubview(descriptionView) @@ -527,6 +527,7 @@ final class StarsTransactionsScreenComponent: Component { StarsBalanceComponent( theme: environment.theme, strings: environment.strings, + dateTimeFormat: environment.dateTimeFormat, count: self.starsState?.balance ?? 0, purchaseAvailable: !premiumConfiguration.areStarsDisabled, buy: { [weak self] in diff --git a/submodules/TelegramUI/Sources/ChatController.swift b/submodules/TelegramUI/Sources/ChatController.swift index 5eb3cce511..06fc772896 100644 --- a/submodules/TelegramUI/Sources/ChatController.swift +++ b/submodules/TelegramUI/Sources/ChatController.swift @@ -2924,7 +2924,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G strongSelf.chatDisplayNode.dismissInput() if let receiptMessageId = invoice.receiptMessageId { if invoice.currency == "XTR" { - let _ = (strongSelf.context.engine.payments.requestBotPaymentReceipt(messageId: message.id) + let _ = (strongSelf.context.engine.payments.requestBotPaymentReceipt(messageId: receiptMessageId) |> deliverOnMainQueue).start(next: { [weak self] receipt in guard let strongSelf = self else { return