Skip to content

Commit d89a4a7

Browse files
author
Isaac
committed
Various improvements
1 parent 278f3ca commit d89a4a7

File tree

5 files changed

+18
-23
lines changed

5 files changed

+18
-23
lines changed

submodules/ChatListUI/Sources/ChatListController.swift

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7177,9 +7177,6 @@ private final class ChatListLocationContext {
71777177
titleContent = NetworkStatusTitle(text: presentationData.strings.State_WaitingForNetwork, activity: true, hasProxy: false, connectsViaProxy: connectsViaProxy, isPasscodeSet: isRoot && isPasscodeSet, isManuallyLocked: isRoot && isManuallyLocked, peerStatus: peerStatus)
71787178
case let .connecting(proxy):
71797179
let text = presentationData.strings.State_Connecting
7180-
/*if let layout = strongSelf.validLayout, proxy != nil && layout.metrics.widthClass != .regular && layout.size.width > 320.0 {*/
7181-
//text = self.presentationData.strings.State_ConnectingToProxy
7182-
//}
71837180
if let proxy = proxy, proxy.hasConnectionIssues {
71847181
checkProxy = true
71857182
}

submodules/Display/Source/TextNode.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1216,11 +1216,11 @@ open class TextNode: ASDisplayNode, TextNodeProtocol {
12161216
public static let all: RenderContentTypes = [.text, .emoji]
12171217
}
12181218

1219-
final class DrawingParameters: NSObject {
1219+
public final class DrawingParameters: NSObject {
12201220
let cachedLayout: TextNodeLayout?
12211221
let renderContentTypes: RenderContentTypes
12221222

1223-
init(cachedLayout: TextNodeLayout?, renderContentTypes: RenderContentTypes) {
1223+
public init(cachedLayout: TextNodeLayout?, renderContentTypes: RenderContentTypes) {
12241224
self.cachedLayout = cachedLayout
12251225
self.renderContentTypes = renderContentTypes
12261226

@@ -1295,7 +1295,7 @@ open class TextNode: ASDisplayNode, TextNodeProtocol {
12951295
}
12961296
}
12971297

1298-
private static func calculateLayoutV2(
1298+
public static func calculateLayoutV2(
12991299
attributedString: NSAttributedString,
13001300
minimumNumberOfLines: Int,
13011301
maximumNumberOfLines: Int,
@@ -1685,7 +1685,7 @@ open class TextNode: ASDisplayNode, TextNodeProtocol {
16851685
)
16861686
}
16871687

1688-
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 {
1688+
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 {
16891689
guard let attributedString else {
16901690
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)
16911691
}

submodules/MtProtoKit/Sources/MTApiEnvironment.m

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -264,14 +264,11 @@ - (NSData * _Nonnull)serialize {
264264

265265
- (NSString * _Nonnull)serializeToString {
266266
NSData *data = [self serialize];
267-
if ([data respondsToSelector:@selector(base64EncodedDataWithOptions:)]) {
268-
return [[data base64EncodedStringWithOptions:kNilOptions] stringByTrimmingCharactersInSet:[NSCharacterSet characterSetWithCharactersInString:@"="]];
269-
} else {
270-
#pragma clang diagnostic push
271-
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
272-
return [self.serialize base64Encoding];
273-
#pragma clang diagnostic pop
274-
}
267+
NSString *result = [data base64EncodedStringWithOptions:kNilOptions];
268+
result = [result stringByReplacingOccurrencesOfString:@"+" withString:@"-"];
269+
result = [result stringByReplacingOccurrencesOfString:@"/" withString:@"_"];
270+
result = [result stringByReplacingOccurrencesOfString:@"=" withString:@""];
271+
return result;
275272
}
276273

277274
- (BOOL)isEqual:(id)object {

submodules/SettingsUI/Sources/Data and Storage/ProxyServerSettingsController.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ private func shareLink(for server: ProxyServerSettings) -> String {
1616
switch server.connection {
1717
case let .mtp(secret):
1818
let secret = MTProxySecret.parseData(secret)?.serializeToString() ?? ""
19-
link = "https://t.me/proxy?server=\(server.host)&port=\(server.port)"
19+
link = "tg://proxy?server=\(server.host)&port=\(server.port)"
2020
link += "&secret=\(secret.addingPercentEncoding(withAllowedCharacters: CharacterSet.urlQueryValueAllowed) ?? "")"
2121
case let .socks5(username, password):
2222
link = "https://t.me/socks?server=\(server.host)&port=\(server.port)"
@@ -332,10 +332,10 @@ func proxyServerSettingsController(sharedContext: SharedAccountContext, context:
332332
let signal = combineLatest(updatedPresentationData, statePromise.get())
333333
|> deliverOnMainQueue
334334
|> map { presentationData, state -> (ItemListControllerState, (ItemListNodeState, Any)) in
335-
let leftNavigationButton = ItemListNavigationButton(content: .text(presentationData.strings.Common_Cancel), style: .regular, enabled: true, action: {
335+
let leftNavigationButton = ItemListNavigationButton(content: .text("___close"), style: .regular, enabled: true, action: {
336336
dismissImpl?()
337337
})
338-
let rightNavigationButton = ItemListNavigationButton(content: .text(presentationData.strings.Common_Done), style: .bold, enabled: state.isComplete, action: {
338+
let rightNavigationButton = ItemListNavigationButton(content: .text("___done"), style: .bold, enabled: state.isComplete, action: {
339339
if let proxyServerSettings = proxyServerSettings(with: state) {
340340
let _ = (updateProxySettingsInteractively(accountManager: accountManager, { settings in
341341
var settings = settings

submodules/TelegramUI/Components/Stories/StoryPeerListComponent/Sources/StoryPeerListComponent.swift

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1689,14 +1689,15 @@ public final class StoryPeerListComponent: Component {
16891689
NSAttributedString.Key.font: Font.semibold(17.0),
16901690
NSAttributedString.Key.foregroundColor: component.theme.rootController.navigationBar.primaryTextColor
16911691
])
1692-
var boundingRect = attributedText.boundingRect(with: CGSize(width: max(0.0, component.maxTitleX - component.minTitleX - 30.0), height: 100.0), options: .usesLineFragmentOrigin, context: nil)
1693-
boundingRect.size.width = ceil(boundingRect.size.width)
1694-
boundingRect.size.height = ceil(boundingRect.size.height)
1692+
1693+
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)
16951694

1696-
let renderer = UIGraphicsImageRenderer(bounds: CGRect(origin: CGPoint(), size: boundingRect.size))
1695+
let renderer = UIGraphicsImageRenderer(bounds: CGRect(origin: CGPoint(), size: cachedLayout.size))
16971696
let image = renderer.image { context in
16981697
UIGraphicsPushContext(context.cgContext)
1699-
attributedText.draw(at: CGPoint())
1698+
1699+
TextNode.draw(CGRect(origin: CGPoint(), size: cachedLayout.size), withParameters: TextNode.DrawingParameters(cachedLayout: cachedLayout, renderContentTypes: .all), isCancelled: { return false }, isRasterizing: false)
1700+
17001701
UIGraphicsPopContext()
17011702
}
17021703
self.titleView.image = image

0 commit comments

Comments
 (0)