Commit bbf41fed by Dmitriy Stepanets

Changed getter for TimePeriodCell frame

parent 2d426c1d
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
<key>1Weather.xcscheme_^#shared#^_</key> <key>1Weather.xcscheme_^#shared#^_</key>
<dict> <dict>
<key>orderHint</key> <key>orderHint</key>
<integer>5</integer> <integer>4</integer>
</dict> </dict>
<key>PG (Playground) 1.xcscheme</key> <key>PG (Playground) 1.xcscheme</key>
<dict> <dict>
......
...@@ -23,7 +23,6 @@ class ForecastCellFactory { ...@@ -23,7 +23,6 @@ class ForecastCellFactory {
private let forecastViewModel:ForecastViewModel private let forecastViewModel:ForecastViewModel
//Public //Public
public var forecastPeriodCellFrame:CGRect = .zero
public var numberOfRows:Int { public var numberOfRows:Int {
return ForecastCellType.allCases.count return ForecastCellType.allCases.count
} }
...@@ -48,8 +47,7 @@ class ForecastCellFactory { ...@@ -48,8 +47,7 @@ class ForecastCellFactory {
case .forecastPeriod: case .forecastPeriod:
let cell = dequeueReusableCell(type: ForecastTimePeriodCell.self, tableView: tableView, indexPath: indexPath) let cell = dequeueReusableCell(type: ForecastTimePeriodCell.self, tableView: tableView, indexPath: indexPath)
cell.delegate = self cell.delegate = self
forecastPeriodCellFrame = cell.frame
if let daily = forecastViewModel.location?.daily, if let daily = forecastViewModel.location?.daily,
let hourly = forecastViewModel.location?.hourly { let hourly = forecastViewModel.location?.hourly {
cell.configure(daily: daily, hourly: hourly) cell.configure(daily: daily, hourly: hourly)
......
...@@ -14,6 +14,7 @@ class ForecastViewController: UIViewController { ...@@ -14,6 +14,7 @@ class ForecastViewController: UIViewController {
private let daysControlView = DaysControlView() private let daysControlView = DaysControlView()
private let tableView = UITableView() private let tableView = UITableView()
private let viewModel:ForecastViewModel private let viewModel:ForecastViewModel
private var timePeriodCellFrame = CGRect.zero
private var localizationObserver:Any? private var localizationObserver:Any?
init(viewModel: ForecastViewModel) { init(viewModel: ForecastViewModel) {
...@@ -113,21 +114,18 @@ private extension ForecastViewController { ...@@ -113,21 +114,18 @@ private extension ForecastViewController {
//MARK:- UITableView Delegate //MARK:- UITableView Delegate
extension ForecastViewController: UITableViewDelegate { extension ForecastViewController: UITableViewDelegate {
func scrollViewDidScroll(_ scrollView: UIScrollView) { func scrollViewDidScroll(_ scrollView: UIScrollView) {
let cellFrame = forecastCellFactory.forecastPeriodCellFrame
guard guard
let navVC = self.navigationController, let navVC = self.navigationController,
viewModel.location?.daily.isEmpty == false viewModel.location?.daily.isEmpty == false
else { else {
return return
} }
let startPointY = cellFrame.origin.y + cellFrame.height - self.daysControlView.frame.height if timePeriodCellFrame == .zero {
guard startPointY > 0 else { timePeriodCellFrame = tableView.cellForRow(at: [0,0])?.frame ?? .zero
//Force reload row to get actual row height
tableView.reloadRows(at: [[0,0]], with: .none)
return
} }
let startPointY = timePeriodCellFrame.origin.y + timePeriodCellFrame.height - self.daysControlView.frame.height
if scrollView.contentOffset.y >= startPointY { if scrollView.contentOffset.y >= startPointY {
if !navVC.isNavigationBarHidden { if !navVC.isNavigationBarHidden {
......
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
<key>Cirque.xcscheme_^#shared#^_</key> <key>Cirque.xcscheme_^#shared#^_</key>
<dict> <dict>
<key>orderHint</key> <key>orderHint</key>
<integer>4</integer> <integer>3</integer>
</dict> </dict>
<key>Localize-Swift.xcscheme</key> <key>Localize-Swift.xcscheme</key>
<dict> <dict>
...@@ -40,14 +40,14 @@ ...@@ -40,14 +40,14 @@
<key>isShown</key> <key>isShown</key>
<false/> <false/>
<key>orderHint</key> <key>orderHint</key>
<integer>2</integer> <integer>1</integer>
</dict> </dict>
<key>SnapKit.xcscheme</key> <key>SnapKit.xcscheme</key>
<dict> <dict>
<key>isShown</key> <key>isShown</key>
<false/> <false/>
<key>orderHint</key> <key>orderHint</key>
<integer>3</integer> <integer>2</integer>
</dict> </dict>
<key>XMLCoder.xcscheme_^#shared#^_</key> <key>XMLCoder.xcscheme_^#shared#^_</key>
<dict> <dict>
......
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