Commit 3e506463 by Demid Merzlyakov

Search is closed properly.

parent b1d774af
...@@ -202,7 +202,7 @@ extension LocationViewController: LocationsViewModelDelegate { ...@@ -202,7 +202,7 @@ extension LocationViewController: LocationsViewModelDelegate {
self.showAlert(withTitle: title, message: message) self.showAlert(withTitle: title, message: message)
} }
func viewModelDidSelectCity(model: LocationsViewModel, city: Location) { func viewModelDidSelectCity(model: LocationsViewModel) {
close() close()
} }
} }
...@@ -353,8 +353,6 @@ extension LocationViewController: UITableViewDelegate { ...@@ -353,8 +353,6 @@ extension LocationViewController: UITableViewDelegate {
// analytics(log: .ANALYTICS_FTUE_SEARCH_POPULAR) // analytics(log: .ANALYTICS_FTUE_SEARCH_POPULAR)
// } // }
} }
self.close()
//TODO: should be done from ViewModel?
} }
} }
......
...@@ -12,7 +12,7 @@ public protocol LocationsViewModelDelegate:class { ...@@ -12,7 +12,7 @@ public protocol LocationsViewModelDelegate:class {
func viewModelDidChange(model:LocationsViewModel) func viewModelDidChange(model:LocationsViewModel)
func viewModelDisplayModeDidChange(model: LocationsViewModel) func viewModelDisplayModeDidChange(model: LocationsViewModel)
func viewModelError(model:LocationsViewModel, title:String?, message:String?) func viewModelError(model:LocationsViewModel, title:String?, message:String?)
func viewModelDidSelectCity(model:LocationsViewModel, city: Location) func viewModelDidSelectCity(model:LocationsViewModel)
} }
public enum LocationsViewModelDisplayMode { public enum LocationsViewModelDisplayMode {
...@@ -192,8 +192,7 @@ public class LocationsViewModel { ...@@ -192,8 +192,7 @@ public class LocationsViewModel {
return return
} }
locationManager.addIfNeeded(partialLocation: city, selectLocation: true) locationManager.addIfNeeded(partialLocation: city, selectLocation: true)
// TODO: close View Controller here, otherwise we can't choose already selected city. self.delegate?.viewModelDidSelectCity(model: self)
// Currently it's done in the didSelectRow method in the VC.
} }
func delete(city: PartialLocation) { func delete(city: PartialLocation) {
...@@ -232,9 +231,6 @@ extension LocationsViewModel: LocationManagerDelegate { ...@@ -232,9 +231,6 @@ extension LocationsViewModel: LocationManagerDelegate {
public func locationManager(_ locationManager: LocationManager, changedSelectedLocation newLocation: Location?) { public func locationManager(_ locationManager: LocationManager, changedSelectedLocation newLocation: Location?) {
DispatchQueue.main.async { DispatchQueue.main.async {
self.delegate?.viewModelDidChange(model: self) self.delegate?.viewModelDidChange(model: self)
if let location = newLocation {
self.delegate?.viewModelDidSelectCity(model: self, city: location)
}
} }
} }
......
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