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.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";

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

View File

@ -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 {

View File

@ -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<EnvironmentType>(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