mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-23 22:55:00 +00:00
Folder improvements
This commit is contained in:
@@ -6,8 +6,6 @@ import Display
|
||||
import SwiftSignalKit
|
||||
import TelegramPresentationData
|
||||
|
||||
private let titleFont = Font.regular(17.0)
|
||||
|
||||
class ChatListHoleItem: ListViewItem {
|
||||
let theme: PresentationTheme
|
||||
|
||||
@@ -45,9 +43,6 @@ class ChatListHoleItem: ListViewItem {
|
||||
Queue.mainQueue().async {
|
||||
completion(nodeLayout, { _ in
|
||||
apply()
|
||||
if let nodeValue = node() as? ChatListHoleItemNode {
|
||||
nodeValue.updateBackgroundAndSeparatorsLayout()
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -56,25 +51,11 @@ class ChatListHoleItem: ListViewItem {
|
||||
}
|
||||
}
|
||||
|
||||
private let separatorHeight = 1.0 / UIScreen.main.scale
|
||||
|
||||
class ChatListHoleItemNode: ListViewItemNode {
|
||||
let separatorNode: ASDisplayNode
|
||||
let labelNode: TextNode
|
||||
|
||||
var relativePosition: (first: Bool, last: Bool) = (false, false)
|
||||
|
||||
required init() {
|
||||
self.separatorNode = ASDisplayNode()
|
||||
self.separatorNode.backgroundColor = UIColor(rgb: 0xc8c7cc)
|
||||
self.separatorNode.isLayerBacked = true
|
||||
|
||||
self.labelNode = TextNode()
|
||||
|
||||
super.init(layerBacked: false, dynamicBounce: false)
|
||||
|
||||
self.addSubnode(self.separatorNode)
|
||||
self.addSubnode(self.labelNode)
|
||||
}
|
||||
|
||||
override func layoutForParams(_ params: ListViewItemLayoutParams, item: ListViewItem, previousItem: ListViewItem?, nextItem: ListViewItem?) {
|
||||
@@ -84,45 +65,17 @@ class ChatListHoleItemNode: ListViewItemNode {
|
||||
}
|
||||
|
||||
func asyncLayout() -> (_ item: ChatListHoleItem, _ params: ListViewItemLayoutParams, _ first: Bool, _ last: Bool) -> (ListViewItemNodeLayout, () -> Void) {
|
||||
let labelNodeLayout = TextNode.asyncLayout(self.labelNode)
|
||||
|
||||
return { item, params, first, last in
|
||||
let baseWidth = params.width - params.leftInset - params.rightInset
|
||||
|
||||
let (labelLayout, labelApply) = labelNodeLayout(TextNodeLayoutArguments(attributedString: NSAttributedString(string: "", font: titleFont, textColor: item.theme.chatList.messageTextColor), backgroundColor: nil, maximumNumberOfLines: 1, truncationType: .end, constrainedSize: CGSize(width: baseWidth, height: CGFloat.greatestFiniteMagnitude), alignment: .natural, cutout: nil, insets: UIEdgeInsets()))
|
||||
|
||||
let insets = ChatListItemNode.insets(first: first, last: last, firstWithHeader: false)
|
||||
let layout = ListViewItemNodeLayout(contentSize: CGSize(width: params.width, height: 68.0), insets: insets)
|
||||
|
||||
let separatorInset: CGFloat
|
||||
if last {
|
||||
separatorInset = 0.0
|
||||
} else {
|
||||
separatorInset = 80.0 + params.leftInset
|
||||
}
|
||||
let layout = ListViewItemNodeLayout(contentSize: CGSize(width: params.width, height: 0.0), insets: UIEdgeInsets())
|
||||
|
||||
return (layout, { [weak self] in
|
||||
if let strongSelf = self {
|
||||
strongSelf.relativePosition = (first, last)
|
||||
|
||||
let _ = labelApply()
|
||||
|
||||
strongSelf.separatorNode.backgroundColor = item.theme.chatList.itemSeparatorColor
|
||||
|
||||
strongSelf.labelNode.frame = CGRect(origin: CGPoint(x: floor((params.width - labelLayout.size.width) / 2.0), y: floor((layout.contentSize.height - labelLayout.size.height) / 2.0)), size: labelLayout.size)
|
||||
|
||||
strongSelf.separatorNode.frame = CGRect(origin: CGPoint(x: separatorInset, y: 68.0 - separatorHeight), size: CGSize(width: params.width - separatorInset, height: separatorHeight))
|
||||
|
||||
strongSelf.contentSize = layout.contentSize
|
||||
strongSelf.insets = layout.insets
|
||||
strongSelf.updateBackgroundAndSeparatorsLayout()
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func updateBackgroundAndSeparatorsLayout() {
|
||||
//let size = self.bounds.size
|
||||
//let insets = self.insets
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user