mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-22 14:20:20 +00:00
Improve Dynamic Type
This commit is contained in:
@@ -554,7 +554,7 @@ func dataAndStorageController(context: AccountContext, focusOnItemTag: DataAndSt
|
||||
pushControllerImpl?(autodownloadMediaConnectionTypeController(context: context, connectionType: connectionType))
|
||||
}, resetAutomaticDownload: {
|
||||
let presentationData = context.sharedContext.currentPresentationData.with { $0 }
|
||||
let actionSheet = ActionSheetController(presentationTheme: presentationData.theme)
|
||||
let actionSheet = ActionSheetController(presentationData: presentationData)
|
||||
actionSheet.setItemGroups([ActionSheetItemGroup(items: [
|
||||
ActionSheetTextItem(title: presentationData.strings.AutoDownloadSettings_ResetHelp),
|
||||
ActionSheetButtonItem(title: presentationData.strings.AutoDownloadSettings_Reset, color: .destructive, action: { [weak actionSheet] in
|
||||
|
||||
@@ -272,7 +272,7 @@ public func intentsSettingsController(context: AccountContext) -> ViewController
|
||||
let _ = updateIntentsSettingsInteractively(accountManager: context.sharedContext.accountManager, f).start()
|
||||
}, resetAll: {
|
||||
let presentationData = context.sharedContext.currentPresentationData.with { $0 }
|
||||
let actionSheet = ActionSheetController(presentationTheme: presentationData.theme)
|
||||
let actionSheet = ActionSheetController(presentationData: presentationData)
|
||||
actionSheet.setItemGroups([ActionSheetItemGroup(items: [
|
||||
ActionSheetButtonItem(title: presentationData.strings.IntentsSettings_Reset, color: .destructive, action: { [weak actionSheet] in
|
||||
actionSheet?.dismissAnimated()
|
||||
|
||||
@@ -389,7 +389,7 @@ func networkUsageStatsController(context: AccountContext) -> ViewController {
|
||||
|
||||
let arguments = NetworkUsageStatsControllerArguments(resetStatistics: { [weak stats] section in
|
||||
let presentationData = context.sharedContext.currentPresentationData.with { $0 }
|
||||
let controller = ActionSheetController(presentationTheme: presentationData.theme)
|
||||
let controller = ActionSheetController(presentationData: presentationData)
|
||||
let dismissAction: () -> Void = { [weak controller] in
|
||||
controller?.dismissAnimated()
|
||||
}
|
||||
|
||||
@@ -216,7 +216,7 @@ private enum ProxySettingsControllerEntry: ItemListNodeEntry {
|
||||
case let .serversHeader(theme, text):
|
||||
return ItemListSectionHeaderItem(presentationData: presentationData, text: text, sectionId: self.section)
|
||||
case let .addServer(theme, text, _):
|
||||
return ProxySettingsActionItem(theme: theme, title: text, icon: .add, sectionId: self.section, editing: false, action: {
|
||||
return ProxySettingsActionItem(presentationData: presentationData, title: text, icon: .add, sectionId: self.section, editing: false, action: {
|
||||
arguments.addNewServer()
|
||||
})
|
||||
case let .server(_, theme, strings, settings, active, status, editing, enabled):
|
||||
@@ -230,7 +230,7 @@ private enum ProxySettingsControllerEntry: ItemListNodeEntry {
|
||||
arguments.removeServer(settings)
|
||||
})
|
||||
case let .shareProxyList(theme, text):
|
||||
return ProxySettingsActionItem(theme: theme, title: text, sectionId: self.section, editing: false, action: {
|
||||
return ProxySettingsActionItem(presentationData: presentationData, title: text, sectionId: self.section, editing: false, action: {
|
||||
arguments.shareProxyList()
|
||||
})
|
||||
case let .useForCalls(theme, text, value):
|
||||
|
||||
@@ -29,7 +29,7 @@ public final class ProxyServerActionSheetController: ActionSheetController {
|
||||
}
|
||||
|
||||
public init(presentationData: PresentationData, accountManager: AccountManager, postbox: Postbox, network: Network, server: ProxyServerSettings, updatedPresentationData: Signal<PresentationData, NoError>?) {
|
||||
let sheetTheme = ActionSheetControllerTheme(presentationTheme: presentationData.theme)
|
||||
let sheetTheme = ActionSheetControllerTheme(presentationData: presentationData)
|
||||
super.init(theme: sheetTheme)
|
||||
|
||||
self._ready.set(.single(true))
|
||||
@@ -63,7 +63,7 @@ public final class ProxyServerActionSheetController: ActionSheetController {
|
||||
if let updatedPresentationData = updatedPresentationData {
|
||||
self.presentationDisposable = updatedPresentationData.start(next: { [weak self] presentationData in
|
||||
if let strongSelf = self {
|
||||
strongSelf.theme = ActionSheetControllerTheme(presentationTheme: presentationData.theme)
|
||||
strongSelf.theme = ActionSheetControllerTheme(presentationData: presentationData)
|
||||
}
|
||||
})
|
||||
}
|
||||
@@ -97,8 +97,6 @@ private final class ProxyServerInfoItem: ActionSheetItem {
|
||||
}
|
||||
}
|
||||
|
||||
private let textFont = Font.regular(16.0)
|
||||
|
||||
private enum ProxyServerInfoStatusType {
|
||||
case generic(String)
|
||||
case failed(String)
|
||||
@@ -107,6 +105,7 @@ private enum ProxyServerInfoStatusType {
|
||||
private final class ProxyServerInfoItemNode: ActionSheetItemNode {
|
||||
private let theme: ActionSheetControllerTheme
|
||||
private let strings: PresentationStrings
|
||||
private let textFont: UIFont
|
||||
|
||||
private let network: Network
|
||||
private let server: ProxyServerSettings
|
||||
@@ -122,6 +121,8 @@ private final class ProxyServerInfoItemNode: ActionSheetItemNode {
|
||||
self.network = network
|
||||
self.server = server
|
||||
|
||||
self.textFont = Font.regular(floor(theme.baseFontSize * 16.0 / 17.0))
|
||||
|
||||
var fieldNodes: [(ImmediateTextNode, ImmediateTextNode)] = []
|
||||
let serverTitleNode = ImmediateTextNode()
|
||||
serverTitleNode.isUserInteractionEnabled = false
|
||||
@@ -317,10 +318,12 @@ private final class ProxyServerActionItemNode: ActionSheetItemNode {
|
||||
self.dismiss = dismiss
|
||||
self.present = present
|
||||
|
||||
let titleFont = Font.regular(floor(theme.baseFontSize * 20.0 / 17.0))
|
||||
|
||||
self.titleNode = ImmediateTextNode()
|
||||
self.titleNode.isUserInteractionEnabled = false
|
||||
self.titleNode.displaysAsynchronously = false
|
||||
self.titleNode.attributedText = NSAttributedString(string: presentationData.strings.SocksProxySetup_ConnectAndSave, font: Font.regular(20.0), textColor: theme.controlAccentColor)
|
||||
self.titleNode.attributedText = NSAttributedString(string: presentationData.strings.SocksProxySetup_ConnectAndSave, font: titleFont, textColor: theme.controlAccentColor)
|
||||
|
||||
self.activityIndicator = ActivityIndicator(type: .custom(theme.controlAccentColor, 22.0, 1.5, false))
|
||||
self.activityIndicator.isHidden = true
|
||||
|
||||
@@ -13,15 +13,15 @@ enum ProxySettingsActionIcon {
|
||||
}
|
||||
|
||||
final class ProxySettingsActionItem: ListViewItem, ItemListItem {
|
||||
let theme: PresentationTheme
|
||||
let presentationData: ItemListPresentationData
|
||||
let title: String
|
||||
let icon: ProxySettingsActionIcon
|
||||
let editing: Bool
|
||||
let sectionId: ItemListSectionId
|
||||
let action: () -> Void
|
||||
|
||||
init(theme: PresentationTheme, title: String, icon: ProxySettingsActionIcon = .none, sectionId: ItemListSectionId, editing: Bool, action: @escaping () -> Void) {
|
||||
self.theme = theme
|
||||
init(presentationData: ItemListPresentationData, title: String, icon: ProxySettingsActionIcon = .none, sectionId: ItemListSectionId, editing: Bool, action: @escaping () -> Void) {
|
||||
self.presentationData = presentationData
|
||||
self.title = title
|
||||
self.icon = icon
|
||||
self.editing = editing
|
||||
@@ -75,8 +75,6 @@ final class ProxySettingsActionItem: ListViewItem, ItemListItem {
|
||||
}
|
||||
}
|
||||
|
||||
private let titleFont = Font.regular(17.0)
|
||||
|
||||
private final class ProxySettingsActionItemNode: ListViewItemNode {
|
||||
private let backgroundNode: ASDisplayNode
|
||||
private let topStripeNode: ASDisplayNode
|
||||
@@ -130,24 +128,26 @@ private final class ProxySettingsActionItemNode: ListViewItemNode {
|
||||
return { item, params, neighbors in
|
||||
var updatedTheme: PresentationTheme?
|
||||
|
||||
if currentItem?.theme !== item.theme {
|
||||
updatedTheme = item.theme
|
||||
let titleFont = Font.regular(item.presentationData.fontSize.itemListBaseFontSize)
|
||||
|
||||
if currentItem?.presentationData.theme !== item.presentationData.theme {
|
||||
updatedTheme = item.presentationData.theme
|
||||
}
|
||||
let leftInset: CGFloat = (item.icon != .none ? 50.0 : 16.0) + params.leftInset
|
||||
|
||||
let editingOffset: CGFloat = (item.editing ? 38.0 : 0.0)
|
||||
|
||||
let (titleLayout, titleApply) = makeTitleLayout(TextNodeLayoutArguments(attributedString: NSAttributedString(string: item.title, font: titleFont, textColor: item.theme.list.itemAccentColor), backgroundColor: nil, maximumNumberOfLines: 1, truncationType: .end, constrainedSize: CGSize(width: params.width - leftInset - editingOffset, height: CGFloat.greatestFiniteMagnitude), alignment: .natural, cutout: nil, insets: UIEdgeInsets()))
|
||||
let (titleLayout, titleApply) = makeTitleLayout(TextNodeLayoutArguments(attributedString: NSAttributedString(string: item.title, font: titleFont, textColor: item.presentationData.theme.list.itemAccentColor), backgroundColor: nil, maximumNumberOfLines: 1, truncationType: .end, constrainedSize: CGSize(width: params.width - leftInset - editingOffset, height: CGFloat.greatestFiniteMagnitude), alignment: .natural, cutout: nil, insets: UIEdgeInsets()))
|
||||
|
||||
let separatorHeight = UIScreenPixel
|
||||
|
||||
let insets = itemListNeighborsGroupedInsets(neighbors)
|
||||
let contentSize = CGSize(width: params.width, height: 44.0)
|
||||
let contentSize = CGSize(width: params.width, height: 22.0 + titleLayout.size.height)
|
||||
|
||||
let layout = ListViewItemNodeLayout(contentSize: contentSize, insets: insets)
|
||||
let layoutSize = layout.size
|
||||
|
||||
let icon = item.icon == .add ? PresentationResourcesItemList.plusIconImage(item.theme) : nil
|
||||
let icon = item.icon == .add ? PresentationResourcesItemList.plusIconImage(item.presentationData.theme) : nil
|
||||
|
||||
return (layout, { [weak self] animated in
|
||||
if let strongSelf = self {
|
||||
@@ -156,10 +156,10 @@ private final class ProxySettingsActionItemNode: ListViewItemNode {
|
||||
strongSelf.accessibilityLabel = item.title
|
||||
|
||||
if let _ = updatedTheme {
|
||||
strongSelf.topStripeNode.backgroundColor = item.theme.list.itemBlocksSeparatorColor
|
||||
strongSelf.bottomStripeNode.backgroundColor = item.theme.list.itemBlocksSeparatorColor
|
||||
strongSelf.backgroundNode.backgroundColor = item.theme.list.itemBlocksBackgroundColor
|
||||
strongSelf.highlightedBackgroundNode.backgroundColor = item.theme.list.itemHighlightedBackgroundColor
|
||||
strongSelf.topStripeNode.backgroundColor = item.presentationData.theme.list.itemBlocksSeparatorColor
|
||||
strongSelf.bottomStripeNode.backgroundColor = item.presentationData.theme.list.itemBlocksSeparatorColor
|
||||
strongSelf.backgroundNode.backgroundColor = item.presentationData.theme.list.itemBlocksBackgroundColor
|
||||
strongSelf.highlightedBackgroundNode.backgroundColor = item.presentationData.theme.list.itemHighlightedBackgroundColor
|
||||
}
|
||||
|
||||
let _ = titleApply()
|
||||
@@ -213,7 +213,7 @@ private final class ProxySettingsActionItemNode: ListViewItemNode {
|
||||
strongSelf.bottomStripeNode.isHidden = hasCorners
|
||||
}
|
||||
|
||||
strongSelf.maskNode.image = hasCorners ? PresentationResourcesItemList.cornersImage(item.theme, top: hasTopCorners, bottom: hasBottomCorners) : nil
|
||||
strongSelf.maskNode.image = hasCorners ? PresentationResourcesItemList.cornersImage(item.presentationData.theme, top: hasTopCorners, bottom: hasBottomCorners) : nil
|
||||
|
||||
strongSelf.backgroundNode.frame = CGRect(origin: CGPoint(x: 0.0, y: -min(insets.top, separatorHeight)), size: CGSize(width: params.width, height: contentSize.height + min(insets.top, separatorHeight) + min(insets.bottom, separatorHeight)))
|
||||
strongSelf.maskNode.frame = strongSelf.backgroundNode.frame.insetBy(dx: params.leftInset, dy: 0.0)
|
||||
|
||||
@@ -22,7 +22,7 @@ public final class ShareProxyServerActionSheetController: ActionSheetController
|
||||
private var isDismissed: Bool = false
|
||||
|
||||
public init(presentationData: PresentationData, updatedPresentationData: Signal<PresentationData, NoError>, link: String) {
|
||||
let sheetTheme = ActionSheetControllerTheme(presentationTheme: presentationData.theme)
|
||||
let sheetTheme = ActionSheetControllerTheme(presentationData: presentationData)
|
||||
super.init(theme: sheetTheme)
|
||||
|
||||
let presentActivityController: (Any) -> Void = { [weak self] item in
|
||||
@@ -67,7 +67,7 @@ public final class ShareProxyServerActionSheetController: ActionSheetController
|
||||
|
||||
self.presentationDisposable = updatedPresentationData.start(next: { [weak self] presentationData in
|
||||
if let strongSelf = self {
|
||||
strongSelf.theme = ActionSheetControllerTheme(presentationTheme: presentationData.theme)
|
||||
strongSelf.theme = ActionSheetControllerTheme(presentationData: presentationData)
|
||||
}
|
||||
})
|
||||
}
|
||||
@@ -119,13 +119,15 @@ private final class ProxyServerQRCodeItemNode: ActionSheetItemNode {
|
||||
self.link = link
|
||||
self.ready = ready
|
||||
|
||||
let textFont = Font.regular(floor(theme.baseFontSize * 13.0 / 17.0))
|
||||
|
||||
self.label = ASTextNode()
|
||||
self.label.isUserInteractionEnabled = false
|
||||
self.label.maximumNumberOfLines = 0
|
||||
self.label.displaysAsynchronously = false
|
||||
self.label.truncationMode = .byTruncatingTail
|
||||
self.label.isUserInteractionEnabled = false
|
||||
self.label.attributedText = NSAttributedString(string: strings.SocksProxySetup_ShareQRCodeInfo, font: ActionSheetTextNode.defaultFont, textColor: self.theme.secondaryTextColor, paragraphAlignment: .center)
|
||||
self.label.attributedText = NSAttributedString(string: strings.SocksProxySetup_ShareQRCodeInfo, font: textFont, textColor: self.theme.secondaryTextColor, paragraphAlignment: .center)
|
||||
|
||||
self.imageNode = TransformImageNode()
|
||||
self.imageNode.clipsToBounds = true
|
||||
|
||||
@@ -402,7 +402,7 @@ public func storageUsageController(context: AccountContext, cacheUsagePromise: P
|
||||
|> deliverOnMainQueue).start(next: { [weak statsPromise] result in
|
||||
if let result = result, case let .result(stats) = result {
|
||||
let presentationData = context.sharedContext.currentPresentationData.with { $0 }
|
||||
let controller = ActionSheetController(presentationTheme: presentationData.theme)
|
||||
let controller = ActionSheetController(presentationData: presentationData)
|
||||
let dismissAction: () -> Void = { [weak controller] in
|
||||
controller?.dismissAnimated()
|
||||
}
|
||||
@@ -624,7 +624,7 @@ public func storageUsageController(context: AccountContext, cacheUsagePromise: P
|
||||
}
|
||||
|
||||
let presentationData = context.sharedContext.currentPresentationData.with { $0 }
|
||||
let controller = ActionSheetController(presentationTheme: presentationData.theme)
|
||||
let controller = ActionSheetController(presentationData: presentationData)
|
||||
let dismissAction: () -> Void = { [weak controller] in
|
||||
controller?.dismissAnimated()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user