Merge branch 'master' of gitlab.com:peter-iakovlev/telegram-ios

This commit is contained in:
Ali 2021-11-17 20:20:37 +04:00
commit 2ab6d7b50e
5 changed files with 38 additions and 12 deletions

View File

@ -9,6 +9,9 @@ public final class SparseNode: ASDisplayNode {
if self.alpha.isZero {
return nil
}
if !self.bounds.contains(point) {
return nil
}
for view in self.view.subviews {
if let result = view.hitTest(self.view.convert(point, to: view), with: event), result.isUserInteractionEnabled {
return result

View File

@ -23,14 +23,16 @@ public class InfoListItem: ListViewItem {
let title: String
let text: InfoListItemText
let style: ItemListStyle
let hasDecorations: Bool
let linkAction: ((InfoListItemLinkAction) -> Void)?
let closeAction: (() -> Void)?
public init(presentationData: ItemListPresentationData, title: String, text: InfoListItemText, style: ItemListStyle, linkAction: ((InfoListItemLinkAction) -> Void)? = nil, closeAction: (() -> Void)?) {
public init(presentationData: ItemListPresentationData, title: String, text: InfoListItemText, style: ItemListStyle, hasDecorations: Bool = true, linkAction: ((InfoListItemLinkAction) -> Void)? = nil, closeAction: (() -> Void)?) {
self.presentationData = presentationData
self.title = title
self.text = text
self.style = style
self.hasDecorations = hasDecorations
self.linkAction = linkAction
self.closeAction = closeAction
}
@ -301,7 +303,7 @@ public class InfoItemNode: ListViewItemNode {
strongSelf.topStripeNode.isHidden = true
default:
hasTopCorners = true
strongSelf.topStripeNode.isHidden = hasCorners
strongSelf.topStripeNode.isHidden = hasCorners || !item.hasDecorations
}
}
let bottomStripeInset: CGFloat
@ -312,10 +314,13 @@ public class InfoItemNode: ListViewItemNode {
default:
bottomStripeInset = 0.0
hasBottomCorners = true
strongSelf.bottomStripeNode.isHidden = hasCorners
strongSelf.bottomStripeNode.isHidden = hasCorners || !item.hasDecorations
}
} else {
bottomStripeInset = leftInset
if !item.hasDecorations {
strongSelf.topStripeNode.isHidden = true
}
}
strongSelf.closeButton.isHidden = item.closeAction == nil

View File

@ -100,6 +100,7 @@ public class ItemListTextWithLabelItemNode: ListViewItemNode {
private let highlightedBackgroundNode: ASDisplayNode
private var linkHighlightingNode: LinkHighlightingNode?
private var selectionNode: ItemListSelectableControlNode?
private let maskNode: ASImageNode
public var item: ItemListTextWithLabelItem?
@ -111,6 +112,9 @@ public class ItemListTextWithLabelItemNode: ListViewItemNode {
self.backgroundNode = ASDisplayNode()
self.backgroundNode.isLayerBacked = true
self.maskNode = ASImageNode()
self.maskNode.isUserInteractionEnabled = false
self.topStripeNode = ASDisplayNode()
self.topStripeNode.isLayerBacked = true
@ -285,7 +289,9 @@ public class ItemListTextWithLabelItemNode: ListViewItemNode {
if strongSelf.bottomStripeNode.supernode == nil {
strongSelf.insertSubnode(strongSelf.bottomStripeNode, at: 0)
}
if strongSelf.maskNode.supernode != nil {
strongSelf.maskNode.removeFromSupernode()
}
strongSelf.bottomStripeNode.frame = CGRect(origin: CGPoint(x: leftInset, y: contentSize.height - separatorHeight), size: CGSize(width: params.width - leftInset, height: separatorHeight))
case .blocks:
leftInset = 16.0 + params.leftInset
@ -299,11 +305,19 @@ public class ItemListTextWithLabelItemNode: ListViewItemNode {
if strongSelf.bottomStripeNode.supernode == nil {
strongSelf.insertSubnode(strongSelf.bottomStripeNode, at: 2)
}
if strongSelf.maskNode.supernode == nil {
strongSelf.insertSubnode(strongSelf.maskNode, at: 3)
}
let hasCorners = itemListHasRoundedBlockLayout(params)
var hasTopCorners = false
var hasBottomCorners = false
switch neighbors.top {
case .sameSection(false):
strongSelf.topStripeNode.isHidden = true
default:
strongSelf.topStripeNode.isHidden = false
hasTopCorners = true
strongSelf.topStripeNode.isHidden = hasCorners
}
let bottomStripeInset: CGFloat
let bottomStripeOffset: CGFloat
@ -314,8 +328,14 @@ public class ItemListTextWithLabelItemNode: ListViewItemNode {
default:
bottomStripeInset = 0.0
bottomStripeOffset = 0.0
hasBottomCorners = true
strongSelf.bottomStripeNode.isHidden = hasCorners
}
strongSelf.maskNode.image = hasCorners ? PresentationResourcesItemList.cornersImage(item.presentationData.theme, top: hasTopCorners, bottom: hasBottomCorners) : nil
strongSelf.backgroundNode.frame = CGRect(origin: CGPoint(x: 0.0, y: -min(insets.top, separatorHeight)), size: CGSize(width: params.width, height: contentSize.height + min(insets.top, separatorHeight) + min(insets.bottom, separatorHeight)))
strongSelf.maskNode.frame = strongSelf.backgroundNode.frame.insetBy(dx: params.leftInset, dy: 0.0)
strongSelf.topStripeNode.frame = CGRect(origin: CGPoint(x: 0.0, y: -min(insets.top, separatorHeight)), size: CGSize(width: params.width, height: separatorHeight))
strongSelf.bottomStripeNode.frame = CGRect(origin: CGPoint(x: bottomStripeInset, y: contentSize.height + bottomStripeOffset), size: CGSize(width: params.width - bottomStripeInset, height: separatorHeight))
}

View File

@ -2475,17 +2475,15 @@ class ChatTextInputPanelNode: ChatInputPanelNode, ASEditableTextNodeDelegate {
let backgroundView = UIImageView(image: backgroundImage)
backgroundView.frame = self.textInputBackgroundNode.frame
func updateIsCaretHidden(view: UIView, isHidden: Bool) {
}
updateIsCaretHidden(view: textInputNode.view, isHidden: true)
let caretColor = textInputNode.textView.tintColor
textInputNode.textView.tintColor = .clear
guard let contentView = textInputNode.view.snapshotView(afterScreenUpdates: true) else {
updateIsCaretHidden(view: textInputNode.view, isHidden: false)
textInputNode.textView.tintColor = caretColor
return nil
}
updateIsCaretHidden(view: textInputNode.view, isHidden: false)
textInputNode.textView.tintColor = caretColor
contentView.frame = textInputNode.frame

View File

@ -64,7 +64,7 @@ private final class PeerInfoScreenInfoItemNode: PeerInfoScreenItemNode {
self.bottomSeparatorNode.backgroundColor = presentationData.theme.list.itemBlocksSeparatorColor
let infoItem = InfoListItem(presentationData: ItemListPresentationData(presentationData), title: item.title, text: item.text, style: .blocks, linkAction: { link in
let infoItem = InfoListItem(presentationData: ItemListPresentationData(presentationData), title: item.title, text: item.text, style: .blocks, hasDecorations: false, linkAction: { link in
item.linkAction?(link)
}, closeAction: nil)
let params = ListViewItemLayoutParams(width: width, leftInset: safeInsets.left, rightInset: safeInsets.right, availableHeight: 1000.0)