Various fixes

This commit is contained in:
Ilya Laktyushin 2025-04-30 16:55:02 +04:00
parent fb853d50b9
commit d09a563200
4 changed files with 61 additions and 11 deletions

View File

@ -14291,10 +14291,13 @@ Sorry for the inconvenience.";
"MediaPicker.CreateStory_any" = "Create %@ Stories"; "MediaPicker.CreateStory_any" = "Create %@ Stories";
"MediaPicker.CombineIntoCollage" = "Combine into Collage"; "MediaPicker.CombineIntoCollage" = "Combine into Collage";
"Gift.Resale.Unavailable.Title" = "Resell Gift"; "Gift.Resale.Unavailable.Title" = "Try Later";
"Gift.Resale.Unavailable.Text" = "Sorry, you can't list this gift yet.\n\Reselling will be available on %@."; "Gift.Resale.Unavailable.Text" = "You will be able to resell this gift on %@.";
"Gift.Transfer.Unavailable.Title" = "Transfer Gift"; "Gift.Transfer.Unavailable.Title" = "Try Later";
"Gift.Transfer.Unavailable.Text" = "Sorry, you can't transfer this gift yet.\n\Transferring will be available on %@."; "Gift.Transfer.Unavailable.Text" = "You will be able to transfer this gift on %@.";
"Premium.CreateMultipleStories" = "Create Multiple Stories"; "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";

View File

@ -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())) 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 var maxStatusWidth: CGFloat = params.width - leftInset - rightInset - badgeSize

View File

@ -1331,11 +1331,7 @@ final class AvatarEditorScreenComponent: Component {
isEnabled: true, isEnabled: true,
displaysProgress: false, displaysProgress: false,
action: { [weak self] in action: { [weak self] in
if isLocked { self?.complete()
self?.presentPremiumToast()
} else {
self?.complete()
}
} }
) )
), ),
@ -1389,11 +1385,34 @@ final class AvatarEditorScreenComponent: Component {
parentController.present(controller, in: .window(.root)) 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() private let queue = Queue()
func complete() { func complete() {
guard let state = self.state, let file = state.selectedFile, let controller = self.controller?() else { guard let state = self.state, let file = state.selectedFile, let controller = self.controller?() else {
return return
} }
if self.isPremiumRequired() {
self.presentPremiumToast()
return
}
let context = controller.context 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 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 { guard let item = result.item else {

View File

@ -22,17 +22,20 @@ private final class SheetContent: CombinedComponent {
let context: AccountContext let context: AccountContext
let configuration: AccountFreezeConfiguration let configuration: AccountFreezeConfiguration
let openTerms: () -> Void
let submitAppeal: () -> Void let submitAppeal: () -> Void
let dismiss: () -> Void let dismiss: () -> Void
init( init(
context: AccountContext, context: AccountContext,
configuration: AccountFreezeConfiguration, configuration: AccountFreezeConfiguration,
openTerms: @escaping () -> Void,
submitAppeal: @escaping () -> Void, submitAppeal: @escaping () -> Void,
dismiss: @escaping () -> Void dismiss: @escaping () -> Void
) { ) {
self.context = context self.context = context
self.configuration = configuration self.configuration = configuration
self.openTerms = openTerms
self.submitAppeal = submitAppeal self.submitAppeal = submitAppeal
self.dismiss = dismiss self.dismiss = dismiss
} }
@ -132,10 +135,14 @@ private final class SheetContent: CombinedComponent {
component: AnyComponent(ParagraphComponent( component: AnyComponent(ParagraphComponent(
title: strings.FrozenAccount_Violation_Title, title: strings.FrozenAccount_Violation_Title,
titleColor: textColor, titleColor: textColor,
text: strings.FrozenAccount_Violation_Text, text: strings.FrozenAccount_Violation_TextNew,
textColor: secondaryTextColor, textColor: secondaryTextColor,
iconName: "Account Freeze/Violation", 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 context: AccountContext
let configuration: AccountFreezeConfiguration let configuration: AccountFreezeConfiguration
let openTerms: () -> Void
let submitAppeal: () -> Void let submitAppeal: () -> Void
init( init(
context: AccountContext, context: AccountContext,
configuration: AccountFreezeConfiguration, configuration: AccountFreezeConfiguration,
openTerms: @escaping () -> Void,
submitAppeal: @escaping () -> Void submitAppeal: @escaping () -> Void
) { ) {
self.context = context self.context = context
self.configuration = configuration self.configuration = configuration
self.openTerms = openTerms
self.submitAppeal = submitAppeal self.submitAppeal = submitAppeal
} }
@ -292,6 +302,7 @@ private final class SheetContainerComponent: CombinedComponent {
content: AnyComponent<EnvironmentType>(SheetContent( content: AnyComponent<EnvironmentType>(SheetContent(
context: context.component.context, context: context.component.context,
configuration: context.component.configuration, configuration: context.component.configuration,
openTerms: context.component.openTerms,
submitAppeal: context.component.submitAppeal, submitAppeal: context.component.submitAppeal,
dismiss: { dismiss: {
animateOut.invoke(Action { _ in animateOut.invoke(Action { _ in
@ -367,12 +378,16 @@ public final class AccountFreezeInfoScreen: ViewControllerComponentContainer {
self.context = context self.context = context
let configuration = AccountFreezeConfiguration.with(appConfiguration: context.currentAppConfiguration.with { $0 }) let configuration = AccountFreezeConfiguration.with(appConfiguration: context.currentAppConfiguration.with { $0 })
var openTermsImpl: (() -> Void)?
var submitAppealImpl: (() -> Void)? var submitAppealImpl: (() -> Void)?
super.init( super.init(
context: context, context: context,
component: SheetContainerComponent( component: SheetContainerComponent(
context: context, context: context,
configuration: configuration, configuration: configuration,
openTerms: {
openTermsImpl?()
},
submitAppeal: { submitAppeal: {
submitAppealImpl?() submitAppealImpl?()
} }
@ -384,6 +399,15 @@ public final class AccountFreezeInfoScreen: ViewControllerComponentContainer {
self.navigationPresentation = .flatModal 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 submitAppealImpl = { [weak self] in
guard let self, let navigationController = self.navigationController as? NavigationController, let url = configuration.freezeAppealUrl else { guard let self, let navigationController = self.navigationController as? NavigationController, let url = configuration.freezeAppealUrl else {
return return