mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-22 14:20:20 +00:00
Improve list offset tracking
This commit is contained in:
@@ -286,7 +286,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
|
||||
private weak var mediaRestrictedTooltipController: TooltipController?
|
||||
private var mediaRestrictedTooltipControllerMode = true
|
||||
|
||||
private var currentMessageTooltipScreens: [TooltipScreen] = []
|
||||
private var currentMessageTooltipScreens: [(TooltipScreen, ListViewItemNode)] = []
|
||||
|
||||
private weak var slowmodeTooltipController: ChatSlowmodeHintController?
|
||||
|
||||
@@ -1697,20 +1697,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
|
||||
if let solution = resultPoll.results.solution {
|
||||
for contentNode in itemNode.contentNodes {
|
||||
if let contentNode = contentNode as? ChatMessagePollBubbleContentNode, let sourceNode = contentNode.solutionTipSourceNode {
|
||||
let absoluteFrame = sourceNode.view.convert(sourceNode.bounds, to: strongSelf.view).insetBy(dx: 0.0, dy: -4.0).offsetBy(dx: 0.0, dy: 0.0)
|
||||
let tooltipScreen = TooltipScreen(text: solution.text, textEntities: solution.entities, icon: nil, location: absoluteFrame, shouldDismissOnTouch: { point in
|
||||
return .dismiss(consume: absoluteFrame.contains(point))
|
||||
}, openUrl: { url in
|
||||
self?.openUrl(url, concealed: false)
|
||||
})
|
||||
tooltipScreen.becameDismissed = { tooltipScreen in
|
||||
guard let strongSelf = self else {
|
||||
return
|
||||
}
|
||||
strongSelf.currentMessageTooltipScreens.removeAll(where: { $0 === tooltipScreen })
|
||||
}
|
||||
strongSelf.currentMessageTooltipScreens.append(tooltipScreen)
|
||||
strongSelf.present(tooltipScreen, in: .current)
|
||||
strongSelf.controllerInteraction?.displayPollSolution(solution, sourceNode)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1962,20 +1949,30 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
|
||||
guard let strongSelf = self else {
|
||||
return
|
||||
}
|
||||
let absoluteFrame = sourceNode.view.convert(sourceNode.bounds, to: strongSelf.view).insetBy(dx: 0.0, dy: -4.0).offsetBy(dx: 0.0, dy: 0.0)
|
||||
let tooltipScreen = TooltipScreen(text: solution.text, textEntities: solution.entities, icon: nil, location: absoluteFrame, shouldDismissOnTouch: { point in
|
||||
return .dismiss(consume: absoluteFrame.contains(point))
|
||||
}, openUrl: { url in
|
||||
self?.openUrl(url, concealed: false)
|
||||
})
|
||||
tooltipScreen.becameDismissed = { tooltipScreen in
|
||||
guard let strongSelf = self else {
|
||||
return
|
||||
var foundItemNode: ListViewItemNode?
|
||||
strongSelf.chatDisplayNode.historyNode.forEachItemNode { itemNode in
|
||||
if let itemNode = itemNode as? ChatMessageItemView {
|
||||
if sourceNode.view.isDescendant(of: itemNode.view) {
|
||||
foundItemNode = itemNode
|
||||
}
|
||||
}
|
||||
strongSelf.currentMessageTooltipScreens.removeAll(where: { $0 === tooltipScreen })
|
||||
}
|
||||
strongSelf.currentMessageTooltipScreens.append(tooltipScreen)
|
||||
strongSelf.present(tooltipScreen, in: .current)
|
||||
if let foundItemNode = foundItemNode {
|
||||
let absoluteFrame = sourceNode.view.convert(sourceNode.bounds, to: strongSelf.view).insetBy(dx: 0.0, dy: -4.0).offsetBy(dx: 0.0, dy: 0.0)
|
||||
let tooltipScreen = TooltipScreen(text: solution.text, textEntities: solution.entities, icon: nil, location: absoluteFrame, shouldDismissOnTouch: { point in
|
||||
return .dismiss(consume: absoluteFrame.contains(point))
|
||||
}, openUrl: { url in
|
||||
self?.openUrl(url, concealed: false)
|
||||
})
|
||||
tooltipScreen.becameDismissed = { tooltipScreen in
|
||||
guard let strongSelf = self else {
|
||||
return
|
||||
}
|
||||
strongSelf.currentMessageTooltipScreens.removeAll(where: { $0.0 === tooltipScreen })
|
||||
}
|
||||
strongSelf.currentMessageTooltipScreens.append((tooltipScreen, foundItemNode))
|
||||
strongSelf.present(tooltipScreen, in: .current)
|
||||
}
|
||||
}, requestMessageUpdate: { [weak self] id in
|
||||
if let strongSelf = self {
|
||||
strongSelf.chatDisplayNode.historyNode.requestMessageUpdate(id)
|
||||
@@ -2689,12 +2686,18 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
|
||||
override public func loadDisplayNode() {
|
||||
self.displayNode = ChatControllerNode(context: self.context, chatLocation: self.chatLocation, subject: self.subject, controllerInteraction: self.controllerInteraction!, chatPresentationInterfaceState: self.presentationInterfaceState, automaticMediaDownloadSettings: self.automaticMediaDownloadSettings, navigationBar: self.navigationBar, controller: self)
|
||||
|
||||
self.chatDisplayNode.historyNode.didScrollWithOffset = { [weak self] offset, transition in
|
||||
self.chatDisplayNode.historyNode.didScrollWithOffset = { [weak self] offset, transition, itemNode in
|
||||
guard let strongSelf = self else {
|
||||
return
|
||||
}
|
||||
for tooltipScreen in strongSelf.currentMessageTooltipScreens {
|
||||
tooltipScreen.addRelativeScrollingOffset(-offset, transition: transition)
|
||||
for (tooltipScreen, tooltipItemNode) in strongSelf.currentMessageTooltipScreens {
|
||||
if let itemNode = itemNode {
|
||||
if itemNode === tooltipItemNode {
|
||||
tooltipScreen.addRelativeScrollingOffset(-offset, transition: transition)
|
||||
}
|
||||
} else {
|
||||
tooltipScreen.addRelativeScrollingOffset(-offset, transition: transition)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user