From 6978789d0c6b1b341b5467507a5b999c720ecf95 Mon Sep 17 00:00:00 2001 From: wuyueyang Date: Fri, 12 Apr 2024 20:30:24 +0800 Subject: [PATCH] New explore design --- Mixin.xcodeproj/project.pbxproj | 12 +- .../Home/ExploreAllAppsViewController.swift | 98 -------- .../Home/ExploreBotsViewController.swift | 220 ++++++++++++++++++ .../Home/ExploreFavoriteViewController.swift | 156 ------------- .../Home/ExploreViewController.swift | 29 +-- 5 files changed, 228 insertions(+), 287 deletions(-) delete mode 100644 Mixin/UserInterface/Controllers/Home/ExploreAllAppsViewController.swift create mode 100644 Mixin/UserInterface/Controllers/Home/ExploreBotsViewController.swift delete mode 100644 Mixin/UserInterface/Controllers/Home/ExploreFavoriteViewController.swift diff --git a/Mixin.xcodeproj/project.pbxproj b/Mixin.xcodeproj/project.pbxproj index 3f314315e1..d1fbd5f6c4 100644 --- a/Mixin.xcodeproj/project.pbxproj +++ b/Mixin.xcodeproj/project.pbxproj @@ -851,9 +851,8 @@ 94B2CD782B0F88D300D268E1 /* DepositView.xib in Resources */ = {isa = PBXBuildFile; fileRef = 94B2CD772B0F88D300D268E1 /* DepositView.xib */; }; 94B5776A2B5E554800AE576E /* ExploreViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 94B577692B5E554800AE576E /* ExploreViewController.swift */; }; 94B5776F2B5E555B00AE576E /* ExploreView.xib in Resources */ = {isa = PBXBuildFile; fileRef = 94B5776E2B5E555B00AE576E /* ExploreView.xib */; }; - 94B577772B5E6E3700AE576E /* ExploreFavoriteViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 94B577752B5E6E3700AE576E /* ExploreFavoriteViewController.swift */; }; 94B5777D2B5E755100AE576E /* SeparatorHeaderFooterView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 94B5777C2B5E755100AE576E /* SeparatorHeaderFooterView.swift */; }; - 94B577822B5E79B800AE576E /* ExploreAllAppsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 94B577812B5E79B800AE576E /* ExploreAllAppsViewController.swift */; }; + 94B577822B5E79B800AE576E /* ExploreBotsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 94B577812B5E79B800AE576E /* ExploreBotsViewController.swift */; }; 94B577872B5EC11500AE576E /* ExploreAction.swift in Sources */ = {isa = PBXBuildFile; fileRef = 94B577862B5EC11500AE576E /* ExploreAction.swift */; }; 94B61EC32B344A7A00BD39AF /* HomeTabBarController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 94B61EC22B344A7A00BD39AF /* HomeTabBarController.swift */; }; 94B6EDFE2B707F15001DCC50 /* WithdrawPreviewViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 94B6EDFD2B707F15001DCC50 /* WithdrawPreviewViewController.swift */; }; @@ -2054,9 +2053,8 @@ 94B2CD772B0F88D300D268E1 /* DepositView.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = DepositView.xib; sourceTree = ""; }; 94B577692B5E554800AE576E /* ExploreViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ExploreViewController.swift; sourceTree = ""; }; 94B5776E2B5E555B00AE576E /* ExploreView.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = ExploreView.xib; sourceTree = ""; }; - 94B577752B5E6E3700AE576E /* ExploreFavoriteViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ExploreFavoriteViewController.swift; sourceTree = ""; }; 94B5777C2B5E755100AE576E /* SeparatorHeaderFooterView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SeparatorHeaderFooterView.swift; sourceTree = ""; }; - 94B577812B5E79B800AE576E /* ExploreAllAppsViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ExploreAllAppsViewController.swift; sourceTree = ""; }; + 94B577812B5E79B800AE576E /* ExploreBotsViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ExploreBotsViewController.swift; sourceTree = ""; }; 94B577862B5EC11500AE576E /* ExploreAction.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ExploreAction.swift; sourceTree = ""; }; 94B61EC22B344A7A00BD39AF /* HomeTabBarController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HomeTabBarController.swift; sourceTree = ""; }; 94B6EDFD2B707F15001DCC50 /* WithdrawPreviewViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WithdrawPreviewViewController.swift; sourceTree = ""; }; @@ -3849,8 +3847,7 @@ 9473F8272AE51097004E5739 /* RegisterToSafeViewController.swift */, 94B5776E2B5E555B00AE576E /* ExploreView.xib */, 94B577692B5E554800AE576E /* ExploreViewController.swift */, - 94B577752B5E6E3700AE576E /* ExploreFavoriteViewController.swift */, - 94B577812B5E79B800AE576E /* ExploreAllAppsViewController.swift */, + 94B577812B5E79B800AE576E /* ExploreBotsViewController.swift */, 94B13FC12B5ED5F9001333BE /* ExploreSearchView.xib */, 94B13FC02B5ED5F9001333BE /* ExploreSearchViewController.swift */, 94CF1F262BA1B74A00BC52C1 /* Web3WalletViewController.swift */, @@ -5299,8 +5296,7 @@ 7B5E9B4A243740C4000AE24E /* ConversationCircleEditorFooterView.swift in Sources */, 7BFE47E22284394000FC4379 /* CheckmarkPeerCell.swift in Sources */, 7CDF316C29890FB200421808 /* ConversationFontSet.swift in Sources */, - 94B577772B5E6E3700AE576E /* ExploreFavoriteViewController.swift in Sources */, - 94B577822B5E79B800AE576E /* ExploreAllAppsViewController.swift in Sources */, + 94B577822B5E79B800AE576E /* ExploreBotsViewController.swift in Sources */, 7B369208233A43C1007321A7 /* SegmentedControl.swift in Sources */, 9427D51A25E0D42E00B1EF0E /* MusicInfoView.swift in Sources */, 7C2AC42928F2B384005F369A /* DepositSuspendedView.swift in Sources */, diff --git a/Mixin/UserInterface/Controllers/Home/ExploreAllAppsViewController.swift b/Mixin/UserInterface/Controllers/Home/ExploreAllAppsViewController.swift deleted file mode 100644 index a535a045a7..0000000000 --- a/Mixin/UserInterface/Controllers/Home/ExploreAllAppsViewController.swift +++ /dev/null @@ -1,98 +0,0 @@ -import UIKit -import MixinServices - -final class ExploreAllAppsViewController: UITableViewController { - - private let headerReuseID = "header" - - private(set) var allUsers: [User]? = nil - - private var indexTitles: [String]? = nil - private var indexedUsers: [[User]] = [] - - override func viewDidLoad() { - super.viewDidLoad() - view.backgroundColor = R.color.background() - tableView.separatorStyle = .none - tableView.register(R.nib.peerCell) - tableView.register(PeerHeaderView.self, forHeaderFooterViewReuseIdentifier: headerReuseID) - tableView.sectionIndexColor = R.color.text_tertiary() - tableView.rowHeight = 70 - reloadData() - NotificationCenter.default.addObserver(self, selector: #selector(reloadData), name: UserDAO.usersDidChangeNotification, object: nil) - } - - // MARK: - UITableViewDataSource - override func numberOfSections(in tableView: UITableView) -> Int { - indexTitles?.count ?? 0 - } - - override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { - indexedUsers[section].count - } - - override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { - let cell = tableView.dequeueReusableCell(withIdentifier: R.reuseIdentifier.peer, for: indexPath)! - let user = indexedUsers[indexPath.section][indexPath.row] - cell.peerInfoView.render(user: user, description: .identityNumber) - return cell - } - - override func sectionIndexTitles(for tableView: UITableView) -> [String]? { - indexTitles - } - - // MARK: - UITableViewDelegate - override func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat { - 34 - } - - override func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? { - let header = tableView.dequeueReusableHeaderFooterView(withIdentifier: headerReuseID) as! PeerHeaderView - header.label.text = indexTitles?[section] - return header - } - - override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { - tableView.deselectRow(at: indexPath, animated: true) - guard let explore = parent as? ExploreViewController else { - return - } - let user = indexedUsers[indexPath.section][indexPath.row] - explore.presentProfile(user: user) - } - - @objc private func reloadData() { - - class ObjcAccessibleUser: NSObject { - - @objc let fullName: String - let user: User - - init(user: User) { - self.fullName = user.fullName ?? "" - self.user = user - super.init() - } - - } - - DispatchQueue.global().async { - let allUsers = UserDAO.shared.getAppUsers() - let objcAccessibleUsers = allUsers.map(ObjcAccessibleUser.init(user:)) - let (titles, indexedObjcUsers) = UILocalizedIndexedCollation.current() - .catalog(objcAccessibleUsers, usingSelector: #selector(getter: ObjcAccessibleUser.fullName)) - let indexedUsers = indexedObjcUsers.map { $0.map(\.user) } - DispatchQueue.main.async { - self.allUsers = allUsers - self.indexTitles = titles - self.indexedUsers = indexedUsers - self.tableView.reloadData() - self.tableView.checkEmpty(dataCount: allUsers.count, - text: R.string.localizable.no_bots(), - photo: R.image.emptyIndicator.ic_data()!) - } - } - } - -} diff --git a/Mixin/UserInterface/Controllers/Home/ExploreBotsViewController.swift b/Mixin/UserInterface/Controllers/Home/ExploreBotsViewController.swift new file mode 100644 index 0000000000..c4f3e4dd7d --- /dev/null +++ b/Mixin/UserInterface/Controllers/Home/ExploreBotsViewController.swift @@ -0,0 +1,220 @@ +import UIKit +import MixinServices + +final class ExploreBotsViewController: UITableViewController { + + private enum FixedSection: Int, CaseIterable { + case actions = 0 + case favorites + } + + private let headerReuseID = "header" + private let actions: [ExploreAction] = [ + .camera, .linkDesktop, .customerService, + ] + + private(set) var allUsers: [User]? = nil + + private var favoriteAppUsers: [User] = [] + private var indexTitles: [String]? = nil + private var indexedUsers: [[User]] = [] + + override func viewDidLoad() { + super.viewDidLoad() + view.backgroundColor = R.color.background() + tableView.separatorStyle = .none + tableView.register(R.nib.exploreActionCell) + tableView.register(R.nib.peerCell) + tableView.register(PeerHeaderView.self, forHeaderFooterViewReuseIdentifier: headerReuseID) + tableView.sectionIndexColor = R.color.text_tertiary() + tableView.rowHeight = 70 + tableView.contentInset.bottom = 10 + reloadFavoriteAppsFromLocal() + reloadFavoriteAppsFromRemote() + reloadAllApps() + let center: NotificationCenter = .default + center.addObserver(self, + selector: #selector(reloadAllApps), + name: UserDAO.usersDidChangeNotification, + object: nil) + center.addObserver(self, + selector: #selector(reloadFavoriteAppsFromLocal), + name: UserDAO.usersDidChangeNotification, + object: nil) + center.addObserver(self, + selector: #selector(reloadFavoriteAppsFromLocal), + name: FavoriteAppsDAO.favoriteAppsDidChangeNotification, + object: nil) + center.addObserver(self, + selector: #selector(updateLinkDesktopAction), + name: AppGroupUserDefaults.Account.extensionSessionDidChangeNotification, + object: nil) + } + + // MARK: - UITableViewDataSource + override func numberOfSections(in tableView: UITableView) -> Int { + FixedSection.allCases.count + (indexTitles?.count ?? 0) + } + + override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { + switch FixedSection(rawValue: section) { + case .actions: + actions.count + case .favorites: + favoriteAppUsers.count + default: + indexedUsers(at: section).count + } + } + + override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { + switch FixedSection(rawValue: indexPath.section) { + case .actions: + let cell = tableView.dequeueReusableCell(withIdentifier: R.reuseIdentifier.explore_action, for: indexPath)! + let action = actions[indexPath.row] + cell.load(action: action) + return cell + case .favorites: + if indexPath.row < favoriteAppUsers.count { + let cell = tableView.dequeueReusableCell(withIdentifier: R.reuseIdentifier.peer, for: indexPath)! + let user = favoriteAppUsers[indexPath.row] + cell.peerInfoView.render(user: user, description: .identityNumber) + cell.peerInfoView.avatarImageView.hasShadow = false + return cell + } else { + let cell = tableView.dequeueReusableCell(withIdentifier: R.reuseIdentifier.explore_action, for: indexPath)! + cell.load(action: .editFavoriteApps) + return cell + } + default: + let cell = tableView.dequeueReusableCell(withIdentifier: R.reuseIdentifier.peer, for: indexPath)! + let user = indexedUser(at: indexPath) + cell.peerInfoView.render(user: user, description: .identityNumber) + return cell + } + } + + override func sectionIndexTitles(for tableView: UITableView) -> [String]? { + indexTitles + } + + override func tableView(_ tableView: UITableView, sectionForSectionIndexTitle title: String, at index: Int) -> Int { + index + FixedSection.allCases.count + } + + // MARK: - UITableViewDelegate + override func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat { + switch FixedSection(rawValue: section) { + case .actions: + 0 + default: + 34 + } + } + + override func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? { + let header = tableView.dequeueReusableHeaderFooterView(withIdentifier: headerReuseID) as! PeerHeaderView + switch FixedSection(rawValue: section) { + case .actions: + return nil + case .favorites: + header.label.text = R.string.localizable.favorite() + return header + default: + header.label.text = indexTitles?[section - FixedSection.allCases.count] + return header + } + } + + override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { + tableView.deselectRow(at: indexPath, animated: true) + if let explore = parent as? ExploreViewController { + let user = indexedUser(at: indexPath) + explore.presentProfile(user: user) + } + } + + @objc private func reloadAllApps() { + + class ObjcAccessibleUser: NSObject { + + @objc let fullName: String + let user: User + + init(user: User) { + self.fullName = user.fullName ?? "" + self.user = user + super.init() + } + + } + + DispatchQueue.global().async { + let allUsers = UserDAO.shared.getAppUsers() + let objcAccessibleUsers = allUsers.map(ObjcAccessibleUser.init(user:)) + let (titles, indexedObjcUsers) = UILocalizedIndexedCollation.current() + .catalog(objcAccessibleUsers, usingSelector: #selector(getter: ObjcAccessibleUser.fullName)) + let indexedUsers = indexedObjcUsers.map { $0.map(\.user) } + DispatchQueue.main.async { + self.allUsers = allUsers + self.indexTitles = titles + self.indexedUsers = indexedUsers + self.tableView.reloadData() + self.tableView.checkEmpty(dataCount: allUsers.count, + text: R.string.localizable.no_bots(), + photo: R.image.emptyIndicator.ic_data()!) + } + } + } + + @objc private func reloadFavoriteAppsFromLocal() { + DispatchQueue.global().async { [weak self] in + let users = FavoriteAppsDAO.shared.favoriteAppUsersOfUser(withId: myUserId) + DispatchQueue.main.async { + guard let self else { + return + } + self.favoriteAppUsers = users + let favorites = IndexSet(integer: FixedSection.favorites.rawValue) + UIView.performWithoutAnimation { + self.tableView.reloadSections(favorites, with: .none) + } + } + } + } + + private func reloadFavoriteAppsFromRemote() { + UserAPI.getFavoriteApps(ofUserWith: myUserId) { (result) in + guard case let .success(apps) = result else { + return + } + DispatchQueue.global().async { + FavoriteAppsDAO.shared.updateFavoriteApps(apps, forUserWith: myUserId) + let appUserIds = apps.map({ $0.appId }) + UserAPI.showUsers(userIds: appUserIds) { (result) in + guard case let .success(users) = result else { + return + } + UserDAO.shared.updateUsers(users: users) + } + } + } + } + + @objc private func updateLinkDesktopAction() { + guard let row = actions.firstIndex(of: .linkDesktop) else { + return + } + let indexPath = IndexPath(row: row, section: FixedSection.actions.rawValue) + tableView.reloadRows(at: [indexPath], with: .none) + } + + private func indexedUsers(at section: Int) -> [User] { + indexedUsers[section - FixedSection.allCases.count] + } + + private func indexedUser(at indexPath: IndexPath) -> User { + indexedUsers(at: indexPath.section)[indexPath.row] + } + +} diff --git a/Mixin/UserInterface/Controllers/Home/ExploreFavoriteViewController.swift b/Mixin/UserInterface/Controllers/Home/ExploreFavoriteViewController.swift deleted file mode 100644 index 539566a432..0000000000 --- a/Mixin/UserInterface/Controllers/Home/ExploreFavoriteViewController.swift +++ /dev/null @@ -1,156 +0,0 @@ -import UIKit -import MixinServices - -final class ExploreFavoriteViewController: UITableViewController { - - private enum Section: Int { - case fixed = 0 - case favorites = 1 - } - - private let fixedActions: [ExploreAction] = [ - .camera, .linkDesktop, .customerService, - ] - - private var favoriteAppUsers: [User] = [] - - override func viewDidLoad() { - super.viewDidLoad() - view.backgroundColor = R.color.background() - tableView.separatorStyle = .none - tableView.register(R.nib.exploreActionCell) - tableView.register(R.nib.peerCell) - tableView.register(SeparatorHeaderFooterView.self, forHeaderFooterViewReuseIdentifier: SeparatorHeaderFooterView.reuseIdentifier) - tableView.rowHeight = 70 - tableView.contentInset.bottom = 10 - reloadFavoriteAppsFromLocal() - reloadFavoriteAppsFromRemote() - NotificationCenter.default.addObserver(self, selector: #selector(reloadFavoriteAppsFromLocal), name: UserDAO.usersDidChangeNotification, object: nil) - NotificationCenter.default.addObserver(self, selector: #selector(reloadFavoriteAppsFromLocal), name: FavoriteAppsDAO.favoriteAppsDidChangeNotification, object: nil) - NotificationCenter.default.addObserver(self, selector: #selector(updateLinkDesktopAction), name: AppGroupUserDefaults.Account.extensionSessionDidChangeNotification, object: nil) - } - - // MARK: - UITableViewDataSource - override func numberOfSections(in tableView: UITableView) -> Int { - 2 - } - - override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { - switch Section(rawValue: section) { - case .fixed: - return fixedActions.count - case .favorites: - return favoriteAppUsers.count + 1 - case nil: - return 0 - } - } - - override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { - switch Section(rawValue: indexPath.section)! { - case .fixed: - let cell = tableView.dequeueReusableCell(withIdentifier: R.reuseIdentifier.explore_action, for: indexPath)! - let action = fixedActions[indexPath.row] - cell.load(action: action) - return cell - case .favorites: - if indexPath.row < favoriteAppUsers.count { - let cell = tableView.dequeueReusableCell(withIdentifier: R.reuseIdentifier.peer, for: indexPath)! - let user = favoriteAppUsers[indexPath.row] - cell.peerInfoView.render(user: user, description: .identityNumber) - cell.peerInfoView.avatarImageView.hasShadow = false - return cell - } else { - let cell = tableView.dequeueReusableCell(withIdentifier: R.reuseIdentifier.explore_action, for: indexPath)! - cell.load(action: .editFavoriteApps) - return cell - } - } - } - - // MARK: - UITableViewDelegate - override func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat { - switch Section(rawValue: section) { - case .favorites: - return 50 - case .fixed, nil: - return .leastNormalMagnitude - } - } - - override func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? { - switch Section(rawValue: section) { - case .favorites: - let headerView = tableView.dequeueReusableHeaderFooterView(withIdentifier: SeparatorHeaderFooterView.reuseIdentifier) - headerView?.backgroundColor = R.color.background() - return headerView - case .fixed, nil: - return nil - } - } - - override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { - tableView.deselectRow(at: indexPath, animated: true) - guard let explore = parent as? ExploreViewController else { - return - } - switch Section(rawValue: indexPath.section) { - case .fixed: - let action = fixedActions[indexPath.row] - explore.perform(action: action) - case .favorites: - if indexPath.row < favoriteAppUsers.count { - let user = favoriteAppUsers[indexPath.row] - explore.openApp(user: user) - } else { - explore.perform(action: .editFavoriteApps) - } - case nil: - break - } - } - - // MARK: - Data Loader - @objc private func updateLinkDesktopAction() { - guard let row = fixedActions.firstIndex(of: .linkDesktop) else { - return - } - let indexPath = IndexPath(row: row, section: Section.fixed.rawValue) - tableView.reloadRows(at: [indexPath], with: .none) - } - - @objc private func reloadFavoriteAppsFromLocal() { - DispatchQueue.global().async { [weak self] in - let users = FavoriteAppsDAO.shared.favoriteAppUsersOfUser(withId: myUserId) - DispatchQueue.main.async { - guard let self else { - return - } - self.favoriteAppUsers = users - let favorites = IndexSet(integer: Section.favorites.rawValue) - UIView.performWithoutAnimation { - self.tableView.reloadSections(favorites, with: .none) - } - } - } - } - - private func reloadFavoriteAppsFromRemote() { - UserAPI.getFavoriteApps(ofUserWith: myUserId) { (result) in - guard case let .success(apps) = result else { - return - } - DispatchQueue.global().async { - FavoriteAppsDAO.shared.updateFavoriteApps(apps, forUserWith: myUserId) - let appUserIds = apps.map({ $0.appId }) - UserAPI.showUsers(userIds: appUserIds) { (result) in - guard case let .success(users) = result else { - return - } - UserDAO.shared.updateUsers(users: users) - } - } - } - } - -} diff --git a/Mixin/UserInterface/Controllers/Home/ExploreViewController.swift b/Mixin/UserInterface/Controllers/Home/ExploreViewController.swift index 3ce0c60f77..bb5b4e3251 100644 --- a/Mixin/UserInterface/Controllers/Home/ExploreViewController.swift +++ b/Mixin/UserInterface/Controllers/Home/ExploreViewController.swift @@ -6,8 +6,7 @@ final class ExploreViewController: UIViewController { @IBOutlet weak var segmentsCollectionView: UICollectionView! @IBOutlet weak var contentContainerView: UIView! - private let favoriteViewController = ExploreFavoriteViewController() - private let allAppsViewController = ExploreAllAppsViewController() + private let exploreBotsViewController = ExploreBotsViewController() private let hiddenSearchTopMargin: CGFloat = -28 private weak var web3WalletViewController: Web3WalletViewController? @@ -18,8 +17,7 @@ final class ExploreViewController: UIViewController { override func viewDidLoad() { super.viewDidLoad() - addContentViewController(allAppsViewController) - addContentViewController(favoriteViewController) + addContentViewController(exploreBotsViewController) segmentsCollectionView.register(R.nib.exploreSegmentCell) if let layout = segmentsCollectionView.collectionViewLayout as? UICollectionViewFlowLayout { layout.scrollDirection = .horizontal @@ -36,7 +34,7 @@ final class ExploreViewController: UIViewController { } @IBAction func searchApps(_ sender: Any) { - let searchViewController = ExploreSearchViewController(users: allAppsViewController.allUsers) + let searchViewController = ExploreSearchViewController(users: exploreBotsViewController.allUsers) addChild(searchViewController) searchViewController.view.alpha = 0 view.addSubview(searchViewController.view) @@ -152,22 +150,12 @@ extension ExploreViewController: UICollectionViewDelegate { removeWeb3WalletViewController() let segment = Segment(rawValue: indexPath.item)! switch segment { - case .favorite: - contentContainerView.bringSubviewToFront(favoriteViewController.view) case .bots: - contentContainerView.bringSubviewToFront(allAppsViewController.view) + contentContainerView.bringSubviewToFront(exploreBotsViewController.view) case .ethereum: let wallet = Web3WalletViewController(chain: .ethereum) addContentViewController(wallet) web3WalletViewController = wallet - case .polygon: - let wallet = Web3WalletViewController(chain: .polygon) - addContentViewController(wallet) - web3WalletViewController = wallet - case .bsc: - let wallet = Web3WalletViewController(chain: .bnbSmartChain) - addContentViewController(wallet) - web3WalletViewController = wallet } } @@ -177,24 +165,15 @@ extension ExploreViewController { private enum Segment: Int, CaseIterable { - case favorite case bots case ethereum - case polygon - case bsc var name: String { switch self { - case .favorite: - R.string.localizable.favorite() case .bots: R.string.localizable.bots_title() case .ethereum: "Ethereum" - case .polygon: - "Polygon" - case .bsc: - "BSC" } }