Commit 87102046 by Dmitriy Stepanets

Fixed UI glitch on day selection did change at ForecastViewController

parent 1159282f
......@@ -7,7 +7,12 @@
<key>1Weather.xcscheme_^#shared#^_</key>
<dict>
<key>orderHint</key>
<integer>26</integer>
<integer>0</integer>
</dict>
<key>OneWeatherNotificationServiceExtension.xcscheme_^#shared#^_</key>
<dict>
<key>orderHint</key>
<integer>38</integer>
</dict>
<key>PG (Playground) 1.xcscheme</key>
<dict>
......
......@@ -82,6 +82,10 @@ class ForecastCellFactory: CellFactoryProtocol {
self.cellsToUpdate = [.dailyTimePeriod, .hourlyTimePeriod, .dailyForecastInfoCell, .precipitation, .wind]
}
public func selectedWeatherDidChange() {
self.cellsToUpdate = [.dailyForecastInfoCell, .precipitation, .wind]
}
public func willDisplay(cell:UITableViewCell) {
switch cell {
case let sunCell as SunPhaseCell:
......@@ -113,6 +117,7 @@ class ForecastCellFactory: CellFactoryProtocol {
cellsToUpdate.remove(.dailyTimePeriod)
}
}
return cell
case .forecastInfo:
let cell = dequeueReusableCell(type: ForecastInfoCell.self, tableView: tableView, indexPath: indexPath)
......
......@@ -74,6 +74,7 @@ class ForecastViewController: UIViewController {
self.timePeriodControl.selectedSegmentIndex = timePeriod.rawValue
}
forecastCellFactory.setTimePeriod(timePeriod: timePeriod)
self.forecastCellFactory.setNeedsUpdate()
self.tableView.reloadData()
}
......@@ -231,19 +232,10 @@ extension ForecastViewController: ForecastViewModelDelegate {
}
func selectedWeatherDidChange() {
switch timePeriod {
case .daily:
var indexPathToReload = [IndexPath]()
for index in 0..<forecastCellFactory.numberOfRows(inSection: 0) {
if index == 0 { continue }
indexPathToReload.append([0, index])
}
tableView.reloadRows(at: indexPathToReload, with: .none)
daysControlView.selectDayAt(index: viewModel.selectedDailyWeatherIndex)
case .hourly:
tableView.reloadData()
DispatchQueue.main.async {
self.forecastCellFactory.selectedWeatherDidChange()
self.daysControlView.selectDayAt(index: self.viewModel.selectedDailyWeatherIndex)
self.tableView.reloadData()
}
}
}
......
......@@ -63,6 +63,7 @@ class ForecastViewModel: ViewModelProtocol {
self.selectedHourlyWeather = $1
}
}
self.delegate?.selectedWeatherDidChange()
}
}
......
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