Commit de2c40ad by Demid Merzlyakov

Forecase wind: update on settings change. Update on city change.

parent ec8f9db9
......@@ -43,9 +43,7 @@ class ForecastWindSpeedCell: UITableViewCell {
//Public
public func configure(with hourly:[HourlyWeather]) {
self.timePeriodView.set(daily: nil, hourly: hourly)
if self.timePeriodView.isEmpty {
self.timePeriodView.set(forecastType: .wind, buttonType: ForecastWindButton.self)
}
self.timePeriodView.set(forecastType: .wind, buttonType: ForecastWindButton.self)
}
}
......
......@@ -248,6 +248,7 @@ extension ForecastViewController: ForecastViewModelDelegate {
func selectedWeatherDidChange() {
DispatchQueue.main.async {
self.forecastCellFactory.setNeedsUpdate()
self.forecastCellFactory.selectedWeatherDidChange()
self.daysControlView.selectDayAt(index: self.viewModel.selectedDailyWeatherIndex)
self.tableView.reloadData()
......
......@@ -34,12 +34,14 @@ class ForecastViewModel: ViewModelProtocol {
private var locationManager: LocationManager
deinit {
Settings.shared.delegate.remove(delegate: self)
self.locationManager.remove(delegate: self)
}
public init(locationManager: LocationManager) {
self.locationManager = locationManager
locationManager.add(delegate: self)
Settings.shared.delegate.add(delegate: self)
}
public func updateWeather() {
......@@ -83,3 +85,13 @@ extension ForecastViewModel: LocationManagerDelegate {
// do nothing
}
}
//MARK:- Settings Delegate
extension ForecastViewModel: SettingsDelegate {
func settingsDidChange() {
onMain {
self.delegate?.viewModelDidChange(model: self)
}
}
}
......@@ -122,7 +122,7 @@ extension TodayViewModel: LocationManagerDelegate {
}
}
//MARK:- Settings View Model
//MARK:- Settings Delegate
extension TodayViewModel: SettingsDelegate {
func settingsDidChange() {
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