mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-06-16 05:55:20 +00:00
Adjust gestures
This commit is contained in:
parent
2747901065
commit
d5c3e43d7a
@ -948,7 +948,7 @@ public final class ChatListContainerNode: ASDisplayNode, UIGestureRecognizerDele
|
|||||||
|
|
||||||
let offset = itemNode.listNode.visibleContentOffset()
|
let offset = itemNode.listNode.visibleContentOffset()
|
||||||
self.contentOffset = offset
|
self.contentOffset = offset
|
||||||
self.contentOffsetChanged?(offset)
|
self.contentOffsetChanged?(offset, self.currentItemNode)
|
||||||
|
|
||||||
self.isSettingUpContentOffset = false
|
self.isSettingUpContentOffset = false
|
||||||
return
|
return
|
||||||
@ -966,7 +966,7 @@ public final class ChatListContainerNode: ASDisplayNode, UIGestureRecognizerDele
|
|||||||
}
|
}
|
||||||
|
|
||||||
self.contentOffset = offset
|
self.contentOffset = offset
|
||||||
self.contentOffsetChanged?(offset)
|
self.contentOffsetChanged?(offset, self.currentItemNode)
|
||||||
|
|
||||||
if !self.isInlineMode, self.currentItemNode.startedScrollingAtUpperBound && self.tempTopInset != 0.0 {
|
if !self.isInlineMode, self.currentItemNode.startedScrollingAtUpperBound && self.tempTopInset != 0.0 {
|
||||||
if case let .known(value) = offset {
|
if case let .known(value) = offset {
|
||||||
@ -1108,7 +1108,7 @@ public final class ChatListContainerNode: ASDisplayNode, UIGestureRecognizerDele
|
|||||||
var groupSelected: ((EngineChatList.Group) -> Void)?
|
var groupSelected: ((EngineChatList.Group) -> Void)?
|
||||||
var updatePeerGrouping: ((EnginePeer.Id, Bool) -> Void)?
|
var updatePeerGrouping: ((EnginePeer.Id, Bool) -> Void)?
|
||||||
var contentOffset: ListViewVisibleContentOffset?
|
var contentOffset: ListViewVisibleContentOffset?
|
||||||
public var contentOffsetChanged: ((ListViewVisibleContentOffset) -> Void)?
|
public var contentOffsetChanged: ((ListViewVisibleContentOffset, ListView) -> Void)?
|
||||||
public var contentScrollingEnded: ((ListView) -> Bool)?
|
public var contentScrollingEnded: ((ListView) -> Bool)?
|
||||||
var didBeginInteractiveDragging: (() -> Void)?
|
var didBeginInteractiveDragging: (() -> Void)?
|
||||||
var endedInteractiveDragging: ((ListView) -> Void)?
|
var endedInteractiveDragging: ((ListView) -> Void)?
|
||||||
@ -1756,6 +1756,8 @@ final class ChatListControllerNode: ASDisplayNode, UIGestureRecognizerDelegate {
|
|||||||
private var tempNavigationScrollingTransition: ContainedViewLayoutTransition?
|
private var tempNavigationScrollingTransition: ContainedViewLayoutTransition?
|
||||||
|
|
||||||
private var allowOverscrollStoryExpansion: Bool = false
|
private var allowOverscrollStoryExpansion: Bool = false
|
||||||
|
private var allowOverscrollItemExpansion: Bool = false
|
||||||
|
private var currentOverscrollItemExpansionTimestamp: Double?
|
||||||
|
|
||||||
private var containerLayout: (layout: ContainerViewLayout, navigationBarHeight: CGFloat, visualNavigationHeight: CGFloat, cleanNavigationBarHeight: CGFloat, storiesInset: CGFloat)?
|
private var containerLayout: (layout: ContainerViewLayout, navigationBarHeight: CGFloat, visualNavigationHeight: CGFloat, cleanNavigationBarHeight: CGFloat, storiesInset: CGFloat)?
|
||||||
|
|
||||||
@ -1807,8 +1809,8 @@ final class ChatListControllerNode: ASDisplayNode, UIGestureRecognizerDelegate {
|
|||||||
|
|
||||||
self.addSubnode(self.mainContainerNode)
|
self.addSubnode(self.mainContainerNode)
|
||||||
|
|
||||||
self.mainContainerNode.contentOffsetChanged = { [weak self] offset in
|
self.mainContainerNode.contentOffsetChanged = { [weak self] offset, listView in
|
||||||
self?.contentOffsetChanged(offset: offset, isPrimary: true)
|
self?.contentOffsetChanged(offset: offset, listView: listView, isPrimary: true)
|
||||||
}
|
}
|
||||||
self.mainContainerNode.contentScrollingEnded = { [weak self] listView in
|
self.mainContainerNode.contentScrollingEnded = { [weak self] listView in
|
||||||
return self?.contentScrollingEnded(listView: listView, isPrimary: true) ?? false
|
return self?.contentScrollingEnded(listView: listView, isPrimary: true) ?? false
|
||||||
@ -2141,15 +2143,6 @@ final class ChatListControllerNode: ASDisplayNode, UIGestureRecognizerDelegate {
|
|||||||
mainDelta = 0.0
|
mainDelta = 0.0
|
||||||
}
|
}
|
||||||
transition.updateSublayerTransformOffset(layer: self.mainContainerNode.layer, offset: CGPoint(x: 0.0, y: -mainDelta))
|
transition.updateSublayerTransformOffset(layer: self.mainContainerNode.layer, offset: CGPoint(x: 0.0, y: -mainDelta))
|
||||||
|
|
||||||
if self.inlineStackContainerNode == nil && self.allowOverscrollStoryExpansion {
|
|
||||||
if let controller = self.controller, let componentView = controller.chatListHeaderView(), let storyPeerListView = componentView.storyPeerListView(), let peerId = storyPeerListView.overscrollSelectedId {
|
|
||||||
self.allowOverscrollStoryExpansion = false
|
|
||||||
HapticFeedback().tap()
|
|
||||||
|
|
||||||
controller.openStories(peerId: peerId)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func requestNavigationBarLayout(transition: Transition) {
|
func requestNavigationBarLayout(transition: Transition) {
|
||||||
@ -2408,11 +2401,44 @@ final class ChatListControllerNode: ASDisplayNode, UIGestureRecognizerDelegate {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private func contentOffsetChanged(offset: ListViewVisibleContentOffset, isPrimary: Bool) {
|
private func contentOffsetChanged(offset: ListViewVisibleContentOffset, listView: ListView, isPrimary: Bool) {
|
||||||
guard let containerLayout = self.containerLayout else {
|
guard let containerLayout = self.containerLayout else {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
self.updateNavigationScrolling(navigationHeight: containerLayout.navigationBarHeight, transition: self.tempNavigationScrollingTransition ?? .immediate)
|
self.updateNavigationScrolling(navigationHeight: containerLayout.navigationBarHeight, transition: self.tempNavigationScrollingTransition ?? .immediate)
|
||||||
|
|
||||||
|
if listView.isDragging {
|
||||||
|
if let controller = self.controller, let componentView = controller.chatListHeaderView(), let storyPeerListView = componentView.storyPeerListView() {
|
||||||
|
if let peerId = storyPeerListView.overscrollSelectedId {
|
||||||
|
if self.allowOverscrollStoryExpansion && self.inlineStackContainerNode == nil && isPrimary {
|
||||||
|
self.allowOverscrollStoryExpansion = false
|
||||||
|
self.allowOverscrollItemExpansion = false
|
||||||
|
self.currentOverscrollItemExpansionTimestamp = nil
|
||||||
|
HapticFeedback().tap()
|
||||||
|
|
||||||
|
controller.openStories(peerId: peerId)
|
||||||
|
}
|
||||||
|
} else if storyPeerListView.overscrollHiddenChatItemsAllowed {
|
||||||
|
if self.allowOverscrollItemExpansion {
|
||||||
|
let timestamp = CACurrentMediaTime()
|
||||||
|
if let _ = self.currentOverscrollItemExpansionTimestamp {
|
||||||
|
} else {
|
||||||
|
self.currentOverscrollItemExpansionTimestamp = timestamp
|
||||||
|
}
|
||||||
|
|
||||||
|
if let currentOverscrollItemExpansionTimestamp = self.currentOverscrollItemExpansionTimestamp, currentOverscrollItemExpansionTimestamp <= timestamp - 0.1 {
|
||||||
|
self.allowOverscrollItemExpansion = false
|
||||||
|
|
||||||
|
if isPrimary {
|
||||||
|
self.mainContainerNode.currentItemNode.revealScrollHiddenItem()
|
||||||
|
} else {
|
||||||
|
self.inlineStackContainerNode?.currentItemNode.revealScrollHiddenItem()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private func shouldStopScrolling(listView: ListView, velocity: CGFloat, isPrimary: Bool) -> Bool {
|
private func shouldStopScrolling(listView: ListView, velocity: CGFloat, isPrimary: Bool) -> Bool {
|
||||||
@ -2444,12 +2470,15 @@ final class ChatListControllerNode: ASDisplayNode, UIGestureRecognizerDelegate {
|
|||||||
private func didBeginInteractiveDragging(isPrimary: Bool) {
|
private func didBeginInteractiveDragging(isPrimary: Bool) {
|
||||||
if isPrimary {
|
if isPrimary {
|
||||||
self.allowOverscrollStoryExpansion = true
|
self.allowOverscrollStoryExpansion = true
|
||||||
|
self.allowOverscrollItemExpansion = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private func endedInteractiveDragging(listView: ListView, isPrimary: Bool) {
|
private func endedInteractiveDragging(listView: ListView, isPrimary: Bool) {
|
||||||
if isPrimary {
|
if isPrimary {
|
||||||
self.allowOverscrollStoryExpansion = false
|
self.allowOverscrollStoryExpansion = false
|
||||||
|
self.allowOverscrollItemExpansion = false
|
||||||
|
self.currentOverscrollItemExpansionTimestamp = nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2518,8 +2547,8 @@ final class ChatListControllerNode: ASDisplayNode, UIGestureRecognizerDelegate {
|
|||||||
inlineStackContainerNode.groupSelected = self.mainContainerNode.groupSelected
|
inlineStackContainerNode.groupSelected = self.mainContainerNode.groupSelected
|
||||||
inlineStackContainerNode.updatePeerGrouping = self.mainContainerNode.updatePeerGrouping
|
inlineStackContainerNode.updatePeerGrouping = self.mainContainerNode.updatePeerGrouping
|
||||||
|
|
||||||
inlineStackContainerNode.contentOffsetChanged = { [weak self] offset in
|
inlineStackContainerNode.contentOffsetChanged = { [weak self] offset, listView in
|
||||||
self?.contentOffsetChanged(offset: offset, isPrimary: false)
|
self?.contentOffsetChanged(offset: offset, listView: listView, isPrimary: false)
|
||||||
}
|
}
|
||||||
inlineStackContainerNode.endedInteractiveDragging = { [weak self] listView in
|
inlineStackContainerNode.endedInteractiveDragging = { [weak self] listView in
|
||||||
self?.didBeginInteractiveDragging(isPrimary: false)
|
self?.didBeginInteractiveDragging(isPrimary: false)
|
||||||
|
@ -2858,32 +2858,7 @@ public final class ChatListNode: ListView {
|
|||||||
strongSelf.scrolledAtTopValue = atTop
|
strongSelf.scrolledAtTopValue = atTop
|
||||||
strongSelf.contentOffsetChanged?(offset)
|
strongSelf.contentOffsetChanged?(offset)
|
||||||
if revealHiddenItems && !strongSelf.currentState.hiddenItemShouldBeTemporaryRevealed {
|
if revealHiddenItems && !strongSelf.currentState.hiddenItemShouldBeTemporaryRevealed {
|
||||||
var isHiddenItemVisible = false
|
//strongSelf.revealScrollHiddenItem()
|
||||||
strongSelf.forEachItemNode({ itemNode in
|
|
||||||
if let itemNode = itemNode as? ChatListItemNode, let item = itemNode.item {
|
|
||||||
if case let .peer(peerData) = item.content, let threadInfo = peerData.threadInfo {
|
|
||||||
if threadInfo.isHidden {
|
|
||||||
isHiddenItemVisible = true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if case let .groupReference(groupReference) = item.content {
|
|
||||||
if groupReference.hiddenByDefault {
|
|
||||||
isHiddenItemVisible = true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
|
||||||
if isHiddenItemVisible {
|
|
||||||
if strongSelf.hapticFeedback == nil {
|
|
||||||
strongSelf.hapticFeedback = HapticFeedback()
|
|
||||||
}
|
|
||||||
strongSelf.hapticFeedback?.impact(.medium)
|
|
||||||
strongSelf.updateState { state in
|
|
||||||
var state = state
|
|
||||||
state.hiddenItemShouldBeTemporaryRevealed = true
|
|
||||||
return state
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2915,6 +2890,35 @@ public final class ChatListNode: ListView {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func revealScrollHiddenItem() {
|
||||||
|
var isHiddenItemVisible = false
|
||||||
|
self.forEachItemNode({ itemNode in
|
||||||
|
if let itemNode = itemNode as? ChatListItemNode, let item = itemNode.item {
|
||||||
|
if case let .peer(peerData) = item.content, let threadInfo = peerData.threadInfo {
|
||||||
|
if threadInfo.isHidden {
|
||||||
|
isHiddenItemVisible = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if case let .groupReference(groupReference) = item.content {
|
||||||
|
if groupReference.hiddenByDefault {
|
||||||
|
isHiddenItemVisible = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
if isHiddenItemVisible {
|
||||||
|
if self.hapticFeedback == nil {
|
||||||
|
self.hapticFeedback = HapticFeedback()
|
||||||
|
}
|
||||||
|
self.hapticFeedback?.impact(.medium)
|
||||||
|
self.updateState { state in
|
||||||
|
var state = state
|
||||||
|
state.hiddenItemShouldBeTemporaryRevealed = true
|
||||||
|
return state
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private func pollFilterUpdates() {
|
private func pollFilterUpdates() {
|
||||||
self.chatFolderUpdates.set(.single(nil))
|
self.chatFolderUpdates.set(.single(nil))
|
||||||
|
|
||||||
|
@ -354,6 +354,7 @@ public final class StoryPeerListComponent: Component {
|
|||||||
private var currentActivityFraction: CGFloat = 0.0
|
private var currentActivityFraction: CGFloat = 0.0
|
||||||
|
|
||||||
public private(set) var overscrollSelectedId: EnginePeer.Id?
|
public private(set) var overscrollSelectedId: EnginePeer.Id?
|
||||||
|
public private(set) var overscrollHiddenChatItemsAllowed: Bool = false
|
||||||
|
|
||||||
private var sharedBlurEffect: NSObject?
|
private var sharedBlurEffect: NSObject?
|
||||||
|
|
||||||
@ -712,7 +713,7 @@ public final class StoryPeerListComponent: Component {
|
|||||||
var rawProgress = CGFloat((timestamp - animationState.startTime) / animationState.duration)
|
var rawProgress = CGFloat((timestamp - animationState.startTime) / animationState.duration)
|
||||||
rawProgress = max(0.0, min(1.0, rawProgress))
|
rawProgress = max(0.0, min(1.0, rawProgress))
|
||||||
|
|
||||||
if !animationState.fromIsUnlocked && animationState.bounce && itemLayout.itemCount > 3 {
|
if !animationState.fromIsUnlocked && animationState.bounce {
|
||||||
let bounceStartFraction: CGFloat = 0.0
|
let bounceStartFraction: CGFloat = 0.0
|
||||||
let bounceGlobalFraction: CGFloat = animationState.interpolatedFraction(at: timestamp, effectiveFromFraction: 0.0, toFraction: 1.0, linear: true)
|
let bounceGlobalFraction: CGFloat = animationState.interpolatedFraction(at: timestamp, effectiveFromFraction: 0.0, toFraction: 1.0, linear: true)
|
||||||
let bounceFraction: CGFloat = 1.0 - max(0.0, min(1.0, bounceGlobalFraction - bounceStartFraction)) / (1.0 - bounceStartFraction)
|
let bounceFraction: CGFloat = 1.0 - max(0.0, min(1.0, bounceGlobalFraction - bounceStartFraction)) / (1.0 - bounceStartFraction)
|
||||||
@ -801,6 +802,13 @@ public final class StoryPeerListComponent: Component {
|
|||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if overscrollStage1 >= 0.6 {
|
||||||
|
self.overscrollHiddenChatItemsAllowed = true
|
||||||
|
} else {
|
||||||
|
self.overscrollHiddenChatItemsAllowed = false
|
||||||
|
}
|
||||||
|
|
||||||
if let overscrollFocusIndex, overscrollStage2 >= 0.6 {
|
if let overscrollFocusIndex, overscrollStage2 >= 0.6 {
|
||||||
self.overscrollSelectedId = self.sortedItems[overscrollFocusIndex].peer.id
|
self.overscrollSelectedId = self.sortedItems[overscrollFocusIndex].peer.id
|
||||||
} else {
|
} else {
|
||||||
|
@ -262,7 +262,7 @@ final class PeerSelectionControllerNode: ASDisplayNode {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
self.mainContainerNode?.contentOffsetChanged = { [weak self] offset in
|
self.mainContainerNode?.contentOffsetChanged = { [weak self] offset, _ in
|
||||||
guard let strongSelf = self else {
|
guard let strongSelf = self else {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user