Skip to content

Commit

Permalink
updated test app - network input
Browse files Browse the repository at this point in the history
  • Loading branch information
Valeriu Popa committed Oct 16, 2023
1 parent 8a08e29 commit 339a2f7
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 21 deletions.
15 changes: 14 additions & 1 deletion CriteoAdViewer/Sources/AdViewer/AdNetwork.swift
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ struct AdNetworks {
let standalone: AdNetwork
let inHouse: AdNetwork
let mraid: AdNetwork
let standaloneSKAdNetwork: AdNetwork
let all: [AdNetwork]
static let defaultPublisherId = "B-056946"

Expand All @@ -82,7 +83,8 @@ struct AdNetworks {
self.inHouse = inHouseNetwork(controller: controller)
self.mediation = googleMediationNetwork(controller)
self.mraid = standaloneMRAIDNetwork(controller)
self.all = [mediation, google, standalone, inHouse, mraid]
self.standaloneSKAdNetwork = standaloneWithSKAdNetworkParams(controller)
self.all = [mediation, google, standalone, inHouse, mraid, standaloneSKAdNetwork]
}
}

Expand Down Expand Up @@ -170,3 +172,14 @@ private func inHouseNetwork(controller: AdViewController) -> AdNetwork {
AdFormat.interstitial: "6yws53jyfjgoq1ghnuqb"
], adViewBuilder: CriteoAdViewBuilder(controller: controller, type: .inHouse))
}

private func standaloneWithSKAdNetworkParams(_ controller: AdViewController) -> AdNetwork {
AdNetwork(
name: "Standalone - SKAdNetwork",
supportedFormats: [
AdFormat.banner320x50
],
defaultAdUnits: [
AdFormat.banner320x50: "31589da9edb442329e17"
], adViewBuilder: CriteoAdViewBuilder(controller: controller, type: .standalone))
}
40 changes: 20 additions & 20 deletions CriteoAdViewer/Sources/AdViewer/AdViewerViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ class AdViewerViewController: FormViewController {
$0.options = defaultNetwork.sizes(type: .banner)
$0.value = $0.options?.first
$0.hidden = .function([Tags.network.rawValue, Tags.type.rawValue]) { form in
if let networkRow: SegmentedRow<AdNetwork> = self.form.rowBy(tag: Tags.network.rawValue),
if let networkRow: PickerInputRow<AdNetwork> = self.form.rowBy(tag: Tags.network.rawValue),
let typeRow: SegmentedRow<AdType> = self.form.rowBy(tag: Tags.type.rawValue),
let sizeRow: SegmentedRow<AdSize> = self.form.rowBy(tag: Tags.size.rawValue),
let network = networkRow.value,
Expand All @@ -172,27 +172,27 @@ class AdViewerViewController: FormViewController {

private func networkSection() -> Section {
Section("Network")
<<< SegmentedRow<AdNetwork>(Tags.network.rawValue) {
$0.options = self.networks.all
$0.value = $0.options?.first
$0.displayValueFor = { network in
network?.name
}
$0.onChange { (row: SegmentedRow<AdNetwork>) in
if let network = row.value,
let typeRow: SegmentedRow<AdType> = self.form.rowBy(tag: Tags.type.rawValue),
let sizeRow: SegmentedRow<AdSize> = self.form.rowBy(tag: Tags.size.rawValue) {
typeRow.options = network.types
typeRow.value = typeRow.options?.first
typeRow.reload()
let sizes: [AdSize] = network.sizes(type: typeRow.value!)
sizeRow.options = sizes
sizeRow.value = sizeRow.options?.first
sizeRow.reload()
<<< PickerInputRow<AdNetwork>(Tags.network.rawValue){
$0.options = self.networks.all
$0.value = $0.options.first
$0.displayValueFor = { network in
network?.name
}
$0.onChange { (row: PickerInputRow<AdNetwork>) in
if let network = row.value,
let typeRow: SegmentedRow<AdType> = self.form.rowBy(tag: Tags.type.rawValue),
let sizeRow: SegmentedRow<AdSize> = self.form.rowBy(tag: Tags.size.rawValue) {
typeRow.options = network.types
typeRow.value = typeRow.options?.first
typeRow.reload()
let sizes: [AdSize] = network.sizes(type: typeRow.value!)
sizeRow.options = sizes
sizeRow.value = sizeRow.options?.first
sizeRow.reload()
}
self.updateAdConfig()
}
self.updateAdConfig()
}
}
}

private func updateAdConfig() {
Expand Down

0 comments on commit 339a2f7

Please sign in to comment.