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
3b01922f
Commit
3b01922f
authored
Jun 08, 2021
by
Demid Merzlyakov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
IOS-106: MREC support.
parent
cc6ee399
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
17 changed files
with
331 additions
and
91 deletions
+331
-91
1Weather.xcodeproj/project.pbxproj
+0
-0
1Weather/Ads/AdManager.swift
+3
-9
1Weather/Ads/AdView.swift
+1
-1
1Weather/Ads/Configuration/AdConfigManager.swift
+7
-13
1Weather/Ads/Native/NativeAdItem.swift
+2
-2
1Weather/Ads/Native/NativeAdViews/NativeAdView.swift
+37
-17
1Weather/Ads/Native/NativeAdViews/NativeBannerView.xib
+1
-1
1Weather/Ads/Native/NativeAdViews/NativeMRECView.xib
+88
-0
1Weather/Ads/Native/NativeBannerContainerView.swift
+6
-9
1Weather/Resources/en.lproj/Localizable.strings
+1
-0
1Weather/UI/Helpers/ForecastTimePeriod/ForecastTimePeriodView.swift
+0
-3
1Weather/UI/SharedCells/AdCells/AdCell.swift
+12
-0
1Weather/UI/SharedCells/AdCells/BannerAdCell.swift
+5
-4
1Weather/UI/SharedCells/AdCells/MRECAdCell.swift
+115
-0
1Weather/UI/View controllers/Forecast/Cells/ForecastCellFactory.swift
+19
-12
1Weather/UI/View controllers/NWSAlert/Cells/NWSAlertCellFactory.swift
+15
-9
1Weather/UI/View controllers/Today/Cells/TodayCellFactory.swift
+19
-11
No files found.
1Weather.xcodeproj/project.pbxproj
View file @
3b01922f
This diff is collapsed.
Click to expand it.
1Weather/Ads/AdManager.swift
View file @
3b01922f
...
@@ -124,17 +124,11 @@ public class AdManager {
...
@@ -124,17 +124,11 @@ public class AdManager {
a9Cache
.
addToPreload
(
placementName
:
placementNameTodayBanner
,
adType
:
.
banner
,
count
:
1
)
a9Cache
.
addToPreload
(
placementName
:
placementNameTodayBanner
,
adType
:
.
banner
,
count
:
1
)
a9Cache
.
addToPreload
(
placementName
:
placementNameTodaySquare
,
adType
:
.
square
,
count
:
1
)
a9Cache
.
addToPreload
(
placementName
:
placementNameTodaySquare
,
adType
:
.
square
,
count
:
1
)
a9Cache
.
addToPreload
(
placementName
:
placementNameDiscussionSquare
,
adType
:
.
square
,
count
:
1
)
a9Cache
.
addToPreload
(
placementName
:
placementNameExtendedSquare
,
adType
:
.
square
,
count
:
1
)
a9Cache
.
addToPreload
(
placementName
:
placementName12WeekInterstitial
,
adType
:
.
interstitial
,
count
:
1
)
a9Cache
.
addToPreload
(
placementName
:
placementNameForecastHourlyBanner
,
adType
:
.
banner
,
count
:
1
)
a9Cache
.
addToPreload
(
placementName
:
placementNameForecastHourlyBanner
,
adType
:
.
banner
,
count
:
1
)
a9Cache
.
addToPreload
(
placementName
:
placementNameForecastHourlySquare
,
adType
:
.
square
,
count
:
1
)
a9Cache
.
addToPreload
(
placementName
:
placementNameForecastHourlySquare
,
adType
:
.
square
,
count
:
1
)
a9Cache
.
addToPreload
(
placementName
:
placementNameForecastExtendedBanner
,
adType
:
.
banner
,
count
:
1
)
a9Cache
.
addToPreload
(
placementName
:
placementNameForecastDailyBanner
,
adType
:
.
banner
,
count
:
1
)
a9Cache
.
addToPreload
(
placementName
:
placementNameForecastExtendedSquare
,
adType
:
.
square
,
count
:
1
)
a9Cache
.
addToPreload
(
placementName
:
placementNameForecastDailySquare
,
adType
:
.
square
,
count
:
1
)
a9Cache
.
addToPreload
(
placementName
:
placementNameForecast12WeekSquare
,
adType
:
.
square
,
count
:
1
)
a9Cache
.
addToPreload
(
placementName
:
placementNameNWSAlertBanner
,
adType
:
.
banner
,
count
:
1
)
a9Cache
.
addToPreload
(
placementName
:
placementNamePrecipitationBanner
,
adType
:
.
banner
,
count
:
1
)
a9Cache
.
addToPreload
(
placementName
:
placementNameRadarInterstitial
,
adType
:
.
interstitial
,
count
:
1
)
a9Cache
.
addToPreload
(
placementName
:
placementNameSunMoonBanner
,
adType
:
.
banner
,
count
:
1
)
a9Cache
.
startPreloadingBids
()
a9Cache
.
startPreloadingBids
()
}
}
...
...
1Weather/Ads/AdView.swift
View file @
3b01922f
...
@@ -127,7 +127,7 @@ public class AdView: UIView {
...
@@ -127,7 +127,7 @@ public class AdView: UIView {
log
.
warning
(
"failed to guess the top view controller."
)
log
.
warning
(
"failed to guess the top view controller."
)
return
return
}
}
bannerView
=
NativeBannerContainerView
(
adUnitId
:
placement
.
adUnitId
,
rootViewController
:
topViewController
)
bannerView
=
NativeBannerContainerView
(
adUnitId
:
placement
.
adUnitId
,
adType
:
adType
,
rootViewController
:
topViewController
)
if
let
bannerView
=
bannerView
{
if
let
bannerView
=
bannerView
{
...
...
1Weather/Ads/Configuration/AdConfigManager.swift
View file @
3b01922f
...
@@ -14,19 +14,13 @@ extension Notification.Name {
...
@@ -14,19 +14,13 @@ extension Notification.Name {
typealias
AdPlacementName
=
String
typealias
AdPlacementName
=
String
let
placementNameTodayBanner
:
AdPlacementName
=
"1W_iOS_Native_Banner_ForD_ATF"
//TODO: wrong?
let
placementNameTodayBanner
:
AdPlacementName
=
"today_banner"
let
placementNameTodaySquare
:
AdPlacementName
=
"1W_iOS_Native_MREC_Today_BTF2"
let
placementNameTodaySquare
:
AdPlacementName
=
"today_square"
let
placementNameDiscussionSquare
:
AdPlacementName
=
"1W_iOS_Native_MREC_Forecast_discussion"
let
placementNameForecastHourlyBanner
:
AdPlacementName
=
"forecast_hourly_banner"
let
placementNameExtendedSquare
:
AdPlacementName
=
"1W_iOS_Native_MREC_Forecast_discussion"
// TODO: wrong?
let
placementNameForecastHourlySquare
:
AdPlacementName
=
"forecast_hourly_square"
let
placementName12WeekInterstitial
:
AdPlacementName
=
"1W_iOS_Int"
//TODO: definitely wrong
let
placementNameForecastDailyBanner
:
AdPlacementName
=
"forecast_daily_banner"
let
placementNameForecastHourlyBanner
:
AdPlacementName
=
"1W_iOS_Native_Banner_Hourly_ATF"
let
placementNameForecastDailySquare
:
AdPlacementName
=
"forecast_daily_square"
let
placementNameForecastHourlySquare
:
AdPlacementName
=
"1W_iOS_Native_MREC_Forecast_Hourly_BTF1"
let
placementNameNWSAlertBanner
:
AdPlacementName
=
"nws_alert_banner"
let
placementNameForecastExtendedBanner
:
AdPlacementName
=
"1W_iOS_Native_Banner_ForD_ATF"
// TODO: definitely wrong
let
placementNameForecastExtendedSquare
:
AdPlacementName
=
"1W_iOS_Native_MREC_Forecast_discussion"
// TODO: definitely wrong
let
placementNameForecast12WeekSquare
:
AdPlacementName
=
"1W_iOS_Native_MREC_Today_Details"
//TODO: definitely wrong
let
placementNamePrecipitationBanner
:
AdPlacementName
=
"1W_iOS_Native_Banner_Precipitation_ATF"
let
placementNameRadarInterstitial
:
AdPlacementName
=
"1W_iOS_Int"
//TODO: definitely wrong
let
placementNameSunMoonBanner
:
AdPlacementName
=
"1W_iOS_Native_Banner_Sunmoon_ATF"
class
AdConfigManager
:
NSObject
{
class
AdConfigManager
:
NSObject
{
@objc
@objc
...
...
1Weather/Ads/Native/NativeAdItem.swift
View file @
3b01922f
...
@@ -98,12 +98,12 @@ extension NativeAdItem: GADNativeAdDelegate {
...
@@ -98,12 +98,12 @@ extension NativeAdItem: GADNativeAdDelegate {
}
}
extension
NativeAdItem
:
GADBannerViewDelegate
{
extension
NativeAdItem
:
GADBannerViewDelegate
{
func
ad
ViewDidRecordImpression
(
_
bannerView
:
GADBannerView
)
{
func
banner
ViewDidRecordImpression
(
_
bannerView
:
GADBannerView
)
{
log
.
info
(
"Impression recorded (banner)"
)
log
.
info
(
"Impression recorded (banner)"
)
analytics
(
log
:
.
ANALYTICS_AD_IMPRESSION
)
analytics
(
log
:
.
ANALYTICS_AD_IMPRESSION
)
}
}
func
ad
ViewWillPresentScreen
(
_
bannerView
:
GADBannerView
)
{
func
banner
ViewWillPresentScreen
(
_
bannerView
:
GADBannerView
)
{
log
.
info
(
"Click recorded (will present screen)"
)
log
.
info
(
"Click recorded (will present screen)"
)
analytics
(
log
:
.
ANALYTICS_AD_CLICKED
)
analytics
(
log
:
.
ANALYTICS_AD_CLICKED
)
}
}
...
...
1Weather/Ads/Native/Native
Banner
View.swift
→
1Weather/Ads/Native/Native
AdViews/NativeAd
View.swift
View file @
3b01922f
//
//
// Native
Banner
View.swift
// Native
Ad
View.swift
//
BaconRead
er
//
1Weath
er
//
//
// Created by Rishab Dutta on 24/07/20.
// Created by Demid Merzlyakov on 07.06.2021.
// Copyright © 2020 OneLouder Apps. All rights reserved.
//
//
import
Foundation
import
Foundation
import
GoogleMobileAds
import
GoogleMobileAds
class
NativeBannerView
:
GADNativeAdView
{
class
NativeAdView
:
GADNativeAdView
{
@IBOutlet
weak
var
sponsoredLabel
:
UILabel
!
@IBOutlet
weak
var
sponsoredLabel
:
UILabel
?
@IBOutlet
weak
var
adChoicesViewCustomOutlet
:
GADAdChoicesView
!
@IBOutlet
weak
var
adChoicesViewCustomOutlet
:
GADAdChoicesView
?
var
headlineLabel
:
UILabel
?
{
var
headlineLabel
:
UILabel
?
{
headlineView
as?
UILabel
headlineView
as?
UILabel
...
@@ -22,6 +20,10 @@ class NativeBannerView: GADNativeAdView {
...
@@ -22,6 +20,10 @@ class NativeBannerView: GADNativeAdView {
advertiserView
as?
UILabel
advertiserView
as?
UILabel
}
}
var
bodyLabel
:
UILabel
?
{
bodyView
as?
UILabel
}
var
iconImageView
:
UIImageView
?
{
var
iconImageView
:
UIImageView
?
{
iconView
as?
UIImageView
iconView
as?
UIImageView
}
}
...
@@ -30,14 +32,28 @@ class NativeBannerView: GADNativeAdView {
...
@@ -30,14 +32,28 @@ class NativeBannerView: GADNativeAdView {
callToActionView
as?
UILabel
callToActionView
as?
UILabel
}
}
class
func
instantiateWithXib
()
->
NativeBannerView
?
{
var
mainImageView
:
UIImageView
?
{
let
nib
=
UINib
(
nibName
:
"
\(
NativeBannerView
.
self
)
"
,
bundle
:
nil
)
imageView
as?
UIImageView
let
bView
=
nib
.
instantiate
(
withOwner
:
self
,
options
:
nil
)
.
first
as?
NativeBannerView
}
public
class
func
instantiateWithXib
(
adType
:
AdType
)
->
NativeAdView
?
{
var
xibName
:
String
!
switch
adType
{
case
.
banner
:
xibName
=
"NativeBannerView"
case
.
square
:
xibName
=
"NativeMRECView"
case
.
interstitial
:
assertionFailure
(
"Incorrect ad type - interstitial"
)
return
nil
}
let
nib
=
UINib
(
nibName
:
xibName
,
bundle
:
nil
)
let
bView
=
nib
.
instantiate
(
withOwner
:
self
,
options
:
nil
)
.
first
as?
NativeAdView
bView
?
.
setupPostXib
()
bView
?
.
setupPostXib
()
return
bView
return
bView
}
}
private
func
setupPostXib
()
{
func
setupPostXib
()
{
let
currentTheme
=
ThemeManager
.
currentTheme
let
currentTheme
=
ThemeManager
.
currentTheme
callToActionLabel
?
.
backgroundColor
=
currentTheme
.
nativeAdCallToActionColor
callToActionLabel
?
.
backgroundColor
=
currentTheme
.
nativeAdCallToActionColor
callToActionLabel
?
.
layer
.
cornerRadius
=
2
callToActionLabel
?
.
layer
.
cornerRadius
=
2
...
@@ -47,17 +63,20 @@ class NativeBannerView: GADNativeAdView {
...
@@ -47,17 +63,20 @@ class NativeBannerView: GADNativeAdView {
advertiserLabel
?
.
textColor
=
currentTheme
.
primaryTextColor
advertiserLabel
?
.
textColor
=
currentTheme
.
primaryTextColor
self
.
adChoicesView
=
self
.
adChoicesViewCustomOutlet
self
.
adChoicesView
=
self
.
adChoicesViewCustomOutlet
sponsoredLabel
.
text
=
"ads.native.sponsored"
.
localized
()
sponsoredLabel
?
.
text
=
"ads.native.sponsored"
.
localized
()
sponsoredLabel
.
textColor
=
currentTheme
.
primaryTextColor
sponsoredLabel
?
.
textColor
=
currentTheme
.
primaryTextColor
bodyLabel
?
.
textColor
=
currentTheme
.
secondaryTextColor
setupFonts
()
setupFonts
()
}
}
private
func
setupFonts
()
{
private
func
setupFonts
()
{
callToActionLabel
?
.
font
=
AppFont
.
SFCompactDisplay
.
regular
(
size
:
10
)
callToActionLabel
?
.
font
=
AppFont
.
SFCompactDisplay
.
regular
(
size
:
10
)
sponsoredLabel
.
font
=
AppFont
.
SFCompactDisplay
.
regular
(
size
:
10
)
sponsoredLabel
?
.
font
=
AppFont
.
SFCompactDisplay
.
regular
(
size
:
10
)
headlineLabel
?
.
font
=
AppFont
.
SFCompactDisplay
.
semibold
(
size
:
18
)
headlineLabel
?
.
font
=
AppFont
.
SFCompactDisplay
.
semibold
(
size
:
18
)
advertiserLabel
?
.
font
=
AppFont
.
SFCompactDisplay
.
regular
(
size
:
12
)
advertiserLabel
?
.
font
=
AppFont
.
SFCompactDisplay
.
regular
(
size
:
12
)
callToActionLabel
?
.
font
=
AppFont
.
SFCompactDisplay
.
light
(
size
:
10
)
callToActionLabel
?
.
font
=
AppFont
.
SFCompactDisplay
.
light
(
size
:
10
)
bodyLabel
?
.
font
=
AppFont
.
SFCompactDisplay
.
regular
(
size
:
10
)
}
}
var
nativeAdItem
:
NativeAdItem
?
{
var
nativeAdItem
:
NativeAdItem
?
{
...
@@ -75,9 +94,10 @@ class NativeBannerView: GADNativeAdView {
...
@@ -75,9 +94,10 @@ class NativeBannerView: GADNativeAdView {
iconImageView
?
.
image
=
nativeAd
?
.
icon
?
.
image
iconImageView
?
.
image
=
nativeAd
?
.
icon
?
.
image
advertiserLabel
?
.
text
=
nativeAd
?
.
advertiser
advertiserLabel
?
.
text
=
nativeAd
?
.
advertiser
callToActionLabel
?
.
text
=
nativeAd
?
.
callToAction
callToActionLabel
?
.
text
=
nativeAd
?
.
callToAction
bodyLabel
?
.
text
=
nativeAd
?
.
body
mainImageView
?
.
image
=
nativeAd
?
.
images
?
.
first
?
.
image
setupPostXib
()
setupPostXib
()
}
}
}
}
1Weather/Ads/Native/NativeBannerView.xib
→
1Weather/Ads/Native/Native
AdViews/Native
BannerView.xib
View file @
3b01922f
...
@@ -17,7 +17,7 @@
...
@@ -17,7 +17,7 @@
<objects>
<objects>
<placeholder
placeholderIdentifier=
"IBFilesOwner"
id=
"-1"
userLabel=
"File's Owner"
/>
<placeholder
placeholderIdentifier=
"IBFilesOwner"
id=
"-1"
userLabel=
"File's Owner"
/>
<placeholder
placeholderIdentifier=
"IBFirstResponder"
id=
"-2"
customClass=
"UIResponder"
/>
<placeholder
placeholderIdentifier=
"IBFirstResponder"
id=
"-2"
customClass=
"UIResponder"
/>
<view
contentMode=
"scaleToFill"
id=
"iN0-l3-epB"
customClass=
"Native
Banner
View"
customModule=
"_Weather"
customModuleProvider=
"target"
>
<view
contentMode=
"scaleToFill"
id=
"iN0-l3-epB"
customClass=
"Native
Ad
View"
customModule=
"_Weather"
customModuleProvider=
"target"
>
<rect
key=
"frame"
x=
"0.0"
y=
"0.0"
width=
"320"
height=
"64"
/>
<rect
key=
"frame"
x=
"0.0"
y=
"0.0"
width=
"320"
height=
"64"
/>
<autoresizingMask
key=
"autoresizingMask"
widthSizable=
"YES"
heightSizable=
"YES"
/>
<autoresizingMask
key=
"autoresizingMask"
widthSizable=
"YES"
heightSizable=
"YES"
/>
<subviews>
<subviews>
...
...
1Weather/Ads/Native/NativeAdViews/NativeMRECView.xib
0 → 100644
View file @
3b01922f
<?xml version="1.0" encoding="UTF-8"?>
<document
type=
"com.apple.InterfaceBuilder3.CocoaTouch.XIB"
version=
"3.0"
toolsVersion=
"18122"
targetRuntime=
"iOS.CocoaTouch"
propertyAccessControl=
"none"
useAutolayout=
"YES"
useTraitCollections=
"YES"
useSafeAreas=
"YES"
colorMatched=
"YES"
>
<device
id=
"retina6_1"
orientation=
"portrait"
appearance=
"light"
/>
<dependencies>
<deployment
identifier=
"iOS"
/>
<plugIn
identifier=
"com.apple.InterfaceBuilder.IBCocoaTouchPlugin"
version=
"18093"
/>
<capability
name=
"Safe area layout guides"
minToolsVersion=
"9.0"
/>
<capability
name=
"System colors in document resources"
minToolsVersion=
"11.0"
/>
<capability
name=
"documents saved in the Xcode 8 format"
minToolsVersion=
"8.0"
/>
</dependencies>
<objects>
<placeholder
placeholderIdentifier=
"IBFilesOwner"
id=
"-1"
userLabel=
"File's Owner"
customClass=
"GADNativeAdView"
/>
<placeholder
placeholderIdentifier=
"IBFirstResponder"
id=
"-2"
customClass=
"UIResponder"
/>
<view
contentMode=
"scaleToFill"
id=
"A8i-el-bXZ"
customClass=
"NativeAdView"
customModule=
"_Weather"
customModuleProvider=
"target"
>
<rect
key=
"frame"
x=
"0.0"
y=
"0.0"
width=
"300"
height=
"250"
/>
<autoresizingMask
key=
"autoresizingMask"
widthSizable=
"YES"
heightSizable=
"YES"
/>
<subviews>
<imageView
clipsSubviews=
"YES"
userInteractionEnabled=
"NO"
contentMode=
"scaleAspectFit"
horizontalHuggingPriority=
"251"
verticalHuggingPriority=
"251"
translatesAutoresizingMaskIntoConstraints=
"NO"
id=
"TNc-iz-mnZ"
>
<rect
key=
"frame"
x=
"0.0"
y=
"0.0"
width=
"300"
height=
"155"
/>
<constraints>
<constraint
firstAttribute=
"height"
constant=
"155"
id=
"2of-WV-KVU"
/>
</constraints>
</imageView>
<label
opaque=
"NO"
userInteractionEnabled=
"NO"
contentMode=
"left"
horizontalHuggingPriority=
"251"
verticalHuggingPriority=
"251"
text=
"Headline"
textAlignment=
"natural"
lineBreakMode=
"tailTruncation"
baselineAdjustment=
"alignBaselines"
adjustsFontSizeToFit=
"NO"
translatesAutoresizingMaskIntoConstraints=
"NO"
id=
"ALU-9y-yCS"
>
<rect
key=
"frame"
x=
"10"
y=
"160"
width=
"280"
height=
"20"
/>
<fontDescription
key=
"fontDescription"
type=
"system"
pointSize=
"16"
/>
<nil
key=
"textColor"
/>
<nil
key=
"highlightedColor"
/>
</label>
<label
opaque=
"NO"
userInteractionEnabled=
"NO"
contentMode=
"left"
horizontalHuggingPriority=
"251"
verticalHuggingPriority=
"251"
text=
"Body"
textAlignment=
"natural"
lineBreakMode=
"tailTruncation"
numberOfLines=
"2"
baselineAdjustment=
"alignBaselines"
adjustsFontSizeToFit=
"NO"
translatesAutoresizingMaskIntoConstraints=
"NO"
id=
"b9r-uH-Qrr"
>
<rect
key=
"frame"
x=
"10"
y=
"180"
width=
"222"
height=
"11"
/>
<fontDescription
key=
"fontDescription"
type=
"system"
pointSize=
"9"
/>
<nil
key=
"textColor"
/>
<nil
key=
"highlightedColor"
/>
</label>
<label
opaque=
"NO"
userInteractionEnabled=
"NO"
contentMode=
"left"
horizontalHuggingPriority=
"251"
verticalHuggingPriority=
"251"
text=
"CTA"
textAlignment=
"center"
lineBreakMode=
"tailTruncation"
baselineAdjustment=
"alignBaselines"
adjustsFontSizeToFit=
"NO"
translatesAutoresizingMaskIntoConstraints=
"NO"
id=
"7po-us-Uyw"
>
<rect
key=
"frame"
x=
"10"
y=
"210"
width=
"78"
height=
"26"
/>
<color
key=
"backgroundColor"
red=
"0.066666666669999999"
green=
"0.49803921569999998"
blue=
"1"
alpha=
"1"
colorSpace=
"calibratedRGB"
/>
<constraints>
<constraint
firstAttribute=
"height"
constant=
"26"
id=
"5wk-Js-TvA"
/>
<constraint
firstAttribute=
"width"
constant=
"78"
id=
"mQK-sj-eIi"
/>
</constraints>
<fontDescription
key=
"fontDescription"
type=
"system"
pointSize=
"12"
/>
<color
key=
"textColor"
white=
"1"
alpha=
"1"
colorSpace=
"custom"
customColorSpace=
"genericGamma22GrayColorSpace"
/>
<nil
key=
"highlightedColor"
/>
</label>
<imageView
clipsSubviews=
"YES"
userInteractionEnabled=
"NO"
contentMode=
"scaleAspectFit"
horizontalHuggingPriority=
"251"
verticalHuggingPriority=
"251"
translatesAutoresizingMaskIntoConstraints=
"NO"
id=
"k7n-sU-yPp"
>
<rect
key=
"frame"
x=
"236"
y=
"184"
width=
"54"
height=
"54"
/>
<constraints>
<constraint
firstAttribute=
"width"
constant=
"54"
id=
"DaG-29-Yci"
/>
<constraint
firstAttribute=
"height"
constant=
"54"
id=
"Ol9-Ch-SAu"
/>
</constraints>
</imageView>
</subviews>
<viewLayoutGuide
key=
"safeArea"
id=
"4vU-qI-YDI"
/>
<color
key=
"backgroundColor"
systemColor=
"systemBackgroundColor"
/>
<constraints>
<constraint
firstItem=
"k7n-sU-yPp"
firstAttribute=
"leading"
secondItem=
"b9r-uH-Qrr"
secondAttribute=
"trailing"
constant=
"4"
id=
"42b-ug-6to"
/>
<constraint
firstItem=
"TNc-iz-mnZ"
firstAttribute=
"leading"
secondItem=
"A8i-el-bXZ"
secondAttribute=
"leading"
id=
"5EK-gf-w66"
/>
<constraint
firstItem=
"7po-us-Uyw"
firstAttribute=
"leading"
secondItem=
"A8i-el-bXZ"
secondAttribute=
"leading"
constant=
"10"
id=
"5FJ-Je-u1p"
/>
<constraint
firstItem=
"b9r-uH-Qrr"
firstAttribute=
"top"
secondItem=
"ALU-9y-yCS"
secondAttribute=
"bottom"
id=
"7uv-BN-qIz"
/>
<constraint
firstAttribute=
"bottom"
secondItem=
"7po-us-Uyw"
secondAttribute=
"bottom"
constant=
"14"
id=
"Apu-0q-oJC"
/>
<constraint
firstAttribute=
"bottom"
secondItem=
"k7n-sU-yPp"
secondAttribute=
"bottom"
constant=
"12"
id=
"CRP-vK-rgT"
/>
<constraint
firstAttribute=
"trailing"
secondItem=
"k7n-sU-yPp"
secondAttribute=
"trailing"
constant=
"10"
id=
"IBC-YR-xho"
/>
<constraint
firstItem=
"b9r-uH-Qrr"
firstAttribute=
"leading"
secondItem=
"ALU-9y-yCS"
secondAttribute=
"leading"
id=
"aoN-Pv-cUM"
/>
<constraint
firstItem=
"ALU-9y-yCS"
firstAttribute=
"leading"
secondItem=
"A8i-el-bXZ"
secondAttribute=
"leading"
constant=
"10"
id=
"dBl-Mj-Bmh"
/>
<constraint
firstItem=
"ALU-9y-yCS"
firstAttribute=
"top"
secondItem=
"TNc-iz-mnZ"
secondAttribute=
"bottom"
constant=
"5"
id=
"j1x-NM-1zu"
/>
<constraint
firstAttribute=
"trailing"
secondItem=
"TNc-iz-mnZ"
secondAttribute=
"trailing"
id=
"o1v-BR-AAi"
/>
<constraint
firstAttribute=
"trailing"
secondItem=
"ALU-9y-yCS"
secondAttribute=
"trailing"
constant=
"10"
id=
"tNs-jB-g7c"
/>
<constraint
firstItem=
"TNc-iz-mnZ"
firstAttribute=
"top"
secondItem=
"A8i-el-bXZ"
secondAttribute=
"top"
id=
"u0g-go-6RF"
/>
</constraints>
<freeformSimulatedSizeMetrics
key=
"simulatedDestinationMetrics"
/>
<connections>
<outlet
property=
"bodyView"
destination=
"b9r-uH-Qrr"
id=
"mHO-sW-gX7"
/>
<outlet
property=
"callToActionView"
destination=
"7po-us-Uyw"
id=
"VBG-Fk-Pn7"
/>
<outlet
property=
"headlineView"
destination=
"ALU-9y-yCS"
id=
"pHO-sW-gXV"
/>
<outlet
property=
"iconView"
destination=
"k7n-sU-yPp"
id=
"4P6-sq-Gob"
/>
<outlet
property=
"imageView"
destination=
"TNc-iz-mnZ"
id=
"TN6-iz-mnZ"
/>
</connections>
<point
key=
"canvasLocation"
x=
"214.49275362318843"
y=
"-94.419642857142847"
/>
</view>
</objects>
<resources>
<systemColor
name=
"systemBackgroundColor"
>
<color
white=
"1"
alpha=
"1"
colorSpace=
"custom"
customColorSpace=
"genericGamma22GrayColorSpace"
/>
</systemColor>
</resources>
</document>
1Weather/Ads/Native/NativeBannerContainerView.swift
View file @
3b01922f
...
@@ -21,6 +21,7 @@ class NativeBannerContainerView: UIView {
...
@@ -21,6 +21,7 @@ class NativeBannerContainerView: UIView {
private
let
log
=
AdLogger
(
componentName
:
"NativeBannerContainerView"
)
private
let
log
=
AdLogger
(
componentName
:
"NativeBannerContainerView"
)
private
var
adLoader
:
NativeAdLoader
private
var
adLoader
:
NativeAdLoader
private
let
adType
:
AdType
weak
var
delegate
:
NativeBannerContainerViewDelegate
?
weak
var
delegate
:
NativeBannerContainerViewDelegate
?
...
@@ -30,7 +31,8 @@ class NativeBannerContainerView: UIView {
...
@@ -30,7 +31,8 @@ class NativeBannerContainerView: UIView {
}
}
}
}
init
(
adUnitId
:
String
,
rootViewController
:
UIViewController
)
{
init
(
adUnitId
:
String
,
adType
:
AdType
,
rootViewController
:
UIViewController
)
{
self
.
adType
=
adType
self
.
adLoader
=
NativeAdLoader
(
adUnitId
:
adUnitId
,
rootViewController
:
rootViewController
,
adTypes
:
[
.
native
,
.
gamBanner
])
self
.
adLoader
=
NativeAdLoader
(
adUnitId
:
adUnitId
,
rootViewController
:
rootViewController
,
adTypes
:
[
.
native
,
.
gamBanner
])
super
.
init
(
frame
:
.
zero
)
super
.
init
(
frame
:
.
zero
)
self
.
adLoader
.
delegate
=
self
self
.
adLoader
.
delegate
=
self
...
@@ -76,17 +78,12 @@ private extension NativeBannerContainerView {
...
@@ -76,17 +78,12 @@ private extension NativeBannerContainerView {
extension
NativeBannerContainerView
:
NativeAdLoaderDelegate
{
extension
NativeBannerContainerView
:
NativeAdLoaderDelegate
{
func
adLoader
(
_
adLoader
:
GADAdLoader
,
didReceive
nativeAd
:
GADNativeAd
)
{
func
adLoader
(
_
adLoader
:
GADAdLoader
,
didReceive
nativeAd
:
GADNativeAd
)
{
log
.
debug
(
"Banner ad recieved (native_banner) by:
\(
String
(
describing
:
nativeAd
.
responseInfo
.
adNetworkClassName
)
)
"
)
log
.
debug
(
"Banner ad recieved (native_banner) by:
\(
String
(
describing
:
nativeAd
.
responseInfo
.
adNetworkClassName
)
)
"
)
guard
let
adView
=
NativeAdView
.
instantiateWithXib
(
adType
:
adType
)
else
{
return
}
guard
let
nativeBannerView
=
NativeBannerView
.
instantiateWithXib
()
else
{
return
}
let
nativeAdItem
=
NativeAdItem
(
nativeAd
:
nativeAd
,
adUnitId
:
adLoader
.
adUnitID
)
let
nativeAdItem
=
NativeAdItem
(
nativeAd
:
nativeAd
,
adUnitId
:
adLoader
.
adUnitID
)
adView
.
nativeAdItem
=
nativeAdItem
nativeBannerView
.
nativeAdItem
=
nativeAdItem
addAsSubview
(
view
:
adView
)
addAsSubview
(
view
:
nativeBannerView
)
print
(
"native ad loader:
\(
String
(
describing
:
nativeAd
.
headline
)
)
"
)
print
(
"native ad loader:
\(
String
(
describing
:
nativeAd
.
headline
)
)
"
)
delegate
?
.
adLoader
(
adLoader
,
didReceive
:
nativeAd
)
delegate
?
.
adLoader
(
adLoader
,
didReceive
:
nativeAd
)
}
}
func
adLoader
(
_
adLoader
:
GADAdLoader
,
didFailToReceiveAdWithError
error
:
Error
)
{
func
adLoader
(
_
adLoader
:
GADAdLoader
,
didFailToReceiveAdWithError
error
:
Error
)
{
...
...
1Weather/Resources/en.lproj/Localizable.strings
View file @
3b01922f
...
@@ -271,3 +271,4 @@
...
@@ -271,3 +271,4 @@
// Ads
// Ads
"ads.native.sponsored" = "Sponsored";
"ads.native.sponsored" = "Sponsored";
"ads.placeholder" = "Advertisment";
1Weather/UI/Helpers/ForecastTimePeriod/ForecastTimePeriodView.swift
View file @
3b01922f
...
@@ -165,7 +165,6 @@ class ForecastTimePeriodView: UIView {
...
@@ -165,7 +165,6 @@ class ForecastTimePeriodView: UIView {
}
}
private
func
updateGraphLayout
()
{
private
func
updateGraphLayout
()
{
print
(
"[ForecastTimePeriod] Update graph layout"
)
graphRect
=
(
stackView
.
arrangedSubviews
.
first
as?
PeriodButtonProtocol
)?
.
graphRect
??
.
zero
graphRect
=
(
stackView
.
arrangedSubviews
.
first
as?
PeriodButtonProtocol
)?
.
graphRect
??
.
zero
graphView
.
frame
=
.
init
(
x
:
0
,
graphView
.
frame
=
.
init
(
x
:
0
,
y
:
graphRect
.
origin
.
y
,
y
:
graphRect
.
origin
.
y
,
...
@@ -299,8 +298,6 @@ class ForecastTimePeriodView: UIView {
...
@@ -299,8 +298,6 @@ class ForecastTimePeriodView: UIView {
self
.
graphView
.
drawAdditionalGraph
(
with
:
[
CGPoint
]())
self
.
graphView
.
drawAdditionalGraph
(
with
:
[
CGPoint
]())
self
.
tintGraphAt
(
button
:
selectedButton
)
self
.
tintGraphAt
(
button
:
selectedButton
)
}
}
print
(
"[ForecastTimePeriod] Draw graph"
)
}
}
private
func
tintGraphAt
(
button
:
PeriodButtonProtocol
)
{
private
func
tintGraphAt
(
button
:
PeriodButtonProtocol
)
{
...
...
1Weather/UI/SharedCells/AdCells/AdCell.swift
0 → 100644
View file @
3b01922f
//
// TodayAdCell.swift
// 1Weather
//
// Created by Dmitry Stepanets on 12.02.2021.
//
import
UIKit
protocol
AdCell
{
var
adView
:
AdView
?
{
get
set
}
}
1Weather/UI/
View controllers/Today/Cells/
AdCell.swift
→
1Weather/UI/
SharedCells/AdCells/Banner
AdCell.swift
View file @
3b01922f
//
//
//
Today
AdCell.swift
//
Banner
AdCell.swift
// 1Weather
// 1Weather
//
//
// Created by Dmitry Stepanets on 12.02.2021.
// Created by Dmitry Stepanets on 12.02.2021.
...
@@ -7,7 +7,8 @@
...
@@ -7,7 +7,8 @@
import
UIKit
import
UIKit
class
AdCell
:
UITableViewCell
{
class
BannerAdCell
:
UITableViewCell
,
AdCell
{
//Private
//Private
private
let
container
=
UIView
()
private
let
container
=
UIView
()
private
let
label
=
UILabel
()
private
let
label
=
UILabel
()
...
@@ -60,7 +61,7 @@ class AdCell: UITableViewCell {
...
@@ -60,7 +61,7 @@ class AdCell: UITableViewCell {
}
}
//MARK:- Prepare
//MARK:- Prepare
private
extension
AdCell
{
private
extension
Banner
AdCell
{
func
prepareCellStyle
()
{
func
prepareCellStyle
()
{
selectionStyle
=
.
none
selectionStyle
=
.
none
}
}
...
@@ -82,7 +83,7 @@ private extension AdCell {
...
@@ -82,7 +83,7 @@ private extension AdCell {
subview
.
removeFromSuperview
()
subview
.
removeFromSuperview
()
}
}
label
.
text
=
"
Advertisment"
label
.
text
=
"
ads.placeholder"
.
localized
()
label
.
font
=
AppFont
.
SFPro
.
regular
(
size
:
14
)
label
.
font
=
AppFont
.
SFPro
.
regular
(
size
:
14
)
container
.
addSubview
(
label
)
container
.
addSubview
(
label
)
...
...
1Weather/UI/SharedCells/AdCells/MRECAdCell.swift
0 → 100644
View file @
3b01922f
//
// MRECAdCell.swift
// 1Weather
//
// Created by Demid Merzlyakov on 08.06.2021.
//
import
UIKit
class
MRECAdCell
:
UITableViewCell
,
AdCell
{
//Private
private
let
container
=
UIView
()
private
let
label
=
UILabel
()
public
var
adView
:
AdView
?
=
nil
{
didSet
{
guard
adView
!=
oldValue
else
{
return
}
prepareAd
()
}
}
private
let
gradientView
=
GradientView
(
startColor
:
UIColor
.
white
.
withAlphaComponent
(
0
),
endColor
:
UIColor
(
hex
:
0xdaddec
),
opacity
:
0.5
)
override
init
(
style
:
UITableViewCell
.
CellStyle
,
reuseIdentifier
:
String
?)
{
super
.
init
(
style
:
style
,
reuseIdentifier
:
reuseIdentifier
)
prepareCellStyle
()
prepareContainer
()
prepareAd
()
prepareGradient
()
updateUI
()
}
required
init
?(
coder
:
NSCoder
)
{
fatalError
(
"init(coder:) has not been implemented"
)
}
override
func
traitCollectionDidChange
(
_
previousTraitCollection
:
UITraitCollection
?)
{
super
.
traitCollectionDidChange
(
previousTraitCollection
)
updateUI
()
}
private
func
updateUI
()
{
contentView
.
backgroundColor
=
ThemeManager
.
currentTheme
.
baseBackgroundColor
container
.
backgroundColor
=
ThemeManager
.
currentTheme
.
containerBackgroundColor
label
.
textColor
=
ThemeManager
.
currentTheme
.
secondaryTextColor
switch
interfaceStyle
{
case
.
light
:
gradientView
.
isHidden
=
false
container
.
layer
.
borderWidth
=
1
/
UIScreen
.
main
.
scale
container
.
layer
.
borderColor
=
UIColor
(
hex
:
0xc7c7c7
)
.
cgColor
case
.
dark
:
gradientView
.
isHidden
=
true
container
.
layer
.
borderWidth
=
0
}
}
}
//MARK:- Prepare
private
extension
MRECAdCell
{
func
prepareCellStyle
()
{
selectionStyle
=
.
none
}
func
prepareContainer
()
{
label
.
text
=
"ads.placeholder"
.
localized
()
label
.
font
=
AppFont
.
SFPro
.
regular
(
size
:
10
)
label
.
textColor
=
ThemeManager
.
currentTheme
.
secondaryTextColor
contentView
.
addSubview
(
label
)
contentView
.
addSubview
(
container
)
label
.
snp
.
makeConstraints
{
make
in
make
.
top
.
equalToSuperview
()
.
inset
(
18
)
make
.
trailing
.
equalTo
(
container
.
snp
.
trailing
)
}
container
.
snp
.
makeConstraints
{
(
make
)
in
make
.
top
.
equalTo
(
label
.
snp
.
bottom
)
.
offset
(
6
)
make
.
height
.
equalTo
(
250
)
make
.
bottom
.
equalToSuperview
()
.
inset
(
18
)
make
.
centerX
.
equalToSuperview
()
make
.
width
.
equalTo
(
300
)
}
}
func
prepareAd
()
{
for
subview
in
container
.
subviews
{
subview
.
removeFromSuperview
()
}
label
.
snp
.
makeConstraints
{
(
make
)
in
make
.
center
.
equalToSuperview
()
}
if
let
adView
=
adView
{
container
.
addSubview
(
adView
)
adView
.
snp
.
makeConstraints
{
(
make
)
in
make
.
center
.
equalToSuperview
()
make
.
size
.
equalToSuperview
()
}
}
}
func
prepareGradient
()
{
contentView
.
addSubview
(
gradientView
)
contentView
.
bringSubviewToFront
(
container
)
gradientView
.
snp
.
makeConstraints
{
(
make
)
in
make
.
left
.
bottom
.
right
.
equalToSuperview
()
make
.
height
.
equalToSuperview
()
.
multipliedBy
(
0.5
)
}
}
}
1Weather/UI/View controllers/Forecast/Cells/ForecastCellFactory.swift
View file @
3b01922f
...
@@ -10,11 +10,8 @@ import UIKit
...
@@ -10,11 +10,8 @@ import UIKit
private
enum
DailyForecastCellType
:
Int
,
CaseIterable
{
private
enum
DailyForecastCellType
:
Int
,
CaseIterable
{
case
forecast
=
0
case
forecast
=
0
case
forecastInfo
case
forecastInfo
case
ad
case
adBanner
// case forecast
case
adMREC
// case conditions
// case precipitation
// case dayTime
case
sun
case
sun
case
moon
case
moon
}
}
...
@@ -22,7 +19,8 @@ private enum DailyForecastCellType:Int, CaseIterable {
...
@@ -22,7 +19,8 @@ private enum DailyForecastCellType:Int, CaseIterable {
private
enum
HourlyForecastCellType
:
Int
,
CaseIterable
{
private
enum
HourlyForecastCellType
:
Int
,
CaseIterable
{
case
day
case
day
case
forecastHourly
case
forecastHourly
case
ad
case
adBanner
case
adMREC
case
precipitation
case
precipitation
case
wind
case
wind
}
}
...
@@ -66,7 +64,8 @@ class ForecastCellFactory: CellFactoryProtocol {
...
@@ -66,7 +64,8 @@ class ForecastCellFactory: CellFactoryProtocol {
registerCell
(
type
:
ForecastWindSpeedCell
.
self
,
tableView
:
tableView
)
registerCell
(
type
:
ForecastWindSpeedCell
.
self
,
tableView
:
tableView
)
registerCell
(
type
:
SunPhaseCell
.
self
,
tableView
:
tableView
)
registerCell
(
type
:
SunPhaseCell
.
self
,
tableView
:
tableView
)
registerCell
(
type
:
MoonPhaseCell
.
self
,
tableView
:
tableView
)
registerCell
(
type
:
MoonPhaseCell
.
self
,
tableView
:
tableView
)
registerCell
(
type
:
AdCell
.
self
,
tableView
:
tableView
)
registerCell
(
type
:
BannerAdCell
.
self
,
tableView
:
tableView
)
registerCell
(
type
:
MRECAdCell
.
self
,
tableView
:
tableView
)
}
}
public
func
cellFromTableView
(
tableView
:
UITableView
,
indexPath
:
IndexPath
)
->
UITableViewCell
{
public
func
cellFromTableView
(
tableView
:
UITableView
,
indexPath
:
IndexPath
)
->
UITableViewCell
{
...
@@ -117,7 +116,7 @@ class ForecastCellFactory: CellFactoryProtocol {
...
@@ -117,7 +116,7 @@ class ForecastCellFactory: CellFactoryProtocol {
var
timePeriodString
:
String
!
var
timePeriodString
:
String
!
switch
timePeriod
{
switch
timePeriod
{
case
.
daily
:
case
.
daily
:
placementName
=
placementNameForecast
Extended
Banner
placementName
=
placementNameForecast
Daily
Banner
timePeriodString
=
"D"
timePeriodString
=
"D"
case
.
hourly
:
case
.
hourly
:
placementName
=
placementNameForecastHourlyBanner
placementName
=
placementNameForecastHourlyBanner
...
@@ -175,8 +174,12 @@ class ForecastCellFactory: CellFactoryProtocol {
...
@@ -175,8 +174,12 @@ class ForecastCellFactory: CellFactoryProtocol {
cell
.
configure
(
with
:
loc
)
cell
.
configure
(
with
:
loc
)
}
}
return
cell
return
cell
case
.
ad
:
case
.
adBanner
:
let
cell
=
dequeueReusableCell
(
type
:
AdCell
.
self
,
tableView
:
tableView
,
indexPath
:
indexPath
)
let
cell
=
dequeueReusableCell
(
type
:
BannerAdCell
.
self
,
tableView
:
tableView
,
indexPath
:
indexPath
)
cell
.
adView
=
adView
(
for
:
timePeriod
,
indexPath
:
indexPath
)
return
cell
case
.
adMREC
:
let
cell
=
dequeueReusableCell
(
type
:
MRECAdCell
.
self
,
tableView
:
tableView
,
indexPath
:
indexPath
)
cell
.
adView
=
adView
(
for
:
timePeriod
,
indexPath
:
indexPath
)
cell
.
adView
=
adView
(
for
:
timePeriod
,
indexPath
:
indexPath
)
return
cell
return
cell
}
}
...
@@ -221,8 +224,12 @@ class ForecastCellFactory: CellFactoryProtocol {
...
@@ -221,8 +224,12 @@ class ForecastCellFactory: CellFactoryProtocol {
}
}
}
}
return
cell
return
cell
case
.
ad
:
case
.
adBanner
:
let
cell
=
dequeueReusableCell
(
type
:
AdCell
.
self
,
tableView
:
tableView
,
indexPath
:
indexPath
)
let
cell
=
dequeueReusableCell
(
type
:
BannerAdCell
.
self
,
tableView
:
tableView
,
indexPath
:
indexPath
)
cell
.
adView
=
adView
(
for
:
timePeriod
,
indexPath
:
indexPath
)
return
cell
case
.
adMREC
:
let
cell
=
dequeueReusableCell
(
type
:
MRECAdCell
.
self
,
tableView
:
tableView
,
indexPath
:
indexPath
)
cell
.
adView
=
adView
(
for
:
timePeriod
,
indexPath
:
indexPath
)
cell
.
adView
=
adView
(
for
:
timePeriod
,
indexPath
:
indexPath
)
return
cell
return
cell
}
}
...
...
1Weather/UI/View controllers/NWSAlert/Cells/NWSAlertCellFactory.swift
View file @
3b01922f
...
@@ -12,7 +12,8 @@ fileprivate enum NWSAlertCellType: Int {
...
@@ -12,7 +12,8 @@ fileprivate enum NWSAlertCellType: Int {
case
header
=
0
case
header
=
0
case
forecastOffice
case
forecastOffice
case
extendedInfoBlock
case
extendedInfoBlock
case
ad
case
adBanner
case
adMREC
}
}
fileprivate
protocol
NWSAlertTableViewSection
{
fileprivate
protocol
NWSAlertTableViewSection
{
...
@@ -67,11 +68,11 @@ fileprivate struct ExtendedInfoSection: NWSAlertTableViewSection {
...
@@ -67,11 +68,11 @@ fileprivate struct ExtendedInfoSection: NWSAlertTableViewSection {
return
.
extendedInfoBlock
return
.
extendedInfoBlock
}
}
if
numberOfRows
==
1
{
if
numberOfRows
==
1
{
return
.
ad
return
.
ad
Banner
}
}
else
{
else
{
if
row
==
1
{
if
row
==
1
{
return
.
ad
return
.
ad
Banner
}
}
else
{
else
{
return
.
extendedInfoBlock
return
.
extendedInfoBlock
...
@@ -115,7 +116,7 @@ class NWSAlertCellFactory: CellFactoryProtocol {
...
@@ -115,7 +116,7 @@ class NWSAlertCellFactory: CellFactoryProtocol {
}
}
let
adView
=
adViewCache
[
indexPath
]
??
AdView
()
let
adView
=
adViewCache
[
indexPath
]
??
AdView
()
adView
.
loggingAlias
=
"⚠️ Alert Banner"
adView
.
loggingAlias
=
"⚠️ Alert Banner"
adView
.
set
(
placementName
:
placementName
Precipitation
Banner
,
adType
:
.
banner
)
adView
.
set
(
placementName
:
placementName
NWSAlert
Banner
,
adType
:
.
banner
)
adViewCache
[
indexPath
]
=
adView
adViewCache
[
indexPath
]
=
adView
return
adView
return
adView
}
}
...
@@ -124,7 +125,8 @@ class NWSAlertCellFactory: CellFactoryProtocol {
...
@@ -124,7 +125,8 @@ class NWSAlertCellFactory: CellFactoryProtocol {
registerCell
(
type
:
NWSAlertCell
.
self
,
tableView
:
tableView
)
registerCell
(
type
:
NWSAlertCell
.
self
,
tableView
:
tableView
)
registerCell
(
type
:
NWSForecastOfficeTableViewCell
.
self
,
tableView
:
tableView
)
registerCell
(
type
:
NWSForecastOfficeTableViewCell
.
self
,
tableView
:
tableView
)
registerCell
(
type
:
NWSAlertInfoBlockTableViewCell
.
self
,
tableView
:
tableView
)
registerCell
(
type
:
NWSAlertInfoBlockTableViewCell
.
self
,
tableView
:
tableView
)
registerCell
(
type
:
AdCell
.
self
,
tableView
:
tableView
)
registerCell
(
type
:
BannerAdCell
.
self
,
tableView
:
tableView
)
registerCell
(
type
:
MRECAdCell
.
self
,
tableView
:
tableView
)
}
}
func
cellFromTableView
(
tableView
:
UITableView
,
indexPath
:
IndexPath
)
->
UITableViewCell
{
func
cellFromTableView
(
tableView
:
UITableView
,
indexPath
:
IndexPath
)
->
UITableViewCell
{
...
@@ -147,10 +149,14 @@ class NWSAlertCellFactory: CellFactoryProtocol {
...
@@ -147,10 +149,14 @@ class NWSAlertCellFactory: CellFactoryProtocol {
let
extendedInfoBlockCell
=
dequeueReusableCell
(
type
:
NWSAlertInfoBlockTableViewCell
.
self
,
tableView
:
tableView
,
indexPath
:
indexPath
)
let
extendedInfoBlockCell
=
dequeueReusableCell
(
type
:
NWSAlertInfoBlockTableViewCell
.
self
,
tableView
:
tableView
,
indexPath
:
indexPath
)
extendedInfoBlockCell
.
configure
(
with
:
info
)
extendedInfoBlockCell
.
configure
(
with
:
info
)
return
extendedInfoBlockCell
return
extendedInfoBlockCell
case
.
ad
:
case
.
adBanner
:
let
adCell
=
dequeueReusableCell
(
type
:
AdCell
.
self
,
tableView
:
tableView
,
indexPath
:
indexPath
)
let
cell
=
dequeueReusableCell
(
type
:
BannerAdCell
.
self
,
tableView
:
tableView
,
indexPath
:
indexPath
)
adCell
.
adView
=
adView
(
for
:
indexPath
)
cell
.
adView
=
adView
(
for
:
indexPath
)
return
adCell
return
cell
case
.
adMREC
:
let
cell
=
dequeueReusableCell
(
type
:
MRECAdCell
.
self
,
tableView
:
tableView
,
indexPath
:
indexPath
)
cell
.
adView
=
adView
(
for
:
indexPath
)
return
cell
}
}
}
}
...
...
1Weather/UI/View controllers/Today/Cells/TodayCellFactory.swift
View file @
3b01922f
...
@@ -11,7 +11,8 @@ import OneWeatherCore
...
@@ -11,7 +11,8 @@ import OneWeatherCore
public
enum
TodayCellType
:
Int
{
public
enum
TodayCellType
:
Int
{
case
alert
=
0
case
alert
=
0
case
forecast
case
forecast
case
ad
case
adBanner
case
adMREC
case
conditions
case
conditions
case
forecastPeriod
case
forecastPeriod
case
precipitation
case
precipitation
...
@@ -54,9 +55,9 @@ class TodayCellFactory: CellFactoryProtocol {
...
@@ -54,9 +55,9 @@ class TodayCellFactory: CellFactoryProtocol {
private
var
cellsToUpdate
:
CellsToUpdate
=
[
.
condition
,
.
timePeriod
,
.
precipitation
,
.
dayTime
]
private
var
cellsToUpdate
:
CellsToUpdate
=
[
.
condition
,
.
timePeriod
,
.
precipitation
,
.
dayTime
]
private
let
todayViewModel
:
TodayViewModel
private
let
todayViewModel
:
TodayViewModel
private
var
todaySection
=
TodaySection
(
allRows
:
[
.
alert
,
.
forecast
,
.
ad
,
private
var
todaySection
=
TodaySection
(
allRows
:
[
.
alert
,
.
forecast
,
.
ad
Banner
,
.
conditions
,
.
forecastPeriod
,
.
precipitation
,
.
conditions
,
.
forecastPeriod
,
.
precipitation
,
.
airQuality
,
.
dayTime
,
.
sun
,
.
moon
])
.
airQuality
,
.
dayTime
,
.
sun
,
.
moon
,
.
adMREC
])
private
var
adViewCache
=
[
IndexPath
:
AdView
]()
private
var
adViewCache
=
[
IndexPath
:
AdView
]()
...
@@ -76,7 +77,8 @@ class TodayCellFactory: CellFactoryProtocol {
...
@@ -76,7 +77,8 @@ class TodayCellFactory: CellFactoryProtocol {
public
func
registerCells
(
on
tableView
:
UITableView
)
{
public
func
registerCells
(
on
tableView
:
UITableView
)
{
registerCell
(
type
:
TodayAlertCell
.
self
,
tableView
:
tableView
)
registerCell
(
type
:
TodayAlertCell
.
self
,
tableView
:
tableView
)
registerCell
(
type
:
TodayForecastCell
.
self
,
tableView
:
tableView
)
registerCell
(
type
:
TodayForecastCell
.
self
,
tableView
:
tableView
)
registerCell
(
type
:
AdCell
.
self
,
tableView
:
tableView
)
registerCell
(
type
:
BannerAdCell
.
self
,
tableView
:
tableView
)
registerCell
(
type
:
MRECAdCell
.
self
,
tableView
:
tableView
)
registerCell
(
type
:
TodayConditionsCell
.
self
,
tableView
:
tableView
)
registerCell
(
type
:
TodayConditionsCell
.
self
,
tableView
:
tableView
)
registerCell
(
type
:
TodayForecastTimePeriodCell
.
self
,
tableView
:
tableView
)
registerCell
(
type
:
TodayForecastTimePeriodCell
.
self
,
tableView
:
tableView
)
registerCell
(
type
:
PrecipitationCell
.
self
,
tableView
:
tableView
)
registerCell
(
type
:
PrecipitationCell
.
self
,
tableView
:
tableView
)
...
@@ -92,7 +94,11 @@ class TodayCellFactory: CellFactoryProtocol {
...
@@ -92,7 +94,11 @@ class TodayCellFactory: CellFactoryProtocol {
}
}
let
adView
=
AdView
()
let
adView
=
AdView
()
adView
.
loggingAlias
=
"📍 Today Banner"
adView
.
loggingAlias
=
"📍 Today Banner"
adView
.
set
(
placementName
:
placementNameTodayBanner
,
adType
:
.
banner
)
var
adType
=
AdType
.
banner
if
cellType
(
at
:
indexPath
)
==
.
adMREC
{
adType
=
.
square
}
adView
.
set
(
placementName
:
placementNameTodayBanner
,
adType
:
adType
)
adViewCache
[
indexPath
]
=
adView
adViewCache
[
indexPath
]
=
adView
return
adView
return
adView
}
}
...
@@ -117,16 +123,17 @@ class TodayCellFactory: CellFactoryProtocol {
...
@@ -117,16 +123,17 @@ class TodayCellFactory: CellFactoryProtocol {
let
cell
=
dequeueReusableCell
(
type
:
TodayForecastCell
.
self
,
tableView
:
tableView
,
indexPath
:
indexPath
)
let
cell
=
dequeueReusableCell
(
type
:
TodayForecastCell
.
self
,
tableView
:
tableView
,
indexPath
:
indexPath
)
cell
.
configure
(
with
:
loc
)
cell
.
configure
(
with
:
loc
)
return
cell
return
cell
case
.
ad
:
case
.
adBanner
:
let
cell
=
dequeueReusableCell
(
type
:
AdCell
.
self
,
tableView
:
tableView
,
indexPath
:
indexPath
)
let
cell
=
dequeueReusableCell
(
type
:
BannerAdCell
.
self
,
tableView
:
tableView
,
indexPath
:
indexPath
)
cell
.
adView
=
adView
(
for
:
indexPath
)
return
cell
case
.
adMREC
:
let
cell
=
dequeueReusableCell
(
type
:
MRECAdCell
.
self
,
tableView
:
tableView
,
indexPath
:
indexPath
)
cell
.
adView
=
adView
(
for
:
indexPath
)
cell
.
adView
=
adView
(
for
:
indexPath
)
return
cell
return
cell
case
.
conditions
:
case
.
conditions
:
let
cell
=
dequeueReusableCell
(
type
:
TodayConditionsCell
.
self
,
tableView
:
tableView
,
indexPath
:
indexPath
)
let
cell
=
dequeueReusableCell
(
type
:
TodayConditionsCell
.
self
,
tableView
:
tableView
,
indexPath
:
indexPath
)
// if cellsToUpdate.contains(.condition) {
cell
.
configure
(
with
:
loc
)
cell
.
configure
(
with
:
loc
)
// cellsToUpdate.remove(.condition)
// }
return
cell
return
cell
case
.
forecastPeriod
:
case
.
forecastPeriod
:
let
cell
=
dequeueReusableCell
(
type
:
TodayForecastTimePeriodCell
.
self
,
tableView
:
tableView
,
indexPath
:
indexPath
)
let
cell
=
dequeueReusableCell
(
type
:
TodayForecastTimePeriodCell
.
self
,
tableView
:
tableView
,
indexPath
:
indexPath
)
...
@@ -195,7 +202,8 @@ class TodayCellFactory: CellFactoryProtocol {
...
@@ -195,7 +202,8 @@ class TodayCellFactory: CellFactoryProtocol {
var
rowsToHide
=
Set
<
TodayCellType
>
()
var
rowsToHide
=
Set
<
TodayCellType
>
()
if
isAppPro
()
||
!
AdConfigManager
.
shared
.
adConfig
.
adsEnabled
{
if
isAppPro
()
||
!
AdConfigManager
.
shared
.
adConfig
.
adsEnabled
{
rowsToHide
.
insert
(
.
ad
)
rowsToHide
.
insert
(
.
adBanner
)
rowsToHide
.
insert
(
.
adMREC
)
}
}
let
location
=
self
.
todayViewModel
.
location
let
location
=
self
.
todayViewModel
.
location
...
...
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