mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-06-16 05:55:20 +00:00
Various fixes
This commit is contained in:
parent
64931938b7
commit
517230cef7
@ -250,7 +250,7 @@ open class ListView: ASDisplayNode, UIScrollViewAccessibilityDelegate, UIGesture
|
||||
public final var snapToBottomInsetUntilFirstInteraction: Bool = false
|
||||
|
||||
public final var updateFloatingHeaderOffset: ((CGFloat, ContainedViewLayoutTransition) -> Void)?
|
||||
public final var didScrollWithOffset: ((CGFloat, ContainedViewLayoutTransition, ListViewItemNode?) -> Void)?
|
||||
public final var didScrollWithOffset: ((CGFloat, ContainedViewLayoutTransition, ListViewItemNode?, Bool) -> Void)?
|
||||
public final var addContentOffset: ((CGFloat, ListViewItemNode?) -> Void)?
|
||||
|
||||
public final var updateScrollingIndicator: ((ScrollingIndicatorState?, ContainedViewLayoutTransition) -> Void)?
|
||||
@ -287,6 +287,10 @@ open class ListView: ASDisplayNode, UIScrollViewAccessibilityDelegate, UIGesture
|
||||
public private(set) var isDragging = false
|
||||
public private(set) var isDeceleratingAfterTracking = false
|
||||
|
||||
private var isTrackingOrDecelerating: Bool {
|
||||
return self.isTracking || self.isDragging || self.isDeceleratingAfterTracking
|
||||
}
|
||||
|
||||
private final var transactionQueue: ListViewTransactionQueue
|
||||
private final var transactionOffset: CGFloat = 0.0
|
||||
|
||||
@ -953,7 +957,7 @@ open class ListView: ASDisplayNode, UIScrollViewAccessibilityDelegate, UIGesture
|
||||
anchor = 0.0
|
||||
}
|
||||
|
||||
self.didScrollWithOffset?(deltaY, .immediate, nil)
|
||||
self.didScrollWithOffset?(deltaY, .immediate, nil, self.isTrackingOrDecelerating)
|
||||
|
||||
for itemNode in self.itemNodes {
|
||||
itemNode.updateFrame(itemNode.frame.offsetBy(dx: 0.0, dy: -deltaY), within: self.visibleSize)
|
||||
@ -1244,7 +1248,7 @@ open class ListView: ASDisplayNode, UIScrollViewAccessibilityDelegate, UIGesture
|
||||
}
|
||||
|
||||
if abs(offset) > CGFloat.ulpOfOne {
|
||||
self.didScrollWithOffset?(-offset, .immediate, nil)
|
||||
self.didScrollWithOffset?(-offset, .immediate, nil, self.isTrackingOrDecelerating)
|
||||
|
||||
for itemNode in self.itemNodes {
|
||||
var frame = itemNode.frame
|
||||
@ -2284,7 +2288,7 @@ open class ListView: ASDisplayNode, UIScrollViewAccessibilityDelegate, UIGesture
|
||||
offsetHeight = 0.0
|
||||
|
||||
nextNode.updateFrame(nextNode.frame.offsetBy(dx: 0.0, dy: nextHeight), within: self.visibleSize)
|
||||
self.didScrollWithOffset?(nextHeight, .immediate, nextNode)
|
||||
self.didScrollWithOffset?(nextHeight, .immediate, nextNode, self.isTrackingOrDecelerating)
|
||||
|
||||
nextNode.apparentHeight = 0.0
|
||||
|
||||
@ -2394,7 +2398,6 @@ open class ListView: ASDisplayNode, UIScrollViewAccessibilityDelegate, UIGesture
|
||||
var frame = self.itemNodes[i].frame
|
||||
frame.origin.y -= offsetHeight
|
||||
self.itemNodes[i].updateFrame(frame, within: self.visibleSize)
|
||||
//self.didScrollWithOffset?(offsetHeight, .immediate, self.itemNodes[i])
|
||||
if let accessoryItemNode = self.itemNodes[i].accessoryItemNode {
|
||||
self.itemNodes[i].layoutAccessoryItemNode(accessoryItemNode, leftInset: listInsets.left, rightInset: listInsets.right)
|
||||
}
|
||||
@ -2406,7 +2409,6 @@ open class ListView: ASDisplayNode, UIScrollViewAccessibilityDelegate, UIGesture
|
||||
var frame = self.itemNodes[i].frame
|
||||
frame.origin.y += offsetHeight
|
||||
self.itemNodes[i].updateFrame(frame, within: self.visibleSize)
|
||||
//self.didScrollWithOffset?(-offsetHeight, .immediate, self.itemNodes[i])
|
||||
if let accessoryItemNode = self.itemNodes[i].accessoryItemNode {
|
||||
self.itemNodes[i].layoutAccessoryItemNode(accessoryItemNode, leftInset: listInsets.left, rightInset: listInsets.right)
|
||||
}
|
||||
@ -2848,7 +2850,7 @@ open class ListView: ASDisplayNode, UIScrollViewAccessibilityDelegate, UIGesture
|
||||
var frame = itemNode.frame
|
||||
frame.origin.y += offset
|
||||
itemNode.updateFrame(frame, within: self.visibleSize)
|
||||
self.didScrollWithOffset?(-offset, .immediate, itemNode)
|
||||
self.didScrollWithOffset?(-offset, .immediate, itemNode, self.isTrackingOrDecelerating)
|
||||
if let accessoryItemNode = itemNode.accessoryItemNode {
|
||||
itemNode.layoutAccessoryItemNode(accessoryItemNode, leftInset: listInsets.left, rightInset: listInsets.right)
|
||||
}
|
||||
@ -3003,10 +3005,10 @@ open class ListView: ASDisplayNode, UIScrollViewAccessibilityDelegate, UIGesture
|
||||
for itemNode in self.itemNodes {
|
||||
itemNode.applyAbsoluteOffset(value: CGPoint(x: 0.0, y: -completeOffset), animationCurve: animationCurve, duration: animationDuration)
|
||||
}
|
||||
self.didScrollWithOffset?(-completeOffset, ContainedViewLayoutTransition.animated(duration: animationDuration, curve: animationCurve), nil)
|
||||
self.didScrollWithOffset?(-completeOffset, ContainedViewLayoutTransition.animated(duration: animationDuration, curve: animationCurve), nil, self.isTrackingOrDecelerating)
|
||||
}
|
||||
} else {
|
||||
self.didScrollWithOffset?(-completeOffset, .immediate, nil)
|
||||
self.didScrollWithOffset?(-completeOffset, .immediate, nil, self.isTrackingOrDecelerating)
|
||||
}
|
||||
} else {
|
||||
self.visibleSize = updateSizeAndInsets.size
|
||||
@ -3049,7 +3051,7 @@ open class ListView: ASDisplayNode, UIScrollViewAccessibilityDelegate, UIGesture
|
||||
for itemNode in self.itemNodes {
|
||||
itemNode.applyAbsoluteOffset(value: CGPoint(x: 0.0, y: -completeOffset), animationCurve: .spring, duration: duration)
|
||||
}
|
||||
self.didScrollWithOffset?(-completeOffset, .animated(duration: duration, curve: .spring), nil)
|
||||
self.didScrollWithOffset?(-completeOffset, .animated(duration: duration, curve: .spring), nil, self.isTrackingOrDecelerating)
|
||||
}
|
||||
} else {
|
||||
if let snapshotView = snapshotView {
|
||||
@ -3072,7 +3074,7 @@ open class ListView: ASDisplayNode, UIScrollViewAccessibilityDelegate, UIGesture
|
||||
let (snappedTopInset, snapToBoundsOffset) = self.snapToBounds(snapTopItem: scrollToItem != nil && scrollToItem?.directionHint != .Down, stackFromBottom: self.stackFromBottom, updateSizeAndInsets: updateSizeAndInsets, scrollToItem: scrollToItem, insetDeltaOffsetFix: 0.0)
|
||||
|
||||
if !snappedTopInset.isZero && previousApparentFrames.isEmpty {
|
||||
self.didScrollWithOffset?(-snappedTopInset, .immediate, nil)
|
||||
self.didScrollWithOffset?(-snappedTopInset, .immediate, nil, self.isTrackingOrDecelerating)
|
||||
|
||||
for itemNode in self.itemNodes {
|
||||
itemNode.updateFrame(itemNode.frame.offsetBy(dx: 0.0, dy: snappedTopInset), within: self.visibleSize)
|
||||
@ -3380,7 +3382,7 @@ open class ListView: ASDisplayNode, UIScrollViewAccessibilityDelegate, UIGesture
|
||||
for itemNode in temporaryPreviousNodes {
|
||||
itemNode.applyAbsoluteOffset(value: CGPoint(x: 0.0, y: -offset), animationCurve: animationCurve, duration: animationDuration)
|
||||
}
|
||||
self.didScrollWithOffset?(-offset, .animated(duration: animationDuration, curve: animationCurve), nil)
|
||||
self.didScrollWithOffset?(-offset, .animated(duration: animationDuration, curve: animationCurve), nil, self.isTrackingOrDecelerating)
|
||||
if let verticalScrollIndicator = self.verticalScrollIndicator {
|
||||
verticalScrollIndicator.layer.add(reverseAnimation, forKey: nil)
|
||||
}
|
||||
@ -4315,7 +4317,7 @@ open class ListView: ASDisplayNode, UIScrollViewAccessibilityDelegate, UIGesture
|
||||
let offset = offsetRanges.offsetForIndex(index)
|
||||
if offset != 0.0 {
|
||||
itemNode.updateFrame(itemNode.frame.offsetBy(dx: 0.0, dy: offset), within: self.visibleSize)
|
||||
self.didScrollWithOffset?(-offset, .immediate, itemNode)
|
||||
self.didScrollWithOffset?(-offset, .immediate, itemNode, self.isTrackingOrDecelerating)
|
||||
}
|
||||
|
||||
index += 1
|
||||
|
@ -213,7 +213,7 @@ open class ItemListController: ViewController, KeyShortcutResponder, Presentable
|
||||
}
|
||||
}
|
||||
|
||||
public var didScrollWithOffset: ((CGFloat, ContainedViewLayoutTransition, ListViewItemNode?) -> Void)? {
|
||||
public var didScrollWithOffset: ((CGFloat, ContainedViewLayoutTransition, ListViewItemNode?, Bool) -> Void)? {
|
||||
didSet {
|
||||
if self.isNodeLoaded {
|
||||
(self.displayNode as! ItemListControllerNode).listNode.didScrollWithOffset = self.didScrollWithOffset
|
||||
|
@ -283,7 +283,7 @@ public func quickReactionSetupController(
|
||||
|
||||
let controller = ItemListController(context: context, state: signal)
|
||||
|
||||
controller.didScrollWithOffset = { [weak controller] offset, transition, _ in
|
||||
controller.didScrollWithOffset = { [weak controller] offset, transition, _, _ in
|
||||
guard let controller = controller else {
|
||||
return
|
||||
}
|
||||
|
@ -5844,7 +5844,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
|
||||
self.chatDisplayNode.historyNode.voicePlaylistItemChanged(nil, currentItem)
|
||||
}
|
||||
|
||||
self.chatDisplayNode.historyNode.didScrollWithOffset = { [weak self] offset, transition, itemNode in
|
||||
self.chatDisplayNode.historyNode.didScrollWithOffset = { [weak self] offset, transition, itemNode, isTracking in
|
||||
guard let strongSelf = self else {
|
||||
return
|
||||
}
|
||||
@ -5870,7 +5870,9 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
|
||||
}
|
||||
}
|
||||
|
||||
strongSelf.chatDisplayNode.loadingPlaceholderNode?.addContentOffset(offset: offset, transition: transition)
|
||||
if isTracking {
|
||||
strongSelf.chatDisplayNode.loadingPlaceholderNode?.addContentOffset(offset: offset, transition: transition)
|
||||
}
|
||||
strongSelf.chatDisplayNode.messageTransitionNode.addExternalOffset(offset: offset, transition: transition, itemNode: itemNode)
|
||||
}
|
||||
|
||||
|
@ -328,12 +328,7 @@ final class ChatLoadingPlaceholderNode: ASDisplayNode {
|
||||
}
|
||||
}
|
||||
|
||||
private var ignoreFirstContentOffset = true
|
||||
func addContentOffset(offset: CGFloat, transition: ContainedViewLayoutTransition) {
|
||||
guard !self.ignoreFirstContentOffset else {
|
||||
self.ignoreFirstContentOffset = false
|
||||
return
|
||||
}
|
||||
self.scrollingContainer.bounds = self.scrollingContainer.bounds.offsetBy(dx: 0.0, dy: -offset)
|
||||
transition.animateOffsetAdditive(node: self.scrollingContainer, offset: offset)
|
||||
if let (rect, containerSize) = self.absolutePosition {
|
||||
|
@ -353,12 +353,15 @@ class ChatMessageBubbleItemNode: ChatMessageItemView, ChatMessagePreviewItemNode
|
||||
self.containerNode = ContextControllerSourceNode()
|
||||
}
|
||||
|
||||
private var absoluteRect: (CGRect, CGSize)?
|
||||
fileprivate var absoluteRect: (CGRect, CGSize)?
|
||||
fileprivate func updateAbsoluteRect(_ rect: CGRect, within containerSize: CGSize) {
|
||||
self.absoluteRect = (rect, containerSize)
|
||||
guard let backgroundWallpaperNode = self.backgroundWallpaperNode else {
|
||||
return
|
||||
}
|
||||
guard !self.sourceNode.isExtractedToContextPreview else {
|
||||
return
|
||||
}
|
||||
let mappedRect = CGRect(origin: CGPoint(x: rect.minX + backgroundWallpaperNode.frame.minX, y: rect.minY + backgroundWallpaperNode.frame.minY), size: rect.size)
|
||||
backgroundWallpaperNode.update(rect: mappedRect, within: containerSize)
|
||||
}
|
||||
@ -2711,8 +2714,8 @@ class ChatMessageBubbleItemNode: ChatMessageItemView, ChatMessagePreviewItemNode
|
||||
|
||||
container?.isExtractedToContextPreviewUpdated(isExtractedToContextPreview)
|
||||
|
||||
if !isExtractedToContextPreview, let (rect, size) = strongSelf.absoluteRect {
|
||||
container?.updateAbsoluteRect(relativeFrame.offsetBy(dx: rect.minX, dy: rect.minY), within: size)
|
||||
if !isExtractedToContextPreview, let (rect, size) = container?.absoluteRect {
|
||||
container?.updateAbsoluteRect(rect, within: size)
|
||||
}
|
||||
|
||||
for contentNode in strongSelf.contentNodes {
|
||||
@ -4009,11 +4012,12 @@ class ChatMessageBubbleItemNode: ChatMessageItemView, ChatMessagePreviewItemNode
|
||||
|
||||
override func updateAbsoluteRect(_ rect: CGRect, within containerSize: CGSize) {
|
||||
self.absoluteRect = (rect, containerSize)
|
||||
if !self.mainContextSourceNode.isExtractedToContextPreview {
|
||||
var rect = rect
|
||||
rect.origin.y = containerSize.height - rect.maxY + self.insets.top
|
||||
self.updateAbsoluteRectInternal(rect, within: containerSize)
|
||||
guard !self.mainContextSourceNode.isExtractedToContextPreview else {
|
||||
return
|
||||
}
|
||||
var rect = rect
|
||||
rect.origin.y = containerSize.height - rect.maxY + self.insets.top
|
||||
self.updateAbsoluteRectInternal(rect, within: containerSize)
|
||||
}
|
||||
|
||||
private func updateAbsoluteRectInternal(_ rect: CGRect, within containerSize: CGSize) {
|
||||
@ -4025,6 +4029,13 @@ class ChatMessageBubbleItemNode: ChatMessageItemView, ChatMessagePreviewItemNode
|
||||
contentNode.updateAbsoluteRect(CGRect(origin: CGPoint(x: rect.minX + contentNode.frame.minX, y: rect.minY + contentNode.frame.minY), size: rect.size), within: containerSize)
|
||||
}
|
||||
|
||||
for container in self.contentContainers {
|
||||
var containerFrame = self.mainContainerNode.frame
|
||||
containerFrame.origin.x += rect.minX
|
||||
containerFrame.origin.y += rect.minY
|
||||
container.updateAbsoluteRect(containerFrame, within: containerSize)
|
||||
}
|
||||
|
||||
if let shareButtonNode = self.shareButtonNode {
|
||||
var shareButtonNodeFrame = shareButtonNode.frame
|
||||
shareButtonNodeFrame.origin.x += rect.minX
|
||||
|
Loading…
x
Reference in New Issue
Block a user