Commit 87d13ddf by Dmitry Stepanets

[IOS-276]: Fixed Ads showing for Pro users

parent 8320c224
......@@ -31,21 +31,20 @@ private enum ForecastCellType {
}
private struct HourlySection {
let rows: [ForecastCellType] = {
var rows: [ForecastCellType] {
// TODO: use dependency injection instead of a singleton
let showAds = FeatureAvailabilityManager.shared.isAvailable(feature: .ads)
//TODO: dependency injection
if FeatureAvailabilityManager.shared.isAvailable(feature: .ads) {
if showAds {
return [.day, .forecastHourly, .adBanner, .precipitation, .wind, .adMREC]
}
else {
return [.day, .forecastHourly, .precipitation, .wind]
}
}()
}
}
private struct DailySection {
let rows: [ForecastCellType] = {
var rows: [ForecastCellType] {
//TODO: dependency injection
if FeatureAvailabilityManager.shared.isAvailable(feature: .ads) {
return [.forecastDaily, .forecastDailyInfo, .adBanner, .sun, .moon, .adMREC]
......@@ -53,7 +52,7 @@ private struct DailySection {
else {
return [.forecastDaily, .forecastDailyInfo, .sun, .moon]
}
}()
}
}
......
......@@ -11,7 +11,7 @@ import OneWeatherCore
class ForecastViewController: UIViewController {
//Private
private let forecastCellFactory:ForecastCellFactory
private let forecastCellFactory: ForecastCellFactory
private let cityButton = NavigationCityButton()
private let daysControlView = DaysControlView()
private let coordinator: ForecastCoordinator
......@@ -278,11 +278,13 @@ extension ForecastViewController: UITableViewDataSource {
//MARK:- ViewModel Delegate
extension ForecastViewController: ForecastViewModelDelegate {
func viewModelDidChange<P>(model: P) where P : ViewModelProtocol {
refreshCityButton()
refreshTimePeriodControl()
forecastCellFactory.setNeedsUpdate()
tableView.reloadData()
refreshDayButtons()
onMain {
self.refreshCityButton()
self.refreshTimePeriodControl()
self.forecastCellFactory.setNeedsUpdate()
self.tableView.reloadData()
self.refreshDayButtons()
}
}
func selectedWeatherDidChange() {
......
......@@ -100,10 +100,9 @@ extension ForecastViewModel: SettingsDelegate {
}
}
//MARK: - StoreManager Observer
extension ForecastViewModel: StoreManagerObserver {
func storeManagerUpdatedStatus(_ storeManager: StoreManager) {
onMain {
self.delegate?.viewModelDidChange(model: self)
}
self.delegate?.viewModelDidChange(model: self)
}
}
......@@ -41,7 +41,7 @@ class TodayViewModel: ViewModelProtocol {
FeatureAvailabilityManager.shared
}
public lazy var todayCellFactory:TodayCellFactory = {
public lazy var todayCellFactory: TodayCellFactory = {
let factory = TodayCellFactory(viewModel: self)
factory.delegate = self
return factory
......
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