Commit c65cc864 by Demid Merzlyakov

IOS-184: navigate to forecast from today.

parent a79fbc1a
......@@ -59,6 +59,7 @@ private extension ArrowButton {
}
func prepareBackground() {
gradientBackground.isUserInteractionEnabled = false
gradientBackground.layer.cornerRadius = 9
insertSubview(gradientBackground, belowSubview: imageView!)
......
......@@ -9,8 +9,13 @@ import UIKit
import OneWeatherCore
import OneWeatherAnalytics
protocol PrecipitationCellDelegate: AnyObject {
func precipitationCtaClicked()
}
class PrecipitationCell: UITableViewCell {
//Private
public var delegate: PrecipitationCellDelegate?
private let headingLabel = UILabel()
private let headingButton = ArrowButton()
private let minutelyForecastView = MinutelyForecastView()
......@@ -39,8 +44,6 @@ class PrecipitationCell: UITableViewCell {
}
public func configure(with dayily:[DailyWeather], location: Location) {
//TODO: Hide button for now
headingButton.isHidden = true
minutelyForecastView.configure(with: location, forecastType: .precipitation)
......@@ -98,7 +101,6 @@ class PrecipitationCell: UITableViewCell {
public func configure(with hourly:[HourlyWeather], location: Location) {
self.headingLabel.font = AppFont.SFPro.bold(size: 18)
self.headingButton.isHidden = true
self.headingLabel.text = "precipitation.title".localized().capitalized
self.headingLabel.textColor = ThemeManager.currentTheme.primaryTextColor
......@@ -158,7 +160,7 @@ class PrecipitationCell: UITableViewCell {
//Private
@objc private func handleArrowButton() {
self.delegate?.precipitationCtaClicked()
}
@objc private func handlePrecipButton(button:PrecipButton) {
......
......@@ -160,6 +160,7 @@ class TodayCellFactory: CellFactory {
return cell
case .precipitation:
let cell = dequeueReusableCell(type: PrecipitationCell.self, tableView: tableView, indexPath: indexPath)
cell.delegate = self
if cellsToUpdate.contains(.precipitation) {
if let location = todayViewModel.location {
cell.configure(with: loc.daily, location: location)
......@@ -284,3 +285,11 @@ extension TodayCellFactory: AdViewDelegate {
}
}
}
extension TodayCellFactory: PrecipitationCellDelegate {
func precipitationCtaClicked() {
onMain {
self.todayViewModel.openForecast(timePeriod: .minutely)
}
}
}
......@@ -177,6 +177,10 @@ class TodayViewModel: ViewModelProtocol {
public func openShorts(atIndex index: Int) {
AppCoordinator.instance.openShorts(atIndex: index)
}
public func openForecast(timePeriod: TimePeriod) {
AppCoordinator.instance.openForecast(timePeriod: timePeriod)
}
}
//MARK:- LocationManager Delegate
......
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