From d09a563200398808b485eea7ca71c35f760d168b Mon Sep 17 00:00:00 2001 From: Ilya Laktyushin Date: Wed, 30 Apr 2025 16:55:02 +0400 Subject: [PATCH] Various fixes --- .../Telegram-iOS/en.lproj/Localizable.strings | 11 ++++--- .../Sources/ContactsPeerItem.swift | 4 +++ .../Sources/AvatarEditorScreen.swift | 29 +++++++++++++++---- .../Sources/AccountFreezeInfoScreen.swift | 28 ++++++++++++++++-- 4 files changed, 61 insertions(+), 11 deletions(-) diff --git a/Telegram/Telegram-iOS/en.lproj/Localizable.strings b/Telegram/Telegram-iOS/en.lproj/Localizable.strings index b806c2063c..d2f419b70a 100644 --- a/Telegram/Telegram-iOS/en.lproj/Localizable.strings +++ b/Telegram/Telegram-iOS/en.lproj/Localizable.strings @@ -14291,10 +14291,13 @@ Sorry for the inconvenience."; "MediaPicker.CreateStory_any" = "Create %@ Stories"; "MediaPicker.CombineIntoCollage" = "Combine into Collage"; -"Gift.Resale.Unavailable.Title" = "Resell Gift"; -"Gift.Resale.Unavailable.Text" = "Sorry, you can't list this gift yet.\n\Reselling will be available on %@."; +"Gift.Resale.Unavailable.Title" = "Try Later"; +"Gift.Resale.Unavailable.Text" = "You will be able to resell this gift on %@."; -"Gift.Transfer.Unavailable.Title" = "Transfer Gift"; -"Gift.Transfer.Unavailable.Text" = "Sorry, you can't transfer this gift yet.\n\Transferring will be available on %@."; +"Gift.Transfer.Unavailable.Title" = "Try Later"; +"Gift.Transfer.Unavailable.Text" = "You will be able to transfer this gift on %@."; "Premium.CreateMultipleStories" = "Create Multiple Stories"; + +"FrozenAccount.Violation.TextNew" = "Your account was frozen for breaking Telegram's [Terms and Conditions]()."; +"FrozenAccount.Violation.TextNew_URL" = "https://telegram.org/tos"; diff --git a/submodules/ContactsPeerItem/Sources/ContactsPeerItem.swift b/submodules/ContactsPeerItem/Sources/ContactsPeerItem.swift index 79ce46c3fc..dba6b75463 100644 --- a/submodules/ContactsPeerItem/Sources/ContactsPeerItem.swift +++ b/submodules/ContactsPeerItem/Sources/ContactsPeerItem.swift @@ -1106,6 +1106,10 @@ public class ContactsPeerItemNode: ItemListRevealOptionsItemNode { } } + if let rightLabelTextLayoutAndApply { + additionalTitleInset += rightLabelTextLayoutAndApply.0.size.width + 36.0 + } + let (titleLayout, titleApply) = makeTitleLayout(TextNodeLayoutArguments(attributedString: titleAttributedString, backgroundColor: nil, maximumNumberOfLines: 1, truncationType: .end, constrainedSize: CGSize(width: max(0.0, params.width - leftInset - rightInset - additionalTitleInset), height: CGFloat.infinity), alignment: .natural, cutout: nil, insets: UIEdgeInsets())) var maxStatusWidth: CGFloat = params.width - leftInset - rightInset - badgeSize diff --git a/submodules/TelegramUI/Components/AvatarEditorScreen/Sources/AvatarEditorScreen.swift b/submodules/TelegramUI/Components/AvatarEditorScreen/Sources/AvatarEditorScreen.swift index 27b026e833..bcce0831af 100644 --- a/submodules/TelegramUI/Components/AvatarEditorScreen/Sources/AvatarEditorScreen.swift +++ b/submodules/TelegramUI/Components/AvatarEditorScreen/Sources/AvatarEditorScreen.swift @@ -1331,11 +1331,7 @@ final class AvatarEditorScreenComponent: Component { isEnabled: true, displaysProgress: false, action: { [weak self] in - if isLocked { - self?.presentPremiumToast() - } else { - self?.complete() - } + self?.complete() } ) ), @@ -1389,11 +1385,34 @@ final class AvatarEditorScreenComponent: Component { parentController.present(controller, in: .window(.root)) } + private func isPremiumRequired() -> Bool { + guard let component = self.component, let state = self.state else { + return false + } + if component.peerType != .suggest, !component.context.isPremium { + if state.selectedBackground.isPremium { + return true + } + if let selectedFile = state.selectedFile { + if selectedFile.isSticker { + return true + } + } + } + return false + } + private let queue = Queue() func complete() { guard let state = self.state, let file = state.selectedFile, let controller = self.controller?() else { return } + + if self.isPremiumRequired() { + self.presentPremiumToast() + return + } + let context = controller.context let _ = context.animationCache.getFirstFrame(queue: self.queue, sourceId: file.resource.id.stringRepresentation, size: CGSize(width: 640.0, height: 640.0), fetch: animationCacheFetchFile(context: context, userLocation: .other, userContentType: .sticker, resource: .media(media: .standalone(media: file), resource: file.resource), type: AnimationCacheAnimationType(file: file), keyframeOnly: true, customColor: nil), completion: { result in guard let item = result.item else { diff --git a/submodules/TelegramUI/Components/Settings/AccountFreezeInfoScreen/Sources/AccountFreezeInfoScreen.swift b/submodules/TelegramUI/Components/Settings/AccountFreezeInfoScreen/Sources/AccountFreezeInfoScreen.swift index e6b664a823..480ec2ea73 100644 --- a/submodules/TelegramUI/Components/Settings/AccountFreezeInfoScreen/Sources/AccountFreezeInfoScreen.swift +++ b/submodules/TelegramUI/Components/Settings/AccountFreezeInfoScreen/Sources/AccountFreezeInfoScreen.swift @@ -22,17 +22,20 @@ private final class SheetContent: CombinedComponent { let context: AccountContext let configuration: AccountFreezeConfiguration + let openTerms: () -> Void let submitAppeal: () -> Void let dismiss: () -> Void init( context: AccountContext, configuration: AccountFreezeConfiguration, + openTerms: @escaping () -> Void, submitAppeal: @escaping () -> Void, dismiss: @escaping () -> Void ) { self.context = context self.configuration = configuration + self.openTerms = openTerms self.submitAppeal = submitAppeal self.dismiss = dismiss } @@ -132,10 +135,14 @@ private final class SheetContent: CombinedComponent { component: AnyComponent(ParagraphComponent( title: strings.FrozenAccount_Violation_Title, titleColor: textColor, - text: strings.FrozenAccount_Violation_Text, + text: strings.FrozenAccount_Violation_TextNew, textColor: secondaryTextColor, iconName: "Account Freeze/Violation", - iconColor: linkColor + iconColor: linkColor, + action: { + component.openTerms() + component.dismiss() + } )) ) ) @@ -257,15 +264,18 @@ private final class SheetContainerComponent: CombinedComponent { let context: AccountContext let configuration: AccountFreezeConfiguration + let openTerms: () -> Void let submitAppeal: () -> Void init( context: AccountContext, configuration: AccountFreezeConfiguration, + openTerms: @escaping () -> Void, submitAppeal: @escaping () -> Void ) { self.context = context self.configuration = configuration + self.openTerms = openTerms self.submitAppeal = submitAppeal } @@ -292,6 +302,7 @@ private final class SheetContainerComponent: CombinedComponent { content: AnyComponent(SheetContent( context: context.component.context, configuration: context.component.configuration, + openTerms: context.component.openTerms, submitAppeal: context.component.submitAppeal, dismiss: { animateOut.invoke(Action { _ in @@ -367,12 +378,16 @@ public final class AccountFreezeInfoScreen: ViewControllerComponentContainer { self.context = context let configuration = AccountFreezeConfiguration.with(appConfiguration: context.currentAppConfiguration.with { $0 }) + var openTermsImpl: (() -> Void)? var submitAppealImpl: (() -> Void)? super.init( context: context, component: SheetContainerComponent( context: context, configuration: configuration, + openTerms: { + openTermsImpl?() + }, submitAppeal: { submitAppealImpl?() } @@ -384,6 +399,15 @@ public final class AccountFreezeInfoScreen: ViewControllerComponentContainer { self.navigationPresentation = .flatModal + openTermsImpl = { [weak self] in + guard let self, let navigationController = self.navigationController as? NavigationController else { + return + } + let presentationData = context.sharedContext.currentPresentationData.with { $0 } + Queue.mainQueue().after(0.4) { + context.sharedContext.openExternalUrl(context: context, urlContext: .generic, url: presentationData.strings.FrozenAccount_Violation_TextNew_URL, forceExternal: false, presentationData: presentationData, navigationController: navigationController, dismissInput: {}) + } + } submitAppealImpl = { [weak self] in guard let self, let navigationController = self.navigationController as? NavigationController, let url = configuration.freezeAppealUrl else { return