mirror of
https://github.com/TelegramMessenger/Telegram-iOS.git
synced 2026-07-06 03:33:41 +02:00
Various improvements
This commit is contained in:
parent
278f3ca420
commit
d89a4a79cf
5 changed files with 18 additions and 23 deletions
|
|
@ -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
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue