Commit 80a15f6b by Demid Merzlyakov

Analytics: added missing events.

parent f76e0e72
......@@ -39,7 +39,7 @@ class ForecastCellFactory: CellFactoryProtocol {
//Private
private var cellsToUpdate:CellsToUpdate = [.dailyTimePeriod, .hourlyTimePeriod, .dailyForecastInfoCell, .precipitation, .wind]
private let forecastViewModel:ForecastViewModel
private var currentTimePeriod = TimePeriod.daily
public var timePeriod = TimePeriod.daily
//Public
var numberOfSections: Int {
......@@ -47,17 +47,13 @@ class ForecastCellFactory: CellFactoryProtocol {
}
public func numberOfRows(inSection section: Int) -> Int {
return currentTimePeriod == .daily ? DailyForecastCellType.allCases.count : HourlyForecastCellType.allCases.count
return timePeriod == .daily ? DailyForecastCellType.allCases.count : HourlyForecastCellType.allCases.count
}
public init(viewModel: ForecastViewModel) {
self.forecastViewModel = viewModel
}
public func setTimePeriod(timePeriod:TimePeriod) {
self.currentTimePeriod = timePeriod
}
public func registerCells(on tableView:UITableView) {
registerCell(type: ForecastDailyCell.self, tableView: tableView)
registerCell(type: ForecastDayCell.self, tableView: tableView)
......@@ -70,7 +66,7 @@ class ForecastCellFactory: CellFactoryProtocol {
}
public func cellFromTableView(tableView:UITableView, indexPath:IndexPath) -> UITableViewCell {
switch currentTimePeriod {
switch timePeriod {
case .daily:
return dailyCellFor(tableView: tableView, indexPath: indexPath)
case .hourly:
......
......@@ -49,11 +49,26 @@ class ForecastViewController: UIViewController {
refreshDayButtons()
}
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
analytics(log: .ANALYTICS_VIEW_FORECAST)
analyticsLogCurrentTimePeriod()
}
override func viewDidLayoutSubviews() {
super.viewDidLayoutSubviews()
self.tableView.layoutTableHeaderView()
}
private func analyticsLogCurrentTimePeriod() {
switch forecastCellFactory.timePeriod {
case .daily:
analytics(log: .ANALYTICS_VIEW_FORECAST_EXTENDED)
case .hourly:
analytics(log: .ANALYTICS_VIEW_FORECAST_HOURLY)
}
}
private func refreshCityButton() {
cityButton.configure(with: viewModel.location)
cityButton.isHidden = false
......@@ -72,9 +87,10 @@ class ForecastViewController: UIViewController {
if self.timePeriodControl.selectedSegmentIndex != timePeriod.rawValue {
self.timePeriodControl.selectedSegmentIndex = timePeriod.rawValue
}
forecastCellFactory.setTimePeriod(timePeriod: timePeriod)
forecastCellFactory.timePeriod = timePeriod
self.forecastCellFactory.setNeedsUpdate()
self.tableView.reloadData()
analyticsLogCurrentTimePeriod()
}
@objc private func handleSegmentDidChange() {
......
......@@ -30,6 +30,11 @@ class NWSAlertViewController: UIViewController {
prepareTableView()
}
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
analytics(log: .ANALYTICS_VIEW_ALERT_DETAILS)
}
deinit {
if let observer = localizationObserver {
NotificationCenter.default.removeObserver(observer)
......
......@@ -33,6 +33,11 @@ class NotificationsViewController: UIViewController {
tableView.reloadData()
}
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
analytics(log: .ANALYTICS_VIEW_ALERTS)
}
deinit {
if let observer = localizationObserver {
......
......@@ -81,6 +81,11 @@ class RadarViewController: UIViewController {
initialConfigure()
}
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
analytics(log: .ANALYTICS_VIEW_RADAR)
}
//Private
private func updateUI() {
view.backgroundColor = ThemeManager.currentTheme.baseBackgroundColor
......@@ -212,6 +217,7 @@ class RadarViewController: UIViewController {
}
isFullScreen = true
fullScreenButton.setImage(image: UIImage(named: "cross_icon"))
analytics(log: .ANALYTICS_VIEW_RADAR_FULLSCREEN)
}
self.view.setNeedsLayout()
......
......@@ -35,6 +35,11 @@ class SettingsViewController: UIViewController {
updateUI()
}
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
analytics(log: .ANALYTICS_VIEW_SETTINGS)
}
override func traitCollectionDidChange(_ previousTraitCollection: UITraitCollection?) {
super.traitCollectionDidChange(previousTraitCollection)
updateUI()
......
......@@ -61,6 +61,7 @@ class MenuViewModel: NSObject, ViewModelProtocol {
public func viewAboutUs() {
self.delegate?.presentWebView(url: ONE_WEATHER_ABOUT_US_URL)
analytics(log: .ANALYTICS_VIEW_ABOUT)
}
public func viewAdChoices() {
......
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