Commit 87102046 by Dmitriy Stepanets

Fixed UI glitch on day selection did change at ForecastViewController

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