Commit 387d5c72 by Demid Merzlyakov

IOS-108: move ad banner on the NWSAlert screen 1 section up.

parent a3de7b82
...@@ -32,9 +32,17 @@ fileprivate struct HeaderSection: NWSAlertTableViewSection { ...@@ -32,9 +32,17 @@ fileprivate struct HeaderSection: NWSAlertTableViewSection {
//do nothing //do nothing
} }
private let rows: [NWSAlertCellType] = [.header, .forecastOffice] private let rows: [NWSAlertCellType] = {
if !isAppPro() && AdConfigManager.shared.adConfig.adsEnabled {
return [.header, .forecastOffice, .adBanner]
}
else {
return [.header, .forecastOffice]
}
}()
var numberOfRows: Int { var numberOfRows: Int {
return rows.count rows.count
} }
func type(forRow row: Int) -> NWSAlertCellType { func type(forRow row: Int) -> NWSAlertCellType {
...@@ -44,19 +52,13 @@ fileprivate struct HeaderSection: NWSAlertTableViewSection { ...@@ -44,19 +52,13 @@ fileprivate struct HeaderSection: NWSAlertTableViewSection {
fileprivate struct ExtendedInfoSection: NWSAlertTableViewSection { fileprivate struct ExtendedInfoSection: NWSAlertTableViewSection {
private var alert: NWSAlert private var alert: NWSAlert
private var countOfAds: Int {
if !isAppPro() && AdConfigManager.shared.adConfig.adsEnabled {
return 1
}
return 0
}
init(alert: NWSAlert) { init(alert: NWSAlert) {
self.alert = alert self.alert = alert
} }
var numberOfRows: Int { var numberOfRows: Int {
countOfAds + (alert.extendedInfo?.infoBlocks.count ?? 0) alert.extendedInfo?.infoBlocks.count ?? 0
} }
mutating func update(with alert: NWSAlert) { mutating func update(with alert: NWSAlert) {
...@@ -64,25 +66,10 @@ fileprivate struct ExtendedInfoSection: NWSAlertTableViewSection { ...@@ -64,25 +66,10 @@ fileprivate struct ExtendedInfoSection: NWSAlertTableViewSection {
} }
func type(forRow row: Int) -> NWSAlertCellType { func type(forRow row: Int) -> NWSAlertCellType {
guard countOfAds > 0 else { .extendedInfoBlock
return .extendedInfoBlock
}
if numberOfRows == 1 {
return .adBanner
}
else {
if row == 1 {
return .adBanner
}
else {
return .extendedInfoBlock
}
}
} }
let rows: [NWSAlertCellType] = [.extendedInfoBlock] let rows: [NWSAlertCellType] = [.extendedInfoBlock]
} }
class NWSAlertCellFactory: CellFactoryProtocol { class NWSAlertCellFactory: CellFactoryProtocol {
......
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