Commit 1460b447 by Demid Merzlyakov

Radar: handle bell icon, arrow icon, click on city.

parent a554db24
......@@ -32,6 +32,12 @@ class RadarCoordinator: Coordinator {
notificationsCoordinator.start()
}
public func openLocationsSearch() {
let searchCoordinator = LocationSearchCoordinator(parentViewController: navigationController)
searchCoordinator.parentCoordinator = self
searchCoordinator.start()
}
func viewControllerDidEnd(controller: UIViewController) {
//
}
......
......@@ -186,7 +186,7 @@ class RadarViewController: UIViewController {
//MARK: Handlers
@objc private func handleCityButton() {
coordinator.openLocationsSearch()
}
@objc private func handleNotificationButton() {
......@@ -230,7 +230,7 @@ class RadarViewController: UIViewController {
}
@objc private func handleLocationButton() {
radarViewModel.useCurrentLocationTapped(in: self)
}
}
......@@ -365,6 +365,10 @@ extension RadarViewController: RadarViewModelDelegate {
pinnedLayersView.selectLayer(radarLayer: selectedLayer)
}
}
func viewModel(model: RadarViewModel, tellsToNavigateTo coordinates: CLLocationCoordinate2D) {
mapView.setCenter(coordinates, animated: true)
}
}
//MARK:- MapView delegate
......
......@@ -7,10 +7,12 @@
import UIKit
import Swarm
import CoreLocation
protocol RadarViewModelDelegate: ViewModelDelegate {
func viewModel(model:RadarViewModel, didSelectLayer layer:RadarLayer)
func viewModelPinnedLayersDidChange(model:RadarViewModel)
func viewModel(model:RadarViewModel, tellsToNavigateTo coordinates: CLLocationCoordinate2D)
}
class RadarViewModel: ViewModelProtocol {
......@@ -119,6 +121,19 @@ class RadarViewModel: ViewModelProtocol {
return items
}
public func useCurrentLocationTapped(in vc: UIViewController) {
locationManager.useCurrentLocation(presentDialogsIn: vc) { (result) in
switch result {
case .success:
break
case .denied:
break
case.useSearch:
break
}
}
}
//Private
private func rebuildLayers() {
let pinnedLayerIds = Settings.shared.pinnedLayerIds
......@@ -143,6 +158,10 @@ extension RadarViewModel: LocationManagerDelegate {
func locationManager(_ locationManager: LocationManager, changedSelectedLocation newLocation: Location?) {
self.rebuildLayers()
if let coordinates = newLocation?.coordinates {
self.delegate?.viewModel(model: self, tellsToNavigateTo: coordinates)
}
DispatchQueue.main.async {
self.delegate?.viewModelDidChange(model: self)
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment