Commit 87d13ddf by Dmitry Stepanets

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

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