mirror of
https://github.com/metabolist/metatext.git
synced 2024-12-23 05:56:30 +00:00
50 lines
1.7 KiB
Swift
50 lines
1.7 KiB
Swift
// Copyright © 2021 Metabolist. All rights reserved.
|
|
|
|
import UIKit
|
|
import ViewModels
|
|
|
|
final class ExploreViewController: UICollectionViewController {
|
|
private let viewModel: ExploreViewModel
|
|
private let rootViewModel: RootViewModel
|
|
private let identification: Identification
|
|
|
|
init(viewModel: ExploreViewModel, rootViewModel: RootViewModel, identification: Identification) {
|
|
self.viewModel = viewModel
|
|
self.rootViewModel = rootViewModel
|
|
self.identification = identification
|
|
|
|
super.init(collectionViewLayout: UICollectionViewFlowLayout())
|
|
|
|
tabBarItem = UITabBarItem(
|
|
title: NSLocalizedString("main-navigation.explore", comment: ""),
|
|
image: UIImage(systemName: "magnifyingglass"),
|
|
selectedImage: nil)
|
|
}
|
|
|
|
@available(*, unavailable)
|
|
required init?(coder: NSCoder) {
|
|
fatalError("init(coder:) has not been implemented")
|
|
}
|
|
|
|
override func viewDidLoad() {
|
|
super.viewDidLoad()
|
|
|
|
navigationItem.title = NSLocalizedString("main-navigation.explore", comment: "")
|
|
|
|
let searchController = UISearchController(
|
|
searchResultsController: TableViewController(
|
|
viewModel: viewModel.searchViewModel,
|
|
rootViewModel: rootViewModel,
|
|
identification: identification,
|
|
parentNavigationController: navigationController))
|
|
|
|
searchController.searchResultsUpdater = self
|
|
navigationItem.searchController = searchController
|
|
}
|
|
}
|
|
|
|
extension ExploreViewController: UISearchResultsUpdating {
|
|
func updateSearchResults(for searchController: UISearchController) {
|
|
viewModel.searchViewModel.query = searchController.searchBar.text ?? ""
|
|
}
|
|
}
|