Update navigation bar appearance in SearchViewController
This commit is contained in:
parent
57380b9989
commit
407e0ae304
|
@ -23,15 +23,15 @@ final class HeightFixedSearchBar: UISearchBar {
|
||||||
final class SearchViewController: UIViewController, NeedsDependency {
|
final class SearchViewController: UIViewController, NeedsDependency {
|
||||||
|
|
||||||
let logger = Logger(subsystem: "SearchViewController", category: "ViewController")
|
let logger = Logger(subsystem: "SearchViewController", category: "ViewController")
|
||||||
|
|
||||||
weak var context: AppContext! { willSet { precondition(!isViewLoaded) } }
|
weak var context: AppContext! { willSet { precondition(!isViewLoaded) } }
|
||||||
weak var coordinator: SceneCoordinator! { willSet { precondition(!isViewLoaded) } }
|
weak var coordinator: SceneCoordinator! { willSet { precondition(!isViewLoaded) } }
|
||||||
|
|
||||||
var searchTransitionController = SearchTransitionController()
|
var searchTransitionController = SearchTransitionController()
|
||||||
|
|
||||||
var disposeBag = Set<AnyCancellable>()
|
var disposeBag = Set<AnyCancellable>()
|
||||||
var viewModel: SearchViewModel!
|
var viewModel: SearchViewModel!
|
||||||
|
|
||||||
// use AutoLayout could set search bar margin automatically to
|
// use AutoLayout could set search bar margin automatically to
|
||||||
// layout alongside with split mode button (on iPad)
|
// layout alongside with split mode button (on iPad)
|
||||||
let titleViewContainer = UIView()
|
let titleViewContainer = UIView()
|
||||||
|
@ -85,6 +85,7 @@ extension SearchViewController {
|
||||||
title = L10n.Scene.Search.title
|
title = L10n.Scene.Search.title
|
||||||
|
|
||||||
setupSearchBar()
|
setupSearchBar()
|
||||||
|
setupNavigationBarAppearance()
|
||||||
|
|
||||||
// collectionView.translatesAutoresizingMaskIntoConstraints = false
|
// collectionView.translatesAutoresizingMaskIntoConstraints = false
|
||||||
// view.addSubview(collectionView)
|
// view.addSubview(collectionView)
|
||||||
|
@ -101,7 +102,7 @@ extension SearchViewController {
|
||||||
// )
|
// )
|
||||||
|
|
||||||
guard let discoveryViewController = self.discoveryViewController else { return }
|
guard let discoveryViewController = self.discoveryViewController else { return }
|
||||||
|
|
||||||
addChild(discoveryViewController)
|
addChild(discoveryViewController)
|
||||||
discoveryViewController.view.translatesAutoresizingMaskIntoConstraints = false
|
discoveryViewController.view.translatesAutoresizingMaskIntoConstraints = false
|
||||||
view.addSubview(discoveryViewController.view)
|
view.addSubview(discoveryViewController.view)
|
||||||
|
@ -111,15 +112,16 @@ extension SearchViewController {
|
||||||
discoveryViewController.view.trailingAnchor.constraint(equalTo: view.trailingAnchor),
|
discoveryViewController.view.trailingAnchor.constraint(equalTo: view.trailingAnchor),
|
||||||
discoveryViewController.view.bottomAnchor.constraint(equalTo: view.bottomAnchor),
|
discoveryViewController.view.bottomAnchor.constraint(equalTo: view.bottomAnchor),
|
||||||
])
|
])
|
||||||
|
|
||||||
// discoveryViewController.view.isHidden = true
|
// discoveryViewController.view.isHidden = true
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override func viewDidAppear(_ animated: Bool) {
|
override func viewDidAppear(_ animated: Bool) {
|
||||||
super.viewDidAppear(animated)
|
super.viewDidAppear(animated)
|
||||||
|
|
||||||
viewModel.viewDidAppeared.send()
|
viewModel.viewDidAppeared.send()
|
||||||
|
|
||||||
// note:
|
// note:
|
||||||
// need set alpha because (maybe) SDK forget set alpha back
|
// need set alpha because (maybe) SDK forget set alpha back
|
||||||
titleViewContainer.alpha = 1
|
titleViewContainer.alpha = 1
|
||||||
|
@ -164,6 +166,20 @@ extension SearchViewController {
|
||||||
.store(in: &disposeBag)
|
.store(in: &disposeBag)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private func setupNavigationBarAppearance() {
|
||||||
|
let appearance = UINavigationBarAppearance()
|
||||||
|
appearance.configureWithOpaqueBackground()
|
||||||
|
appearance.shadowColor = nil
|
||||||
|
|
||||||
|
navigationItem.standardAppearance = appearance
|
||||||
|
navigationItem.scrollEdgeAppearance = appearance
|
||||||
|
navigationItem.compactAppearance = appearance
|
||||||
|
|
||||||
|
if #available(iOS 15, *) {
|
||||||
|
navigationItem.compactScrollEdgeAppearance = appearance
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// MARK: - UISearchBarDelegate
|
// MARK: - UISearchBarDelegate
|
||||||
|
|
Loading…
Reference in New Issue