From bd9c495fb4bbb5d974d872f2cdfc41b1364cade0 Mon Sep 17 00:00:00 2001 From: Ilya Laktyushin Date: Wed, 22 May 2024 19:12:37 +0400 Subject: [PATCH] Various fixes --- .../Telegram-iOS/en.lproj/Localizable.strings | 26 +++++++++++++++++ .../Sources/HashtagSearchControllerNode.swift | 10 +++++-- .../Sources/StarsTransactionScreen.swift | 14 +++++----- .../Sources/StarsTransactionsScreen.swift | 15 +++++----- .../Sources/StarsTransferScreen.swift | 28 +++++++++++++------ 5 files changed, 67 insertions(+), 26 deletions(-) diff --git a/Telegram/Telegram-iOS/en.lproj/Localizable.strings b/Telegram/Telegram-iOS/en.lproj/Localizable.strings index d8dd72eb9c..50df79bff4 100644 --- a/Telegram/Telegram-iOS/en.lproj/Localizable.strings +++ b/Telegram/Telegram-iOS/en.lproj/Localizable.strings @@ -12226,6 +12226,13 @@ Sorry for the inconvenience."; "Conversation.ContextMenuAddFactCheck" = "Add Fact Check"; "Conversation.ContextMenuEditFactCheck" = "Edit Fact Check"; +"Stars.Intro.Title" = "Telegram Stars"; +"Stars.Intro.Description" = "Buy Stars to unlock content and services in miniapps on Telegram."; +"Stars.Intro.Balance" = "Balance"; +"Stars.Intro.AllTransactions" = "All Transactions"; +"Stars.Intro.Incoming" = "Incoming"; +"Stars.Intro.Outgoing" = "Outgoing"; + "Stars.Purchase.GetStars" = "Get Stars"; "Stars.Purchase.GetStarsInfo" = "Choose how many Stars you would like to buy."; @@ -12241,4 +12248,23 @@ Sorry for the inconvenience."; "Stars.Purchase.Info" = "By proceeding and purchasing Stars, you agree with [Terms and Conditions]()."; "Stars.Purchase.Terms_URL" = "https://telegram.org/tos"; +"Stars.Transaction.To" = "To"; +"Stars.Transaction.Id" = "Transaction ID"; +"Stars.Transaction.Date" = "Date"; +"Stars.Transaction.Terms" = "Review the [Terms of Service]() for Stars."; +"Stars.Transaction.Terms_URL" = "https://telegram.org/tos"; +"Stars.Transaction.CopiedId" = "Transaction ID copied to clipboard."; + +"Stars.Transfer.Title" = "Confirm Your Purchase"; +"Stars.Transfer.Info" = "Do you want to buy **%1$@** in **%2$@** for **%3$@**?"; +"Stars.Transfer.Info.Stars_1" = "%@ Star"; +"Stars.Transfer.Info.Stars_any" = "%@ Stars"; +"Stars.Transfer.Pay" = "Confirm and Pay"; +"Stars.Transfer.PurchasedTitle" = "Purchase Completed"; +"Stars.Transfer.PurchasedText" = "You acquired **%1$@** in **%2$@** for **%3$@**."; +"Stars.Transfer.Purchased.Stars_1" = "%@ Star"; +"Stars.Transfer.Purchased.Stars_any" = "%@ Stars"; + +"Stars.Transfer.Balance" = "Balance"; + "Settings.Stars" = "Your Stars"; diff --git a/submodules/HashtagSearchUI/Sources/HashtagSearchControllerNode.swift b/submodules/HashtagSearchUI/Sources/HashtagSearchControllerNode.swift index d18914e627..df4143f00b 100644 --- a/submodules/HashtagSearchUI/Sources/HashtagSearchControllerNode.swift +++ b/submodules/HashtagSearchUI/Sources/HashtagSearchControllerNode.swift @@ -64,9 +64,7 @@ final class HashtagSearchControllerNode: ASDisplayNode { } else { self.currentController = nil } - - self.isSearching.set(self.currentController?.searching.get() ?? .single(false)) - + let myChatContents = HashtagSearchGlobalChatContents(context: context, kind: .hashTagSearch, query: cleanHashtag, onlyMy: true) self.myChatContents = myChatContents self.myController = context.sharedContext.makeChatController(context: context, chatLocation: .customChatContents, subject: .customChatContents(contents: myChatContents), botStart: nil, mode: .standard(.default)) @@ -96,14 +94,20 @@ final class HashtagSearchControllerNode: ASDisplayNode { self.currentController?.displayNode.isHidden = true self.myController?.displayNode.isHidden = false self.globalController?.displayNode.isHidden = true + + self.isSearching.set(self.myChatContents?.searching ?? .single(false)) } else { if let _ = peer { self.currentController?.displayNode.isHidden = false self.myController?.displayNode.isHidden = true self.globalController?.displayNode.isHidden = true + + self.isSearching.set(self.currentController?.searching.get() ?? .single(false)) } else { self.myController?.displayNode.isHidden = false self.globalController?.displayNode.isHidden = true + + self.isSearching.set(self.myChatContents?.searching ?? .single(false)) } } diff --git a/submodules/TelegramUI/Components/Stars/StarsTransactionsScreen/Sources/StarsTransactionScreen.swift b/submodules/TelegramUI/Components/Stars/StarsTransactionsScreen/Sources/StarsTransactionScreen.swift index 584423ebb0..81da4e62d2 100644 --- a/submodules/TelegramUI/Components/Stars/StarsTransactionsScreen/Sources/StarsTransactionScreen.swift +++ b/submodules/TelegramUI/Components/Stars/StarsTransactionsScreen/Sources/StarsTransactionScreen.swift @@ -169,8 +169,8 @@ private final class StarsTransactionSheetContent: CombinedComponent { } else { descriptionText = "+ \(transaction.count) ⭐️" } - additionalText = "You can dispute this transaction [here]()." - buttonText = "OK" + additionalText = strings.Stars_Transaction_Terms + buttonText = strings.Common_OK transactionId = transaction.id date = transaction.date @@ -207,7 +207,6 @@ private final class StarsTransactionSheetContent: CombinedComponent { avatarSize: 90.0, color: UIColor(rgb: 0xf7ab04) ), -// PremiumStarComponent(isIntro: false, isVisible: true, hasIdleAnimations: true), availableSize: CGSize(width: context.availableSize.width, height: 200.0), transition: .immediate ) @@ -238,7 +237,7 @@ private final class StarsTransactionSheetContent: CombinedComponent { if let toPeer { tableItems.append(.init( id: "to", - title: strings.GiftLink_To, + title: strings.Stars_Transaction_Date, component: AnyComponent( Button( content: AnyComponent(PeerCellComponent(context: context.component.context, textColor: tableLinkColor, peer: toPeer)), @@ -257,7 +256,7 @@ private final class StarsTransactionSheetContent: CombinedComponent { tableItems.append(.init( id: "transaction", - title: "Transaction ID", + title: strings.Stars_Transaction_Id, component: AnyComponent( MultilineTextComponent( text: .plain(NSAttributedString(string: transactionId, font: Font.monospace(15.0), textColor: tableTextColor)), @@ -269,7 +268,7 @@ private final class StarsTransactionSheetContent: CombinedComponent { tableItems.append(.init( id: "date", - title: strings.GiftLink_Date, + title: strings.Stars_Transaction_Date, component: AnyComponent( MultilineTextComponent(text: .plain(NSAttributedString(string: stringForMediumDate(timestamp: date, strings: strings, dateTimeFormat: dateTimeFormat), font: tableFont, textColor: tableTextColor))) ) @@ -299,7 +298,8 @@ private final class StarsTransactionSheetContent: CombinedComponent { } }, tapAction: { attributes, _ in - + let presentationData = component.context.sharedContext.currentPresentationData.with { $0 } + component.context.sharedContext.openExternalUrl(context: component.context, urlContext: .generic, url: strings.Stars_Transaction_Terms_URL, forceExternal: true, presentationData: presentationData, navigationController: nil, dismissInput: {}) } ), availableSize: CGSize(width: context.availableSize.width - textSideInset * 2.0, height: context.availableSize.height), diff --git a/submodules/TelegramUI/Components/Stars/StarsTransactionsScreen/Sources/StarsTransactionsScreen.swift b/submodules/TelegramUI/Components/Stars/StarsTransactionsScreen/Sources/StarsTransactionsScreen.swift index 4522f76b66..248b1b8876 100644 --- a/submodules/TelegramUI/Components/Stars/StarsTransactionsScreen/Sources/StarsTransactionsScreen.swift +++ b/submodules/TelegramUI/Components/Stars/StarsTransactionsScreen/Sources/StarsTransactionsScreen.swift @@ -392,7 +392,7 @@ final class StarsTransactionsScreenComponent: Component { transition: .immediate, component: AnyComponent( MultilineTextComponent( - text: .plain(NSAttributedString(string: "Telegram Stars", font: Font.bold(28.0), textColor: environment.theme.list.itemPrimaryTextColor)), + text: .plain(NSAttributedString(string: environment.strings.Stars_Intro_Title, font: Font.bold(28.0), textColor: environment.theme.list.itemPrimaryTextColor)), horizontalAlignment: .center, truncationType: .end, maximumNumberOfLines: 1 @@ -415,8 +415,8 @@ final class StarsTransactionsScreenComponent: Component { let markdownAttributes = MarkdownAttributes(body: MarkdownAttributeSet(font: textFont, textColor: textColor), bold: MarkdownAttributeSet(font: boldTextFont, textColor: textColor), link: MarkdownAttributeSet(font: textFont, textColor: linkColor), linkAttribute: { contents in return (TelegramTextAttributes.URL, contents) }) - let balanceAttributedString = parseMarkdownIntoAttributedString(" Balance\n > **\(starsState?.balance ?? 0)**", attributes: markdownAttributes, textAlignment: .right).mutableCopy() as! NSMutableAttributedString - if let range = balanceAttributedString.string.range(of: ">"), let chevronImage = generateTintedImage(image: UIImage(bundleImageName: "Item List/PremiumIcon"), color: UIColor(rgb: 0xf09903)) { + let balanceAttributedString = parseMarkdownIntoAttributedString(" \(environment.strings.Stars_Intro_Balance)\n # **\(self.starsState?.balance ?? 0)**", attributes: markdownAttributes, textAlignment: .right).mutableCopy() as! NSMutableAttributedString + if let range = balanceAttributedString.string.range(of: "#"), let chevronImage = generateTintedImage(image: UIImage(bundleImageName: "Item List/PremiumIcon"), color: UIColor(rgb: 0xf09903)) { balanceAttributedString.addAttribute(.attachment, value: chevronImage, range: NSRange(range, in: balanceAttributedString.string)) balanceAttributedString.addAttribute(.foregroundColor, value: UIColor(rgb: 0xf09903), range: NSRange(range, in: balanceAttributedString.string)) balanceAttributedString.addAttribute(.baselineOffset, value: 2.0, range: NSRange(range, in: balanceAttributedString.string)) @@ -446,7 +446,7 @@ final class StarsTransactionsScreenComponent: Component { transition: .immediate, component: AnyComponent( BalancedTextComponent( - text: .plain(NSAttributedString(string: "Buy Stars to unlock content and services in miniapps on Telegram.", font: Font.regular(15.0), textColor: environment.theme.list.itemPrimaryTextColor)), + text: .plain(NSAttributedString(string: environment.strings.Stars_Intro_Description, font: Font.regular(15.0), textColor: environment.theme.list.itemPrimaryTextColor)), horizontalAlignment: .center, maximumNumberOfLines: 0, lineSpacing: 0.2 @@ -501,7 +501,6 @@ final class StarsTransactionsScreenComponent: Component { contentHeight += balanceSize.height contentHeight += 44.0 - //TODO: localize let transactions = self.starsState?.transactions ?? [] let allItems = StarsTransactionsListPanelComponent.Items( items: transactions.map { StarsTransactionsListPanelComponent.Item(transaction: $0) } @@ -517,7 +516,7 @@ final class StarsTransactionsScreenComponent: Component { if !allItems.items.isEmpty { panelItems.append(StarsTransactionsPanelContainerComponent.Item( id: "all", - title: "All Transactions", + title: environment.strings.Stars_Intro_AllTransactions, panel: AnyComponent(StarsTransactionsListPanelComponent( context: component.context, items: allItems, @@ -530,7 +529,7 @@ final class StarsTransactionsScreenComponent: Component { if !outgoingItems.items.isEmpty { panelItems.append(StarsTransactionsPanelContainerComponent.Item( id: "incoming", - title: "Incoming", + title: environment.strings.Stars_Intro_Incoming, panel: AnyComponent(StarsTransactionsListPanelComponent( context: component.context, items: incomingItems, @@ -542,7 +541,7 @@ final class StarsTransactionsScreenComponent: Component { panelItems.append(StarsTransactionsPanelContainerComponent.Item( id: "outgoing", - title: "Outgoing", + title: environment.strings.Stars_Intro_Outgoing, panel: AnyComponent(StarsTransactionsListPanelComponent( context: component.context, items: outgoingItems, diff --git a/submodules/TelegramUI/Components/Stars/StarsTransferScreen/Sources/StarsTransferScreen.swift b/submodules/TelegramUI/Components/Stars/StarsTransferScreen/Sources/StarsTransferScreen.swift index f09f5e029c..d5a25d275b 100644 --- a/submodules/TelegramUI/Components/Stars/StarsTransferScreen/Sources/StarsTransferScreen.swift +++ b/submodules/TelegramUI/Components/Stars/StarsTransferScreen/Sources/StarsTransferScreen.swift @@ -156,7 +156,7 @@ private final class SheetContent: CombinedComponent { let presentationData = component.context.sharedContext.currentPresentationData.with { $0 } let theme = presentationData.theme -// let strings = presentationData.strings + let strings = presentationData.strings // let sideInset: CGFloat = 16.0 + environment.safeInsets.left @@ -216,10 +216,9 @@ private final class SheetContent: CombinedComponent { let constrainedTitleWidth = context.availableSize.width - 16.0 * 2.0 - contentSize.height += 130.0 let title = title.update( - component: Text(text: "Confirm Your Purchase", font: Font.bold(24.0), color: theme.list.itemPrimaryTextColor), + component: Text(text: strings.Stars_Transfer_Title, font: Font.bold(24.0), color: theme.list.itemPrimaryTextColor), availableSize: CGSize(width: constrainedTitleWidth, height: context.availableSize.height), transition: .immediate ) @@ -240,7 +239,14 @@ private final class SheetContent: CombinedComponent { let amount = component.invoice.totalAmount let text = text.update( component: BalancedTextComponent( - text: .markdown(text: "Do you want to buy **\(component.invoice.title)** in **\(state.peer?.compactDisplayTitle ?? "")** for **\(amount) Stars**?", attributes: markdownAttributes), + text: .markdown( + text: strings.Stars_Transfer_Info( + component.invoice.title, + state.peer?.compactDisplayTitle ?? "", + strings.Stars_Transfer_Info_Stars(Int32(amount)) + ).string, + attributes: markdownAttributes + ), horizontalAlignment: .center, maximumNumberOfLines: 0, lineSpacing: 0.2 @@ -258,7 +264,7 @@ private final class SheetContent: CombinedComponent { state.cachedChevronImage = (generateTintedImage(image: UIImage(bundleImageName: "Premium/Stars/Star"), color: UIColor(rgb: 0xf09903))!, theme) } - let balanceAttributedString = parseMarkdownIntoAttributedString("Balance\n # **\(state.balance ?? 0)**", attributes: markdownAttributes).mutableCopy() as! NSMutableAttributedString + let balanceAttributedString = parseMarkdownIntoAttributedString("\(strings.Stars_Transfer_Balance)\n # **\(state.balance ?? 0)**", attributes: markdownAttributes).mutableCopy() as! NSMutableAttributedString if let range = balanceAttributedString.string.range(of: "#"), let chevronImage = state.cachedChevronImage?.0 { balanceAttributedString.addAttribute(.attachment, value: chevronImage, range: NSRange(range, in: balanceAttributedString.string)) balanceAttributedString.addAttribute(.foregroundColor, value: UIColor(rgb: 0xf09903), range: NSRange(range, in: balanceAttributedString.string)) @@ -281,8 +287,8 @@ private final class SheetContent: CombinedComponent { state.cachedStarImage = (generateTintedImage(image: UIImage(bundleImageName: "Item List/PremiumIcon"), color: .white)!, theme) } - let buttonAttributedString = NSMutableAttributedString(string: "Confirm and Pay > \(amount)", font: Font.semibold(17.0), textColor: .white, paragraphAlignment: .center) - if let range = buttonAttributedString.string.range(of: ">"), let starImage = state.cachedStarImage?.0 { + let buttonAttributedString = NSMutableAttributedString(string: "\(strings.Stars_Transfer_Pay) # \(amount)", font: Font.semibold(17.0), textColor: .white, paragraphAlignment: .center) + if let range = buttonAttributedString.string.range(of: "#"), let starImage = state.cachedStarImage?.0 { buttonAttributedString.addAttribute(.attachment, value: starImage, range: NSRange(range, in: buttonAttributedString.string)) buttonAttributedString.addAttribute(.foregroundColor, value: UIColor(rgb: 0xffffff), range: NSRange(range, in: buttonAttributedString.string)) buttonAttributedString.addAttribute(.baselineOffset, value: 1.0, range: NSRange(range, in: buttonAttributedString.string)) @@ -323,7 +329,13 @@ private final class SheetContent: CombinedComponent { let presentationData = accountContext.sharedContext.currentPresentationData.with { $0 } let resultController = UndoOverlayController( presentationData: presentationData, - content: .image(image: UIImage(bundleImageName: "Premium/Stars/Star")!, title: "Purchase Completed", text: "You acquired **\(invoice.title)** in **\(botTitle)** for **\(invoice.totalAmount) Stars**.", round: false, undoText: nil), + content: .image( + image: UIImage(bundleImageName: "Premium/Stars/Star")!, + title: presentationData.strings.Stars_Transfer_PurchasedTitle, + text: presentationData.strings.Stars_Transfer_PurchasedText(invoice.title, botTitle, presentationData.strings.Stars_Transfer_Purchased_Stars(Int32(invoice.totalAmount))).string, + round: false, + undoText: nil + ), elevatedLayout: true, action: { _ in return true}) controller?.present(resultController, in: .window(.root))