mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-06-16 05:55:20 +00:00
Hide ad better
This commit is contained in:
parent
e285f405d9
commit
ca6821c4f1
@ -4297,6 +4297,16 @@ open class ListView: ASDisplayNode, UIScrollViewAccessibilityDelegate, UIGesture
|
||||
}
|
||||
}
|
||||
|
||||
public func enumerateItemNodes(_ f: (ASDisplayNode) -> Bool) {
|
||||
for itemNode in self.itemNodes {
|
||||
if itemNode.index != nil {
|
||||
if !f(itemNode) {
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public func forEachVisibleItemNode(_ f: (ASDisplayNode) -> Void) {
|
||||
for itemNode in self.itemNodes {
|
||||
if itemNode.index != nil && itemNode.frame.maxY > self.insets.top && itemNode.frame.minY < self.visibleSize.height - self.insets.bottom {
|
||||
|
@ -4964,11 +4964,21 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
|
||||
self.chatDisplayNode.historyNode.contentPositionChanged = { [weak self] offset in
|
||||
guard let strongSelf = self else { return }
|
||||
|
||||
var minOffsetForNavigation: CGFloat = 40.0
|
||||
strongSelf.chatDisplayNode.historyNode.enumerateItemNodes { itemNode in
|
||||
if let itemNode = itemNode as? ChatMessageBubbleItemNode {
|
||||
if itemNode.item?.content.firstMessage.adAttribute != nil {
|
||||
minOffsetForNavigation += itemNode.bounds.height
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
let offsetAlpha: CGFloat
|
||||
let plainInputSeparatorAlpha: CGFloat
|
||||
switch offset {
|
||||
case let .known(offset):
|
||||
if offset < 40.0 {
|
||||
if offset < minOffsetForNavigation {
|
||||
offsetAlpha = 0.0
|
||||
} else {
|
||||
offsetAlpha = 1.0
|
||||
|
@ -1972,6 +1972,9 @@ class ChatMessageBubbleItemNode: ChatMessageItemView, ChatMessagePreviewItemNode
|
||||
if dateHeaderAtBottom {
|
||||
layoutInsets.top += layoutConstants.timestampHeaderHeight
|
||||
}
|
||||
if isAd {
|
||||
layoutInsets.top += 4.0
|
||||
}
|
||||
|
||||
let layout = ListViewItemNodeLayout(contentSize: layoutSize, insets: layoutInsets)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user