Various Fixes

This commit is contained in:
Ilya Laktyushin 2021-08-30 02:52:57 +03:00
parent 455a04c363
commit 68401649bd
3 changed files with 51 additions and 20 deletions

View File

@ -3996,7 +3996,7 @@ open class ListView: ASDisplayNode, UIScrollViewAccessibilityDelegate, UIGesture
var offset: CGFloat = 6.0
if let reorderScrollStartTimestamp = self.reorderScrollStartTimestamp, reorderScrollStartTimestamp + 2.0 < timestamp {
offset *= 2.0
offset *= 1.5
}
if reorderOffset < effectiveInsets.top + 10.0 {
if self.itemNodes[0].apparentFrame.minY < effectiveInsets.top {

View File

@ -268,7 +268,7 @@ final class ChatMediaInputMetaSectionItemNode: ListViewItemNode {
expandTransition.updateTransformScale(node: self.scalingNode, scale: expandScale)
expandTransition.updatePosition(node: self.scalingNode, position: CGPoint(x: boundsSize.width / 2.0, y: boundsSize.height / 2.0 + (expanded ? -53.0 : -7.0)))
let titleSize = self.titleNode.updateLayout(CGSize(width: expandedBoundingSize.width, height: expandedBoundingSize.height))
let titleSize = self.titleNode.updateLayout(CGSize(width: expandedBoundingSize.width + 10.0, height: expandedBoundingSize.height))
let titleFrame = CGRect(origin: CGPoint(x: floorToScreenPixels((expandedBoundingSize.width - titleSize.width) / 2.0), y: expandedBoundingSize.height - titleSize.height + 6.0), size: titleSize)
let displayTitleFrame = expanded ? titleFrame : CGRect(origin: CGPoint(x: titleFrame.minX, y: self.imageNode.position.y - titleFrame.size.height), size: titleFrame.size)

View File

@ -1292,6 +1292,7 @@ final class ChatMediaInputNode: ChatInputNode {
}
if let index = index {
strongSelf.panelFocusScrollToIndex = index
strongSelf.panelFocusInitialPosition = position
}
strongSelf.interfaceInteraction?.updateTextInputStateAndMode { inputTextState, inputMode in
if case let .media(mode, expanded, _) = inputMode {
@ -2257,24 +2258,26 @@ final class ChatMediaInputNode: ChatInputNode {
}
var scrollToItem: ListViewScrollToItem?
if let targetIndex = self.panelFocusScrollToIndex, !self.listView.isReordering {
var position: ListViewScrollPosition
if self.panelIsFocused {
if let initialPosition = self.panelFocusInitialPosition {
position = .top(96.0 + (initialPosition.y - self.listView.frame.height / 2.0) * 0.5)
if self.paneArrangement.currentIndex == 1 {
if let targetIndex = self.panelFocusScrollToIndex, !self.listView.isReordering {
var position: ListViewScrollPosition
if self.panelIsFocused {
if let initialPosition = self.panelFocusInitialPosition {
position = .top(96.0 + (initialPosition.y - self.listView.frame.height / 2.0) * 0.5)
} else {
position = .top(96.0)
}
} else {
position = .top(96.0)
if let initialPosition = self.panelFocusInitialPosition {
position = .top(self.listView.frame.height / 2.0 + 96.0 + (initialPosition.y - self.listView.frame.height / 2.0))
} else {
position = .top(self.listView.frame.height / 2.0 + 96.0)
}
self.panelFocusScrollToIndex = nil
self.panelFocusInitialPosition = nil
}
} else {
if let initialPosition = self.panelFocusInitialPosition {
position = .top(self.listView.frame.height / 2.0 + 96.0 + (initialPosition.y - self.listView.frame.height / 2.0))
} else {
position = .top(self.listView.frame.height / 2.0 + 96.0)
}
self.panelFocusScrollToIndex = nil
self.panelFocusInitialPosition = nil
scrollToItem = ListViewScrollToItem(index: targetIndex, position: position, animated: true, curve: .Spring(duration: 0.4), directionHint: .Down, displayLink: true)
}
scrollToItem = ListViewScrollToItem(index: targetIndex, position: position, animated: true, curve: .Spring(duration: 0.4), directionHint: .Down, displayLink: true)
}
self.listView.transaction(deleteIndices: transition.deletions, insertIndicesAndItems: transition.insertions, updateIndicesAndItems: transition.updates, options: options, scrollToItem: scrollToItem, updateOpaqueState: transition.updateOpaqueState, completion: { [weak self] _ in
@ -2290,9 +2293,37 @@ final class ChatMediaInputNode: ChatInputNode {
private func enqueueGifPanelTransition(_ transition: ChatMediaInputPanelTransition, firstTime: Bool) {
var options = ListViewDeleteAndInsertOptions()
options.insert(.Synchronous)
options.insert(.LowLatency)
self.gifListView.transaction(deleteIndices: transition.deletions, insertIndicesAndItems: transition.insertions, updateIndicesAndItems: transition.updates, options: options, updateOpaqueState: nil, completion: { _ in
if firstTime {
options.insert(.Synchronous)
options.insert(.LowLatency)
} else {
options.insert(.AnimateInsertion)
}
var scrollToItem: ListViewScrollToItem?
if self.paneArrangement.currentIndex == 0 {
if let targetIndex = self.panelFocusScrollToIndex {
var position: ListViewScrollPosition
if self.panelIsFocused {
if let initialPosition = self.panelFocusInitialPosition {
position = .top(96.0 + (initialPosition.y - self.gifListView.frame.height / 2.0) * 0.5)
} else {
position = .top(96.0)
}
} else {
if let initialPosition = self.panelFocusInitialPosition {
position = .top(self.gifListView.frame.height / 2.0 + 96.0 + (initialPosition.y - self.gifListView.frame.height / 2.0))
} else {
position = .top(self.gifListView.frame.height / 2.0 + 96.0)
}
self.panelFocusScrollToIndex = nil
self.panelFocusInitialPosition = nil
}
scrollToItem = ListViewScrollToItem(index: targetIndex, position: position, animated: true, curve: .Spring(duration: 0.4), directionHint: .Down, displayLink: true)
}
}
self.gifListView.transaction(deleteIndices: transition.deletions, insertIndicesAndItems: transition.insertions, updateIndicesAndItems: transition.updates, options: options, scrollToItem: scrollToItem, updateOpaqueState: nil, completion: { _ in
})
}