mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-06-16 05:55:20 +00:00
Improve Dynamic Type
This commit is contained in:
parent
fd8dd0c976
commit
f1f4827f95
@ -440,7 +440,7 @@ private enum DeviceContactInfoEntry: ItemListNodeEntry {
|
|||||||
case let .phoneNumberShareViaExceptionInfo(_, theme, text):
|
case let .phoneNumberShareViaExceptionInfo(_, theme, text):
|
||||||
return ItemListTextItem(presentationData: presentationData, text: .markdown(text), sectionId: self.section)
|
return ItemListTextItem(presentationData: presentationData, text: .markdown(text), sectionId: self.section)
|
||||||
case let .editingPhoneNumber(_, theme, strings, id, title, label, value, hasActiveRevealControls):
|
case let .editingPhoneNumber(_, theme, strings, id, title, label, value, hasActiveRevealControls):
|
||||||
return UserInfoEditingPhoneItem(theme: theme, strings: strings, id: id, label: title, value: value, editing: UserInfoEditingPhoneItemEditing(editable: true, hasActiveRevealControls: hasActiveRevealControls), sectionId: self.section, setPhoneIdWithRevealedOptions: { lhs, rhs in
|
return UserInfoEditingPhoneItem(presentationData: presentationData, id: id, label: title, value: value, editing: UserInfoEditingPhoneItemEditing(editable: true, hasActiveRevealControls: hasActiveRevealControls), sectionId: self.section, setPhoneIdWithRevealedOptions: { lhs, rhs in
|
||||||
arguments.setPhoneIdWithRevealedOptions(lhs, rhs)
|
arguments.setPhoneIdWithRevealedOptions(lhs, rhs)
|
||||||
}, updated: { value in
|
}, updated: { value in
|
||||||
arguments.updatePhone(id, value)
|
arguments.updatePhone(id, value)
|
||||||
@ -450,7 +450,7 @@ private enum DeviceContactInfoEntry: ItemListNodeEntry {
|
|||||||
arguments.deletePhone(id)
|
arguments.deletePhone(id)
|
||||||
}, tag: DeviceContactInfoEntryTag.editingPhone(id))
|
}, tag: DeviceContactInfoEntryTag.editingPhone(id))
|
||||||
case let .addPhoneNumber(_, theme, title):
|
case let .addPhoneNumber(_, theme, title):
|
||||||
return UserInfoEditingPhoneActionItem(theme: theme, title: title, sectionId: self.section, action: {
|
return UserInfoEditingPhoneActionItem(presentationData: presentationData, title: title, sectionId: self.section, action: {
|
||||||
arguments.addPhoneNumber()
|
arguments.addPhoneNumber()
|
||||||
})
|
})
|
||||||
case let .email(_, index, theme, title, label, value, selected):
|
case let .email(_, index, theme, title, label, value, selected):
|
||||||
|
@ -8,13 +8,13 @@ import ItemListUI
|
|||||||
import PresentationDataUtils
|
import PresentationDataUtils
|
||||||
|
|
||||||
class UserInfoEditingPhoneActionItem: ListViewItem, ItemListItem {
|
class UserInfoEditingPhoneActionItem: ListViewItem, ItemListItem {
|
||||||
let theme: PresentationTheme
|
let presentationData: ItemListPresentationData
|
||||||
let title: String
|
let title: String
|
||||||
let sectionId: ItemListSectionId
|
let sectionId: ItemListSectionId
|
||||||
let action: () -> Void
|
let action: () -> Void
|
||||||
|
|
||||||
init(theme: PresentationTheme, title: String, sectionId: ItemListSectionId, action: @escaping () -> Void, tag: Any? = nil) {
|
init(presentationData: ItemListPresentationData, title: String, sectionId: ItemListSectionId, action: @escaping () -> Void, tag: Any? = nil) {
|
||||||
self.theme = theme
|
self.presentationData = presentationData
|
||||||
self.title = title
|
self.title = title
|
||||||
self.sectionId = sectionId
|
self.sectionId = sectionId
|
||||||
self.action = action
|
self.action = action
|
||||||
@ -61,8 +61,6 @@ class UserInfoEditingPhoneActionItem: ListViewItem, ItemListItem {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private let titleFont = Font.regular(15.0)
|
|
||||||
|
|
||||||
class UserInfoEditingPhoneActionItemNode: ListViewItemNode {
|
class UserInfoEditingPhoneActionItemNode: ListViewItemNode {
|
||||||
private let backgroundNode: ASDisplayNode
|
private let backgroundNode: ASDisplayNode
|
||||||
private let topStripeNode: ASDisplayNode
|
private let topStripeNode: ASDisplayNode
|
||||||
@ -114,15 +112,17 @@ class UserInfoEditingPhoneActionItemNode: ListViewItemNode {
|
|||||||
let currentItem = self.item
|
let currentItem = self.item
|
||||||
|
|
||||||
return { item, params, neighbors in
|
return { item, params, neighbors in
|
||||||
|
let titleFont = Font.regular(floor(item.presentationData.fontSize.itemListBaseFontSize * 15.0 / 17.0))
|
||||||
|
|
||||||
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
|
||||||
}
|
}
|
||||||
|
|
||||||
let textColor = item.theme.list.itemAccentColor
|
let textColor = item.presentationData.theme.list.itemAccentColor
|
||||||
|
|
||||||
let iconImage = PresentationResourcesItemList.addPhoneIcon(item.theme)
|
let iconImage = PresentationResourcesItemList.addPhoneIcon(item.presentationData.theme)
|
||||||
|
|
||||||
let (titleLayout, titleApply) = makeTitleLayout(TextNodeLayoutArguments(attributedString: NSAttributedString(string: item.title, font: titleFont, textColor: textColor), backgroundColor: nil, maximumNumberOfLines: 1, truncationType: .end, constrainedSize: CGSize(width: params.width - params.leftInset - params.rightInset - 20.0, height: CGFloat.greatestFiniteMagnitude), alignment: .natural, cutout: nil, insets: UIEdgeInsets()))
|
let (titleLayout, titleApply) = makeTitleLayout(TextNodeLayoutArguments(attributedString: NSAttributedString(string: item.title, font: titleFont, textColor: textColor), backgroundColor: nil, maximumNumberOfLines: 1, truncationType: .end, constrainedSize: CGSize(width: params.width - params.leftInset - params.rightInset - 20.0, height: CGFloat.greatestFiniteMagnitude), alignment: .natural, cutout: nil, insets: UIEdgeInsets()))
|
||||||
|
|
||||||
@ -133,9 +133,9 @@ class UserInfoEditingPhoneActionItemNode: ListViewItemNode {
|
|||||||
let itemBackgroundColor: UIColor
|
let itemBackgroundColor: UIColor
|
||||||
let itemSeparatorColor: UIColor
|
let itemSeparatorColor: UIColor
|
||||||
|
|
||||||
itemBackgroundColor = item.theme.list.plainBackgroundColor
|
itemBackgroundColor = item.presentationData.theme.list.plainBackgroundColor
|
||||||
itemSeparatorColor = item.theme.list.itemPlainSeparatorColor
|
itemSeparatorColor = item.presentationData.theme.list.itemPlainSeparatorColor
|
||||||
contentSize = CGSize(width: params.width, height: 44.0)
|
contentSize = CGSize(width: params.width, height: 22.0 + titleLayout.size.height)
|
||||||
insets = itemListNeighborsPlainInsets(neighbors)
|
insets = itemListNeighborsPlainInsets(neighbors)
|
||||||
|
|
||||||
let layout = ListViewItemNodeLayout(contentSize: contentSize, insets: insets)
|
let layout = ListViewItemNodeLayout(contentSize: contentSize, insets: insets)
|
||||||
@ -148,7 +148,7 @@ class UserInfoEditingPhoneActionItemNode: 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
|
||||||
}
|
}
|
||||||
|
|
||||||
strongSelf.iconNode.image = iconImage
|
strongSelf.iconNode.image = iconImage
|
||||||
|
@ -19,8 +19,7 @@ struct UserInfoEditingPhoneItemEditing {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class UserInfoEditingPhoneItem: ListViewItem, ItemListItem {
|
class UserInfoEditingPhoneItem: ListViewItem, ItemListItem {
|
||||||
let theme: PresentationTheme
|
let presentationData: ItemListPresentationData
|
||||||
let strings: PresentationStrings
|
|
||||||
let id: Int64
|
let id: Int64
|
||||||
let label: String
|
let label: String
|
||||||
let value: String
|
let value: String
|
||||||
@ -32,9 +31,8 @@ class UserInfoEditingPhoneItem: ListViewItem, ItemListItem {
|
|||||||
let delete: () -> Void
|
let delete: () -> Void
|
||||||
let tag: ItemListItemTag?
|
let tag: ItemListItemTag?
|
||||||
|
|
||||||
init(theme: PresentationTheme, strings: PresentationStrings, id: Int64, label: String, value: String, editing: UserInfoEditingPhoneItemEditing, sectionId: ItemListSectionId, setPhoneIdWithRevealedOptions: @escaping (Int64?, Int64?) -> Void, updated: @escaping (String) -> Void, selectLabel: (() -> Void)?, delete: @escaping () -> Void, tag: ItemListItemTag?) {
|
init(presentationData: ItemListPresentationData, id: Int64, label: String, value: String, editing: UserInfoEditingPhoneItemEditing, sectionId: ItemListSectionId, setPhoneIdWithRevealedOptions: @escaping (Int64?, Int64?) -> Void, updated: @escaping (String) -> Void, selectLabel: (() -> Void)?, delete: @escaping () -> Void, tag: ItemListItemTag?) {
|
||||||
self.theme = theme
|
self.presentationData = presentationData
|
||||||
self.strings = strings
|
|
||||||
self.id = id
|
self.id = id
|
||||||
self.label = label
|
self.label = label
|
||||||
self.value = value
|
self.value = value
|
||||||
@ -83,8 +81,6 @@ class UserInfoEditingPhoneItem: ListViewItem, ItemListItem {
|
|||||||
var selectable: Bool = false
|
var selectable: Bool = false
|
||||||
}
|
}
|
||||||
|
|
||||||
private let titleFont = Font.regular(15.0)
|
|
||||||
|
|
||||||
class UserInfoEditingPhoneItemNode: ItemListRevealOptionsItemNode, ItemListItemNode, ItemListItemFocusableNode {
|
class UserInfoEditingPhoneItemNode: ItemListRevealOptionsItemNode, ItemListItemNode, ItemListItemFocusableNode {
|
||||||
private let backgroundNode: ASDisplayNode
|
private let backgroundNode: ASDisplayNode
|
||||||
private let topStripeNode: ASDisplayNode
|
private let topStripeNode: ASDisplayNode
|
||||||
@ -184,9 +180,11 @@ class UserInfoEditingPhoneItemNode: ItemListRevealOptionsItemNode, ItemListItemN
|
|||||||
super.didLoad()
|
super.didLoad()
|
||||||
|
|
||||||
if let item = self.item {
|
if let item = self.item {
|
||||||
self.phoneNode.numberField?.textField.textColor = item.theme.list.itemPrimaryTextColor
|
self.phoneNode.numberField?.textField.textColor = item.presentationData.theme.list.itemPrimaryTextColor
|
||||||
self.phoneNode.numberField?.textField.keyboardAppearance = item.theme.rootController.keyboardColor.keyboardAppearance
|
self.phoneNode.numberField?.textField.keyboardAppearance = item.presentationData.theme.rootController.keyboardColor.keyboardAppearance
|
||||||
self.phoneNode.numberField?.textField.tintColor = item.theme.list.itemAccentColor
|
self.phoneNode.numberField?.textField.tintColor = item.presentationData.theme.list.itemAccentColor
|
||||||
|
let titleFont = Font.regular(floor(item.presentationData.fontSize.itemListBaseFontSize * 15.0 / 17.0))
|
||||||
|
self.phoneNode.numberField?.textField.font = titleFont
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -197,15 +195,17 @@ class UserInfoEditingPhoneItemNode: ItemListRevealOptionsItemNode, ItemListItemN
|
|||||||
let currentItem = self.item
|
let currentItem = self.item
|
||||||
|
|
||||||
return { item, params, neighbors in
|
return { item, params, neighbors in
|
||||||
|
let titleFont = Font.regular(floor(item.presentationData.fontSize.itemListBaseFontSize * 15.0 / 17.0))
|
||||||
|
|
||||||
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
|
||||||
}
|
}
|
||||||
|
|
||||||
let controlSizeAndApply = editableControlLayout(item.theme, false)
|
let controlSizeAndApply = editableControlLayout(item.presentationData.theme, false)
|
||||||
|
|
||||||
let textColor = item.theme.list.itemAccentColor
|
let textColor = item.presentationData.theme.list.itemAccentColor
|
||||||
|
|
||||||
let (labelLayout, labelApply) = makeLabelLayout(TextNodeLayoutArguments(attributedString: NSAttributedString(string: item.label, font: titleFont, textColor: textColor), backgroundColor: nil, maximumNumberOfLines: 1, truncationType: .end, constrainedSize: CGSize(width: params.width - params.leftInset - params.rightInset - 20.0, height: CGFloat.greatestFiniteMagnitude), alignment: .natural, cutout: nil, insets: UIEdgeInsets()))
|
let (labelLayout, labelApply) = makeLabelLayout(TextNodeLayoutArguments(attributedString: NSAttributedString(string: item.label, font: titleFont, textColor: textColor), backgroundColor: nil, maximumNumberOfLines: 1, truncationType: .end, constrainedSize: CGSize(width: params.width - params.leftInset - params.rightInset - 20.0, height: CGFloat.greatestFiniteMagnitude), alignment: .natural, cutout: nil, insets: UIEdgeInsets()))
|
||||||
|
|
||||||
@ -216,9 +216,9 @@ class UserInfoEditingPhoneItemNode: ItemListRevealOptionsItemNode, ItemListItemN
|
|||||||
let itemBackgroundColor: UIColor
|
let itemBackgroundColor: UIColor
|
||||||
let itemSeparatorColor: UIColor
|
let itemSeparatorColor: UIColor
|
||||||
|
|
||||||
itemBackgroundColor = item.theme.list.plainBackgroundColor
|
itemBackgroundColor = item.presentationData.theme.list.plainBackgroundColor
|
||||||
itemSeparatorColor = item.theme.list.itemPlainSeparatorColor
|
itemSeparatorColor = item.presentationData.theme.list.itemPlainSeparatorColor
|
||||||
contentSize = CGSize(width: params.width, height: 44.0)
|
contentSize = CGSize(width: params.width, height: 22.0 + labelLayout.size.height)
|
||||||
insets = itemListNeighborsPlainInsets(neighbors)
|
insets = itemListNeighborsPlainInsets(neighbors)
|
||||||
|
|
||||||
let layout = ListViewItemNodeLayout(contentSize: contentSize, insets: insets)
|
let layout = ListViewItemNodeLayout(contentSize: contentSize, insets: insets)
|
||||||
@ -236,7 +236,8 @@ class UserInfoEditingPhoneItemNode: ItemListRevealOptionsItemNode, ItemListItemN
|
|||||||
|
|
||||||
strongSelf.phoneNode.numberField?.textField.textColor = updatedTheme.list.itemPrimaryTextColor
|
strongSelf.phoneNode.numberField?.textField.textColor = updatedTheme.list.itemPrimaryTextColor
|
||||||
strongSelf.phoneNode.numberField?.textField.keyboardAppearance = updatedTheme.rootController.keyboardColor.keyboardAppearance
|
strongSelf.phoneNode.numberField?.textField.keyboardAppearance = updatedTheme.rootController.keyboardColor.keyboardAppearance
|
||||||
strongSelf.phoneNode.numberField?.textField.tintColor = item.theme.list.itemAccentColor
|
strongSelf.phoneNode.numberField?.textField.tintColor = item.presentationData.theme.list.itemAccentColor
|
||||||
|
strongSelf.phoneNode.numberField?.textField.font = titleFont
|
||||||
|
|
||||||
strongSelf.clearButton.setImage(generateClearIcon(color: updatedTheme.list.inputClearButtonColor), for: [])
|
strongSelf.clearButton.setImage(generateClearIcon(color: updatedTheme.list.inputClearButtonColor), for: [])
|
||||||
}
|
}
|
||||||
@ -283,7 +284,7 @@ class UserInfoEditingPhoneItemNode: ItemListRevealOptionsItemNode, ItemListItemN
|
|||||||
|
|
||||||
strongSelf.updateLayout(size: layout.contentSize, leftInset: params.leftInset, rightInset: params.rightInset)
|
strongSelf.updateLayout(size: layout.contentSize, leftInset: params.leftInset, rightInset: params.rightInset)
|
||||||
|
|
||||||
strongSelf.setRevealOptions((left: [], right: [ItemListRevealOption(key: 0, title: item.strings.Common_Delete, icon: .none, color: item.theme.list.itemDisclosureActions.destructive.fillColor, textColor: item.theme.list.itemDisclosureActions.destructive.foregroundColor)]))
|
strongSelf.setRevealOptions((left: [], right: [ItemListRevealOption(key: 0, title: item.presentationData.strings.Common_Delete, icon: .none, color: item.presentationData.theme.list.itemDisclosureActions.destructive.fillColor, textColor: item.presentationData.theme.list.itemDisclosureActions.destructive.foregroundColor)]))
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -83,6 +83,7 @@ class ThemeSettingsFontSizeItemNode: ListViewItemNode, ItemListItemNode {
|
|||||||
private var sliderView: TGPhotoEditorSliderView?
|
private var sliderView: TGPhotoEditorSliderView?
|
||||||
private let leftIconNode: ASImageNode
|
private let leftIconNode: ASImageNode
|
||||||
private let rightIconNode: ASImageNode
|
private let rightIconNode: ASImageNode
|
||||||
|
private let disabledOverlayNode: ASDisplayNode
|
||||||
|
|
||||||
private var item: ThemeSettingsFontSizeItem?
|
private var item: ThemeSettingsFontSizeItem?
|
||||||
private var layoutParams: ListViewItemLayoutParams?
|
private var layoutParams: ListViewItemLayoutParams?
|
||||||
@ -111,10 +112,14 @@ class ThemeSettingsFontSizeItemNode: ListViewItemNode, ItemListItemNode {
|
|||||||
self.rightIconNode.displaysAsynchronously = false
|
self.rightIconNode.displaysAsynchronously = false
|
||||||
self.rightIconNode.displayWithoutProcessing = true
|
self.rightIconNode.displayWithoutProcessing = true
|
||||||
|
|
||||||
|
self.disabledOverlayNode = ASDisplayNode()
|
||||||
|
|
||||||
super.init(layerBacked: false, dynamicBounce: false)
|
super.init(layerBacked: false, dynamicBounce: false)
|
||||||
|
|
||||||
self.addSubnode(self.leftIconNode)
|
self.addSubnode(self.leftIconNode)
|
||||||
self.addSubnode(self.rightIconNode)
|
self.addSubnode(self.rightIconNode)
|
||||||
|
|
||||||
|
self.addSubnode(self.disabledOverlayNode)
|
||||||
}
|
}
|
||||||
|
|
||||||
override func didLoad() {
|
override func didLoad() {
|
||||||
@ -159,7 +164,7 @@ class ThemeSettingsFontSizeItemNode: ListViewItemNode, ItemListItemNode {
|
|||||||
|
|
||||||
sliderView.frame = CGRect(origin: CGPoint(x: params.leftInset + 38.0, y: 8.0), size: CGSize(width: params.width - params.leftInset - params.rightInset - 38.0 * 2.0, height: 44.0))
|
sliderView.frame = CGRect(origin: CGPoint(x: params.leftInset + 38.0, y: 8.0), size: CGSize(width: params.width - params.leftInset - params.rightInset - 38.0 * 2.0, height: 44.0))
|
||||||
}
|
}
|
||||||
self.view.addSubview(sliderView)
|
self.view.insertSubview(sliderView, belowSubview: self.disabledOverlayNode.view)
|
||||||
sliderView.addTarget(self, action: #selector(self.sliderValueChanged), for: .valueChanged)
|
sliderView.addTarget(self, action: #selector(self.sliderValueChanged), for: .valueChanged)
|
||||||
self.sliderView = sliderView
|
self.sliderView = sliderView
|
||||||
}
|
}
|
||||||
@ -204,6 +209,10 @@ class ThemeSettingsFontSizeItemNode: ListViewItemNode, ItemListItemNode {
|
|||||||
strongSelf.topStripeNode.backgroundColor = item.theme.list.itemBlocksSeparatorColor
|
strongSelf.topStripeNode.backgroundColor = item.theme.list.itemBlocksSeparatorColor
|
||||||
strongSelf.bottomStripeNode.backgroundColor = item.theme.list.itemBlocksSeparatorColor
|
strongSelf.bottomStripeNode.backgroundColor = item.theme.list.itemBlocksSeparatorColor
|
||||||
|
|
||||||
|
strongSelf.disabledOverlayNode.backgroundColor = item.theme.list.itemBlocksBackgroundColor.withAlphaComponent(0.4)
|
||||||
|
strongSelf.disabledOverlayNode.isHidden = item.enabled
|
||||||
|
strongSelf.disabledOverlayNode.frame = CGRect(origin: CGPoint(x: params.leftInset, y: 8.0), size: CGSize(width: params.width - params.leftInset - params.rightInset, height: 44.0))
|
||||||
|
|
||||||
if strongSelf.backgroundNode.supernode == nil {
|
if strongSelf.backgroundNode.supernode == nil {
|
||||||
strongSelf.insertSubnode(strongSelf.backgroundNode, at: 0)
|
strongSelf.insertSubnode(strongSelf.backgroundNode, at: 0)
|
||||||
}
|
}
|
||||||
|
@ -7,6 +7,7 @@ import AsyncDisplayKit
|
|||||||
import TelegramCore
|
import TelegramCore
|
||||||
import SyncCore
|
import SyncCore
|
||||||
import TelegramPresentationData
|
import TelegramPresentationData
|
||||||
|
import TelegramUIPreferences
|
||||||
import AccountContext
|
import AccountContext
|
||||||
|
|
||||||
private class ChatGridLiveSelectorRecognizer: UIPanGestureRecognizer {
|
private class ChatGridLiveSelectorRecognizer: UIPanGestureRecognizer {
|
||||||
@ -73,11 +74,11 @@ struct ChatHistoryGridViewTransition {
|
|||||||
let stationaryItems: GridNodeStationaryItems
|
let stationaryItems: GridNodeStationaryItems
|
||||||
}
|
}
|
||||||
|
|
||||||
private func mappedInsertEntries(context: AccountContext, peerId: PeerId, controllerInteraction: ChatControllerInteraction, entries: [ChatHistoryViewTransitionInsertEntry], theme: PresentationTheme, strings: PresentationStrings) -> [GridNodeInsertItem] {
|
private func mappedInsertEntries(context: AccountContext, peerId: PeerId, controllerInteraction: ChatControllerInteraction, entries: [ChatHistoryViewTransitionInsertEntry], theme: PresentationTheme, strings: PresentationStrings, fontSize: PresentationFontSize) -> [GridNodeInsertItem] {
|
||||||
return entries.map { entry -> GridNodeInsertItem in
|
return entries.map { entry -> GridNodeInsertItem in
|
||||||
switch entry.entry {
|
switch entry.entry {
|
||||||
case let .MessageEntry(message, _, _, _, _, _):
|
case let .MessageEntry(message, _, _, _, _, _):
|
||||||
return GridNodeInsertItem(index: entry.index, item: GridMessageItem(theme: theme, strings: strings, context: context, message: message, controllerInteraction: controllerInteraction), previousIndex: entry.previousIndex)
|
return GridNodeInsertItem(index: entry.index, item: GridMessageItem(theme: theme, strings: strings, fontSize: fontSize, context: context, message: message, controllerInteraction: controllerInteraction), previousIndex: entry.previousIndex)
|
||||||
case .MessageGroupEntry:
|
case .MessageGroupEntry:
|
||||||
return GridNodeInsertItem(index: entry.index, item: GridHoleItem(), previousIndex: entry.previousIndex)
|
return GridNodeInsertItem(index: entry.index, item: GridHoleItem(), previousIndex: entry.previousIndex)
|
||||||
case .UnreadEntry:
|
case .UnreadEntry:
|
||||||
@ -90,11 +91,11 @@ private func mappedInsertEntries(context: AccountContext, peerId: PeerId, contro
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private func mappedUpdateEntries(context: AccountContext, peerId: PeerId, controllerInteraction: ChatControllerInteraction, entries: [ChatHistoryViewTransitionUpdateEntry], theme: PresentationTheme, strings: PresentationStrings) -> [GridNodeUpdateItem] {
|
private func mappedUpdateEntries(context: AccountContext, peerId: PeerId, controllerInteraction: ChatControllerInteraction, entries: [ChatHistoryViewTransitionUpdateEntry], theme: PresentationTheme, strings: PresentationStrings, fontSize: PresentationFontSize) -> [GridNodeUpdateItem] {
|
||||||
return entries.map { entry -> GridNodeUpdateItem in
|
return entries.map { entry -> GridNodeUpdateItem in
|
||||||
switch entry.entry {
|
switch entry.entry {
|
||||||
case let .MessageEntry(message, _, _, _, _, _):
|
case let .MessageEntry(message, _, _, _, _, _):
|
||||||
return GridNodeUpdateItem(index: entry.index, previousIndex: entry.previousIndex, item: GridMessageItem(theme: theme, strings: strings, context: context, message: message, controllerInteraction: controllerInteraction))
|
return GridNodeUpdateItem(index: entry.index, previousIndex: entry.previousIndex, item: GridMessageItem(theme: theme, strings: strings, fontSize: fontSize, context: context, message: message, controllerInteraction: controllerInteraction))
|
||||||
case .MessageGroupEntry:
|
case .MessageGroupEntry:
|
||||||
return GridNodeUpdateItem(index: entry.index, previousIndex: entry.previousIndex, item: GridHoleItem())
|
return GridNodeUpdateItem(index: entry.index, previousIndex: entry.previousIndex, item: GridHoleItem())
|
||||||
case .UnreadEntry:
|
case .UnreadEntry:
|
||||||
@ -189,7 +190,7 @@ private func mappedChatHistoryViewListTransition(context: AccountContext, peerId
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return ChatHistoryGridViewTransition(historyView: transition.historyView, topOffsetWithinMonth: topOffsetWithinMonth, deleteItems: transition.deleteItems.map { $0.index }, insertItems: mappedInsertEntries(context: context, peerId: peerId, controllerInteraction: controllerInteraction, entries: transition.insertEntries, theme: presentationData.theme.theme, strings: presentationData.strings), updateItems: mappedUpdateEntries(context: context, peerId: peerId, controllerInteraction: controllerInteraction, entries: transition.updateEntries, theme: presentationData.theme.theme, strings: presentationData.strings), scrollToItem: mappedScrollToItem, stationaryItems: stationaryItems)
|
return ChatHistoryGridViewTransition(historyView: transition.historyView, topOffsetWithinMonth: topOffsetWithinMonth, deleteItems: transition.deleteItems.map { $0.index }, insertItems: mappedInsertEntries(context: context, peerId: peerId, controllerInteraction: controllerInteraction, entries: transition.insertEntries, theme: presentationData.theme.theme, strings: presentationData.strings, fontSize: presentationData.fontSize), updateItems: mappedUpdateEntries(context: context, peerId: peerId, controllerInteraction: controllerInteraction, entries: transition.updateEntries, theme: presentationData.theme.theme, strings: presentationData.strings, fontSize: presentationData.fontSize), scrollToItem: mappedScrollToItem, stationaryItems: stationaryItems)
|
||||||
}
|
}
|
||||||
|
|
||||||
private func gridNodeLayoutForContainerLayout(size: CGSize) -> GridNodeLayoutType {
|
private func gridNodeLayoutForContainerLayout(size: CGSize) -> GridNodeLayoutType {
|
||||||
|
@ -5,6 +5,7 @@ import Display
|
|||||||
import TelegramCore
|
import TelegramCore
|
||||||
import SyncCore
|
import SyncCore
|
||||||
import TelegramPresentationData
|
import TelegramPresentationData
|
||||||
|
import TelegramUIPreferences
|
||||||
import AccountContext
|
import AccountContext
|
||||||
|
|
||||||
enum ChatInputContextPanelPlacement {
|
enum ChatInputContextPanelPlacement {
|
||||||
@ -17,10 +18,12 @@ class ChatInputContextPanelNode: ASDisplayNode {
|
|||||||
var interfaceInteraction: ChatPanelInterfaceInteraction?
|
var interfaceInteraction: ChatPanelInterfaceInteraction?
|
||||||
var placement: ChatInputContextPanelPlacement = .overPanels
|
var placement: ChatInputContextPanelPlacement = .overPanels
|
||||||
var theme: PresentationTheme
|
var theme: PresentationTheme
|
||||||
|
var fontSize: PresentationFontSize
|
||||||
|
|
||||||
init(context: AccountContext, theme: PresentationTheme, strings: PresentationStrings) {
|
init(context: AccountContext, theme: PresentationTheme, strings: PresentationStrings, fontSize: PresentationFontSize) {
|
||||||
self.context = context
|
self.context = context
|
||||||
self.theme = theme
|
self.theme = theme
|
||||||
|
self.fontSize = fontSize
|
||||||
|
|
||||||
super.init()
|
super.init()
|
||||||
}
|
}
|
||||||
|
@ -59,7 +59,7 @@ func inputContextPanelForChatPresentationIntefaceState(_ chatPresentationInterfa
|
|||||||
if let currentPanel = currentPanel as? DisabledContextResultsChatInputContextPanelNode {
|
if let currentPanel = currentPanel as? DisabledContextResultsChatInputContextPanelNode {
|
||||||
return currentPanel
|
return currentPanel
|
||||||
} else {
|
} else {
|
||||||
let panel = DisabledContextResultsChatInputContextPanelNode(context: context, theme: chatPresentationInterfaceState.theme, strings: chatPresentationInterfaceState.strings)
|
let panel = DisabledContextResultsChatInputContextPanelNode(context: context, theme: chatPresentationInterfaceState.theme, strings: chatPresentationInterfaceState.strings, fontSize: chatPresentationInterfaceState.fontSize)
|
||||||
panel.interfaceInteraction = interfaceInteraction
|
panel.interfaceInteraction = interfaceInteraction
|
||||||
return panel
|
return panel
|
||||||
}
|
}
|
||||||
@ -75,7 +75,7 @@ func inputContextPanelForChatPresentationIntefaceState(_ chatPresentationInterfa
|
|||||||
currentPanel.updateResults(results.map({ $0.file }))
|
currentPanel.updateResults(results.map({ $0.file }))
|
||||||
return currentPanel
|
return currentPanel
|
||||||
} else {
|
} else {
|
||||||
let panel = HorizontalStickersChatContextPanelNode(context: context, theme: chatPresentationInterfaceState.theme, strings: chatPresentationInterfaceState.strings)
|
let panel = HorizontalStickersChatContextPanelNode(context: context, theme: chatPresentationInterfaceState.theme, strings: chatPresentationInterfaceState.strings, fontSize: chatPresentationInterfaceState.fontSize)
|
||||||
panel.controllerInteraction = controllerInteraction
|
panel.controllerInteraction = controllerInteraction
|
||||||
panel.interfaceInteraction = interfaceInteraction
|
panel.interfaceInteraction = interfaceInteraction
|
||||||
panel.updateResults(results.map({ $0.file }))
|
panel.updateResults(results.map({ $0.file }))
|
||||||
@ -88,7 +88,7 @@ func inputContextPanelForChatPresentationIntefaceState(_ chatPresentationInterfa
|
|||||||
currentPanel.updateResults(results)
|
currentPanel.updateResults(results)
|
||||||
return currentPanel
|
return currentPanel
|
||||||
} else {
|
} else {
|
||||||
let panel = HashtagChatInputContextPanelNode(context: context, theme: chatPresentationInterfaceState.theme, strings: chatPresentationInterfaceState.strings)
|
let panel = HashtagChatInputContextPanelNode(context: context, theme: chatPresentationInterfaceState.theme, strings: chatPresentationInterfaceState.strings, fontSize: chatPresentationInterfaceState.fontSize)
|
||||||
panel.interfaceInteraction = interfaceInteraction
|
panel.interfaceInteraction = interfaceInteraction
|
||||||
panel.updateResults(results)
|
panel.updateResults(results)
|
||||||
return panel
|
return panel
|
||||||
@ -100,7 +100,7 @@ func inputContextPanelForChatPresentationIntefaceState(_ chatPresentationInterfa
|
|||||||
currentPanel.updateResults(results)
|
currentPanel.updateResults(results)
|
||||||
return currentPanel
|
return currentPanel
|
||||||
} else {
|
} else {
|
||||||
let panel = EmojisChatInputContextPanelNode(context: context, theme: chatPresentationInterfaceState.theme, strings: chatPresentationInterfaceState.strings)
|
let panel = EmojisChatInputContextPanelNode(context: context, theme: chatPresentationInterfaceState.theme, strings: chatPresentationInterfaceState.strings, fontSize: chatPresentationInterfaceState.fontSize)
|
||||||
panel.interfaceInteraction = interfaceInteraction
|
panel.interfaceInteraction = interfaceInteraction
|
||||||
panel.updateResults(results)
|
panel.updateResults(results)
|
||||||
return panel
|
return panel
|
||||||
@ -112,7 +112,7 @@ func inputContextPanelForChatPresentationIntefaceState(_ chatPresentationInterfa
|
|||||||
currentPanel.updateResults(peers)
|
currentPanel.updateResults(peers)
|
||||||
return currentPanel
|
return currentPanel
|
||||||
} else {
|
} else {
|
||||||
let panel = MentionChatInputContextPanelNode(context: context, theme: chatPresentationInterfaceState.theme, strings: chatPresentationInterfaceState.strings, mode: .input)
|
let panel = MentionChatInputContextPanelNode(context: context, theme: chatPresentationInterfaceState.theme, strings: chatPresentationInterfaceState.strings, fontSize: chatPresentationInterfaceState.fontSize, mode: .input)
|
||||||
panel.interfaceInteraction = interfaceInteraction
|
panel.interfaceInteraction = interfaceInteraction
|
||||||
panel.updateResults(peers)
|
panel.updateResults(peers)
|
||||||
return panel
|
return panel
|
||||||
@ -126,7 +126,7 @@ func inputContextPanelForChatPresentationIntefaceState(_ chatPresentationInterfa
|
|||||||
currentPanel.updateResults(commands)
|
currentPanel.updateResults(commands)
|
||||||
return currentPanel
|
return currentPanel
|
||||||
} else {
|
} else {
|
||||||
let panel = CommandChatInputContextPanelNode(context: context, theme: chatPresentationInterfaceState.theme, strings: chatPresentationInterfaceState.strings)
|
let panel = CommandChatInputContextPanelNode(context: context, theme: chatPresentationInterfaceState.theme, strings: chatPresentationInterfaceState.strings, fontSize: chatPresentationInterfaceState.fontSize)
|
||||||
panel.interfaceInteraction = interfaceInteraction
|
panel.interfaceInteraction = interfaceInteraction
|
||||||
panel.updateResults(commands)
|
panel.updateResults(commands)
|
||||||
return panel
|
return panel
|
||||||
@ -142,7 +142,7 @@ func inputContextPanelForChatPresentationIntefaceState(_ chatPresentationInterfa
|
|||||||
currentPanel.updateResults(results)
|
currentPanel.updateResults(results)
|
||||||
return currentPanel
|
return currentPanel
|
||||||
} else {
|
} else {
|
||||||
let panel = VerticalListContextResultsChatInputContextPanelNode(context: context, theme: chatPresentationInterfaceState.theme, strings: chatPresentationInterfaceState.strings)
|
let panel = VerticalListContextResultsChatInputContextPanelNode(context: context, theme: chatPresentationInterfaceState.theme, strings: chatPresentationInterfaceState.strings, fontSize: chatPresentationInterfaceState.fontSize)
|
||||||
panel.interfaceInteraction = interfaceInteraction
|
panel.interfaceInteraction = interfaceInteraction
|
||||||
panel.updateResults(results)
|
panel.updateResults(results)
|
||||||
return panel
|
return panel
|
||||||
@ -152,7 +152,7 @@ func inputContextPanelForChatPresentationIntefaceState(_ chatPresentationInterfa
|
|||||||
currentPanel.updateResults(results)
|
currentPanel.updateResults(results)
|
||||||
return currentPanel
|
return currentPanel
|
||||||
} else {
|
} else {
|
||||||
let panel = HorizontalListContextResultsChatInputContextPanelNode(context: context, theme: chatPresentationInterfaceState.theme, strings: chatPresentationInterfaceState.strings)
|
let panel = HorizontalListContextResultsChatInputContextPanelNode(context: context, theme: chatPresentationInterfaceState.theme, strings: chatPresentationInterfaceState.strings, fontSize: chatPresentationInterfaceState.fontSize)
|
||||||
panel.interfaceInteraction = interfaceInteraction
|
panel.interfaceInteraction = interfaceInteraction
|
||||||
panel.updateResults(results)
|
panel.updateResults(results)
|
||||||
return panel
|
return panel
|
||||||
@ -178,7 +178,7 @@ func chatOverlayContextPanelForChatPresentationIntefaceState(_ chatPresentationI
|
|||||||
currentPanel.updateResults(peers)
|
currentPanel.updateResults(peers)
|
||||||
return currentPanel
|
return currentPanel
|
||||||
} else {
|
} else {
|
||||||
let panel = MentionChatInputContextPanelNode(context: context, theme: chatPresentationInterfaceState.theme, strings: chatPresentationInterfaceState.strings, mode: .search)
|
let panel = MentionChatInputContextPanelNode(context: context, theme: chatPresentationInterfaceState.theme, strings: chatPresentationInterfaceState.strings, fontSize: chatPresentationInterfaceState.fontSize, mode: .search)
|
||||||
panel.interfaceInteraction = interfaceInteraction
|
panel.interfaceInteraction = interfaceInteraction
|
||||||
panel.updateResults(peers)
|
panel.updateResults(peers)
|
||||||
return panel
|
return panel
|
||||||
|
@ -6,6 +6,7 @@ import TelegramCore
|
|||||||
import SyncCore
|
import SyncCore
|
||||||
import Display
|
import Display
|
||||||
import TelegramPresentationData
|
import TelegramPresentationData
|
||||||
|
import TelegramUIPreferences
|
||||||
import MergeLists
|
import MergeLists
|
||||||
import AccountContext
|
import AccountContext
|
||||||
|
|
||||||
@ -34,8 +35,8 @@ private struct CommandChatInputContextPanelEntry: Comparable, Identifiable {
|
|||||||
return lhs.index < rhs.index
|
return lhs.index < rhs.index
|
||||||
}
|
}
|
||||||
|
|
||||||
func item(context: AccountContext, commandSelected: @escaping (PeerCommand, Bool) -> Void) -> ListViewItem {
|
func item(context: AccountContext, fontSize: PresentationFontSize, commandSelected: @escaping (PeerCommand, Bool) -> Void) -> ListViewItem {
|
||||||
return CommandChatInputPanelItem(context: context, theme: self.theme, command: self.command, commandSelected: commandSelected)
|
return CommandChatInputPanelItem(context: context, theme: self.theme, fontSize: fontSize, command: self.command, commandSelected: commandSelected)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -45,12 +46,12 @@ private struct CommandChatInputContextPanelTransition {
|
|||||||
let updates: [ListViewUpdateItem]
|
let updates: [ListViewUpdateItem]
|
||||||
}
|
}
|
||||||
|
|
||||||
private func preparedTransition(from fromEntries: [CommandChatInputContextPanelEntry], to toEntries: [CommandChatInputContextPanelEntry], context: AccountContext, commandSelected: @escaping (PeerCommand, Bool) -> Void) -> CommandChatInputContextPanelTransition {
|
private func preparedTransition(from fromEntries: [CommandChatInputContextPanelEntry], to toEntries: [CommandChatInputContextPanelEntry], context: AccountContext, fontSize: PresentationFontSize, commandSelected: @escaping (PeerCommand, Bool) -> Void) -> CommandChatInputContextPanelTransition {
|
||||||
let (deleteIndices, indicesAndItems, updateIndices) = mergeListsStableWithUpdates(leftList: fromEntries, rightList: toEntries)
|
let (deleteIndices, indicesAndItems, updateIndices) = mergeListsStableWithUpdates(leftList: fromEntries, rightList: toEntries)
|
||||||
|
|
||||||
let deletions = deleteIndices.map { ListViewDeleteItem(index: $0, directionHint: nil) }
|
let deletions = deleteIndices.map { ListViewDeleteItem(index: $0, directionHint: nil) }
|
||||||
let insertions = indicesAndItems.map { ListViewInsertItem(index: $0.0, previousIndex: $0.2, item: $0.1.item(context: context, commandSelected: commandSelected), directionHint: nil) }
|
let insertions = indicesAndItems.map { ListViewInsertItem(index: $0.0, previousIndex: $0.2, item: $0.1.item(context: context, fontSize: fontSize, commandSelected: commandSelected), directionHint: nil) }
|
||||||
let updates = updateIndices.map { ListViewUpdateItem(index: $0.0, previousIndex: $0.2, item: $0.1.item(context: context, commandSelected: commandSelected), directionHint: nil) }
|
let updates = updateIndices.map { ListViewUpdateItem(index: $0.0, previousIndex: $0.2, item: $0.1.item(context: context, fontSize: fontSize, commandSelected: commandSelected), directionHint: nil) }
|
||||||
|
|
||||||
return CommandChatInputContextPanelTransition(deletions: deletions, insertions: insertions, updates: updates)
|
return CommandChatInputContextPanelTransition(deletions: deletions, insertions: insertions, updates: updates)
|
||||||
}
|
}
|
||||||
@ -62,7 +63,7 @@ final class CommandChatInputContextPanelNode: ChatInputContextPanelNode {
|
|||||||
private var enqueuedTransitions: [(CommandChatInputContextPanelTransition, Bool)] = []
|
private var enqueuedTransitions: [(CommandChatInputContextPanelTransition, Bool)] = []
|
||||||
private var validLayout: (CGSize, CGFloat, CGFloat, CGFloat)?
|
private var validLayout: (CGSize, CGFloat, CGFloat, CGFloat)?
|
||||||
|
|
||||||
override init(context: AccountContext, theme: PresentationTheme, strings: PresentationStrings) {
|
override init(context: AccountContext, theme: PresentationTheme, strings: PresentationStrings, fontSize: PresentationFontSize) {
|
||||||
self.listView = ListView()
|
self.listView = ListView()
|
||||||
self.listView.isOpaque = false
|
self.listView.isOpaque = false
|
||||||
self.listView.stackFromBottom = true
|
self.listView.stackFromBottom = true
|
||||||
@ -70,7 +71,7 @@ final class CommandChatInputContextPanelNode: ChatInputContextPanelNode {
|
|||||||
self.listView.limitHitTestToNodes = true
|
self.listView.limitHitTestToNodes = true
|
||||||
self.listView.view.disablesInteractiveTransitionGestureRecognizer = true
|
self.listView.view.disablesInteractiveTransitionGestureRecognizer = true
|
||||||
|
|
||||||
super.init(context: context, theme: theme, strings: strings)
|
super.init(context: context, theme: theme, strings: strings, fontSize: fontSize)
|
||||||
|
|
||||||
self.isOpaque = false
|
self.isOpaque = false
|
||||||
self.clipsToBounds = true
|
self.clipsToBounds = true
|
||||||
@ -96,7 +97,7 @@ final class CommandChatInputContextPanelNode: ChatInputContextPanelNode {
|
|||||||
|
|
||||||
private func prepareTransition(from: [CommandChatInputContextPanelEntry]? , to: [CommandChatInputContextPanelEntry]) {
|
private func prepareTransition(from: [CommandChatInputContextPanelEntry]? , to: [CommandChatInputContextPanelEntry]) {
|
||||||
let firstTime = self.currentEntries == nil
|
let firstTime = self.currentEntries == nil
|
||||||
let transition = preparedTransition(from: from ?? [], to: to, context: self.context, commandSelected: { [weak self] command, sendImmediately in
|
let transition = preparedTransition(from: from ?? [], to: to, context: self.context, fontSize: self.fontSize, commandSelected: { [weak self] command, sendImmediately in
|
||||||
if let strongSelf = self, let interfaceInteraction = strongSelf.interfaceInteraction {
|
if let strongSelf = self, let interfaceInteraction = strongSelf.interfaceInteraction {
|
||||||
if sendImmediately {
|
if sendImmediately {
|
||||||
interfaceInteraction.sendBotCommand(command.peer, "/" + command.command.text)
|
interfaceInteraction.sendBotCommand(command.peer, "/" + command.command.text)
|
||||||
|
@ -7,20 +7,23 @@ import SyncCore
|
|||||||
import SwiftSignalKit
|
import SwiftSignalKit
|
||||||
import Postbox
|
import Postbox
|
||||||
import TelegramPresentationData
|
import TelegramPresentationData
|
||||||
|
import TelegramUIPreferences
|
||||||
import AvatarNode
|
import AvatarNode
|
||||||
import AccountContext
|
import AccountContext
|
||||||
|
|
||||||
final class CommandChatInputPanelItem: ListViewItem {
|
final class CommandChatInputPanelItem: ListViewItem {
|
||||||
fileprivate let context: AccountContext
|
fileprivate let context: AccountContext
|
||||||
fileprivate let theme: PresentationTheme
|
fileprivate let theme: PresentationTheme
|
||||||
|
fileprivate let fontSize: PresentationFontSize
|
||||||
fileprivate let command: PeerCommand
|
fileprivate let command: PeerCommand
|
||||||
fileprivate let commandSelected: (PeerCommand, Bool) -> Void
|
fileprivate let commandSelected: (PeerCommand, Bool) -> Void
|
||||||
|
|
||||||
let selectable: Bool = true
|
let selectable: Bool = true
|
||||||
|
|
||||||
public init(context: AccountContext, theme: PresentationTheme, command: PeerCommand, commandSelected: @escaping (PeerCommand, Bool) -> Void) {
|
public init(context: AccountContext, theme: PresentationTheme, fontSize: PresentationFontSize, command: PeerCommand, commandSelected: @escaping (PeerCommand, Bool) -> Void) {
|
||||||
self.context = context
|
self.context = context
|
||||||
self.theme = theme
|
self.theme = theme
|
||||||
|
self.fontSize = fontSize
|
||||||
self.command = command
|
self.command = command
|
||||||
self.commandSelected = commandSelected
|
self.commandSelected = commandSelected
|
||||||
}
|
}
|
||||||
@ -78,8 +81,6 @@ final class CommandChatInputPanelItem: ListViewItem {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private let avatarFont = avatarPlaceholderFont(size: 16.0)
|
private let avatarFont = avatarPlaceholderFont(size: 16.0)
|
||||||
private let textFont = Font.medium(14.0)
|
|
||||||
private let descriptionFont = Font.regular(14.0)
|
|
||||||
|
|
||||||
final class CommandChatInputPanelItemNode: ListViewItemNode {
|
final class CommandChatInputPanelItemNode: ListViewItemNode {
|
||||||
static let itemHeight: CGFloat = 42.0
|
static let itemHeight: CGFloat = 42.0
|
||||||
@ -134,6 +135,9 @@ final class CommandChatInputPanelItemNode: ListViewItemNode {
|
|||||||
let makeTextLayout = TextNode.asyncLayout(self.textNode)
|
let makeTextLayout = TextNode.asyncLayout(self.textNode)
|
||||||
|
|
||||||
return { [weak self] item, params, mergedTop, mergedBottom in
|
return { [weak self] item, params, mergedTop, mergedBottom in
|
||||||
|
let textFont = Font.medium(floor(item.fontSize.baseDisplaySize * 14.0 / 17.0))
|
||||||
|
let descriptionFont = Font.regular(floor(item.fontSize.baseDisplaySize * 14.0 / 17.0))
|
||||||
|
|
||||||
let leftInset: CGFloat = 55.0 + params.leftInset
|
let leftInset: CGFloat = 55.0 + params.leftInset
|
||||||
let rightInset: CGFloat = 10.0 + params.rightInset
|
let rightInset: CGFloat = 10.0 + params.rightInset
|
||||||
|
|
||||||
|
@ -6,6 +6,7 @@ import AsyncDisplayKit
|
|||||||
import Display
|
import Display
|
||||||
import TelegramPresentationData
|
import TelegramPresentationData
|
||||||
import TelegramStringFormatting
|
import TelegramStringFormatting
|
||||||
|
import TelegramUIPreferences
|
||||||
import AccountContext
|
import AccountContext
|
||||||
|
|
||||||
final class DisabledContextResultsChatInputContextPanelNode: ChatInputContextPanelNode {
|
final class DisabledContextResultsChatInputContextPanelNode: ChatInputContextPanelNode {
|
||||||
@ -15,14 +16,14 @@ final class DisabledContextResultsChatInputContextPanelNode: ChatInputContextPan
|
|||||||
|
|
||||||
private var validLayout: (CGSize, CGFloat, CGFloat, CGFloat)?
|
private var validLayout: (CGSize, CGFloat, CGFloat, CGFloat)?
|
||||||
|
|
||||||
override init(context: AccountContext, theme: PresentationTheme, strings: PresentationStrings) {
|
override init(context: AccountContext, theme: PresentationTheme, strings: PresentationStrings, fontSize: PresentationFontSize) {
|
||||||
self.containerNode = ASDisplayNode()
|
self.containerNode = ASDisplayNode()
|
||||||
self.separatorNode = ASDisplayNode()
|
self.separatorNode = ASDisplayNode()
|
||||||
self.textNode = ImmediateTextNode()
|
self.textNode = ImmediateTextNode()
|
||||||
self.textNode.maximumNumberOfLines = 0
|
self.textNode.maximumNumberOfLines = 0
|
||||||
self.textNode.textAlignment = .center
|
self.textNode.textAlignment = .center
|
||||||
|
|
||||||
super.init(context: context, theme: theme, strings: strings)
|
super.init(context: context, theme: theme, strings: strings, fontSize: fontSize)
|
||||||
|
|
||||||
self.isOpaque = false
|
self.isOpaque = false
|
||||||
self.clipsToBounds = true
|
self.clipsToBounds = true
|
||||||
|
@ -6,6 +6,7 @@ import TelegramCore
|
|||||||
import SyncCore
|
import SyncCore
|
||||||
import Display
|
import Display
|
||||||
import TelegramPresentationData
|
import TelegramPresentationData
|
||||||
|
import TelegramUIPreferences
|
||||||
import MergeLists
|
import MergeLists
|
||||||
import AccountContext
|
import AccountContext
|
||||||
import Emoji
|
import Emoji
|
||||||
@ -105,7 +106,7 @@ final class EmojisChatInputContextPanelNode: ChatInputContextPanelNode {
|
|||||||
private var validLayout: (CGSize, CGFloat, CGFloat, CGFloat)?
|
private var validLayout: (CGSize, CGFloat, CGFloat, CGFloat)?
|
||||||
private var presentationInterfaceState: ChatPresentationInterfaceState?
|
private var presentationInterfaceState: ChatPresentationInterfaceState?
|
||||||
|
|
||||||
override init(context: AccountContext, theme: PresentationTheme, strings: PresentationStrings) {
|
override init(context: AccountContext, theme: PresentationTheme, strings: PresentationStrings, fontSize: PresentationFontSize) {
|
||||||
self.backgroundNode = ASImageNode()
|
self.backgroundNode = ASImageNode()
|
||||||
self.backgroundNode.displayWithoutProcessing = true
|
self.backgroundNode.displayWithoutProcessing = true
|
||||||
self.backgroundNode.displaysAsynchronously = false
|
self.backgroundNode.displaysAsynchronously = false
|
||||||
@ -130,7 +131,7 @@ final class EmojisChatInputContextPanelNode: ChatInputContextPanelNode {
|
|||||||
self.listView.view.disablesInteractiveTransitionGestureRecognizer = true
|
self.listView.view.disablesInteractiveTransitionGestureRecognizer = true
|
||||||
self.listView.transform = CATransform3DMakeRotation(-CGFloat.pi / 2.0, 0.0, 0.0, 1.0)
|
self.listView.transform = CATransform3DMakeRotation(-CGFloat.pi / 2.0, 0.0, 0.0, 1.0)
|
||||||
|
|
||||||
super.init(context: context, theme: theme, strings: strings)
|
super.init(context: context, theme: theme, strings: strings, fontSize: fontSize)
|
||||||
|
|
||||||
self.placement = .overTextInput
|
self.placement = .overTextInput
|
||||||
self.isOpaque = false
|
self.isOpaque = false
|
||||||
|
@ -7,6 +7,7 @@ import SyncCore
|
|||||||
import Postbox
|
import Postbox
|
||||||
import SwiftSignalKit
|
import SwiftSignalKit
|
||||||
import TelegramPresentationData
|
import TelegramPresentationData
|
||||||
|
import TelegramUIPreferences
|
||||||
import TelegramStringFormatting
|
import TelegramStringFormatting
|
||||||
import AccountContext
|
import AccountContext
|
||||||
import RadialStatusNode
|
import RadialStatusNode
|
||||||
@ -39,6 +40,7 @@ final class GridMessageItemSection: GridSection {
|
|||||||
|
|
||||||
fileprivate let theme: PresentationTheme
|
fileprivate let theme: PresentationTheme
|
||||||
private let strings: PresentationStrings
|
private let strings: PresentationStrings
|
||||||
|
private let fontSize: PresentationFontSize
|
||||||
|
|
||||||
private let roundedTimestamp: Int32
|
private let roundedTimestamp: Int32
|
||||||
private let month: Int32
|
private let month: Int32
|
||||||
@ -48,9 +50,10 @@ final class GridMessageItemSection: GridSection {
|
|||||||
return self.roundedTimestamp.hashValue
|
return self.roundedTimestamp.hashValue
|
||||||
}
|
}
|
||||||
|
|
||||||
init(timestamp: Int32, theme: PresentationTheme, strings: PresentationStrings) {
|
init(timestamp: Int32, theme: PresentationTheme, strings: PresentationStrings, fontSize: PresentationFontSize) {
|
||||||
self.theme = theme
|
self.theme = theme
|
||||||
self.strings = strings
|
self.strings = strings
|
||||||
|
self.fontSize = fontSize
|
||||||
|
|
||||||
var now = time_t(timestamp)
|
var now = time_t(timestamp)
|
||||||
var timeinfoNow: tm = tm()
|
var timeinfoNow: tm = tm()
|
||||||
@ -70,20 +73,20 @@ final class GridMessageItemSection: GridSection {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func node() -> ASDisplayNode {
|
func node() -> ASDisplayNode {
|
||||||
return GridMessageItemSectionNode(theme: self.theme, strings: self.strings, roundedTimestamp: self.roundedTimestamp, month: self.month, year: self.year)
|
return GridMessageItemSectionNode(theme: self.theme, strings: self.strings, fontSize: self.fontSize, roundedTimestamp: self.roundedTimestamp, month: self.month, year: self.year)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private let sectionTitleFont = Font.regular(14.0)
|
|
||||||
|
|
||||||
final class GridMessageItemSectionNode: ASDisplayNode {
|
final class GridMessageItemSectionNode: ASDisplayNode {
|
||||||
var theme: PresentationTheme
|
var theme: PresentationTheme
|
||||||
var strings: PresentationStrings
|
var strings: PresentationStrings
|
||||||
|
var fontSize: PresentationFontSize
|
||||||
let titleNode: ASTextNode
|
let titleNode: ASTextNode
|
||||||
|
|
||||||
init(theme: PresentationTheme, strings: PresentationStrings, roundedTimestamp: Int32, month: Int32, year: Int32) {
|
init(theme: PresentationTheme, strings: PresentationStrings, fontSize: PresentationFontSize, roundedTimestamp: Int32, month: Int32, year: Int32) {
|
||||||
self.theme = theme
|
self.theme = theme
|
||||||
self.strings = strings
|
self.strings = strings
|
||||||
|
self.fontSize = fontSize
|
||||||
|
|
||||||
self.titleNode = ASTextNode()
|
self.titleNode = ASTextNode()
|
||||||
self.titleNode.isUserInteractionEnabled = false
|
self.titleNode.isUserInteractionEnabled = false
|
||||||
@ -92,6 +95,8 @@ final class GridMessageItemSectionNode: ASDisplayNode {
|
|||||||
|
|
||||||
self.backgroundColor = theme.list.plainBackgroundColor.withAlphaComponent(0.9)
|
self.backgroundColor = theme.list.plainBackgroundColor.withAlphaComponent(0.9)
|
||||||
|
|
||||||
|
let sectionTitleFont = Font.regular(floor(fontSize.baseDisplaySize * 14.0 / 17.0))
|
||||||
|
|
||||||
let dateText = stringForMonth(strings: strings, month: month, ofYear: year)
|
let dateText = stringForMonth(strings: strings, month: month, ofYear: year)
|
||||||
self.addSubnode(self.titleNode)
|
self.addSubnode(self.titleNode)
|
||||||
self.titleNode.attributedText = NSAttributedString(string: dateText, font: sectionTitleFont, textColor: theme.list.itemPrimaryTextColor)
|
self.titleNode.attributedText = NSAttributedString(string: dateText, font: sectionTitleFont, textColor: theme.list.itemPrimaryTextColor)
|
||||||
@ -105,7 +110,7 @@ final class GridMessageItemSectionNode: ASDisplayNode {
|
|||||||
let bounds = self.bounds
|
let bounds = self.bounds
|
||||||
|
|
||||||
let titleSize = self.titleNode.measure(CGSize(width: bounds.size.width - 24.0, height: CGFloat.greatestFiniteMagnitude))
|
let titleSize = self.titleNode.measure(CGSize(width: bounds.size.width - 24.0, height: CGFloat.greatestFiniteMagnitude))
|
||||||
self.titleNode.frame = CGRect(origin: CGPoint(x: 12.0, y: 8.0), size: titleSize)
|
self.titleNode.frame = CGRect(origin: CGPoint(x: 12.0, y: floor((bounds.size.height - titleSize.height) / 2.0)), size: titleSize)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -117,13 +122,13 @@ final class GridMessageItem: GridItem {
|
|||||||
private let controllerInteraction: ChatControllerInteraction
|
private let controllerInteraction: ChatControllerInteraction
|
||||||
let section: GridSection?
|
let section: GridSection?
|
||||||
|
|
||||||
init(theme: PresentationTheme, strings: PresentationStrings, context: AccountContext, message: Message, controllerInteraction: ChatControllerInteraction) {
|
init(theme: PresentationTheme, strings: PresentationStrings, fontSize: PresentationFontSize, context: AccountContext, message: Message, controllerInteraction: ChatControllerInteraction) {
|
||||||
self.theme = theme
|
self.theme = theme
|
||||||
self.strings = strings
|
self.strings = strings
|
||||||
self.context = context
|
self.context = context
|
||||||
self.message = message
|
self.message = message
|
||||||
self.controllerInteraction = controllerInteraction
|
self.controllerInteraction = controllerInteraction
|
||||||
self.section = GridMessageItemSection(timestamp: message.timestamp, theme: theme, strings: strings)
|
self.section = GridMessageItemSection(timestamp: message.timestamp, theme: theme, strings: strings, fontSize: fontSize)
|
||||||
}
|
}
|
||||||
|
|
||||||
func node(layout: GridNodeLayout, synchronousLoad: Bool) -> GridItemNode {
|
func node(layout: GridNodeLayout, synchronousLoad: Bool) -> GridItemNode {
|
||||||
|
@ -6,6 +6,7 @@ import TelegramCore
|
|||||||
import SyncCore
|
import SyncCore
|
||||||
import Display
|
import Display
|
||||||
import TelegramPresentationData
|
import TelegramPresentationData
|
||||||
|
import TelegramUIPreferences
|
||||||
import MergeLists
|
import MergeLists
|
||||||
import AccountContext
|
import AccountContext
|
||||||
import AccountContext
|
import AccountContext
|
||||||
@ -35,8 +36,8 @@ private struct HashtagChatInputContextPanelEntry: Comparable, Identifiable {
|
|||||||
return lhs.index < rhs.index
|
return lhs.index < rhs.index
|
||||||
}
|
}
|
||||||
|
|
||||||
func item(account: Account, hashtagSelected: @escaping (String) -> Void) -> ListViewItem {
|
func item(account: Account, fontSize: PresentationFontSize, hashtagSelected: @escaping (String) -> Void) -> ListViewItem {
|
||||||
return HashtagChatInputPanelItem(theme: self.theme, text: self.text, hashtagSelected: hashtagSelected)
|
return HashtagChatInputPanelItem(theme: self.theme, fontSize: fontSize, text: self.text, hashtagSelected: hashtagSelected)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -46,12 +47,12 @@ private struct HashtagChatInputContextPanelTransition {
|
|||||||
let updates: [ListViewUpdateItem]
|
let updates: [ListViewUpdateItem]
|
||||||
}
|
}
|
||||||
|
|
||||||
private func preparedTransition(from fromEntries: [HashtagChatInputContextPanelEntry], to toEntries: [HashtagChatInputContextPanelEntry], account: Account, hashtagSelected: @escaping (String) -> Void) -> HashtagChatInputContextPanelTransition {
|
private func preparedTransition(from fromEntries: [HashtagChatInputContextPanelEntry], to toEntries: [HashtagChatInputContextPanelEntry], account: Account, fontSize: PresentationFontSize, hashtagSelected: @escaping (String) -> Void) -> HashtagChatInputContextPanelTransition {
|
||||||
let (deleteIndices, indicesAndItems, updateIndices) = mergeListsStableWithUpdates(leftList: fromEntries, rightList: toEntries)
|
let (deleteIndices, indicesAndItems, updateIndices) = mergeListsStableWithUpdates(leftList: fromEntries, rightList: toEntries)
|
||||||
|
|
||||||
let deletions = deleteIndices.map { ListViewDeleteItem(index: $0, directionHint: nil) }
|
let deletions = deleteIndices.map { ListViewDeleteItem(index: $0, directionHint: nil) }
|
||||||
let insertions = indicesAndItems.map { ListViewInsertItem(index: $0.0, previousIndex: $0.2, item: $0.1.item(account: account, hashtagSelected: hashtagSelected), directionHint: nil) }
|
let insertions = indicesAndItems.map { ListViewInsertItem(index: $0.0, previousIndex: $0.2, item: $0.1.item(account: account, fontSize: fontSize, hashtagSelected: hashtagSelected), directionHint: nil) }
|
||||||
let updates = updateIndices.map { ListViewUpdateItem(index: $0.0, previousIndex: $0.2, item: $0.1.item(account: account, hashtagSelected: hashtagSelected), directionHint: nil) }
|
let updates = updateIndices.map { ListViewUpdateItem(index: $0.0, previousIndex: $0.2, item: $0.1.item(account: account, fontSize: fontSize, hashtagSelected: hashtagSelected), directionHint: nil) }
|
||||||
|
|
||||||
return HashtagChatInputContextPanelTransition(deletions: deletions, insertions: insertions, updates: updates)
|
return HashtagChatInputContextPanelTransition(deletions: deletions, insertions: insertions, updates: updates)
|
||||||
}
|
}
|
||||||
@ -63,7 +64,7 @@ final class HashtagChatInputContextPanelNode: ChatInputContextPanelNode {
|
|||||||
private var enqueuedTransitions: [(HashtagChatInputContextPanelTransition, Bool)] = []
|
private var enqueuedTransitions: [(HashtagChatInputContextPanelTransition, Bool)] = []
|
||||||
private var validLayout: (CGSize, CGFloat, CGFloat, CGFloat)?
|
private var validLayout: (CGSize, CGFloat, CGFloat, CGFloat)?
|
||||||
|
|
||||||
override init(context: AccountContext, theme: PresentationTheme, strings: PresentationStrings) {
|
override init(context: AccountContext, theme: PresentationTheme, strings: PresentationStrings, fontSize: PresentationFontSize) {
|
||||||
self.listView = ListView()
|
self.listView = ListView()
|
||||||
self.listView.isOpaque = false
|
self.listView.isOpaque = false
|
||||||
self.listView.stackFromBottom = true
|
self.listView.stackFromBottom = true
|
||||||
@ -71,7 +72,7 @@ final class HashtagChatInputContextPanelNode: ChatInputContextPanelNode {
|
|||||||
self.listView.limitHitTestToNodes = true
|
self.listView.limitHitTestToNodes = true
|
||||||
self.listView.view.disablesInteractiveTransitionGestureRecognizer = true
|
self.listView.view.disablesInteractiveTransitionGestureRecognizer = true
|
||||||
|
|
||||||
super.init(context: context, theme: theme, strings: strings)
|
super.init(context: context, theme: theme, strings: strings, fontSize: fontSize)
|
||||||
|
|
||||||
self.isOpaque = false
|
self.isOpaque = false
|
||||||
self.clipsToBounds = true
|
self.clipsToBounds = true
|
||||||
@ -97,7 +98,7 @@ final class HashtagChatInputContextPanelNode: ChatInputContextPanelNode {
|
|||||||
|
|
||||||
private func prepareTransition(from: [HashtagChatInputContextPanelEntry]? , to: [HashtagChatInputContextPanelEntry]) {
|
private func prepareTransition(from: [HashtagChatInputContextPanelEntry]? , to: [HashtagChatInputContextPanelEntry]) {
|
||||||
let firstTime = from == nil
|
let firstTime = from == nil
|
||||||
let transition = preparedTransition(from: from ?? [], to: to, account: self.context.account, hashtagSelected: { [weak self] text in
|
let transition = preparedTransition(from: from ?? [], to: to, account: self.context.account, fontSize: self.fontSize, hashtagSelected: { [weak self] text in
|
||||||
if let strongSelf = self, let interfaceInteraction = strongSelf.interfaceInteraction {
|
if let strongSelf = self, let interfaceInteraction = strongSelf.interfaceInteraction {
|
||||||
interfaceInteraction.updateTextInputStateAndMode { textInputState, inputMode in
|
interfaceInteraction.updateTextInputStateAndMode { textInputState, inputMode in
|
||||||
var hashtagQueryRange: NSRange?
|
var hashtagQueryRange: NSRange?
|
||||||
|
@ -7,16 +7,19 @@ import SyncCore
|
|||||||
import SwiftSignalKit
|
import SwiftSignalKit
|
||||||
import Postbox
|
import Postbox
|
||||||
import TelegramPresentationData
|
import TelegramPresentationData
|
||||||
|
import TelegramUIPreferences
|
||||||
|
|
||||||
final class HashtagChatInputPanelItem: ListViewItem {
|
final class HashtagChatInputPanelItem: ListViewItem {
|
||||||
fileprivate let theme: PresentationTheme
|
fileprivate let theme: PresentationTheme
|
||||||
|
fileprivate let fontSize: PresentationFontSize
|
||||||
fileprivate let text: String
|
fileprivate let text: String
|
||||||
private let hashtagSelected: (String) -> Void
|
private let hashtagSelected: (String) -> Void
|
||||||
|
|
||||||
let selectable: Bool = true
|
let selectable: Bool = true
|
||||||
|
|
||||||
public init(theme: PresentationTheme, text: String, hashtagSelected: @escaping (String) -> Void) {
|
public init(theme: PresentationTheme, fontSize: PresentationFontSize, text: String, hashtagSelected: @escaping (String) -> Void) {
|
||||||
self.theme = theme
|
self.theme = theme
|
||||||
|
self.fontSize = fontSize
|
||||||
self.text = text
|
self.text = text
|
||||||
self.hashtagSelected = hashtagSelected
|
self.hashtagSelected = hashtagSelected
|
||||||
}
|
}
|
||||||
@ -73,8 +76,6 @@ final class HashtagChatInputPanelItem: ListViewItem {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private let textFont = Font.medium(14.0)
|
|
||||||
|
|
||||||
final class HashtagChatInputPanelItemNode: ListViewItemNode {
|
final class HashtagChatInputPanelItemNode: ListViewItemNode {
|
||||||
static let itemHeight: CGFloat = 42.0
|
static let itemHeight: CGFloat = 42.0
|
||||||
private let textNode: TextNode
|
private let textNode: TextNode
|
||||||
@ -115,6 +116,8 @@ final class HashtagChatInputPanelItemNode: ListViewItemNode {
|
|||||||
func asyncLayout() -> (_ item: HashtagChatInputPanelItem, _ params: ListViewItemLayoutParams, _ mergedTop: Bool, _ mergedBottom: Bool) -> (ListViewItemNodeLayout, (ListViewItemUpdateAnimation) -> Void) {
|
func asyncLayout() -> (_ item: HashtagChatInputPanelItem, _ params: ListViewItemLayoutParams, _ mergedTop: Bool, _ mergedBottom: Bool) -> (ListViewItemNodeLayout, (ListViewItemUpdateAnimation) -> Void) {
|
||||||
let makeTextLayout = TextNode.asyncLayout(self.textNode)
|
let makeTextLayout = TextNode.asyncLayout(self.textNode)
|
||||||
return { [weak self] item, params, mergedTop, mergedBottom in
|
return { [weak self] item, params, mergedTop, mergedBottom in
|
||||||
|
let textFont = Font.medium(floor(item.fontSize.baseDisplaySize * 14.0 / 17.0))
|
||||||
|
|
||||||
let baseWidth = params.width - params.leftInset - params.rightInset
|
let baseWidth = params.width - params.leftInset - params.rightInset
|
||||||
|
|
||||||
let leftInset: CGFloat = 15.0 + params.leftInset
|
let leftInset: CGFloat = 15.0 + params.leftInset
|
||||||
|
@ -7,6 +7,7 @@ import SyncCore
|
|||||||
import Display
|
import Display
|
||||||
import SwiftSignalKit
|
import SwiftSignalKit
|
||||||
import TelegramPresentationData
|
import TelegramPresentationData
|
||||||
|
import TelegramUIPreferences
|
||||||
import MergeLists
|
import MergeLists
|
||||||
import AccountContext
|
import AccountContext
|
||||||
import StickerPackPreviewUI
|
import StickerPackPreviewUI
|
||||||
@ -86,7 +87,7 @@ final class HorizontalListContextResultsChatInputContextPanelNode: ChatInputCont
|
|||||||
private var enqueuedTransitions: [(HorizontalListContextResultsChatInputContextPanelTransition, Bool)] = []
|
private var enqueuedTransitions: [(HorizontalListContextResultsChatInputContextPanelTransition, Bool)] = []
|
||||||
private var hasValidLayout = false
|
private var hasValidLayout = false
|
||||||
|
|
||||||
override init(context: AccountContext, theme: PresentationTheme, strings: PresentationStrings) {
|
override init(context: AccountContext, theme: PresentationTheme, strings: PresentationStrings, fontSize: PresentationFontSize) {
|
||||||
self.strings = strings
|
self.strings = strings
|
||||||
|
|
||||||
self.separatorNode = ASDisplayNode()
|
self.separatorNode = ASDisplayNode()
|
||||||
@ -100,7 +101,7 @@ final class HorizontalListContextResultsChatInputContextPanelNode: ChatInputCont
|
|||||||
self.listView.transform = CATransform3DMakeRotation(-CGFloat(CGFloat.pi / 2.0), 0.0, 0.0, 1.0)
|
self.listView.transform = CATransform3DMakeRotation(-CGFloat(CGFloat.pi / 2.0), 0.0, 0.0, 1.0)
|
||||||
self.listView.isHidden = true
|
self.listView.isHidden = true
|
||||||
|
|
||||||
super.init(context: context, theme: theme, strings: strings)
|
super.init(context: context, theme: theme, strings: strings, fontSize: fontSize)
|
||||||
|
|
||||||
self.isOpaque = false
|
self.isOpaque = false
|
||||||
self.clipsToBounds = true
|
self.clipsToBounds = true
|
||||||
|
@ -7,6 +7,7 @@ import SyncCore
|
|||||||
import Display
|
import Display
|
||||||
import SwiftSignalKit
|
import SwiftSignalKit
|
||||||
import TelegramPresentationData
|
import TelegramPresentationData
|
||||||
|
import TelegramUIPreferences
|
||||||
import MergeLists
|
import MergeLists
|
||||||
import AccountContext
|
import AccountContext
|
||||||
import StickerPackPreviewUI
|
import StickerPackPreviewUI
|
||||||
@ -109,7 +110,7 @@ final class HorizontalStickersChatContextPanelNode: ChatInputContextPanelNode {
|
|||||||
|
|
||||||
private var stickerPreviewController: StickerPreviewController?
|
private var stickerPreviewController: StickerPreviewController?
|
||||||
|
|
||||||
override init(context: AccountContext, theme: PresentationTheme, strings: PresentationStrings) {
|
override init(context: AccountContext, theme: PresentationTheme, strings: PresentationStrings, fontSize: PresentationFontSize) {
|
||||||
self.strings = strings
|
self.strings = strings
|
||||||
|
|
||||||
self.backgroundNode = ASImageNode()
|
self.backgroundNode = ASImageNode()
|
||||||
@ -136,7 +137,7 @@ final class HorizontalStickersChatContextPanelNode: ChatInputContextPanelNode {
|
|||||||
|
|
||||||
self.stickersInteraction = HorizontalStickersChatContextPanelInteraction()
|
self.stickersInteraction = HorizontalStickersChatContextPanelInteraction()
|
||||||
|
|
||||||
super.init(context: context, theme: theme, strings: strings)
|
super.init(context: context, theme: theme, strings: strings, fontSize: fontSize)
|
||||||
|
|
||||||
self.placement = .overTextInput
|
self.placement = .overTextInput
|
||||||
self.isOpaque = false
|
self.isOpaque = false
|
||||||
|
@ -3,6 +3,7 @@ import UIKit
|
|||||||
import Display
|
import Display
|
||||||
import AsyncDisplayKit
|
import AsyncDisplayKit
|
||||||
import TelegramPresentationData
|
import TelegramPresentationData
|
||||||
|
import TelegramUIPreferences
|
||||||
import TelegramStringFormatting
|
import TelegramStringFormatting
|
||||||
|
|
||||||
private let timezoneOffset: Int32 = {
|
private let timezoneOffset: Int32 = {
|
||||||
@ -22,11 +23,13 @@ final class ListMessageDateHeader: ListViewItemHeader {
|
|||||||
let id: Int64
|
let id: Int64
|
||||||
let theme: PresentationTheme
|
let theme: PresentationTheme
|
||||||
let strings: PresentationStrings
|
let strings: PresentationStrings
|
||||||
|
let fontSize: PresentationFontSize
|
||||||
|
|
||||||
init(timestamp: Int32, theme: PresentationTheme, strings: PresentationStrings) {
|
init(timestamp: Int32, theme: PresentationTheme, strings: PresentationStrings, fontSize: PresentationFontSize) {
|
||||||
self.timestamp = timestamp
|
self.timestamp = timestamp
|
||||||
self.theme = theme
|
self.theme = theme
|
||||||
self.strings = strings
|
self.strings = strings
|
||||||
|
self.fontSize = fontSize
|
||||||
|
|
||||||
var time: time_t = time_t(timestamp + timezoneOffset)
|
var time: time_t = time_t(timestamp + timezoneOffset)
|
||||||
var timeinfo: tm = tm()
|
var timeinfo: tm = tm()
|
||||||
@ -44,25 +47,24 @@ final class ListMessageDateHeader: ListViewItemHeader {
|
|||||||
let height: CGFloat = 36.0
|
let height: CGFloat = 36.0
|
||||||
|
|
||||||
func node() -> ListViewItemHeaderNode {
|
func node() -> ListViewItemHeaderNode {
|
||||||
return ListMessageDateHeaderNode(theme: self.theme, strings: self.strings, roundedTimestamp: self.roundedTimestamp, month: self.month, year: self.year)
|
return ListMessageDateHeaderNode(theme: self.theme, strings: self.strings, fontSize: self.fontSize, roundedTimestamp: self.roundedTimestamp, month: self.month, year: self.year)
|
||||||
}
|
}
|
||||||
|
|
||||||
func updateNode(_ node: ListViewItemHeaderNode, previous: ListViewItemHeader?, next: ListViewItemHeader?) {
|
func updateNode(_ node: ListViewItemHeaderNode, previous: ListViewItemHeader?, next: ListViewItemHeader?) {
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private let sectionTitleFont = Font.regular(14.0)
|
|
||||||
|
|
||||||
final class ListMessageDateHeaderNode: ListViewItemHeaderNode {
|
final class ListMessageDateHeaderNode: ListViewItemHeaderNode {
|
||||||
var theme: PresentationTheme
|
var theme: PresentationTheme
|
||||||
var strings: PresentationStrings
|
var strings: PresentationStrings
|
||||||
|
var fontSize: PresentationFontSize
|
||||||
let titleNode: ASTextNode
|
let titleNode: ASTextNode
|
||||||
let backgroundNode: ASDisplayNode
|
let backgroundNode: ASDisplayNode
|
||||||
|
|
||||||
init(theme: PresentationTheme, strings: PresentationStrings, roundedTimestamp: Int32, month: Int32, year: Int32) {
|
init(theme: PresentationTheme, strings: PresentationStrings, fontSize: PresentationFontSize, roundedTimestamp: Int32, month: Int32, year: Int32) {
|
||||||
self.theme = theme
|
self.theme = theme
|
||||||
self.strings = strings
|
self.strings = strings
|
||||||
|
self.fontSize = fontSize
|
||||||
|
|
||||||
self.backgroundNode = ASDisplayNode()
|
self.backgroundNode = ASDisplayNode()
|
||||||
self.backgroundNode.isLayerBacked = true
|
self.backgroundNode.isLayerBacked = true
|
||||||
@ -75,6 +77,8 @@ final class ListMessageDateHeaderNode: ListViewItemHeaderNode {
|
|||||||
|
|
||||||
let dateText = stringForMonth(strings: strings, month: month, ofYear: year)
|
let dateText = stringForMonth(strings: strings, month: month, ofYear: year)
|
||||||
|
|
||||||
|
let sectionTitleFont = Font.regular(floor(fontSize.baseDisplaySize * 14.0 / 17.0))
|
||||||
|
|
||||||
self.addSubnode(self.backgroundNode)
|
self.addSubnode(self.backgroundNode)
|
||||||
self.addSubnode(self.titleNode)
|
self.addSubnode(self.titleNode)
|
||||||
self.titleNode.attributedText = NSAttributedString(string: dateText, font: sectionTitleFont, textColor: theme.list.itemPrimaryTextColor)
|
self.titleNode.attributedText = NSAttributedString(string: dateText, font: sectionTitleFont, textColor: theme.list.itemPrimaryTextColor)
|
||||||
@ -97,7 +101,7 @@ final class ListMessageDateHeaderNode: ListViewItemHeaderNode {
|
|||||||
|
|
||||||
override func updateLayout(size: CGSize, leftInset: CGFloat, rightInset: CGFloat) {
|
override func updateLayout(size: CGSize, leftInset: CGFloat, rightInset: CGFloat) {
|
||||||
let titleSize = self.titleNode.measure(CGSize(width: size.width - leftInset - rightInset - 24.0, height: CGFloat.greatestFiniteMagnitude))
|
let titleSize = self.titleNode.measure(CGSize(width: size.width - leftInset - rightInset - 24.0, height: CGFloat.greatestFiniteMagnitude))
|
||||||
self.titleNode.frame = CGRect(origin: CGPoint(x: leftInset + 12.0, y: 8.0), size: titleSize)
|
self.titleNode.frame = CGRect(origin: CGPoint(x: leftInset + 12.0, y: floor((size.height - titleSize.height) / 2.0)), size: titleSize)
|
||||||
self.backgroundNode.frame = CGRect(origin: CGPoint(), size: size)
|
self.backgroundNode.frame = CGRect(origin: CGPoint(), size: size)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -35,7 +35,7 @@ final class ListMessageItem: ListViewItem {
|
|||||||
self.controllerInteraction = controllerInteraction
|
self.controllerInteraction = controllerInteraction
|
||||||
self.message = message
|
self.message = message
|
||||||
if displayHeader {
|
if displayHeader {
|
||||||
self.header = ListMessageDateHeader(timestamp: message.timestamp, theme: theme, strings: strings)
|
self.header = ListMessageDateHeader(timestamp: message.timestamp, theme: theme, strings: strings, fontSize: fontSize)
|
||||||
} else {
|
} else {
|
||||||
self.header = nil
|
self.header = nil
|
||||||
}
|
}
|
||||||
|
@ -6,6 +6,7 @@ import TelegramCore
|
|||||||
import SyncCore
|
import SyncCore
|
||||||
import Display
|
import Display
|
||||||
import TelegramPresentationData
|
import TelegramPresentationData
|
||||||
|
import TelegramUIPreferences
|
||||||
import MergeLists
|
import MergeLists
|
||||||
import TextFormat
|
import TextFormat
|
||||||
import AccountContext
|
import AccountContext
|
||||||
@ -27,8 +28,8 @@ private struct MentionChatInputContextPanelEntry: Comparable, Identifiable {
|
|||||||
return lhs.index < rhs.index
|
return lhs.index < rhs.index
|
||||||
}
|
}
|
||||||
|
|
||||||
func item(context: AccountContext, theme: PresentationTheme, inverted: Bool, peerSelected: @escaping (Peer) -> Void) -> ListViewItem {
|
func item(context: AccountContext, theme: PresentationTheme, fontSize: PresentationFontSize, inverted: Bool, peerSelected: @escaping (Peer) -> Void) -> ListViewItem {
|
||||||
return MentionChatInputPanelItem(context: context, theme: theme, inverted: inverted, peer: self.peer, peerSelected: peerSelected)
|
return MentionChatInputPanelItem(context: context, theme: theme, fontSize: fontSize, inverted: inverted, peer: self.peer, peerSelected: peerSelected)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -38,12 +39,12 @@ private struct CommandChatInputContextPanelTransition {
|
|||||||
let updates: [ListViewUpdateItem]
|
let updates: [ListViewUpdateItem]
|
||||||
}
|
}
|
||||||
|
|
||||||
private func preparedTransition(from fromEntries: [MentionChatInputContextPanelEntry], to toEntries: [MentionChatInputContextPanelEntry], context: AccountContext, theme: PresentationTheme, inverted: Bool, forceUpdate: Bool, peerSelected: @escaping (Peer) -> Void) -> CommandChatInputContextPanelTransition {
|
private func preparedTransition(from fromEntries: [MentionChatInputContextPanelEntry], to toEntries: [MentionChatInputContextPanelEntry], context: AccountContext, theme: PresentationTheme, fontSize: PresentationFontSize, inverted: Bool, forceUpdate: Bool, peerSelected: @escaping (Peer) -> Void) -> CommandChatInputContextPanelTransition {
|
||||||
let (deleteIndices, indicesAndItems, updateIndices) = mergeListsStableWithUpdates(leftList: fromEntries, rightList: toEntries, allUpdated: forceUpdate)
|
let (deleteIndices, indicesAndItems, updateIndices) = mergeListsStableWithUpdates(leftList: fromEntries, rightList: toEntries, allUpdated: forceUpdate)
|
||||||
|
|
||||||
let deletions = deleteIndices.map { ListViewDeleteItem(index: $0, directionHint: nil) }
|
let deletions = deleteIndices.map { ListViewDeleteItem(index: $0, directionHint: nil) }
|
||||||
let insertions = indicesAndItems.map { ListViewInsertItem(index: $0.0, previousIndex: $0.2, item: $0.1.item(context: context, theme: theme, inverted: inverted, peerSelected: peerSelected), directionHint: nil) }
|
let insertions = indicesAndItems.map { ListViewInsertItem(index: $0.0, previousIndex: $0.2, item: $0.1.item(context: context, theme: theme, fontSize: fontSize, inverted: inverted, peerSelected: peerSelected), directionHint: nil) }
|
||||||
let updates = updateIndices.map { ListViewUpdateItem(index: $0.0, previousIndex: $0.2, item: $0.1.item(context: context, theme: theme, inverted: inverted, peerSelected: peerSelected), directionHint: nil) }
|
let updates = updateIndices.map { ListViewUpdateItem(index: $0.0, previousIndex: $0.2, item: $0.1.item(context: context, theme: theme, fontSize: fontSize, inverted: inverted, peerSelected: peerSelected), directionHint: nil) }
|
||||||
|
|
||||||
return CommandChatInputContextPanelTransition(deletions: deletions, insertions: insertions, updates: updates)
|
return CommandChatInputContextPanelTransition(deletions: deletions, insertions: insertions, updates: updates)
|
||||||
}
|
}
|
||||||
@ -62,7 +63,7 @@ final class MentionChatInputContextPanelNode: ChatInputContextPanelNode {
|
|||||||
private var enqueuedTransitions: [(CommandChatInputContextPanelTransition, Bool)] = []
|
private var enqueuedTransitions: [(CommandChatInputContextPanelTransition, Bool)] = []
|
||||||
private var validLayout: (CGSize, CGFloat, CGFloat, CGFloat)?
|
private var validLayout: (CGSize, CGFloat, CGFloat, CGFloat)?
|
||||||
|
|
||||||
init(context: AccountContext, theme: PresentationTheme, strings: PresentationStrings, mode: MentionChatInputContextPanelMode) {
|
init(context: AccountContext, theme: PresentationTheme, strings: PresentationStrings, fontSize: PresentationFontSize, mode: MentionChatInputContextPanelMode) {
|
||||||
self.mode = mode
|
self.mode = mode
|
||||||
|
|
||||||
self.listView = ListView()
|
self.listView = ListView()
|
||||||
@ -72,7 +73,7 @@ final class MentionChatInputContextPanelNode: ChatInputContextPanelNode {
|
|||||||
self.listView.limitHitTestToNodes = true
|
self.listView.limitHitTestToNodes = true
|
||||||
self.listView.view.disablesInteractiveTransitionGestureRecognizer = true
|
self.listView.view.disablesInteractiveTransitionGestureRecognizer = true
|
||||||
|
|
||||||
super.init(context: context, theme: theme, strings: strings)
|
super.init(context: context, theme: theme, strings: strings, fontSize: fontSize)
|
||||||
|
|
||||||
self.isOpaque = false
|
self.isOpaque = false
|
||||||
self.clipsToBounds = true
|
self.clipsToBounds = true
|
||||||
@ -102,7 +103,7 @@ final class MentionChatInputContextPanelNode: ChatInputContextPanelNode {
|
|||||||
|
|
||||||
private func updateToEntries(entries: [MentionChatInputContextPanelEntry], forceUpdate: Bool) {
|
private func updateToEntries(entries: [MentionChatInputContextPanelEntry], forceUpdate: Bool) {
|
||||||
let firstTime = self.currentEntries == nil
|
let firstTime = self.currentEntries == nil
|
||||||
let transition = preparedTransition(from: self.currentEntries ?? [], to: entries, context: self.context, theme: self.theme, inverted: self.mode == .search, forceUpdate: forceUpdate, peerSelected: { [weak self] peer in
|
let transition = preparedTransition(from: self.currentEntries ?? [], to: entries, context: self.context, theme: self.theme, fontSize: self.fontSize, inverted: self.mode == .search, forceUpdate: forceUpdate, peerSelected: { [weak self] peer in
|
||||||
if let strongSelf = self, let interfaceInteraction = strongSelf.interfaceInteraction {
|
if let strongSelf = self, let interfaceInteraction = strongSelf.interfaceInteraction {
|
||||||
switch strongSelf.mode {
|
switch strongSelf.mode {
|
||||||
case .input:
|
case .input:
|
||||||
|
@ -7,21 +7,24 @@ import SyncCore
|
|||||||
import SwiftSignalKit
|
import SwiftSignalKit
|
||||||
import Postbox
|
import Postbox
|
||||||
import TelegramPresentationData
|
import TelegramPresentationData
|
||||||
|
import TelegramUIPreferences
|
||||||
import AvatarNode
|
import AvatarNode
|
||||||
import AccountContext
|
import AccountContext
|
||||||
|
|
||||||
final class MentionChatInputPanelItem: ListViewItem {
|
final class MentionChatInputPanelItem: ListViewItem {
|
||||||
fileprivate let context: AccountContext
|
fileprivate let context: AccountContext
|
||||||
fileprivate let theme: PresentationTheme
|
fileprivate let theme: PresentationTheme
|
||||||
|
fileprivate let fontSize: PresentationFontSize
|
||||||
fileprivate let inverted: Bool
|
fileprivate let inverted: Bool
|
||||||
fileprivate let peer: Peer
|
fileprivate let peer: Peer
|
||||||
private let peerSelected: (Peer) -> Void
|
private let peerSelected: (Peer) -> Void
|
||||||
|
|
||||||
let selectable: Bool = true
|
let selectable: Bool = true
|
||||||
|
|
||||||
public init(context: AccountContext, theme: PresentationTheme, inverted: Bool, peer: Peer, peerSelected: @escaping (Peer) -> Void) {
|
public init(context: AccountContext, theme: PresentationTheme, fontSize: PresentationFontSize, inverted: Bool, peer: Peer, peerSelected: @escaping (Peer) -> Void) {
|
||||||
self.context = context
|
self.context = context
|
||||||
self.theme = theme
|
self.theme = theme
|
||||||
|
self.fontSize = fontSize
|
||||||
self.inverted = inverted
|
self.inverted = inverted
|
||||||
self.peer = peer
|
self.peer = peer
|
||||||
self.peerSelected = peerSelected
|
self.peerSelected = peerSelected
|
||||||
@ -80,8 +83,6 @@ final class MentionChatInputPanelItem: ListViewItem {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private let avatarFont = avatarPlaceholderFont(size: 16.0)
|
private let avatarFont = avatarPlaceholderFont(size: 16.0)
|
||||||
private let primaryFont = Font.medium(14.0)
|
|
||||||
private let secondaryFont = Font.regular(14.0)
|
|
||||||
|
|
||||||
final class MentionChatInputPanelItemNode: ListViewItemNode {
|
final class MentionChatInputPanelItemNode: ListViewItemNode {
|
||||||
static let itemHeight: CGFloat = 42.0
|
static let itemHeight: CGFloat = 42.0
|
||||||
@ -133,6 +134,9 @@ final class MentionChatInputPanelItemNode: ListViewItemNode {
|
|||||||
let previousItem = self.item
|
let previousItem = self.item
|
||||||
|
|
||||||
return { [weak self] item, params, mergedTop, mergedBottom in
|
return { [weak self] item, params, mergedTop, mergedBottom in
|
||||||
|
let primaryFont = Font.medium(floor(item.fontSize.baseDisplaySize * 14.0 / 17.0))
|
||||||
|
let secondaryFont = Font.regular(floor(item.fontSize.baseDisplaySize * 14.0 / 17.0))
|
||||||
|
|
||||||
let leftInset: CGFloat = 55.0 + params.leftInset
|
let leftInset: CGFloat = 55.0 + params.leftInset
|
||||||
let rightInset: CGFloat = 10.0 + params.rightInset
|
let rightInset: CGFloat = 10.0 + params.rightInset
|
||||||
|
|
||||||
|
@ -7,6 +7,7 @@ import SyncCore
|
|||||||
import Display
|
import Display
|
||||||
import SwiftSignalKit
|
import SwiftSignalKit
|
||||||
import TelegramPresentationData
|
import TelegramPresentationData
|
||||||
|
import TelegramUIPreferences
|
||||||
import MergeLists
|
import MergeLists
|
||||||
import AccountContext
|
import AccountContext
|
||||||
import StickerPackPreviewUI
|
import StickerPackPreviewUI
|
||||||
@ -80,7 +81,7 @@ final class StickersChatInputContextPanelNode: ChatInputContextPanelNode {
|
|||||||
|
|
||||||
private var stickerPreviewController: StickerPreviewController?
|
private var stickerPreviewController: StickerPreviewController?
|
||||||
|
|
||||||
override init(context: AccountContext, theme: PresentationTheme, strings: PresentationStrings) {
|
override init(context: AccountContext, theme: PresentationTheme, strings: PresentationStrings, fontSize: PresentationFontSize) {
|
||||||
self.strings = strings
|
self.strings = strings
|
||||||
|
|
||||||
self.listView = ListView()
|
self.listView = ListView()
|
||||||
@ -92,7 +93,7 @@ final class StickersChatInputContextPanelNode: ChatInputContextPanelNode {
|
|||||||
|
|
||||||
self.stickersInteraction = StickersChatInputContextPanelInteraction()
|
self.stickersInteraction = StickersChatInputContextPanelInteraction()
|
||||||
|
|
||||||
super.init(context: context, theme: theme, strings: strings)
|
super.init(context: context, theme: theme, strings: strings, fontSize: fontSize)
|
||||||
|
|
||||||
self.isOpaque = false
|
self.isOpaque = false
|
||||||
self.clipsToBounds = true
|
self.clipsToBounds = true
|
||||||
|
@ -6,6 +6,7 @@ import TelegramCore
|
|||||||
import SyncCore
|
import SyncCore
|
||||||
import Display
|
import Display
|
||||||
import TelegramPresentationData
|
import TelegramPresentationData
|
||||||
|
import TelegramUIPreferences
|
||||||
import MergeLists
|
import MergeLists
|
||||||
import AccountContext
|
import AccountContext
|
||||||
|
|
||||||
@ -127,7 +128,7 @@ final class VerticalListContextResultsChatInputContextPanelNode: ChatInputContex
|
|||||||
private var enqueuedTransitions: [(VerticalListContextResultsChatInputContextPanelTransition, Bool)] = []
|
private var enqueuedTransitions: [(VerticalListContextResultsChatInputContextPanelTransition, Bool)] = []
|
||||||
private var validLayout: (CGSize, CGFloat, CGFloat, CGFloat)?
|
private var validLayout: (CGSize, CGFloat, CGFloat, CGFloat)?
|
||||||
|
|
||||||
override init(context: AccountContext, theme: PresentationTheme, strings: PresentationStrings) {
|
override init(context: AccountContext, theme: PresentationTheme, strings: PresentationStrings, fontSize: PresentationFontSize) {
|
||||||
self.listView = ListView()
|
self.listView = ListView()
|
||||||
self.listView.isOpaque = false
|
self.listView.isOpaque = false
|
||||||
self.listView.stackFromBottom = true
|
self.listView.stackFromBottom = true
|
||||||
@ -136,7 +137,7 @@ final class VerticalListContextResultsChatInputContextPanelNode: ChatInputContex
|
|||||||
self.listView.isHidden = true
|
self.listView.isHidden = true
|
||||||
self.listView.view.disablesInteractiveTransitionGestureRecognizer = true
|
self.listView.view.disablesInteractiveTransitionGestureRecognizer = true
|
||||||
|
|
||||||
super.init(context: context, theme: theme, strings: strings)
|
super.init(context: context, theme: theme, strings: strings, fontSize: fontSize)
|
||||||
|
|
||||||
self.isOpaque = false
|
self.isOpaque = false
|
||||||
self.clipsToBounds = true
|
self.clipsToBounds = true
|
||||||
|
Loading…
x
Reference in New Issue
Block a user