mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-23 14:45:21 +00:00
Optimize inline forum navigation
This commit is contained in:
@@ -1933,8 +1933,13 @@ public class ChatListControllerImpl: TelegramBaseController, ChatListController
|
|||||||
backTitle = self.presentationData.strings.Common_Close
|
backTitle = self.presentationData.strings.Common_Close
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
var navigationBackTitle: String?
|
||||||
|
if case .chatList(.archive) = self.location {
|
||||||
|
navigationBackTitle = self.presentationData.strings.Common_Back
|
||||||
|
}
|
||||||
primaryContent = ChatListHeaderComponent.Content(
|
primaryContent = ChatListHeaderComponent.Content(
|
||||||
title: self.plainTitle,
|
title: self.plainTitle,
|
||||||
|
navigationBackTitle: navigationBackTitle,
|
||||||
titleComponent: primaryContext.chatTitleComponent.flatMap { AnyComponent<Empty>($0) },
|
titleComponent: primaryContext.chatTitleComponent.flatMap { AnyComponent<Empty>($0) },
|
||||||
chatListTitle: primaryContext.chatListTitle,
|
chatListTitle: primaryContext.chatListTitle,
|
||||||
leftButton: primaryContext.leftButton,
|
leftButton: primaryContext.leftButton,
|
||||||
@@ -1952,6 +1957,7 @@ public class ChatListControllerImpl: TelegramBaseController, ChatListController
|
|||||||
if let secondaryContext = self.secondaryContext {
|
if let secondaryContext = self.secondaryContext {
|
||||||
secondaryContent = ChatListHeaderComponent.Content(
|
secondaryContent = ChatListHeaderComponent.Content(
|
||||||
title: self.plainTitle,
|
title: self.plainTitle,
|
||||||
|
navigationBackTitle: nil,
|
||||||
titleComponent: secondaryContext.chatTitleComponent.flatMap { AnyComponent<Empty>($0) },
|
titleComponent: secondaryContext.chatTitleComponent.flatMap { AnyComponent<Empty>($0) },
|
||||||
chatListTitle: secondaryContext.chatListTitle,
|
chatListTitle: secondaryContext.chatListTitle,
|
||||||
leftButton: secondaryContext.leftButton,
|
leftButton: secondaryContext.leftButton,
|
||||||
|
|||||||
@@ -313,7 +313,7 @@ private final class ChatListContainerItemNode: ASDisplayNode {
|
|||||||
private var shimmerNodeOffset: CGFloat = 0.0
|
private var shimmerNodeOffset: CGFloat = 0.0
|
||||||
let listNode: ChatListNode
|
let listNode: ChatListNode
|
||||||
|
|
||||||
private var validLayout: (CGSize, UIEdgeInsets, CGFloat, CGFloat, ChatListControllerLocation?, CGFloat)?
|
private(set) var validLayout: (size: CGSize, insets: UIEdgeInsets, visualNavigationHeight: CGFloat, originalNavigationHeight: CGFloat, inlineNavigationLocation: ChatListControllerLocation?, inlineNavigationTransitionFraction: CGFloat)?
|
||||||
|
|
||||||
init(context: AccountContext, location: ChatListControllerLocation, filter: ChatListFilter?, previewing: Bool, isInlineMode: Bool, controlsHistoryPreload: Bool, presentationData: PresentationData, animationCache: AnimationCache, animationRenderer: MultiAnimationRenderer, becameEmpty: @escaping (ChatListFilter?) -> Void, emptyAction: @escaping (ChatListFilter?) -> Void, secondaryEmptyAction: @escaping () -> Void) {
|
init(context: AccountContext, location: ChatListControllerLocation, filter: ChatListFilter?, previewing: Bool, isInlineMode: Bool, controlsHistoryPreload: Bool, presentationData: PresentationData, animationCache: AnimationCache, animationRenderer: MultiAnimationRenderer, becameEmpty: @escaping (ChatListFilter?) -> Void, emptyAction: @escaping (ChatListFilter?) -> Void, secondaryEmptyAction: @escaping () -> Void) {
|
||||||
self.context = context
|
self.context = context
|
||||||
@@ -1129,7 +1129,14 @@ final class ChatListContainerNode: ASDisplayNode, UIGestureRecognizerDelegate {
|
|||||||
nodeTransition.updateFrame(node: itemNode, frame: itemFrame, completion: { _ in
|
nodeTransition.updateFrame(node: itemNode, frame: itemFrame, completion: { _ in
|
||||||
})
|
})
|
||||||
|
|
||||||
itemNode.updateLayout(size: layout.size, insets: insets, visualNavigationHeight: visualNavigationHeight, originalNavigationHeight: originalNavigationHeight, inlineNavigationLocation: inlineNavigationLocation, inlineNavigationTransitionFraction: inlineNavigationTransitionFraction, transition: nodeTransition)
|
var itemInlineNavigationTransitionFraction = inlineNavigationTransitionFraction
|
||||||
|
if indexDistance != 0 {
|
||||||
|
if itemInlineNavigationTransitionFraction != 0.0 || itemInlineNavigationTransitionFraction != 1.0 {
|
||||||
|
itemInlineNavigationTransitionFraction = itemNode.validLayout?.inlineNavigationTransitionFraction ?? 0.0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
itemNode.updateLayout(size: layout.size, insets: insets, visualNavigationHeight: visualNavigationHeight, originalNavigationHeight: originalNavigationHeight, inlineNavigationLocation: inlineNavigationLocation, inlineNavigationTransitionFraction: itemInlineNavigationTransitionFraction, transition: nodeTransition)
|
||||||
|
|
||||||
if wasAdded, case .animated = transition {
|
if wasAdded, case .animated = transition {
|
||||||
animateSlidingIds.append(id)
|
animateSlidingIds.append(id)
|
||||||
|
|||||||
@@ -71,6 +71,7 @@ public final class HeaderNetworkStatusComponent: Component {
|
|||||||
public final class ChatListHeaderComponent: Component {
|
public final class ChatListHeaderComponent: Component {
|
||||||
public final class Content: Equatable {
|
public final class Content: Equatable {
|
||||||
public let title: String
|
public let title: String
|
||||||
|
public let navigationBackTitle: String?
|
||||||
public let titleComponent: AnyComponent<Empty>?
|
public let titleComponent: AnyComponent<Empty>?
|
||||||
public let chatListTitle: NetworkStatusTitle?
|
public let chatListTitle: NetworkStatusTitle?
|
||||||
public let leftButton: AnyComponentWithIdentity<NavigationButtonComponentEnvironment>?
|
public let leftButton: AnyComponentWithIdentity<NavigationButtonComponentEnvironment>?
|
||||||
@@ -80,6 +81,7 @@ public final class ChatListHeaderComponent: Component {
|
|||||||
|
|
||||||
public init(
|
public init(
|
||||||
title: String,
|
title: String,
|
||||||
|
navigationBackTitle: String?,
|
||||||
titleComponent: AnyComponent<Empty>?,
|
titleComponent: AnyComponent<Empty>?,
|
||||||
chatListTitle: NetworkStatusTitle?,
|
chatListTitle: NetworkStatusTitle?,
|
||||||
leftButton: AnyComponentWithIdentity<NavigationButtonComponentEnvironment>?,
|
leftButton: AnyComponentWithIdentity<NavigationButtonComponentEnvironment>?,
|
||||||
@@ -88,6 +90,7 @@ public final class ChatListHeaderComponent: Component {
|
|||||||
backPressed: (() -> Void)?
|
backPressed: (() -> Void)?
|
||||||
) {
|
) {
|
||||||
self.title = title
|
self.title = title
|
||||||
|
self.navigationBackTitle = navigationBackTitle
|
||||||
self.titleComponent = titleComponent
|
self.titleComponent = titleComponent
|
||||||
self.chatListTitle = chatListTitle
|
self.chatListTitle = chatListTitle
|
||||||
self.leftButton = leftButton
|
self.leftButton = leftButton
|
||||||
@@ -100,6 +103,9 @@ public final class ChatListHeaderComponent: Component {
|
|||||||
if lhs.title != rhs.title {
|
if lhs.title != rhs.title {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
if lhs.navigationBackTitle != rhs.navigationBackTitle {
|
||||||
|
return false
|
||||||
|
}
|
||||||
if lhs.titleComponent != rhs.titleComponent {
|
if lhs.titleComponent != rhs.titleComponent {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
@@ -339,7 +345,7 @@ public final class ChatListHeaderComponent: Component {
|
|||||||
let totalOffset = titleFrame.minX - backButtonTitleFrame.minX
|
let totalOffset = titleFrame.minX - backButtonTitleFrame.minX
|
||||||
|
|
||||||
transition.setBounds(view: self.titleOffsetContainer, bounds: CGRect(origin: CGPoint(x: totalOffset * fraction, y: 0.0), size: self.titleOffsetContainer.bounds.size))
|
transition.setBounds(view: self.titleOffsetContainer, bounds: CGRect(origin: CGPoint(x: totalOffset * fraction, y: 0.0), size: self.titleOffsetContainer.bounds.size))
|
||||||
transition.setAlpha(view: self.titleOffsetContainer, alpha: (1.0 - fraction))
|
transition.setAlpha(view: self.titleOffsetContainer, alpha: pow(1.0 - fraction, 2.0))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -359,7 +365,7 @@ public final class ChatListHeaderComponent: Component {
|
|||||||
let totalOffset = previousTitleFrame.minX - backButtonTitleFrame.minX
|
let totalOffset = previousTitleFrame.minX - backButtonTitleFrame.minX
|
||||||
|
|
||||||
transition.setBounds(view: backButtonView.titleOffsetContainer, bounds: CGRect(origin: CGPoint(x: -totalOffset * (1.0 - fraction), y: 0.0), size: backButtonView.titleOffsetContainer.bounds.size))
|
transition.setBounds(view: backButtonView.titleOffsetContainer, bounds: CGRect(origin: CGPoint(x: -totalOffset * (1.0 - fraction), y: 0.0), size: backButtonView.titleOffsetContainer.bounds.size))
|
||||||
transition.setAlpha(view: backButtonView.titleOffsetContainer, alpha: fraction)
|
transition.setAlpha(view: backButtonView.titleOffsetContainer, alpha: pow(fraction, 2.0))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -664,7 +670,7 @@ public final class ChatListHeaderComponent: Component {
|
|||||||
self.secondaryContentView = secondaryContentView
|
self.secondaryContentView = secondaryContentView
|
||||||
self.addSubview(secondaryContentView)
|
self.addSubview(secondaryContentView)
|
||||||
}
|
}
|
||||||
secondaryContentView.update(context: component.context, theme: component.theme, strings: component.strings, content: secondaryContent, backTitle: component.primaryContent?.title, sideInset: component.sideInset, size: availableSize, transition: secondaryContentTransition)
|
secondaryContentView.update(context: component.context, theme: component.theme, strings: component.strings, content: secondaryContent, backTitle: component.primaryContent?.navigationBackTitle ?? component.primaryContent?.title, sideInset: component.sideInset, size: availableSize, transition: secondaryContentTransition)
|
||||||
secondaryContentTransition.setFrame(view: secondaryContentView, frame: CGRect(origin: CGPoint(), size: availableSize))
|
secondaryContentTransition.setFrame(view: secondaryContentView, frame: CGRect(origin: CGPoint(), size: availableSize))
|
||||||
|
|
||||||
if let primaryContentView = self.primaryContentView {
|
if let primaryContentView = self.primaryContentView {
|
||||||
|
|||||||
Reference in New Issue
Block a user