Skip to content

Commit

Permalink
Fixing hole in search #139
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisballinger committed Aug 14, 2023
1 parent e5335c9 commit 2663535
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
12 changes: 12 additions & 0 deletions iBurn/ListCoordinator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,22 @@ extension ListCoordinator: UISearchControllerDelegate {
func didPresentSearchController(_ searchController: UISearchController) {
pageViewManager.tableView = self.searchDisplayManager.tableViewAdapter.tableView
pageViewManager.objectProvider = self.searchDisplayManager.viewHandler
// hack to fix https://github.com/iBurnApp/iBurn-iOS/issues/139
if #available(iOS 16.0, *) {
parent?.navigationItem.rightBarButtonItem?.isHidden = true
} else {
parent?.navigationItem.rightBarButtonItem?.isEnabled = false
}
}

func didDismissSearchController(_ searchController: UISearchController) {
pageViewManager.tableView = self.tableViewAdapter.tableView
pageViewManager.objectProvider = self.tableViewAdapter.viewHandler
// hack to fix https://github.com/iBurnApp/iBurn-iOS/issues/139
if #available(iOS 16.0, *) {
parent?.navigationItem.rightBarButtonItem?.isHidden = false
} else {
parent?.navigationItem.rightBarButtonItem?.isEnabled = true
}
}
}
9 changes: 3 additions & 6 deletions iBurn/SearchDisplayManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,6 @@ public final class SearchDisplayManager: NSObject {
private let searchText = PassthroughSubject<String, Never>()
private var cancellables: Set<AnyCancellable> = .init()

private var tableViewController: UITableViewController? {
return searchController.searchResultsController as? UITableViewController
}

public init(viewName: String) {
self.viewName = viewName

Expand All @@ -35,7 +31,7 @@ public final class SearchDisplayManager: NSObject {
searchConnection = BRCDatabaseManager.shared.database.newConnection()

// Setup UISearchController
let src = UITableViewController(style: .plain)
let src = UITableViewController()
searchController = UISearchController(searchResultsController: src)
searchController.searchBar.barStyle = Appearance.currentBarStyle

Expand All @@ -57,7 +53,8 @@ public final class SearchDisplayManager: NSObject {

private func setupDefaults(for searchController: UISearchController) {
searchController.obscuresBackgroundDuringPresentation = true
searchController.hidesNavigationBarDuringPresentation = true
// works around a bug introduced in iOS 16(?) https://github.com/iBurnApp/iBurn-iOS/issues/139
searchController.hidesNavigationBarDuringPresentation = false
searchController.searchBar.delegate = self
searchController.searchResultsUpdater = self
searchController.delegate = self
Expand Down

0 comments on commit 2663535

Please sign in to comment.