mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-10-09 03:20:48 +00:00
Fix story gestures
This commit is contained in:
parent
39fb99c91e
commit
a8783e8d83
@ -225,8 +225,10 @@ public final class StoryContentContextImpl: StoryContentContext {
|
||||
nextItemId = mappedItems[focusedIndex + 1].id
|
||||
}
|
||||
|
||||
let mappedFocusedIndex = peerStoryItemsView.items.firstIndex(where: { $0.id == mappedItems[focusedIndex].id })
|
||||
|
||||
var loadKeys: [StoryKey] = []
|
||||
if let mappedFocusedIndex = peerStoryItemsView.items.firstIndex(where: { $0.id == mappedItems[focusedIndex].id }) {
|
||||
if let mappedFocusedIndex {
|
||||
for index in (mappedFocusedIndex - 2) ... (mappedFocusedIndex + 2) {
|
||||
if index >= 0 && index < peerStoryItemsView.items.count {
|
||||
if let item = peerStoryItemsView.items[index].value.get(Stories.StoredItem.self), case .placeholder = item {
|
||||
@ -263,7 +265,7 @@ public final class StoryContentContextImpl: StoryContentContext {
|
||||
peer: peer,
|
||||
additionalPeerData: additionalPeerData,
|
||||
item: StoryContentItem(
|
||||
position: focusedIndex,
|
||||
position: mappedFocusedIndex ?? focusedIndex,
|
||||
peerId: peer.id,
|
||||
storyItem: mappedItem
|
||||
),
|
||||
|
@ -326,14 +326,23 @@ private final class StoryContainerScreenComponent: Component {
|
||||
|
||||
if let component = self.component, let stateValue = component.content.stateValue, let _ = stateValue.slice {
|
||||
var direction: StoryContentContextNavigation.PeerDirection?
|
||||
if abs(velocity.x) > 10.0 {
|
||||
var mayDismiss = false
|
||||
if itemSetPanState.fraction <= -0.3 {
|
||||
direction = .previous
|
||||
} else if itemSetPanState.fraction >= 0.3 {
|
||||
direction = .next
|
||||
} else if abs(velocity.x) > 100.0 {
|
||||
if velocity.x < 0.0 {
|
||||
if stateValue.nextSlice != nil {
|
||||
direction = .next
|
||||
} else {
|
||||
mayDismiss = true
|
||||
}
|
||||
} else {
|
||||
if stateValue.previousSlice != nil {
|
||||
direction = .previous
|
||||
} else {
|
||||
mayDismiss = true
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -349,7 +358,7 @@ private final class StoryContainerScreenComponent: Component {
|
||||
self.itemSetPanState = itemSetPanState
|
||||
self.state?.updated(transition: .immediate)
|
||||
} else {
|
||||
shouldDismiss = true
|
||||
shouldDismiss = mayDismiss
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user