mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-06-16 05:55:20 +00:00
Stories
This commit is contained in:
parent
5386d0675d
commit
b0cbdacca7
@ -966,8 +966,13 @@ public final class ChatListContainerNode: ASDisplayNode, UIGestureRecognizerDele
|
||||
guard let self, !self.isInlineMode else {
|
||||
return
|
||||
}
|
||||
guard let validLayout = self.validLayout else {
|
||||
return
|
||||
}
|
||||
let tempTopInset: CGFloat
|
||||
if self.currentItemNode.startedScrollingAtUpperBound && !self.isInlineMode {
|
||||
if validLayout.inlineNavigationLocation != nil {
|
||||
tempTopInset = 0.0
|
||||
} else if self.currentItemNode.startedScrollingAtUpperBound && !self.isInlineMode {
|
||||
if let controller = self.controller, let storySubscriptions = controller.orderedStorySubscriptions, shouldDisplayStoriesInChatListHeader(storySubscriptions: storySubscriptions, isHidden: controller.location == .chatList(groupId: .archive)) {
|
||||
tempTopInset = ChatListNavigationBar.storiesScrollHeight
|
||||
} else {
|
||||
@ -2029,33 +2034,31 @@ final class ChatListControllerNode: ASDisplayNode, UIGestureRecognizerDelegate {
|
||||
}
|
||||
}
|
||||
|
||||
private func getEffectiveNavigationScrollingOffset() -> CGFloat {
|
||||
let mainOffset: CGFloat
|
||||
private func updateNavigationScrolling(navigationHeight: CGFloat, transition: ContainedViewLayoutTransition) {
|
||||
var mainOffset: CGFloat
|
||||
if let contentOffset = self.mainContainerNode.contentOffset, case let .known(value) = contentOffset {
|
||||
mainOffset = value
|
||||
} else {
|
||||
mainOffset = 1000.0
|
||||
mainOffset = navigationHeight
|
||||
}
|
||||
mainOffset = min(mainOffset, ChatListNavigationBar.searchScrollHeight)
|
||||
|
||||
let resultingOffset: CGFloat
|
||||
if let inlineStackContainerNode = self.inlineStackContainerNode {
|
||||
let inlineOffset: CGFloat
|
||||
var inlineOffset: CGFloat
|
||||
if let contentOffset = inlineStackContainerNode.contentOffset, case let .known(value) = contentOffset {
|
||||
inlineOffset = value
|
||||
} else {
|
||||
inlineOffset = 1000.0
|
||||
inlineOffset = navigationHeight
|
||||
}
|
||||
inlineOffset = min(inlineOffset, ChatListNavigationBar.searchScrollHeight)
|
||||
|
||||
resultingOffset = mainOffset * (1.0 - self.inlineStackContainerTransitionFraction) + inlineOffset * self.inlineStackContainerTransitionFraction
|
||||
} else {
|
||||
resultingOffset = mainOffset
|
||||
}
|
||||
|
||||
return resultingOffset
|
||||
}
|
||||
|
||||
private func updateNavigationScrolling(transition: ContainedViewLayoutTransition) {
|
||||
var offset = self.getEffectiveNavigationScrollingOffset()
|
||||
var offset = resultingOffset
|
||||
if self.isSearchDisplayControllerActive {
|
||||
offset = 0.0
|
||||
}
|
||||
@ -2075,6 +2078,9 @@ final class ChatListControllerNode: ASDisplayNode, UIGestureRecognizerDelegate {
|
||||
crossfadeStoryPeers: false
|
||||
)))
|
||||
}
|
||||
|
||||
let mainDelta = resultingOffset - mainOffset
|
||||
transition.updateSublayerTransformOffset(layer: self.mainContainerNode.layer, offset: CGPoint(x: 0.0, y: -mainDelta))
|
||||
}
|
||||
|
||||
func requestNavigationBarLayout(transition: Transition) {
|
||||
@ -2226,7 +2232,7 @@ final class ChatListControllerNode: ASDisplayNode, UIGestureRecognizerDelegate {
|
||||
}
|
||||
}
|
||||
|
||||
self.updateNavigationScrolling(transition: transition)
|
||||
self.updateNavigationScrolling(navigationHeight: navigationBarLayout.navigationHeight, transition: transition)
|
||||
|
||||
if let navigationBarComponentView = self.navigationBarView.view as? ChatListNavigationBar.View {
|
||||
navigationBarComponentView.deferScrollApplication = false
|
||||
@ -2342,50 +2348,7 @@ final class ChatListControllerNode: ASDisplayNode, UIGestureRecognizerDelegate {
|
||||
let _ = inlineStackContainerNode
|
||||
}
|
||||
|
||||
self.updateNavigationScrolling(transition: self.tempNavigationScrollingTransition ?? .immediate)
|
||||
|
||||
/*if !isPrimary {
|
||||
self.contentOffsetChanged?(offset)
|
||||
if "".isEmpty {
|
||||
return
|
||||
}
|
||||
} else {
|
||||
if "".isEmpty {
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
let targetNode: ChatListContainerNode
|
||||
if isPrimary {
|
||||
targetNode = inlineStackContainerNode
|
||||
} else {
|
||||
targetNode = self.mainContainerNode
|
||||
}
|
||||
|
||||
switch offset {
|
||||
case let .known(value) where (value <= containerLayout.navigationBarHeight - 76.0 - 46.0 - 8.0 + UIScreenPixel || self.contentOffsetSyncLockedIn):
|
||||
if case let .known(otherValue) = targetNode.currentItemNode.visibleContentOffset(), abs(otherValue - value) <= UIScreenPixel {
|
||||
self.contentOffsetSyncLockedIn = true
|
||||
}
|
||||
default:
|
||||
break
|
||||
}
|
||||
|
||||
switch offset {
|
||||
case let .known(value) where self.contentOffsetSyncLockedIn:
|
||||
var targetValue = value
|
||||
if targetValue > containerLayout.navigationBarHeight - 76.0 - 46.0 - 8.0 {
|
||||
targetValue = containerLayout.navigationBarHeight - 76.0 - 46.0 - 8.0
|
||||
}
|
||||
|
||||
targetNode.fixContentOffset(offset: targetValue)
|
||||
|
||||
self.contentOffsetChanged?(offset)
|
||||
default:
|
||||
if !isPrimary {
|
||||
self.contentOffsetChanged?(offset)
|
||||
}
|
||||
}*/
|
||||
self.updateNavigationScrolling(navigationHeight: containerLayout.navigationBarHeight, transition: self.tempNavigationScrollingTransition ?? .immediate)
|
||||
}
|
||||
|
||||
private func shouldStopScrolling(listView: ListView, velocity: CGFloat, isPrimary: Bool) -> Bool {
|
||||
@ -2538,8 +2501,10 @@ final class ChatListControllerNode: ASDisplayNode, UIGestureRecognizerDelegate {
|
||||
})
|
||||
|
||||
self.temporaryContentOffsetChangeTransition = transition
|
||||
self.tempNavigationScrollingTransition = transition
|
||||
self.controller?.requestLayout(transition: transition)
|
||||
self.temporaryContentOffsetChangeTransition = nil
|
||||
self.tempNavigationScrollingTransition = nil
|
||||
} else {
|
||||
inlineStackContainerNode.removeFromSupernode()
|
||||
}
|
||||
|
@ -2155,6 +2155,16 @@ class ChatListItemNode: ItemListRevealOptionsItemNode {
|
||||
}
|
||||
}
|
||||
}
|
||||
if textString.length == 0, case let .groupReference(data) = item.content, let storyState = data.storyState, storyState.stats.totalCount != 0 {
|
||||
//TODO:localize
|
||||
let storyText: String
|
||||
if storyState.stats.totalCount == 1 {
|
||||
storyText = "1 story"
|
||||
} else {
|
||||
storyText = "\(storyState.stats.totalCount) stories"
|
||||
}
|
||||
textString.append(NSAttributedString(string: storyText, font: textFont, textColor: theme.messageTextColor))
|
||||
}
|
||||
attributedText = textString
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user