diff --git a/submodules/AccountContext/Sources/ChatController.swift b/submodules/AccountContext/Sources/ChatController.swift index 0893dbe865..b935369a68 100644 --- a/submodules/AccountContext/Sources/ChatController.swift +++ b/submodules/AccountContext/Sources/ChatController.swift @@ -1031,6 +1031,8 @@ public protocol ChatController: ViewController { func performScrollToTop() -> Bool func transferScrollingVelocity(_ velocity: CGFloat) func updateIsScrollingLockedAtTop(isScrollingLockedAtTop: Bool) + + func playShakeAnimation() } public protocol ChatMessagePreviewItemNode: AnyObject { diff --git a/submodules/StatisticsUI/Sources/TransactionInfoScreen.swift b/submodules/StatisticsUI/Sources/TransactionInfoScreen.swift index 75831f8185..6479c9b7f2 100644 --- a/submodules/StatisticsUI/Sources/TransactionInfoScreen.swift +++ b/submodules/StatisticsUI/Sources/TransactionInfoScreen.swift @@ -147,7 +147,7 @@ private final class SheetContent: CombinedComponent { showPeer = true case let .withdrawal(status, amount, date, provider, _, transactionUrl): labelColor = theme.list.itemDestructiveColor - amountString = amountAttributedString(formatBalanceText(amount, decimalSeparator: dateTimeFormat.decimalSeparator), integralFont: integralFont, fractionalFont: fractionalFont, color: labelColor).mutableCopy() as! NSMutableAttributedString + amountString = amountAttributedString(formatBalanceText(amount, decimalSeparator: dateTimeFormat.groupingSeparator), integralFont: integralFont, fractionalFont: fractionalFont, color: labelColor).mutableCopy() as! NSMutableAttributedString dateString = stringForFullDate(timestamp: date, strings: strings, dateTimeFormat: dateTimeFormat) switch status { diff --git a/submodules/TelegramUI/Components/PeerInfo/PeerInfoScreen/Sources/PeerInfoScreen.swift b/submodules/TelegramUI/Components/PeerInfo/PeerInfoScreen/Sources/PeerInfoScreen.swift index 2bf7e916c0..2e0e110acd 100644 --- a/submodules/TelegramUI/Components/PeerInfo/PeerInfoScreen/Sources/PeerInfoScreen.swift +++ b/submodules/TelegramUI/Components/PeerInfo/PeerInfoScreen/Sources/PeerInfoScreen.swift @@ -982,7 +982,7 @@ private func settingsItems(data: PeerInfoScreenData?, context: AccountContext, p if let starsState = data.starsState { let balanceText: String if starsState.balance > 0 { - balanceText = "\(starsState.balance)" + balanceText = presentationStringsFormattedNumber(Int32(starsState.balance), presentationData.dateTimeFormat.groupingSeparator) } else { balanceText = "" } diff --git a/submodules/TelegramUI/Components/Stars/StarsPurchaseScreen/Sources/StarsPurchaseScreen.swift b/submodules/TelegramUI/Components/Stars/StarsPurchaseScreen/Sources/StarsPurchaseScreen.swift index b1613b5e1f..7576a44836 100644 --- a/submodules/TelegramUI/Components/Stars/StarsPurchaseScreen/Sources/StarsPurchaseScreen.swift +++ b/submodules/TelegramUI/Components/Stars/StarsPurchaseScreen/Sources/StarsPurchaseScreen.swift @@ -787,7 +787,7 @@ private final class StarsPurchaseScreenComponent: CombinedComponent { let balanceValue = balanceValue.update( component: MultilineTextComponent( text: .plain(NSAttributedString( - string: presentationStringsFormattedNumber(Int32(state.starsState?.balance ?? 0), environment.dateTimeFormat.decimalSeparator), + string: presentationStringsFormattedNumber(Int32(state.starsState?.balance ?? 0), environment.dateTimeFormat.groupingSeparator), font: Font.semibold(14.0), textColor: environment.theme.actionSheet.primaryTextColor )), diff --git a/submodules/TelegramUI/Components/Stars/StarsTransactionsScreen/Sources/StarsTransactionScreen.swift b/submodules/TelegramUI/Components/Stars/StarsTransactionsScreen/Sources/StarsTransactionScreen.swift index a9e8e3b5c7..249f5fbca8 100644 --- a/submodules/TelegramUI/Components/Stars/StarsTransactionsScreen/Sources/StarsTransactionScreen.swift +++ b/submodules/TelegramUI/Components/Stars/StarsTransactionsScreen/Sources/StarsTransactionScreen.swift @@ -127,11 +127,12 @@ private final class StarsTransactionSheetContent: CombinedComponent { return { context in let environment = context.environment[ViewControllerComponentContainer.Environment.self].value + let controller = environment.controller + let component = context.component let theme = environment.theme let strings = environment.strings let dateTimeFormat = environment.dateTimeFormat - let accountContext = context.component.context let state = context.state let subject = component.subject @@ -171,7 +172,7 @@ private final class StarsTransactionSheetContent: CombinedComponent { let toPeer: EnginePeer? let photo: TelegramMediaWebFile? - let gloss = false + var delayedCloseOnOpenPeer = true switch subject { case let .transaction(transaction): switch transaction.peer { @@ -218,9 +219,10 @@ private final class StarsTransactionSheetContent: CombinedComponent { toPeer = nil } photo = receipt.invoiceMedia.photo + delayedCloseOnOpenPeer = false } - let formattedAmount = presentationStringsFormattedNumber(abs(Int32(count)), dateTimeFormat.decimalSeparator) + let formattedAmount = presentationStringsFormattedNumber(abs(Int32(count)), dateTimeFormat.groupingSeparator) if count < 0 { amountText = "- \(formattedAmount)" } else { @@ -300,11 +302,16 @@ private final class StarsTransactionSheetContent: CombinedComponent { ) ), action: { - if toPeer.id != accountContext.account.peerId { + if delayedCloseOnOpenPeer { component.openPeer(toPeer) Queue.mainQueue().after(1.0, { component.cancel(false) }) + } else { + if let controller = controller() as? StarsTransactionScreen, let navigationController = controller.navigationController, let chatController = navigationController.viewControllers.first(where: { $0 is ChatController }) as? ChatController { + chatController.playShakeAnimation() + } + component.cancel(true) } } ) @@ -325,11 +332,15 @@ private final class StarsTransactionSheetContent: CombinedComponent { id: "transaction", title: strings.Stars_Transaction_Id, component: AnyComponent( - TransactionCellComponent( - textColor: tableTextColor, - accentColor: tableLinkColor, - transactionId: transactionId, - copy: { + Button( + content: AnyComponent( + TransactionCellComponent( + textColor: tableTextColor, + accentColor: tableLinkColor, + transactionId: transactionId + ) + ), + action: { component.copyTransactionId() } ) @@ -393,7 +404,7 @@ private final class StarsTransactionSheetContent: CombinedComponent { fontSize: 17.0, height: 50.0, cornerRadius: 10.0, - gloss: gloss, + gloss: false, iconName: nil, animationName: nil, iconPosition: .left, @@ -656,7 +667,7 @@ public class StarsTransactionScreen: ViewControllerComponentContainer { guard let peer else { return } - context.sharedContext.navigateToChatController(NavigateToChatControllerParams(navigationController: navigationController, chatController: nil, context: context, chatLocation: .peer(peer), subject: nil, botStart: nil, updateTextInputState: nil, keepStack: .always, useExisting: false, purposefulAction: nil, scrollToEndIfExists: false, activateMessageSearch: nil, animated: true)) + context.sharedContext.navigateToChatController(NavigateToChatControllerParams(navigationController: navigationController, chatController: nil, context: context, chatLocation: .peer(peer), subject: nil, botStart: nil, updateTextInputState: nil, keepStack: .always, useExisting: true, purposefulAction: nil, scrollToEndIfExists: false, activateMessageSearch: nil, animated: true)) }) } @@ -1029,13 +1040,11 @@ private final class TransactionCellComponent: Component { let textColor: UIColor let accentColor: UIColor let transactionId: String - let copy: () -> Void - - init(textColor: UIColor, accentColor: UIColor, transactionId: String, copy: @escaping () -> Void) { + + init(textColor: UIColor, accentColor: UIColor, transactionId: String) { self.textColor = textColor self.accentColor = accentColor self.transactionId = transactionId - self.copy = copy } static func ==(lhs: TransactionCellComponent, rhs: TransactionCellComponent) -> Bool { @@ -1075,14 +1084,7 @@ private final class TransactionCellComponent: Component { let buttonSize = self.button.update( transition: .immediate, component: AnyComponent( - Button( - content: AnyComponent( - BundleIconComponent(name: "Chat/Context Menu/Copy", tintColor: component.accentColor) - ), - action: { - component.copy() - } - ) + BundleIconComponent(name: "Chat/Context Menu/Copy", tintColor: component.accentColor) ), environment: {}, containerSize: CGSize(width: availableSize.width, height: availableSize.height) diff --git a/submodules/TelegramUI/Components/Stars/StarsTransactionsScreen/Sources/StarsTransactionsListPanelComponent.swift b/submodules/TelegramUI/Components/Stars/StarsTransactionsScreen/Sources/StarsTransactionsListPanelComponent.swift index a484bfaab4..d080c4e5da 100644 --- a/submodules/TelegramUI/Components/Stars/StarsTransactionsScreen/Sources/StarsTransactionsListPanelComponent.swift +++ b/submodules/TelegramUI/Components/Stars/StarsTransactionsScreen/Sources/StarsTransactionsListPanelComponent.swift @@ -237,7 +237,7 @@ final class StarsTransactionsListPanelComponent: Component { let itemLabel: NSAttributedString let labelString: String - let formattedLabel = presentationStringsFormattedNumber(abs(Int32(item.transaction.count)), environment.dateTimeFormat.decimalSeparator) + let formattedLabel = presentationStringsFormattedNumber(abs(Int32(item.transaction.count)), environment.dateTimeFormat.groupingSeparator) if item.transaction.count < 0 { labelString = "- \(formattedLabel)" } else { @@ -475,8 +475,7 @@ private final class AvatarComponent: Component { super.init(frame: frame) - self.iconView.contentMode = .center - self.iconView.image = UIImage(bundleImageName: "Premium/Stars/Apple") + self.iconView.contentMode = .scaleAspectFit self.addSubnode(self.avatarNode) self.addSubview(self.backgroundView) @@ -492,8 +491,8 @@ private final class AvatarComponent: Component { self.state = state let size = CGSize(width: 40.0, height: 40.0) - - let gradientImage = generateGradientFilledCircleImage(diameter: size.width, colors: [UIColor(rgb: 0x2a9ef1).cgColor, UIColor(rgb: 0x72d5fd).cgColor], direction: .mirroredDiagonal) + var iconInset: CGFloat = 3.0 + var iconOffset: CGFloat = 0.0 switch component.peer { case let .peer(peer): @@ -507,34 +506,73 @@ private final class AvatarComponent: Component { self.iconView.isHidden = true self.avatarNode.isHidden = false case .appStore: - self.backgroundView.image = gradientImage + self.backgroundView.image = generateGradientFilledCircleImage( + diameter: size.width, + colors: [ + UIColor(rgb: 0x2a9ef1).cgColor, + UIColor(rgb: 0x72d5fd).cgColor + ], + direction: .mirroredDiagonal + ) self.backgroundView.isHidden = false self.iconView.isHidden = false self.avatarNode.isHidden = true + self.iconView.image = UIImage(bundleImageName: "Premium/Stars/Apple") case .playMarket: - self.backgroundView.image = gradientImage + self.backgroundView.image = generateGradientFilledCircleImage( + diameter: size.width, + colors: [ + UIColor(rgb: 0x54cb68).cgColor, + UIColor(rgb: 0xa0de7e).cgColor + ], + direction: .mirroredDiagonal + ) self.backgroundView.isHidden = false self.iconView.isHidden = false self.avatarNode.isHidden = true + self.iconView.image = UIImage(bundleImageName: "Premium/Stars/Google") case .fragment: - self.backgroundView.image = gradientImage + self.backgroundView.image = generateFilledCircleImage(diameter: size.width, color: UIColor(rgb: 0x1b1f24)) self.backgroundView.isHidden = false self.iconView.isHidden = false self.avatarNode.isHidden = true + self.iconView.image = UIImage(bundleImageName: "Premium/Stars/Fragment") + iconOffset = 2.0 case .premiumBot: - self.backgroundView.image = gradientImage + iconInset = 7.0 + self.backgroundView.image = generateGradientFilledCircleImage( + diameter: size.width, + colors: [ + UIColor(rgb: 0x6b93ff).cgColor, + UIColor(rgb: 0x6b93ff).cgColor, + UIColor(rgb: 0x8d77ff).cgColor, + UIColor(rgb: 0xb56eec).cgColor, + UIColor(rgb: 0xb56eec).cgColor + ], + direction: .mirroredDiagonal + ) self.backgroundView.isHidden = false self.iconView.isHidden = false self.avatarNode.isHidden = true + self.iconView.image = generateTintedImage(image: UIImage(bundleImageName: "Chat/Input/Media/EntityInputPremiumIcon"), color: .white) case .unsupported: - self.backgroundView.image = gradientImage + iconInset = 7.0 + self.backgroundView.image = generateGradientFilledCircleImage( + diameter: size.width, + colors: [ + UIColor(rgb: 0xb1b1b1).cgColor, + UIColor(rgb: 0xcdcdcd).cgColor + ], + direction: .mirroredDiagonal + ) self.backgroundView.isHidden = false self.iconView.isHidden = false self.avatarNode.isHidden = true + self.iconView.image = generateTintedImage(image: UIImage(bundleImageName: "Chat/Input/Media/EntityInputPremiumIcon"), color: .white) } self.avatarNode.frame = CGRect(origin: .zero, size: size) - self.iconView.frame = CGRect(origin: .zero, size: size) + self.iconView.frame = CGRect(origin: .zero, size: size).insetBy(dx: iconInset, dy: iconInset).offsetBy(dx: 0.0, dy: iconOffset) self.backgroundView.frame = CGRect(origin: .zero, size: size) return size diff --git a/submodules/TelegramUI/Components/Stars/StarsTransactionsScreen/Sources/StarsTransactionsScreen.swift b/submodules/TelegramUI/Components/Stars/StarsTransactionsScreen/Sources/StarsTransactionsScreen.swift index 100c8fcb75..d28c3f34ce 100644 --- a/submodules/TelegramUI/Components/Stars/StarsTransactionsScreen/Sources/StarsTransactionsScreen.swift +++ b/submodules/TelegramUI/Components/Stars/StarsTransactionsScreen/Sources/StarsTransactionsScreen.swift @@ -437,7 +437,7 @@ final class StarsTransactionsScreenComponent: Component { transition: .immediate, component: AnyComponent(MultilineTextComponent( text: .plain(NSAttributedString( - string: presentationStringsFormattedNumber(Int32(self.starsState?.balance ?? 0), environment.dateTimeFormat.decimalSeparator), + string: presentationStringsFormattedNumber(Int32(self.starsState?.balance ?? 0), environment.dateTimeFormat.groupingSeparator), font: Font.semibold(14.0), textColor: environment.theme.actionSheet.primaryTextColor )), diff --git a/submodules/TelegramUI/Components/Stars/StarsTransferScreen/Sources/StarsTransferScreen.swift b/submodules/TelegramUI/Components/Stars/StarsTransferScreen/Sources/StarsTransferScreen.swift index bb7982eae8..027842be37 100644 --- a/submodules/TelegramUI/Components/Stars/StarsTransferScreen/Sources/StarsTransferScreen.swift +++ b/submodules/TelegramUI/Components/Stars/StarsTransferScreen/Sources/StarsTransferScreen.swift @@ -331,7 +331,7 @@ private final class SheetContent: CombinedComponent { let balanceValue = balanceValue.update( component: MultilineTextComponent( text: .plain(NSAttributedString( - string: presentationStringsFormattedNumber(Int32(state.balance ?? 0), environment.dateTimeFormat.decimalSeparator), + string: presentationStringsFormattedNumber(Int32(state.balance ?? 0), environment.dateTimeFormat.groupingSeparator), font: Font.semibold(16.0), textColor: textColor )), diff --git a/submodules/TelegramUI/Images.xcassets/Premium/Stars/Android.imageset/Contents.json b/submodules/TelegramUI/Images.xcassets/Premium/Stars/Google.imageset/Contents.json similarity index 100% rename from submodules/TelegramUI/Images.xcassets/Premium/Stars/Android.imageset/Contents.json rename to submodules/TelegramUI/Images.xcassets/Premium/Stars/Google.imageset/Contents.json diff --git a/submodules/TelegramUI/Images.xcassets/Premium/Stars/Android.imageset/android.pdf b/submodules/TelegramUI/Images.xcassets/Premium/Stars/Google.imageset/android.pdf similarity index 100% rename from submodules/TelegramUI/Images.xcassets/Premium/Stars/Android.imageset/android.pdf rename to submodules/TelegramUI/Images.xcassets/Premium/Stars/Google.imageset/android.pdf diff --git a/submodules/TelegramUI/Images.xcassets/Premium/Stars/TopUp.imageset/Contents.json b/submodules/TelegramUI/Images.xcassets/Premium/Stars/TopUp.imageset/Contents.json deleted file mode 100644 index d9b19f790f..0000000000 --- a/submodules/TelegramUI/Images.xcassets/Premium/Stars/TopUp.imageset/Contents.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "images" : [ - { - "filename" : "topbalance.pdf", - "idiom" : "universal" - } - ], - "info" : { - "author" : "xcode", - "version" : 1 - } -} diff --git a/submodules/TelegramUI/Images.xcassets/Premium/Stars/TopUp.imageset/topbalance.pdf b/submodules/TelegramUI/Images.xcassets/Premium/Stars/TopUp.imageset/topbalance.pdf deleted file mode 100644 index 46857c5e60..0000000000 Binary files a/submodules/TelegramUI/Images.xcassets/Premium/Stars/TopUp.imageset/topbalance.pdf and /dev/null differ