Files
comaps/iphone/Maps/UI/BottomMenu/TabBar/BottomTabBarInteractor.swift
Konstantin Pastbin e3e4a1985a Organic Maps sources as of 02.04.2025 (fad26bbf22ac3da75e01e62aa01e5c8e11861005)
To expand with full Organic Maps and Maps.ME commits history run:
  git remote add om-historic [om-historic.git repo url]
  git fetch --tags om-historic
  git replace squashed-history historic-commits
2025-05-08 21:10:51 +07:00

60 lines
2.1 KiB
Swift

protocol BottomTabBarInteractorProtocol: AnyObject {
func openSearch()
func openHelp()
func openFaq()
func openBookmarks()
func openMenu()
}
class BottomTabBarInteractor {
weak var presenter: BottomTabBarPresenterProtocol?
private weak var viewController: UIViewController?
private weak var mapViewController: MapViewController?
private weak var controlsManager: MWMMapViewControlsManager?
private let searchManager: SearchOnMapManager
init(viewController: UIViewController, mapViewController: MapViewController, controlsManager: MWMMapViewControlsManager) {
self.viewController = viewController
self.mapViewController = mapViewController
self.controlsManager = controlsManager
self.searchManager = mapViewController.searchManager
}
}
extension BottomTabBarInteractor: BottomTabBarInteractorProtocol {
func openSearch() {
searchManager.isSearching ? searchManager.close() : searchManager.startSearching(isRouting: false)
}
func openHelp() {
MapViewController.shared()?.navigationController?.pushViewController(AboutController(), animated: true)
}
func openFaq() {
guard let navigationController = MapViewController.shared()?.navigationController else { return }
let aboutController = AboutController(onDidAppearCompletionHandler: {
navigationController.pushViewController(FaqController(), animated: true)
})
navigationController.pushViewController(aboutController, animated: true)
}
func openBookmarks() {
mapViewController?.bookmarksCoordinator.open()
}
func openMenu() {
guard let state = controlsManager?.menuState else {
fatalError("ERROR: Failed to retrieve the current MapViewControlsManager's state.")
}
switch state {
case .inactive: controlsManager?.menuState = .active
case .active: controlsManager?.menuState = .inactive
case .hidden:
// When the current controls manager's state is hidden, accidental taps on the menu button during the hiding animation should be skipped.
break;
case .layers: fallthrough
@unknown default: fatalError("ERROR: Unexpected MapViewControlsManager's state: \(state)")
}
}
}