mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-10-09 11:23:48 +00:00
Fix Dynamic Type in secret chat key item and "open in" selection
This commit is contained in:
parent
1d4fe238fe
commit
4a05d43645
@ -11,7 +11,7 @@ import PresentationDataUtils
|
|||||||
import EncryptionKeyVisualization
|
import EncryptionKeyVisualization
|
||||||
|
|
||||||
class ItemListSecretChatKeyItem: ListViewItem, ItemListItem {
|
class ItemListSecretChatKeyItem: ListViewItem, ItemListItem {
|
||||||
let theme: PresentationTheme
|
let presentationData: ItemListPresentationData
|
||||||
let icon: UIImage?
|
let icon: UIImage?
|
||||||
let title: String
|
let title: String
|
||||||
let fingerprint: SecretChatKeyFingerprint
|
let fingerprint: SecretChatKeyFingerprint
|
||||||
@ -20,8 +20,8 @@ class ItemListSecretChatKeyItem: ListViewItem, ItemListItem {
|
|||||||
let disclosureStyle: ItemListDisclosureStyle
|
let disclosureStyle: ItemListDisclosureStyle
|
||||||
let action: (() -> Void)?
|
let action: (() -> Void)?
|
||||||
|
|
||||||
init(theme: PresentationTheme, icon: UIImage? = nil, title: String, fingerprint: SecretChatKeyFingerprint, sectionId: ItemListSectionId, style: ItemListStyle, disclosureStyle: ItemListDisclosureStyle = .arrow, action: (() -> Void)?) {
|
init(presentationData: ItemListPresentationData, icon: UIImage? = nil, title: String, fingerprint: SecretChatKeyFingerprint, sectionId: ItemListSectionId, style: ItemListStyle, disclosureStyle: ItemListDisclosureStyle = .arrow, action: (() -> Void)?) {
|
||||||
self.theme = theme
|
self.presentationData = presentationData
|
||||||
self.icon = icon
|
self.icon = icon
|
||||||
self.title = title
|
self.title = title
|
||||||
self.fingerprint = fingerprint
|
self.fingerprint = fingerprint
|
||||||
@ -72,8 +72,6 @@ class ItemListSecretChatKeyItem: ListViewItem, ItemListItem {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private let titleFont = Font.regular(17.0)
|
|
||||||
|
|
||||||
class ItemListSecretChatKeyItemNode: ListViewItemNode {
|
class ItemListSecretChatKeyItemNode: ListViewItemNode {
|
||||||
private let backgroundNode: ASDisplayNode
|
private let backgroundNode: ASDisplayNode
|
||||||
private let topStripeNode: ASDisplayNode
|
private let topStripeNode: ASDisplayNode
|
||||||
@ -150,9 +148,9 @@ class ItemListSecretChatKeyItemNode: ListViewItemNode {
|
|||||||
var updateArrowImage: UIImage?
|
var updateArrowImage: UIImage?
|
||||||
var updatedTheme: PresentationTheme?
|
var updatedTheme: PresentationTheme?
|
||||||
|
|
||||||
if currentItem?.theme !== item.theme {
|
if currentItem?.presentationData.theme !== item.presentationData.theme {
|
||||||
updatedTheme = item.theme
|
updatedTheme = item.presentationData.theme
|
||||||
updateArrowImage = PresentationResourcesItemList.disclosureArrowImage(item.theme)
|
updateArrowImage = PresentationResourcesItemList.disclosureArrowImage(item.presentationData.theme)
|
||||||
}
|
}
|
||||||
|
|
||||||
var updateIcon = false
|
var updateIcon = false
|
||||||
@ -172,25 +170,26 @@ class ItemListSecretChatKeyItemNode: ListViewItemNode {
|
|||||||
let itemSeparatorColor: UIColor
|
let itemSeparatorColor: UIColor
|
||||||
|
|
||||||
var leftInset = 16.0 + params.leftInset
|
var leftInset = 16.0 + params.leftInset
|
||||||
|
|
||||||
switch item.style {
|
|
||||||
case .plain:
|
|
||||||
itemBackgroundColor = item.theme.list.plainBackgroundColor
|
|
||||||
itemSeparatorColor = item.theme.list.itemPlainSeparatorColor
|
|
||||||
contentSize = CGSize(width: params.width, height: 44.0)
|
|
||||||
insets = itemListNeighborsPlainInsets(neighbors)
|
|
||||||
case .blocks:
|
|
||||||
itemBackgroundColor = item.theme.list.itemBlocksBackgroundColor
|
|
||||||
itemSeparatorColor = item.theme.list.itemBlocksSeparatorColor
|
|
||||||
contentSize = CGSize(width: params.width, height: 44.0)
|
|
||||||
insets = itemListNeighborsGroupedInsets(neighbors)
|
|
||||||
}
|
|
||||||
|
|
||||||
if let _ = item.icon {
|
if let _ = item.icon {
|
||||||
leftInset += 43.0
|
leftInset += 43.0
|
||||||
}
|
}
|
||||||
|
|
||||||
let (titleLayout, titleApply) = makeTitleLayout(TextNodeLayoutArguments(attributedString: NSAttributedString(string: item.title, font: titleFont, textColor: item.theme.list.itemPrimaryTextColor), backgroundColor: nil, maximumNumberOfLines: 1, truncationType: .end, constrainedSize: CGSize(width: params.width - params.rightInset - 20.0 - leftInset, height: CGFloat.greatestFiniteMagnitude), alignment: .natural, cutout: nil, insets: UIEdgeInsets()))
|
let titleFont = Font.regular(item.presentationData.fontSize.itemListBaseFontSize)
|
||||||
|
|
||||||
|
let (titleLayout, titleApply) = makeTitleLayout(TextNodeLayoutArguments(attributedString: NSAttributedString(string: item.title, font: titleFont, textColor: item.presentationData.theme.list.itemPrimaryTextColor), backgroundColor: nil, maximumNumberOfLines: 1, truncationType: .end, constrainedSize: CGSize(width: params.width - params.rightInset - 20.0 - leftInset, height: CGFloat.greatestFiniteMagnitude), alignment: .natural, cutout: nil, insets: UIEdgeInsets()))
|
||||||
|
|
||||||
|
switch item.style {
|
||||||
|
case .plain:
|
||||||
|
itemBackgroundColor = item.presentationData.theme.list.plainBackgroundColor
|
||||||
|
itemSeparatorColor = item.presentationData.theme.list.itemPlainSeparatorColor
|
||||||
|
contentSize = CGSize(width: params.width, height: 22.0 + titleLayout.size.height)
|
||||||
|
insets = itemListNeighborsPlainInsets(neighbors)
|
||||||
|
case .blocks:
|
||||||
|
itemBackgroundColor = item.presentationData.theme.list.itemBlocksBackgroundColor
|
||||||
|
itemSeparatorColor = item.presentationData.theme.list.itemBlocksSeparatorColor
|
||||||
|
contentSize = CGSize(width: params.width, height: 22.0 + titleLayout.size.height)
|
||||||
|
insets = itemListNeighborsGroupedInsets(neighbors)
|
||||||
|
}
|
||||||
|
|
||||||
let layout = ListViewItemNodeLayout(contentSize: contentSize, insets: insets)
|
let layout = ListViewItemNodeLayout(contentSize: contentSize, insets: insets)
|
||||||
|
|
||||||
@ -219,7 +218,7 @@ class ItemListSecretChatKeyItemNode: ListViewItemNode {
|
|||||||
strongSelf.topStripeNode.backgroundColor = itemSeparatorColor
|
strongSelf.topStripeNode.backgroundColor = itemSeparatorColor
|
||||||
strongSelf.bottomStripeNode.backgroundColor = itemSeparatorColor
|
strongSelf.bottomStripeNode.backgroundColor = itemSeparatorColor
|
||||||
strongSelf.backgroundNode.backgroundColor = itemBackgroundColor
|
strongSelf.backgroundNode.backgroundColor = itemBackgroundColor
|
||||||
strongSelf.highlightedBackgroundNode.backgroundColor = item.theme.list.itemHighlightedBackgroundColor
|
strongSelf.highlightedBackgroundNode.backgroundColor = item.presentationData.theme.list.itemHighlightedBackgroundColor
|
||||||
}
|
}
|
||||||
|
|
||||||
let _ = titleApply()
|
let _ = titleApply()
|
||||||
@ -271,7 +270,7 @@ class ItemListSecretChatKeyItemNode: ListViewItemNode {
|
|||||||
strongSelf.keyNode.image = updateKeyImage
|
strongSelf.keyNode.image = updateKeyImage
|
||||||
}
|
}
|
||||||
if let image = strongSelf.keyNode.image {
|
if let image = strongSelf.keyNode.image {
|
||||||
strongSelf.keyNode.frame = CGRect(origin: CGPoint(x: params.width - rightInset - image.size.width, y: 10.0), size: image.size)
|
strongSelf.keyNode.frame = CGRect(origin: CGPoint(x: params.width - rightInset - image.size.width, y: floor((layout.contentSize.height - image.size.height) / 2.0)), size: image.size)
|
||||||
}
|
}
|
||||||
|
|
||||||
if let arrowImage = strongSelf.arrowNode.image {
|
if let arrowImage = strongSelf.arrowNode.image {
|
||||||
@ -285,7 +284,7 @@ class ItemListSecretChatKeyItemNode: ListViewItemNode {
|
|||||||
strongSelf.arrowNode.isHidden = false
|
strongSelf.arrowNode.isHidden = false
|
||||||
}
|
}
|
||||||
|
|
||||||
strongSelf.highlightedBackgroundNode.frame = CGRect(origin: CGPoint(x: 0.0, y: -UIScreenPixel), size: CGSize(width: params.width, height: 44.0 + UIScreenPixel))
|
strongSelf.highlightedBackgroundNode.frame = CGRect(origin: CGPoint(x: 0.0, y: -UIScreenPixel), size: CGSize(width: params.width, height: layout.contentSize.height + UIScreenPixel))
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -466,7 +466,7 @@ private enum UserInfoEntry: ItemListNodeEntry {
|
|||||||
arguments.openGroupsInCommon()
|
arguments.openGroupsInCommon()
|
||||||
})
|
})
|
||||||
case let .secretEncryptionKey(theme, text, fingerprint):
|
case let .secretEncryptionKey(theme, text, fingerprint):
|
||||||
return ItemListSecretChatKeyItem(theme: theme, title: text, fingerprint: fingerprint, sectionId: self.section, style: .plain, action: {
|
return ItemListSecretChatKeyItem(presentationData: presentationData, title: text, fingerprint: fingerprint, sectionId: self.section, style: .plain, action: {
|
||||||
arguments.openEncryptionKey(fingerprint)
|
arguments.openEncryptionKey(fingerprint)
|
||||||
})
|
})
|
||||||
case let .botAddToGroup(theme, text):
|
case let .botAddToGroup(theme, text):
|
||||||
|
@ -11,16 +11,16 @@ import OpenInExternalAppUI
|
|||||||
|
|
||||||
class WebBrowserItem: ListViewItem, ItemListItem {
|
class WebBrowserItem: ListViewItem, ItemListItem {
|
||||||
let account: Account
|
let account: Account
|
||||||
let theme: PresentationTheme
|
let presentationData: ItemListPresentationData
|
||||||
let title: String
|
let title: String
|
||||||
let application: OpenInApplication
|
let application: OpenInApplication
|
||||||
let checked: Bool
|
let checked: Bool
|
||||||
public let sectionId: ItemListSectionId
|
public let sectionId: ItemListSectionId
|
||||||
let action: () -> Void
|
let action: () -> Void
|
||||||
|
|
||||||
public init(account: Account, theme: PresentationTheme, title: String, application: OpenInApplication, checked: Bool, sectionId: ItemListSectionId, action: @escaping () -> Void) {
|
public init(account: Account, presentationData: ItemListPresentationData, title: String, application: OpenInApplication, checked: Bool, sectionId: ItemListSectionId, action: @escaping () -> Void) {
|
||||||
self.account = account
|
self.account = account
|
||||||
self.theme = theme
|
self.presentationData = presentationData
|
||||||
self.title = title
|
self.title = title
|
||||||
self.application = application
|
self.application = application
|
||||||
self.checked = checked
|
self.checked = checked
|
||||||
@ -69,8 +69,6 @@ class WebBrowserItem: ListViewItem, ItemListItem {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private let titleFont = Font.regular(17.0)
|
|
||||||
|
|
||||||
private final class WebBrowserItemNode: ListViewItemNode {
|
private final class WebBrowserItemNode: ListViewItemNode {
|
||||||
private let backgroundNode: ASDisplayNode
|
private let backgroundNode: ASDisplayNode
|
||||||
private let topStripeNode: ASDisplayNode
|
private let topStripeNode: ASDisplayNode
|
||||||
@ -138,7 +136,7 @@ private final class WebBrowserItemNode: ListViewItemNode {
|
|||||||
var leftInset: CGFloat = params.leftInset + 16.0 + 43.0
|
var leftInset: CGFloat = params.leftInset + 16.0 + 43.0
|
||||||
|
|
||||||
let iconSize = CGSize(width: 29.0, height: 29.0)
|
let iconSize = CGSize(width: 29.0, height: 29.0)
|
||||||
let arguments = TransformImageArguments(corners: ImageCorners(radius: 5.0), imageSize: iconSize, boundingSize: iconSize, intrinsicInsets: UIEdgeInsets(), emptyColor: item.theme.list.mediaPlaceholderColor)
|
let arguments = TransformImageArguments(corners: ImageCorners(radius: 5.0), imageSize: iconSize, boundingSize: iconSize, intrinsicInsets: UIEdgeInsets(), emptyColor: item.presentationData.theme.list.mediaPlaceholderColor)
|
||||||
let imageApply = makeIconLayout(arguments)
|
let imageApply = makeIconLayout(arguments)
|
||||||
|
|
||||||
var updatedIconSignal: Signal<(TransformImageArguments) -> DrawingContext?, NoError>?
|
var updatedIconSignal: Signal<(TransformImageArguments) -> DrawingContext?, NoError>?
|
||||||
@ -157,24 +155,23 @@ private final class WebBrowserItemNode: ListViewItemNode {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let (titleLayout, titleApply) = makeTitleLayout(TextNodeLayoutArguments(attributedString: NSAttributedString(string: item.title, font: titleFont, textColor: item.theme.list.itemPrimaryTextColor), backgroundColor: nil, maximumNumberOfLines: 1, truncationType: .end, constrainedSize: CGSize(width: params.width - leftInset - 20.0, height: CGFloat.greatestFiniteMagnitude), alignment: .natural, cutout: nil, insets: UIEdgeInsets()))
|
let titleFont = Font.regular(item.presentationData.fontSize.itemListBaseFontSize)
|
||||||
|
|
||||||
|
let (titleLayout, titleApply) = makeTitleLayout(TextNodeLayoutArguments(attributedString: NSAttributedString(string: item.title, font: titleFont, textColor: item.presentationData.theme.list.itemPrimaryTextColor), backgroundColor: nil, maximumNumberOfLines: 1, truncationType: .end, constrainedSize: CGSize(width: params.width - leftInset - 20.0, height: CGFloat.greatestFiniteMagnitude), alignment: .natural, cutout: nil, insets: UIEdgeInsets()))
|
||||||
|
|
||||||
let separatorHeight = UIScreenPixel
|
let separatorHeight = UIScreenPixel
|
||||||
|
|
||||||
let insets = itemListNeighborsGroupedInsets(neighbors)
|
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 layout = ListViewItemNodeLayout(contentSize: contentSize, insets: insets)
|
||||||
|
|
||||||
var updateCheckImage: UIImage?
|
var updateCheckImage: UIImage?
|
||||||
var updatedTheme: PresentationTheme?
|
var updatedTheme: PresentationTheme?
|
||||||
|
|
||||||
if currentItem?.theme !== item.theme {
|
if currentItem?.presentationData.theme !== item.presentationData.theme {
|
||||||
updatedTheme = item.theme
|
updatedTheme = item.presentationData.theme
|
||||||
}
|
updateCheckImage = PresentationResourcesItemList.checkIconImage(item.presentationData.theme)
|
||||||
|
|
||||||
if currentItem?.theme !== item.theme {
|
|
||||||
updateCheckImage = PresentationResourcesItemList.checkIconImage(item.theme)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return (layout, { [weak self] in
|
return (layout, { [weak self] in
|
||||||
@ -195,10 +192,10 @@ private final class WebBrowserItemNode: ListViewItemNode {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if let _ = updatedTheme {
|
if let _ = updatedTheme {
|
||||||
strongSelf.topStripeNode.backgroundColor = item.theme.list.itemBlocksSeparatorColor
|
strongSelf.topStripeNode.backgroundColor = item.presentationData.theme.list.itemBlocksSeparatorColor
|
||||||
strongSelf.bottomStripeNode.backgroundColor = item.theme.list.itemBlocksSeparatorColor
|
strongSelf.bottomStripeNode.backgroundColor = item.presentationData.theme.list.itemBlocksSeparatorColor
|
||||||
strongSelf.backgroundNode.backgroundColor = item.theme.list.itemBlocksBackgroundColor
|
strongSelf.backgroundNode.backgroundColor = item.presentationData.theme.list.itemBlocksBackgroundColor
|
||||||
strongSelf.highlightedBackgroundNode.backgroundColor = item.theme.list.itemHighlightedBackgroundColor
|
strongSelf.highlightedBackgroundNode.backgroundColor = item.presentationData.theme.list.itemHighlightedBackgroundColor
|
||||||
}
|
}
|
||||||
|
|
||||||
let _ = titleApply()
|
let _ = titleApply()
|
||||||
@ -246,7 +243,7 @@ private final class WebBrowserItemNode: ListViewItemNode {
|
|||||||
strongSelf.bottomStripeNode.isHidden = hasCorners
|
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.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)
|
strongSelf.maskNode.frame = strongSelf.backgroundNode.frame.insetBy(dx: params.leftInset, dy: 0.0)
|
||||||
|
@ -71,7 +71,7 @@ private enum WebBrowserSettingsControllerEntry: ItemListNodeEntry {
|
|||||||
case let .browserHeader(theme, text):
|
case let .browserHeader(theme, text):
|
||||||
return ItemListSectionHeaderItem(presentationData: presentationData, text: text, sectionId: self.section)
|
return ItemListSectionHeaderItem(presentationData: presentationData, text: text, sectionId: self.section)
|
||||||
case let .browser(theme, title, application, identifier, selected, _):
|
case let .browser(theme, title, application, identifier, selected, _):
|
||||||
return WebBrowserItem(account: arguments.context.account, theme: theme, title: title, application: application, checked: selected, sectionId: self.section) {
|
return WebBrowserItem(account: arguments.context.account, presentationData: presentationData, title: title, application: application, checked: selected, sectionId: self.section) {
|
||||||
arguments.updateDefaultBrowser(identifier)
|
arguments.updateDefaultBrowser(identifier)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user