@@ -55,8 +55,6 @@ import TextFormat
5555import AvatarUploadToastScreen
5656import AdsInfoScreen
5757import AdsReportScreen
58- import SearchBarNode
59- import ChatListFilterTabContainerNode
6058
6159private final class ContextControllerContentSourceImpl : ContextControllerContentSource {
6260 let controller : ViewController
@@ -770,8 +768,6 @@ public class ChatListControllerImpl: TelegramBaseController, ChatListController
770768 } )
771769
772770 self . updateNavigationMetadata ( )
773-
774- self . updateTabBarSearchState ( ViewController . TabBarSearchState ( isActive: false ) , transition: . immediate)
775771 }
776772
777773 required public init ( coder aDecoder: NSCoder ) {
@@ -2842,9 +2838,14 @@ public class ChatListControllerImpl: TelegramBaseController, ChatListController
28422838 func updateHeaderContent( ) -> ( primaryContent: ChatListHeaderComponent . Content ? , secondaryContent: ChatListHeaderComponent . Content ? ) {
28432839 var primaryContent : ChatListHeaderComponent . Content ?
28442840 if let primaryContext = self . primaryContext {
2845- var displayBackButton : Bool = false
2846- if self . previousItem != nil {
2847- displayBackButton = true
2841+ var backTitle : String ?
2842+ if let previousItem = self . previousItem {
2843+ switch previousItem {
2844+ case let . item( item) :
2845+ backTitle = item. title ?? self . presentationData. strings. Common_Back
2846+ case . close:
2847+ backTitle = self . presentationData. strings. Common_Close
2848+ }
28482849 }
28492850 var navigationBackTitle : String ?
28502851 if case . chatList( . archive) = self . location {
@@ -2857,7 +2858,8 @@ public class ChatListControllerImpl: TelegramBaseController, ChatListController
28572858 chatListTitle: primaryContext. chatListTitle,
28582859 leftButton: primaryContext. leftButton,
28592860 rightButtons: primaryContext. rightButtons,
2860- backPressed: displayBackButton ? { [ weak self] in
2861+ backTitle: backTitle,
2862+ backPressed: backTitle != nil ? { [ weak self] in
28612863 guard let self else {
28622864 return
28632865 }
@@ -2874,6 +2876,7 @@ public class ChatListControllerImpl: TelegramBaseController, ChatListController
28742876 chatListTitle: secondaryContext. chatListTitle,
28752877 leftButton: secondaryContext. leftButton,
28762878 rightButtons: secondaryContext. rightButtons,
2879+ backTitle: nil ,
28772880 backPressed: { [ weak self] in
28782881 guard let self else {
28792882 return
@@ -4635,7 +4638,9 @@ public class ChatListControllerImpl: TelegramBaseController, ChatListController
46354638 searchContentNode = navigationBarView. searchContentNode
46364639 }
46374640
4638- self . activateSearch ( filter: filter, query: query, skipScrolling: false , searchContentNode: searchContentNode)
4641+ if let searchContentNode {
4642+ self . activateSearch ( filter: filter, query: query, skipScrolling: false , searchContentNode: searchContentNode)
4643+ }
46394644 }
46404645
46414646 public func activateSearch( query: String ? = nil ) {
@@ -4649,37 +4654,45 @@ public class ChatListControllerImpl: TelegramBaseController, ChatListController
46494654 }
46504655
46514656 private var previousSearchToggleTimestamp : Double ?
4652- func activateSearch( filter: ChatListSearchFilter = . chats, query: String ? = nil , skipScrolling: Bool = false , searchContentNode: NavigationBarSearchContentNode ? ) {
4653- Task { @MainActor [ weak self] in
4654- guard let self else {
4655- return
4656- }
4657-
4658- let currentTimestamp = CACurrentMediaTime ( )
4659- if let previousSearchActivationTimestamp = self . previousSearchToggleTimestamp, currentTimestamp < previousSearchActivationTimestamp + 0.6 {
4657+ func activateSearch( filter: ChatListSearchFilter = . chats, query: String ? = nil , skipScrolling: Bool = false , searchContentNode: NavigationBarSearchContentNode ) {
4658+ let currentTimestamp = CACurrentMediaTime ( )
4659+ if let previousSearchActivationTimestamp = self . previousSearchToggleTimestamp, currentTimestamp < previousSearchActivationTimestamp + 0.6 {
4660+ return
4661+ }
4662+ self . previousSearchToggleTimestamp = currentTimestamp
4663+
4664+ if let storyTooltip = self . storyTooltip {
4665+ storyTooltip. dismiss ( )
4666+ }
4667+
4668+ var filter = filter
4669+ if case . forum = self . chatListDisplayNode. effectiveContainerNode. location {
4670+ filter = . topics
4671+ }
4672+
4673+ if self . chatListDisplayNode. searchDisplayController == nil {
4674+ /*if !skipScrolling, let searchContentNode = self.searchContentNode, searchContentNode.expansionProgress != 1.0 {
4675+ self.scrollToTop?()
4676+ DispatchQueue.main.asyncAfter(deadline: DispatchTime.now() + 0.2, execute: { [weak self] in
4677+ self?.activateSearch(filter: filter, query: query, skipScrolling: true)
4678+ })
46604679 return
4661- }
4662- self . previousSearchToggleTimestamp = currentTimestamp
4663-
4664- if let storyTooltip = self . storyTooltip {
4665- storyTooltip. dismiss ( )
4666- }
4667-
4668- var filter = filter
4669- if case . forum = self . chatListDisplayNode. effectiveContainerNode. location {
4670- filter = . topics
4671- }
4680+ }*/
4681+ //TODO:scroll to top?
46724682
4673- if self . chatListDisplayNode. searchDisplayController == nil {
4674- let ( _, _) = await combineLatest ( self . chatListDisplayNode. mainContainerNode. currentItemNode. contentsReady |> take ( 1 ) , self . context. account. postbox. tailChatListView ( groupId: . root, count: 16 , summaryComponents: ChatListEntrySummaryComponents ( components: [ : ] ) ) |> take ( 1 ) ) . get ( )
4675-
4676- do {
4683+ let _ = ( combineLatest ( self . chatListDisplayNode. mainContainerNode. currentItemNode. contentsReady |> take ( 1 ) , self . context. account. postbox. tailChatListView ( groupId: . root, count: 16 , summaryComponents: ChatListEntrySummaryComponents ( components: [ : ] ) ) |> take ( 1 ) )
4684+ |> deliverOnMainQueue) . startStandalone ( next: { [ weak self] _, chatListView in
4685+ Task { @MainActor in
4686+ guard let strongSelf = self else {
4687+ return
4688+ }
4689+
46774690 /*if let scrollToTop = strongSelf.scrollToTop {
4678- scrollToTop()
4679- }*/
4691+ scrollToTop()
4692+ }*/
46804693
46814694 let tabsIsEmpty : Bool
4682- if let ( resolvedItems, displayTabsAtBottom, _) = self . tabContainerData {
4695+ if let ( resolvedItems, displayTabsAtBottom, _) = strongSelf . tabContainerData {
46834696 tabsIsEmpty = resolvedItems. count <= 1 || displayTabsAtBottom
46844697 } else {
46854698 tabsIsEmpty = true
@@ -4689,44 +4702,41 @@ public class ChatListControllerImpl: TelegramBaseController, ChatListController
46894702
46904703 let displaySearchFilters = true
46914704
4692- if let filterContainerNodeAndActivate = await self . chatListDisplayNode. activateSearch ( placeholderNode: searchContentNode? . placeholderNode, displaySearchFilters: displaySearchFilters, hasDownloads: self . hasDownloads, initialFilter: filter, navigationController: self . navigationController as? NavigationController , searchBarIsExternal : true ) {
4705+ if let filterContainerNodeAndActivate = await strongSelf . chatListDisplayNode. activateSearch ( placeholderNode: searchContentNode. placeholderNode, displaySearchFilters: displaySearchFilters, hasDownloads: strongSelf . hasDownloads, initialFilter: filter, navigationController: strongSelf . navigationController as? NavigationController ) {
46934706 let ( filterContainerNode, activate) = filterContainerNodeAndActivate
46944707 if displaySearchFilters {
46954708 let searchTabsNode = SparseNode ( )
4696- self . searchTabsNode = searchTabsNode
4709+ strongSelf . searchTabsNode = searchTabsNode
46974710 searchTabsNode. addSubnode ( filterContainerNode)
46984711 }
46994712
47004713 activate ( filter != . downloads)
47014714
4702- if let searchContentNode = self . chatListDisplayNode. searchDisplayController? . contentNode as? ChatListSearchContainerNode {
4715+ if let searchContentNode = strongSelf . chatListDisplayNode. searchDisplayController? . contentNode as? ChatListSearchContainerNode {
47034716 searchContentNode. search ( filter: filter, query: query)
47044717 }
47054718 }
47064719
47074720 let transition : ContainedViewLayoutTransition = . animated( duration: 0.4 , curve: . spring)
4708- self . setDisplayNavigationBar ( false , transition: transition)
4709- self . updateTabBarSearchState ( ViewController . TabBarSearchState ( isActive: true ) , transition: transition)
4710- if let searchBarNode = self . currentTabBarSearchNode ? ( ) as? SearchBarNode {
4711- self . chatListDisplayNode. searchDisplayController? . setSearchBar ( searchBarNode)
4712- searchBarNode. activate ( )
4713- }
4714-
4715- self . isSearchActive = true
4716- if let navigationController = self . navigationController as? NavigationController {
4717- for controller in navigationController. globalOverlayControllers {
4718- if let controller = controller as? VoiceChatOverlayController {
4719- controller. updateVisibility ( )
4720- break
4721- }
4722- }
4723- }
4721+ strongSelf. setDisplayNavigationBar ( false , transition: transition)
4722+
4723+ ( strongSelf. parent as? TabBarController ) ? . updateIsTabBarHidden ( true , transition: . animated( duration: 0.4 , curve: . spring) )
47244724 }
4725- } else if self . isSearchActive {
4726- if let searchContentNode = self . chatListDisplayNode. searchDisplayController? . contentNode as? ChatListSearchContainerNode {
4727- searchContentNode. search ( filter: filter, query: query)
4725+ } )
4726+
4727+ self . isSearchActive = true
4728+ if let navigationController = self . navigationController as? NavigationController {
4729+ for controller in navigationController. globalOverlayControllers {
4730+ if let controller = controller as? VoiceChatOverlayController {
4731+ controller. updateVisibility ( )
4732+ break
4733+ }
47284734 }
47294735 }
4736+ } else if self . isSearchActive {
4737+ if let searchContentNode = self . chatListDisplayNode. searchDisplayController? . contentNode as? ChatListSearchContainerNode {
4738+ searchContentNode. search ( filter: filter, query: query)
4739+ }
47304740 }
47314741 }
47324742
@@ -4756,8 +4766,6 @@ public class ChatListControllerImpl: TelegramBaseController, ChatListController
47564766 }
47574767 completion = self . chatListDisplayNode. deactivateSearch ( placeholderNode: searchContentNode. placeholderNode, animated: animated)
47584768 searchContentNode. placeholderNode. frame = previousFrame
4759- } else {
4760- completion = self . chatListDisplayNode. deactivateSearch ( placeholderNode: nil , animated: animated)
47614769 }
47624770
47634771 self . chatListDisplayNode. tempAllowAvatarExpansion = true
@@ -4772,7 +4780,7 @@ public class ChatListControllerImpl: TelegramBaseController, ChatListController
47724780
47734781 completion ? ( )
47744782
4775- self . updateTabBarSearchState ( ViewController . TabBarSearchState ( isActive : false ) , transition : transition )
4783+ ( self . parent as? TabBarController ) ? . updateIsTabBarHidden ( false , transition : . animated ( duration : 0.4 , curve : . spring ) )
47764784
47774785 self . isSearchActive = false
47784786 if let navigationController = self . navigationController as? NavigationController {
@@ -6228,14 +6236,6 @@ public class ChatListControllerImpl: TelegramBaseController, ChatListController
62286236 strongSelf. context. sharedContext. mainWindow? . presentInGlobalOverlay ( controller)
62296237 } )
62306238 }
6231-
6232- override public func tabBarActivateSearch( ) {
6233- self . activateSearch ( )
6234- }
6235-
6236- override public func tabBarDeactivateSearch( ) {
6237- self . deactivateSearch ( animated: true )
6238- }
62396239
62406240 private var playedSignUpCompletedAnimation = false
62416241 public func playSignUpCompletedAnimation( ) {
0 commit comments