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
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
30 additions
and
10 deletions
+30
-10
1Weather/UI/View controllers/NWSAlert/Cells/NWSAlertCellFactory.swift
+18
-6
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 {
fileprivate
struct
ExtendedInfoSection
:
NWSAlertTableViewSection
{
private
var
alert
:
NWSAlert
private
let
countOfAds
=
1
init
(
alert
:
NWSAlert
)
{
self
.
alert
=
alert
}
var
numberOfRows
:
Int
{
alert
.
extendedInfo
?
.
infoBlocks
.
count
??
0
countOfAds
+
(
alert
.
extendedInfo
?
.
infoBlocks
.
count
??
0
)
}
mutating
func
update
(
with
alert
:
NWSAlert
)
{
...
...
@@ -56,7 +57,18 @@ fileprivate struct ExtendedInfoSection: NWSAlertTableViewSection {
}
func
type
(
forRow
row
:
Int
)
->
NWSAlertCellType
{
return
.
extendedInfoBlock
if
numberOfRows
==
1
{
return
.
ad
}
else
{
if
row
==
1
{
return
.
ad
}
else
{
return
.
extendedInfoBlock
}
}
}
let
rows
:
[
NWSAlertCellType
]
=
[
.
extendedInfoBlock
]
...
...
@@ -93,8 +105,8 @@ class NWSAlertCellFactory: CellFactoryProtocol {
return
adView
}
let
adView
=
adViewCache
[
indexPath
]
??
AdView
()
adView
.
loggingAlias
=
"
📍 Today
Banner"
adView
.
set
(
placementName
:
placementName
Today
Banner
,
adType
:
.
banner
)
adView
.
loggingAlias
=
"
⚠️ Alert
Banner"
adView
.
set
(
placementName
:
placementName
Precipitation
Banner
,
adType
:
.
banner
)
adViewCache
[
indexPath
]
=
adView
return
adView
}
...
...
@@ -119,8 +131,8 @@ class NWSAlertCellFactory: CellFactoryProtocol {
forecastOfficeCell
.
configure
(
with
:
alert
)
return
forecastOfficeCell
case
.
extendedInfoBlock
:
#warning("We've got to handle ads here.")
guard
let
info
=
alert
.
extendedInfo
?
.
infoBlocks
[
indexPath
.
row
]
else
{
let
adsCount
=
adViewCache
.
keys
.
filter
({
$0
.
row
<
indexPath
.
row
})
.
count
guard
let
info
=
alert
.
extendedInfo
?
.
infoBlocks
[
indexPath
.
row
-
adsCount
]
else
{
return
UITableViewCell
()
}
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 {
func
prepareContainer
()
{
contentView
.
addSubview
(
containerView
)
containerView
.
snp
.
makeConstraints
{
(
make
)
in
make
.
top
.
equalToSuperview
()
.
inset
(
18
)
make
.
top
.
equalToSuperview
()
make
.
left
.
equalToSuperview
()
.
inset
(
18
)
make
.
right
.
equalToSuperview
()
.
inset
(
18
)
make
.
bottom
.
equalToSuperview
()
make
.
bottom
.
equalToSuperview
()
.
inset
(
18
)
}
containerView
.
layer
.
cornerRadius
=
8
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 {
private
func
prepareContainer
()
{
contentView
.
addSubview
(
containerView
)
containerView
.
snp
.
makeConstraints
{
(
make
)
in
make
.
top
.
equalToSuperview
()
.
inset
(
18
)
make
.
top
.
equalToSuperview
()
make
.
left
.
equalToSuperview
()
.
inset
(
18
)
make
.
right
.
equalToSuperview
()
.
inset
(
18
)
make
.
bottom
.
equalToSuperview
()
make
.
bottom
.
equalToSuperview
()
.
inset
(
18
)
}
containerView
.
layer
.
cornerRadius
=
8
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 {
func
tableView
(
_
tableView
:
UITableView
,
estimatedHeightForRowAt
indexPath
:
IndexPath
)
->
CGFloat
{
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