Commit 80b5e714 by Demid Merzlyakov

IOS-73: native ad layout.

parent a3a4eb93
......@@ -10,14 +10,33 @@ import Foundation
import GoogleMobileAds
class BRNativeBannerView: GADNativeAdView {
@IBOutlet weak var sponsoredLabel: UILabel!
@IBOutlet weak var adChoicesViewCustomOutlet: GADAdChoicesView!
class func instantiateWithXib() -> BRNativeBannerView? {
let nib = UINib(nibName: "\(BRNativeBannerView.self)", bundle: nil)
let bView = nib.instantiate(withOwner: self, options: nil).first as? BRNativeBannerView
bView?.setupPostXib()
return bView
}
private func setupPostXib() {
let currentTheme = ThemeManager.currentTheme
self.callToActionView?.backgroundColor = currentTheme.nativeAdCallToActionColor
self.callToActionView?.layer.cornerRadius = 2
self.callToActionView?.clipsToBounds = true
(self.headlineView as? UILabel)?.textColor = currentTheme.primaryTextColor
(self.advertiserView as? UILabel)?.textColor = currentTheme.primaryTextColor
self.adChoicesView = self.adChoicesViewCustomOutlet
sponsoredLabel.text = "ads.native.sponsored".localized()
sponsoredLabel.textColor = currentTheme.primaryTextColor
}
var nativeAdItem: NativeAdItem? {
willSet {
self.adChoicesView = self.adChoicesViewCustomOutlet
}
didSet {
nativeAd = nativeAdItem?.nativeAd
setupView()
......@@ -29,6 +48,7 @@ class BRNativeBannerView: GADNativeAdView {
(iconView as? UIImageView)?.image = nativeAd?.icon?.image
(advertiserView as? UILabel)?.text = nativeAd?.advertiser
(callToActionView as? UILabel)?.text = nativeAd?.callToAction
setupPostXib()
}
}
......
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="16097" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
<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="16087"/>
<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>
<customFonts key="customFonts">
<array key="SF-Pro.ttf">
<string>SFPro-Regular</string>
<string>SFPro-Semibold</string>
</array>
</customFonts>
<objects>
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner"/>
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
<view contentMode="scaleToFill" id="iN0-l3-epB" customClass="BRNativeBannerView" customModule="BaconReader" customModuleProvider="target">
<rect key="frame" x="0.0" y="0.0" width="320" height="50"/>
<view contentMode="scaleToFill" id="iN0-l3-epB" customClass="BRNativeBannerView" customModule="_Weather" customModuleProvider="target">
<rect key="frame" x="0.0" y="0.0" width="320" height="64"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="eaA-5a-cX3">
<rect key="frame" x="0.0" y="0.0" width="60" height="50"/>
<rect key="frame" x="12" y="9" width="40" height="40"/>
<constraints>
<constraint firstAttribute="width" constant="60" id="IvN-D3-kN1"/>
<constraint firstAttribute="width" constant="40" id="6ZZ-jb-7ZN"/>
<constraint firstAttribute="height" constant="40" id="ant-Au-KVU"/>
</constraints>
</imageView>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="1000" verticalCompressionResistancePriority="1000" placeholderIntrinsicWidth="148" placeholderIntrinsicHeight="15" text="Label" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="VsC-Xg-upl">
<rect key="frame" x="68" y="8" width="164" height="15"/>
<fontDescription key="fontDescription" type="system" pointSize="12"/>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="1000" verticalCompressionResistancePriority="1000" placeholderIntrinsicWidth="148" placeholderIntrinsicHeight="15" text="Label" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" preferredMaxLayoutWidth="149" translatesAutoresizingMaskIntoConstraints="NO" id="VsC-Xg-upl">
<rect key="frame" x="64" y="11" width="148" height="15"/>
<fontDescription key="fontDescription" name="SFPro-Semibold" family="SF Pro" pointSize="18"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" verticalCompressionResistancePriority="1000" placeholderIntrinsicWidth="148" placeholderIntrinsicHeight="12" text="Label" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="lTc-8y-qle">
<rect key="frame" x="68" y="27" width="164" height="15"/>
<fontDescription key="fontDescription" type="system" pointSize="12"/>
<rect key="frame" x="64" y="29" width="167" height="12"/>
<fontDescription key="fontDescription" name="SFPro-Regular" family="SF Pro" pointSize="12"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="ugd-1P-6ea">
<rect key="frame" x="240" y="0.0" width="80" height="50"/>
<rect key="frame" x="239" y="27" width="69" height="22"/>
<color key="backgroundColor" red="0.066666666666666666" green="0.49803921568627452" blue="1" alpha="1" colorSpace="calibratedRGB"/>
<constraints>
<constraint firstAttribute="width" constant="80" id="cDN-Y8-VOr"/>
<constraint firstAttribute="height" constant="22" id="WS5-UR-JYL"/>
<constraint firstAttribute="width" constant="69" id="t8x-Db-p3Z"/>
</constraints>
<fontDescription key="fontDescription" type="system" pointSize="12"/>
<color key="textColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Sponsored" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="XLW-zy-iAT">
<rect key="frame" x="244" y="6" width="52" height="12"/>
<fontDescription key="fontDescription" type="system" pointSize="10"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
<view contentMode="scaleToFill" horizontalCompressionResistancePriority="1000" translatesAutoresizingMaskIntoConstraints="NO" id="28Q-DN-nbV" customClass="GADAdChoicesView">
<rect key="frame" x="300" y="7.5" width="8" height="9"/>
<color key="backgroundColor" systemColor="systemBackgroundColor"/>
<constraints>
<constraint firstAttribute="width" relation="greaterThanOrEqual" constant="8" id="I4w-tj-TCL"/>
<constraint firstAttribute="width" priority="250" constant="8" id="ag4-wU-uBL"/>
<constraint firstAttribute="height" constant="9" id="ltQ-ay-EqL"/>
</constraints>
</view>
</subviews>
<color key="backgroundColor" systemColor="systemBackgroundColor" cocoaTouchSystemColor="whiteColor"/>
<viewLayoutGuide key="safeArea" id="vUN-kp-3ea"/>
<color key="backgroundColor" systemColor="systemBackgroundColor"/>
<constraints>
<constraint firstItem="VsC-Xg-upl" firstAttribute="top" secondItem="iN0-l3-epB" secondAttribute="top" constant="8" id="8Dj-HX-wth"/>
<constraint firstItem="VsC-Xg-upl" firstAttribute="leading" secondItem="eaA-5a-cX3" secondAttribute="trailing" constant="8" id="I0z-Nl-GLm"/>
<constraint firstItem="vUN-kp-3ea" firstAttribute="bottom" secondItem="eaA-5a-cX3" secondAttribute="bottom" id="Ixm-4U-KsW"/>
<constraint firstItem="ugd-1P-6ea" firstAttribute="leading" secondItem="VsC-Xg-upl" secondAttribute="trailing" constant="8" id="JGt-cR-nRx"/>
<constraint firstItem="vUN-kp-3ea" firstAttribute="bottom" secondItem="lTc-8y-qle" secondAttribute="bottom" constant="8" id="JS0-89-xm1"/>
<constraint firstItem="lTc-8y-qle" firstAttribute="top" secondItem="VsC-Xg-upl" secondAttribute="bottom" constant="4" id="NLk-O1-U3Q"/>
<constraint firstItem="eaA-5a-cX3" firstAttribute="top" secondItem="iN0-l3-epB" secondAttribute="top" id="SdU-tC-7IC"/>
<constraint firstItem="eaA-5a-cX3" firstAttribute="leading" secondItem="vUN-kp-3ea" secondAttribute="leading" id="Wmr-hd-DEw"/>
<constraint firstItem="lTc-8y-qle" firstAttribute="leading" secondItem="eaA-5a-cX3" secondAttribute="trailing" constant="8" id="Xon-27-Iwc"/>
<constraint firstItem="vUN-kp-3ea" firstAttribute="bottom" secondItem="ugd-1P-6ea" secondAttribute="bottom" id="ZpJ-el-ui6"/>
<constraint firstAttribute="trailing" secondItem="ugd-1P-6ea" secondAttribute="trailing" id="aR1-OF-dyw"/>
<constraint firstItem="ugd-1P-6ea" firstAttribute="leading" secondItem="lTc-8y-qle" secondAttribute="trailing" constant="8" id="hrG-SE-D7R"/>
<constraint firstItem="ugd-1P-6ea" firstAttribute="top" secondItem="iN0-l3-epB" secondAttribute="top" id="i9E-Fz-ouY"/>
<constraint firstItem="eaA-5a-cX3" firstAttribute="leading" secondItem="iN0-l3-epB" secondAttribute="leading" constant="12" id="1rN-7b-aQR"/>
<constraint firstItem="eaA-5a-cX3" firstAttribute="top" secondItem="iN0-l3-epB" secondAttribute="top" constant="9" id="5pq-Tc-Urj"/>
<constraint firstItem="lTc-8y-qle" firstAttribute="leading" secondItem="VsC-Xg-upl" secondAttribute="leading" id="7F4-Td-70H"/>
<constraint firstItem="VsC-Xg-upl" firstAttribute="top" secondItem="iN0-l3-epB" secondAttribute="top" constant="11" id="8Dj-HX-wth"/>
<constraint firstItem="XLW-zy-iAT" firstAttribute="leading" relation="greaterThanOrEqual" secondItem="VsC-Xg-upl" secondAttribute="trailing" constant="8" id="GKr-05-hYa"/>
<constraint firstItem="ugd-1P-6ea" firstAttribute="leading" relation="greaterThanOrEqual" secondItem="VsC-Xg-upl" secondAttribute="trailing" constant="8" id="IOw-O0-6AH"/>
<constraint firstItem="lTc-8y-qle" firstAttribute="top" secondItem="VsC-Xg-upl" secondAttribute="bottom" constant="3" id="Iil-e1-IEN"/>
<constraint firstAttribute="trailing" secondItem="28Q-DN-nbV" secondAttribute="trailing" constant="12" id="MSw-KS-ywK"/>
<constraint firstItem="XLW-zy-iAT" firstAttribute="top" secondItem="iN0-l3-epB" secondAttribute="top" constant="6" id="R8L-eY-ClU"/>
<constraint firstAttribute="trailing" secondItem="ugd-1P-6ea" secondAttribute="trailing" constant="12" id="Z80-qh-oZo"/>
<constraint firstItem="VsC-Xg-upl" firstAttribute="leading" secondItem="eaA-5a-cX3" secondAttribute="trailing" constant="12" id="hkh-dD-Vac"/>
<constraint firstAttribute="bottom" secondItem="ugd-1P-6ea" secondAttribute="bottom" constant="15" id="iEk-zr-gKO"/>
<constraint firstItem="ugd-1P-6ea" firstAttribute="leading" secondItem="lTc-8y-qle" secondAttribute="trailing" constant="8" id="qdU-J6-PCw"/>
<constraint firstItem="28Q-DN-nbV" firstAttribute="centerY" secondItem="XLW-zy-iAT" secondAttribute="centerY" id="y1m-tp-3KF"/>
<constraint firstItem="28Q-DN-nbV" firstAttribute="leading" secondItem="XLW-zy-iAT" secondAttribute="trailing" constant="4" id="ygk-Yg-8jR"/>
</constraints>
<freeformSimulatedSizeMetrics key="simulatedDestinationMetrics"/>
<viewLayoutGuide key="safeArea" id="vUN-kp-3ea"/>
<connections>
<outlet property="adChoicesViewCustomOutlet" destination="28Q-DN-nbV" id="yYZ-Vw-lAB"/>
<outlet property="advertiserView" destination="lTc-8y-qle" id="zFU-6W-SBX"/>
<outlet property="callToActionView" destination="ugd-1P-6ea" id="VBG-Fk-Pn7"/>
<outlet property="headlineView" destination="VsC-Xg-upl" id="pHO-sW-gXV"/>
<outlet property="iconView" destination="eaA-5a-cX3" id="4P6-sq-Gob"/>
<outlet property="sponsoredLabel" destination="XLW-zy-iAT" id="EZ2-qJ-eFP"/>
</connections>
<point key="canvasLocation" x="214.49275362318843" y="-152.00892857142856"/>
</view>
</objects>
<resources>
<systemColor name="systemBackgroundColor">
<color white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
</systemColor>
</resources>
</document>
{
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"images" : [
{
"filename" : "group4Copy2.pdf",
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
},
"properties" : {
"template-rendering-intent" : "template"
}
}
{
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"colors" : [
{
"color" : {
"color-space" : "display-p3",
"components" : {
"alpha" : "1.000",
"blue" : "0.286",
"green" : "0.434",
"red" : "0.182"
}
},
"idiom" : "universal"
},
{
"appearances" : [
{
"appearance" : "luminosity",
"value" : "dark"
}
],
"color" : {
"color-space" : "display-p3",
"components" : {
"alpha" : "1.000",
"blue" : "0.286",
"green" : "0.434",
"red" : "0.182"
}
},
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
......@@ -268,3 +268,6 @@
// Humidity type, for smart texts
"humidity.type.high" = "high";
"humidity.type.low" = "low";
// Ads
"ads.native.sponsored" = "Sponsored";
......@@ -115,4 +115,9 @@ struct DefaultTheme: ThemeProtocol {
var mapControlsColor: UIColor {
return UIColor(named: "map_controls_color") ?? .red
}
//Ads
var nativeAdCallToActionColor: UIColor {
return UIColor(named: "native_ad_call_to_action_background") ?? .red
}
}
......@@ -49,4 +49,7 @@ public protocol ThemeProtocol {
//Map
var mapControlsColor:UIColor { get }
//Ads
var nativeAdCallToActionColor: UIColor { get }
}
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