Add empty chat list contacts

This commit is contained in:
Ali
2023-04-11 23:10:30 +04:00
parent 85eb44f93e
commit c206824fee
7 changed files with 612 additions and 14 deletions

View File

@@ -5,7 +5,7 @@ import Display
import TelegramPresentationData
private let titleFont = Font.bold(13.0)
private let actionFont = Font.medium(13.0)
private let actionFont = Font.regular(13.0)
public enum ListSectionHeaderActionType {
case generic
@@ -13,6 +13,7 @@ public enum ListSectionHeaderActionType {
}
public final class ListSectionHeaderNode: ASDisplayNode {
private let backgroundLayer: SimpleLayer
private let label: ImmediateTextNode
private var actionButtonLabel: ImmediateTextNode?
private var actionButton: HighlightableButtonNode?
@@ -87,16 +88,29 @@ public final class ListSectionHeaderNode: ASDisplayNode {
public init(theme: PresentationTheme) {
self.theme = theme
self.backgroundLayer = SimpleLayer()
self.label = ImmediateTextNode()
self.label.isUserInteractionEnabled = false
self.label.isAccessibilityElement = true
super.init()
self.layer.addSublayer(self.backgroundLayer)
self.addSubnode(self.label)
self.backgroundColor = theme.chatList.sectionHeaderFillColor
self.backgroundLayer.backgroundColor = theme.chatList.sectionHeaderFillColor.cgColor
}
override public func hitTest(_ point: CGPoint, with event: UIEvent?) -> UIView? {
if let actionButton = self.actionButton {
if actionButton.frame.contains(point) {
return actionButton.view
}
}
return super.hitTest(point, with: event)
}
public func updateTheme(theme: PresentationTheme) {
@@ -105,7 +119,7 @@ public final class ListSectionHeaderNode: ASDisplayNode {
self.label.attributedText = NSAttributedString(string: self.title ?? "", font: titleFont, textColor: self.theme.chatList.sectionHeaderTextColor)
self.backgroundColor = theme.chatList.sectionHeaderFillColor
self.backgroundLayer.backgroundColor = theme.chatList.sectionHeaderFillColor.cgColor
if let action = self.action {
self.actionButtonLabel?.attributedText = NSAttributedString(string: action, font: actionFont, textColor: self.theme.chatList.sectionHeaderTextColor)
}
@@ -126,6 +140,8 @@ public final class ListSectionHeaderNode: ASDisplayNode {
actionButtonLabel.frame = CGRect(origin: CGPoint(x: size.width - rightInset - 16.0 - buttonSize.width, y: 6.0 + UIScreenPixel), size: buttonSize)
actionButton.frame = CGRect(origin: CGPoint(x: size.width - rightInset - 16.0 - buttonSize.width, y: 6.0 + UIScreenPixel), size: buttonSize)
}
self.backgroundLayer.frame = CGRect(origin: CGPoint(x: 0.0, y: -UIScreenPixel), size: CGSize(width: size.width, height: size.height + UIScreenPixel))
}
@objc private func actionButtonPressed() {