From d89a4a79cf38fd47d0ac21878fba141f807a2273 Mon Sep 17 00:00:00 2001 From: Isaac <> Date: Tue, 7 Apr 2026 16:48:11 +0200 Subject: [PATCH] Various improvements --- .../ChatListUI/Sources/ChatListController.swift | 3 --- submodules/Display/Source/TextNode.swift | 8 ++++---- submodules/MtProtoKit/Sources/MTApiEnvironment.m | 13 +++++-------- .../ProxyServerSettingsController.swift | 6 +++--- .../Sources/StoryPeerListComponent.swift | 11 ++++++----- 5 files changed, 18 insertions(+), 23 deletions(-) diff --git a/submodules/ChatListUI/Sources/ChatListController.swift b/submodules/ChatListUI/Sources/ChatListController.swift index b605a693a8..3ce4e72602 100644 --- a/submodules/ChatListUI/Sources/ChatListController.swift +++ b/submodules/ChatListUI/Sources/ChatListController.swift @@ -7177,9 +7177,6 @@ private final class ChatListLocationContext { titleContent = NetworkStatusTitle(text: presentationData.strings.State_WaitingForNetwork, activity: true, hasProxy: false, connectsViaProxy: connectsViaProxy, isPasscodeSet: isRoot && isPasscodeSet, isManuallyLocked: isRoot && isManuallyLocked, peerStatus: peerStatus) case let .connecting(proxy): let text = presentationData.strings.State_Connecting - /*if let layout = strongSelf.validLayout, proxy != nil && layout.metrics.widthClass != .regular && layout.size.width > 320.0 {*/ - //text = self.presentationData.strings.State_ConnectingToProxy - //} if let proxy = proxy, proxy.hasConnectionIssues { checkProxy = true } diff --git a/submodules/Display/Source/TextNode.swift b/submodules/Display/Source/TextNode.swift index 452bff9c44..ecc22273d0 100644 --- a/submodules/Display/Source/TextNode.swift +++ b/submodules/Display/Source/TextNode.swift @@ -1216,11 +1216,11 @@ open class TextNode: ASDisplayNode, TextNodeProtocol { public static let all: RenderContentTypes = [.text, .emoji] } - final class DrawingParameters: NSObject { + public final class DrawingParameters: NSObject { let cachedLayout: TextNodeLayout? let renderContentTypes: RenderContentTypes - init(cachedLayout: TextNodeLayout?, renderContentTypes: RenderContentTypes) { + public init(cachedLayout: TextNodeLayout?, renderContentTypes: RenderContentTypes) { self.cachedLayout = cachedLayout self.renderContentTypes = renderContentTypes @@ -1295,7 +1295,7 @@ open class TextNode: ASDisplayNode, TextNodeProtocol { } } - private static func calculateLayoutV2( + public static func calculateLayoutV2( attributedString: NSAttributedString, minimumNumberOfLines: Int, maximumNumberOfLines: Int, @@ -1685,7 +1685,7 @@ open class TextNode: ASDisplayNode, TextNodeProtocol { ) } - static func calculateLayout(attributedString: NSAttributedString?, minimumNumberOfLines: Int, maximumNumberOfLines: Int, truncationType: CTLineTruncationType, backgroundColor: UIColor?, constrainedSize: CGSize, alignment: NSTextAlignment, verticalAlignment: TextVerticalAlignment, lineSpacingFactor: CGFloat, cutout: TextNodeCutout?, insets: UIEdgeInsets, lineColor: UIColor?, textShadowColor: UIColor?, textShadowBlur: CGFloat?, textStroke: (UIColor, CGFloat)?, displaySpoilers: Bool, displayEmbeddedItemsUnderSpoilers: Bool, customTruncationToken: NSAttributedString?) -> TextNodeLayout { + public static func calculateLayout(attributedString: NSAttributedString?, minimumNumberOfLines: Int, maximumNumberOfLines: Int, truncationType: CTLineTruncationType, backgroundColor: UIColor?, constrainedSize: CGSize, alignment: NSTextAlignment, verticalAlignment: TextVerticalAlignment, lineSpacingFactor: CGFloat, cutout: TextNodeCutout?, insets: UIEdgeInsets, lineColor: UIColor?, textShadowColor: UIColor?, textShadowBlur: CGFloat?, textStroke: (UIColor, CGFloat)?, displaySpoilers: Bool, displayEmbeddedItemsUnderSpoilers: Bool, customTruncationToken: NSAttributedString?) -> TextNodeLayout { guard let attributedString else { return TextNodeLayout(attributedString: attributedString, maximumNumberOfLines: maximumNumberOfLines, truncationType: truncationType, constrainedSize: constrainedSize, explicitAlignment: alignment, resolvedAlignment: alignment, verticalAlignment: verticalAlignment, lineSpacing: lineSpacingFactor, cutout: cutout, insets: insets, size: CGSize(), rawTextSize: CGSize(), truncated: false, firstLineOffset: 0.0, lines: [], blockQuotes: [], backgroundColor: backgroundColor, lineColor: lineColor, textShadowColor: textShadowColor, textShadowBlur: textShadowBlur, textStroke: textStroke, displaySpoilers: displaySpoilers) } diff --git a/submodules/MtProtoKit/Sources/MTApiEnvironment.m b/submodules/MtProtoKit/Sources/MTApiEnvironment.m index e42c2bc549..92b6ab69cf 100644 --- a/submodules/MtProtoKit/Sources/MTApiEnvironment.m +++ b/submodules/MtProtoKit/Sources/MTApiEnvironment.m @@ -264,14 +264,11 @@ static NSData *base64_decode(NSString *str) { - (NSString * _Nonnull)serializeToString { NSData *data = [self serialize]; - if ([data respondsToSelector:@selector(base64EncodedDataWithOptions:)]) { - return [[data base64EncodedStringWithOptions:kNilOptions] stringByTrimmingCharactersInSet:[NSCharacterSet characterSetWithCharactersInString:@"="]]; - } else { -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wdeprecated-declarations" - return [self.serialize base64Encoding]; -#pragma clang diagnostic pop - } + NSString *result = [data base64EncodedStringWithOptions:kNilOptions]; + result = [result stringByReplacingOccurrencesOfString:@"+" withString:@"-"]; + result = [result stringByReplacingOccurrencesOfString:@"/" withString:@"_"]; + result = [result stringByReplacingOccurrencesOfString:@"=" withString:@""]; + return result; } - (BOOL)isEqual:(id)object { diff --git a/submodules/SettingsUI/Sources/Data and Storage/ProxyServerSettingsController.swift b/submodules/SettingsUI/Sources/Data and Storage/ProxyServerSettingsController.swift index b2ba003fb7..62f826c99e 100644 --- a/submodules/SettingsUI/Sources/Data and Storage/ProxyServerSettingsController.swift +++ b/submodules/SettingsUI/Sources/Data and Storage/ProxyServerSettingsController.swift @@ -16,7 +16,7 @@ private func shareLink(for server: ProxyServerSettings) -> String { switch server.connection { case let .mtp(secret): let secret = MTProxySecret.parseData(secret)?.serializeToString() ?? "" - link = "https://t.me/proxy?server=\(server.host)&port=\(server.port)" + link = "tg://proxy?server=\(server.host)&port=\(server.port)" link += "&secret=\(secret.addingPercentEncoding(withAllowedCharacters: CharacterSet.urlQueryValueAllowed) ?? "")" case let .socks5(username, password): link = "https://t.me/socks?server=\(server.host)&port=\(server.port)" @@ -332,10 +332,10 @@ func proxyServerSettingsController(sharedContext: SharedAccountContext, context: let signal = combineLatest(updatedPresentationData, statePromise.get()) |> deliverOnMainQueue |> map { presentationData, state -> (ItemListControllerState, (ItemListNodeState, Any)) in - let leftNavigationButton = ItemListNavigationButton(content: .text(presentationData.strings.Common_Cancel), style: .regular, enabled: true, action: { + let leftNavigationButton = ItemListNavigationButton(content: .text("___close"), style: .regular, enabled: true, action: { dismissImpl?() }) - let rightNavigationButton = ItemListNavigationButton(content: .text(presentationData.strings.Common_Done), style: .bold, enabled: state.isComplete, action: { + let rightNavigationButton = ItemListNavigationButton(content: .text("___done"), style: .bold, enabled: state.isComplete, action: { if let proxyServerSettings = proxyServerSettings(with: state) { let _ = (updateProxySettingsInteractively(accountManager: accountManager, { settings in var settings = settings diff --git a/submodules/TelegramUI/Components/Stories/StoryPeerListComponent/Sources/StoryPeerListComponent.swift b/submodules/TelegramUI/Components/Stories/StoryPeerListComponent/Sources/StoryPeerListComponent.swift index f5b2a60cb2..3b0074726e 100644 --- a/submodules/TelegramUI/Components/Stories/StoryPeerListComponent/Sources/StoryPeerListComponent.swift +++ b/submodules/TelegramUI/Components/Stories/StoryPeerListComponent/Sources/StoryPeerListComponent.swift @@ -1689,14 +1689,15 @@ public final class StoryPeerListComponent: Component { NSAttributedString.Key.font: Font.semibold(17.0), NSAttributedString.Key.foregroundColor: component.theme.rootController.navigationBar.primaryTextColor ]) - var boundingRect = attributedText.boundingRect(with: CGSize(width: max(0.0, component.maxTitleX - component.minTitleX - 30.0), height: 100.0), options: .usesLineFragmentOrigin, context: nil) - boundingRect.size.width = ceil(boundingRect.size.width) - boundingRect.size.height = ceil(boundingRect.size.height) + + let cachedLayout = TextNode.calculateLayout(attributedString: attributedText, minimumNumberOfLines: 1, maximumNumberOfLines: 1, truncationType: .end, backgroundColor: nil, constrainedSize: CGSize(width: max(0.0, component.maxTitleX - component.minTitleX - 46.0), height: 100.0), alignment: .left, verticalAlignment: .middle, lineSpacingFactor: 0.0, cutout: nil, insets: UIEdgeInsets(), lineColor: nil, textShadowColor: nil, textShadowBlur: nil, textStroke: nil, displaySpoilers: false, displayEmbeddedItemsUnderSpoilers: false, customTruncationToken: nil) - let renderer = UIGraphicsImageRenderer(bounds: CGRect(origin: CGPoint(), size: boundingRect.size)) + let renderer = UIGraphicsImageRenderer(bounds: CGRect(origin: CGPoint(), size: cachedLayout.size)) let image = renderer.image { context in UIGraphicsPushContext(context.cgContext) - attributedText.draw(at: CGPoint()) + + TextNode.draw(CGRect(origin: CGPoint(), size: cachedLayout.size), withParameters: TextNode.DrawingParameters(cachedLayout: cachedLayout, renderContentTypes: .all), isCancelled: { return false }, isRasterizing: false) + UIGraphicsPopContext() } self.titleView.image = image