Skip to content

Commit 89f96e2

Browse files
author
Isaac
committed
Revert "[WIP] Tab bar and search"
This reverts commit 5e26b24.
1 parent b04eee8 commit 89f96e2

File tree

33 files changed

+810
-1468
lines changed

33 files changed

+810
-1468
lines changed

Telegram/BUILD

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ load("@build_bazel_rules_apple//apple:ios.bzl",
88
"ios_application",
99
"ios_extension",
1010
"ios_framework",
11+
"ios_unit_test",
12+
"ios_ui_test",
1113
)
1214

1315
load("@build_bazel_rules_apple//apple:resources.bzl",
@@ -20,6 +22,7 @@ load("@build_bazel_rules_swift//swift:swift.bzl",
2022

2123
load(
2224
"@rules_xcodeproj//xcodeproj:defs.bzl",
25+
"top_level_target",
2326
"top_level_targets",
2427
"xcodeproj",
2528
"xcode_provisioning_profile",

submodules/CallListUI/Sources/CallListController.swift

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,8 +155,6 @@ public final class CallListController: TelegramBaseController {
155155
if case .navigation = self.mode {
156156
self.navigationItem.backBarButtonItem = UIBarButtonItem(title: self.presentationData.strings.Common_Back, style: .plain, target: nil, action: nil)
157157
}
158-
159-
self.updateTabBarSearchState(ViewController.TabBarSearchState(isActive: false), transition: .immediate)
160158
}
161159

162160
required public init(coder aDecoder: NSCoder) {

submodules/ChatListUI/BUILD

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,6 @@ swift_library(
118118
"//submodules/TelegramUI/Components/ButtonComponent",
119119
"//submodules/TelegramUI/Components/AnimatedTextComponent",
120120
"//submodules/TelegramUI/Components/EdgeEffect",
121-
"//submodules/TelegramUI/Components/ChatList/ChatListFilterTabContainerNode",
122121
],
123122
visibility = [
124123
"//visibility:public",

submodules/ChatListUI/Sources/ChatListController.swift

Lines changed: 68 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,6 @@ import TextFormat
5555
import AvatarUploadToastScreen
5656
import AdsInfoScreen
5757
import AdsReportScreen
58-
import SearchBarNode
59-
import ChatListFilterTabContainerNode
6058

6159
private 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() {

submodules/ChatListUI/Sources/ChatListControllerNode.swift

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ import ChatListHeaderComponent
2222
import StoryPeerListComponent
2323
import TelegramNotices
2424
import EdgeEffect
25-
import ChatListFilterTabContainerNode
2625

2726
public enum ChatListContainerNodeFilter: Equatable {
2827
case all
@@ -1383,8 +1382,8 @@ final class ChatListControllerNode: ASDisplayNode, ASGestureRecognizerDelegate {
13831382
strings: self.presentationData.strings,
13841383
statusBarHeight: layout.statusBarHeight ?? 0.0,
13851384
sideInset: layout.safeInsets.left,
1386-
search: nil, //ChatListNavigationBar.Search(isEnabled: true),
13871385
isSearchActive: self.isSearchDisplayControllerActive,
1386+
isSearchEnabled: true,
13881387
primaryContent: headerContent?.primaryContent,
13891388
secondaryContent: headerContent?.secondaryContent,
13901389
secondaryTransition: self.inlineStackContainerTransitionFraction,
@@ -1541,8 +1540,7 @@ final class ChatListControllerNode: ASDisplayNode, ASGestureRecognizerDelegate {
15411540
var storiesInset = storiesInset
15421541

15431542
let navigationBarLayout = self.updateNavigationBar(layout: layout, deferScrollApplication: true, transition: ComponentTransition(transition))
1544-
//self.mainContainerNode.initialScrollingOffset = ChatListNavigationBar.searchScrollHeight + navigationBarLayout.storiesInset
1545-
self.mainContainerNode.initialScrollingOffset = navigationBarLayout.storiesInset
1543+
self.mainContainerNode.initialScrollingOffset = ChatListNavigationBar.searchScrollHeight + navigationBarLayout.storiesInset
15461544

15471545
navigationBarHeight = navigationBarLayout.navigationHeight
15481546
visualNavigationHeight = navigationBarLayout.navigationHeight
@@ -1668,7 +1666,7 @@ final class ChatListControllerNode: ASDisplayNode, ASGestureRecognizerDelegate {
16681666
}
16691667

16701668
@MainActor
1671-
func activateSearch(placeholderNode: SearchBarPlaceholderNode?, displaySearchFilters: Bool, hasDownloads: Bool, initialFilter: ChatListSearchFilter, navigationController: NavigationController?, searchBarIsExternal: Bool) async -> (ASDisplayNode, (Bool) -> Void)? {
1669+
func activateSearch(placeholderNode: SearchBarPlaceholderNode, displaySearchFilters: Bool, hasDownloads: Bool, initialFilter: ChatListSearchFilter, navigationController: NavigationController?) async -> (ASDisplayNode, (Bool) -> Void)? {
16721670
guard let (containerLayout, _, _, cleanNavigationBarHeight, _) = self.containerLayout, self.searchDisplayController == nil else {
16731671
return nil
16741672
}
@@ -1714,7 +1712,7 @@ final class ChatListControllerNode: ASDisplayNode, ASGestureRecognizerDelegate {
17141712
if let requestDeactivateSearch = self?.requestDeactivateSearch {
17151713
requestDeactivateSearch()
17161714
}
1717-
}, searchBarIsExternal: searchBarIsExternal)
1715+
})
17181716
self.mainContainerNode.accessibilityElementsHidden = true
17191717
self.inlineStackContainerNode?.accessibilityElementsHidden = true
17201718

@@ -1744,16 +1742,15 @@ final class ChatListControllerNode: ASDisplayNode, ASGestureRecognizerDelegate {
17441742
})
17451743
}
17461744

1747-
func deactivateSearch(placeholderNode: SearchBarPlaceholderNode?, animated: Bool) -> (() -> Void)? {
1745+
func deactivateSearch(placeholderNode: SearchBarPlaceholderNode, animated: Bool) -> (() -> Void)? {
17481746
if let searchDisplayController = self.searchDisplayController {
17491747
self.isSearchDisplayControllerActive = false
17501748
self.searchDisplayController = nil
17511749
self.mainContainerNode.accessibilityElementsHidden = false
17521750
self.inlineStackContainerNode?.accessibilityElementsHidden = false
17531751

17541752
return { [weak self, weak placeholderNode] in
1755-
if let strongSelf = self, let (layout, _, _, cleanNavigationBarHeight, _) = strongSelf.containerLayout {
1756-
let placeholderNode = placeholderNode
1753+
if let strongSelf = self, let placeholderNode, let (layout, _, _, cleanNavigationBarHeight, _) = strongSelf.containerLayout {
17571754
searchDisplayController.deactivate(placeholder: placeholderNode, animated: animated)
17581755

17591756
searchDisplayController.containerLayoutUpdated(layout, navigationBarHeight: cleanNavigationBarHeight, transition: .animated(duration: 0.4, curve: .spring))

0 commit comments

Comments
 (0)