Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
1
1weather
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Dmitriy Stepanets
1weather
Commits
d2321de6
Commit
d2321de6
authored
Apr 27, 2021
by
Demid Merzlyakov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
NWSAlert screen: added an ad.
parent
c2757262
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
29 additions
and
9 deletions
+29
-9
1Weather/UI/View controllers/NWSAlert/Cells/NWSAlertCellFactory.swift
+17
-5
1Weather/UI/View controllers/NWSAlert/Cells/NWSAlertInfoBlockTableViewCell.swift
+2
-2
1Weather/UI/View controllers/NWSAlert/Cells/NWSForecastOfficeTableViewCell.swift
+2
-2
1Weather/UI/View controllers/NWSAlert/NWSAlertViewController.swift
+8
-0
No files found.
1Weather/UI/View controllers/NWSAlert/Cells/NWSAlertCellFactory.swift
View file @
d2321de6
...
@@ -42,13 +42,14 @@ fileprivate struct HeaderSection: NWSAlertTableViewSection {
...
@@ -42,13 +42,14 @@ fileprivate struct HeaderSection: NWSAlertTableViewSection {
fileprivate
struct
ExtendedInfoSection
:
NWSAlertTableViewSection
{
fileprivate
struct
ExtendedInfoSection
:
NWSAlertTableViewSection
{
private
var
alert
:
NWSAlert
private
var
alert
:
NWSAlert
private
let
countOfAds
=
1
init
(
alert
:
NWSAlert
)
{
init
(
alert
:
NWSAlert
)
{
self
.
alert
=
alert
self
.
alert
=
alert
}
}
var
numberOfRows
:
Int
{
var
numberOfRows
:
Int
{
alert
.
extendedInfo
?
.
infoBlocks
.
count
??
0
countOfAds
+
(
alert
.
extendedInfo
?
.
infoBlocks
.
count
??
0
)
}
}
mutating
func
update
(
with
alert
:
NWSAlert
)
{
mutating
func
update
(
with
alert
:
NWSAlert
)
{
...
@@ -56,8 +57,19 @@ fileprivate struct ExtendedInfoSection: NWSAlertTableViewSection {
...
@@ -56,8 +57,19 @@ fileprivate struct ExtendedInfoSection: NWSAlertTableViewSection {
}
}
func
type
(
forRow
row
:
Int
)
->
NWSAlertCellType
{
func
type
(
forRow
row
:
Int
)
->
NWSAlertCellType
{
if
numberOfRows
==
1
{
return
.
ad
}
else
{
if
row
==
1
{
return
.
ad
}
else
{
return
.
extendedInfoBlock
return
.
extendedInfoBlock
}
}
}
}
let
rows
:
[
NWSAlertCellType
]
=
[
.
extendedInfoBlock
]
let
rows
:
[
NWSAlertCellType
]
=
[
.
extendedInfoBlock
]
...
@@ -93,8 +105,8 @@ class NWSAlertCellFactory: CellFactoryProtocol {
...
@@ -93,8 +105,8 @@ class NWSAlertCellFactory: CellFactoryProtocol {
return
adView
return
adView
}
}
let
adView
=
adViewCache
[
indexPath
]
??
AdView
()
let
adView
=
adViewCache
[
indexPath
]
??
AdView
()
adView
.
loggingAlias
=
"
📍 Today
Banner"
adView
.
loggingAlias
=
"
⚠️ Alert
Banner"
adView
.
set
(
placementName
:
placementName
Today
Banner
,
adType
:
.
banner
)
adView
.
set
(
placementName
:
placementName
Precipitation
Banner
,
adType
:
.
banner
)
adViewCache
[
indexPath
]
=
adView
adViewCache
[
indexPath
]
=
adView
return
adView
return
adView
}
}
...
@@ -119,8 +131,8 @@ class NWSAlertCellFactory: CellFactoryProtocol {
...
@@ -119,8 +131,8 @@ class NWSAlertCellFactory: CellFactoryProtocol {
forecastOfficeCell
.
configure
(
with
:
alert
)
forecastOfficeCell
.
configure
(
with
:
alert
)
return
forecastOfficeCell
return
forecastOfficeCell
case
.
extendedInfoBlock
:
case
.
extendedInfoBlock
:
#warning("We've got to handle ads here.")
let
adsCount
=
adViewCache
.
keys
.
filter
({
$0
.
row
<
indexPath
.
row
})
.
count
guard
let
info
=
alert
.
extendedInfo
?
.
infoBlocks
[
indexPath
.
row
]
else
{
guard
let
info
=
alert
.
extendedInfo
?
.
infoBlocks
[
indexPath
.
row
-
adsCount
]
else
{
return
UITableViewCell
()
return
UITableViewCell
()
}
}
let
extendedInfoBlockCell
=
dequeueReusableCell
(
type
:
NWSAlertInfoBlockTableViewCell
.
self
,
tableView
:
tableView
,
indexPath
:
indexPath
)
let
extendedInfoBlockCell
=
dequeueReusableCell
(
type
:
NWSAlertInfoBlockTableViewCell
.
self
,
tableView
:
tableView
,
indexPath
:
indexPath
)
...
...
1Weather/UI/View controllers/NWSAlert/Cells/NWSAlertInfoBlockTableViewCell.swift
View file @
d2321de6
...
@@ -73,10 +73,10 @@ extension NWSAlertInfoBlockTableViewCell {
...
@@ -73,10 +73,10 @@ extension NWSAlertInfoBlockTableViewCell {
func
prepareContainer
()
{
func
prepareContainer
()
{
contentView
.
addSubview
(
containerView
)
contentView
.
addSubview
(
containerView
)
containerView
.
snp
.
makeConstraints
{
(
make
)
in
containerView
.
snp
.
makeConstraints
{
(
make
)
in
make
.
top
.
equalToSuperview
()
.
inset
(
18
)
make
.
top
.
equalToSuperview
()
make
.
left
.
equalToSuperview
()
.
inset
(
18
)
make
.
left
.
equalToSuperview
()
.
inset
(
18
)
make
.
right
.
equalToSuperview
()
.
inset
(
18
)
make
.
right
.
equalToSuperview
()
.
inset
(
18
)
make
.
bottom
.
equalToSuperview
()
make
.
bottom
.
equalToSuperview
()
.
inset
(
18
)
}
}
containerView
.
layer
.
cornerRadius
=
8
containerView
.
layer
.
cornerRadius
=
8
containerView
.
backgroundColor
=
UIColor
(
named
:
"notifications_nwsalert_tile_background"
)
containerView
.
backgroundColor
=
UIColor
(
named
:
"notifications_nwsalert_tile_background"
)
...
...
1Weather/UI/View controllers/NWSAlert/Cells/NWSForecastOfficeTableViewCell.swift
View file @
d2321de6
...
@@ -91,10 +91,10 @@ class NWSForecastOfficeTableViewCell: UITableViewCell {
...
@@ -91,10 +91,10 @@ class NWSForecastOfficeTableViewCell: UITableViewCell {
private
func
prepareContainer
()
{
private
func
prepareContainer
()
{
contentView
.
addSubview
(
containerView
)
contentView
.
addSubview
(
containerView
)
containerView
.
snp
.
makeConstraints
{
(
make
)
in
containerView
.
snp
.
makeConstraints
{
(
make
)
in
make
.
top
.
equalToSuperview
()
.
inset
(
18
)
make
.
top
.
equalToSuperview
()
make
.
left
.
equalToSuperview
()
.
inset
(
18
)
make
.
left
.
equalToSuperview
()
.
inset
(
18
)
make
.
right
.
equalToSuperview
()
.
inset
(
18
)
make
.
right
.
equalToSuperview
()
.
inset
(
18
)
make
.
bottom
.
equalToSuperview
()
make
.
bottom
.
equalToSuperview
()
.
inset
(
18
)
}
}
containerView
.
layer
.
cornerRadius
=
8
containerView
.
layer
.
cornerRadius
=
8
containerView
.
backgroundColor
=
UIColor
(
named
:
"notifications_nwsalert_tile_background"
)
containerView
.
backgroundColor
=
UIColor
(
named
:
"notifications_nwsalert_tile_background"
)
...
...
1Weather/UI/View controllers/NWSAlert/NWSAlertViewController.swift
View file @
d2321de6
...
@@ -110,4 +110,12 @@ extension NWSAlertViewController: UITableViewDelegate, UITableViewDataSource {
...
@@ -110,4 +110,12 @@ extension NWSAlertViewController: UITableViewDelegate, UITableViewDataSource {
func
tableView
(
_
tableView
:
UITableView
,
estimatedHeightForRowAt
indexPath
:
IndexPath
)
->
CGFloat
{
func
tableView
(
_
tableView
:
UITableView
,
estimatedHeightForRowAt
indexPath
:
IndexPath
)
->
CGFloat
{
return
160
return
160
}
}
func
tableView
(
_
tableView
:
UITableView
,
willDisplay
cell
:
UITableViewCell
,
forRowAt
indexPath
:
IndexPath
)
{
viewModel
.
cellFactory
.
willDisplay
(
cell
:
cell
)
}
func
tableView
(
_
tableView
:
UITableView
,
didEndDisplaying
cell
:
UITableViewCell
,
forRowAt
indexPath
:
IndexPath
)
{
viewModel
.
cellFactory
.
didHide
(
cell
:
cell
)
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment