Commit 5f4c203c by Demid Merzlyakov

IOS-73: correct fonts for native ads.

parent 9243ce65
......@@ -8,6 +8,9 @@
/* Begin PBXBuildFile section */
34EAFD887EF2D1D7449A016C /* Pods_1Weather.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6B543196B99BA697763514F6 /* Pods_1Weather.framework */; };
87B66BEC2667A45800B9A59A /* SF-Compact-Display-Semibold.otf in Resources */ = {isa = PBXBuildFile; fileRef = 87B66BEA2667A44F00B9A59A /* SF-Compact-Display-Semibold.otf */; };
87B66BED2667A45B00B9A59A /* SF-Compact-Display-Regular.otf in Resources */ = {isa = PBXBuildFile; fileRef = 87B66BEB2667A44F00B9A59A /* SF-Compact-Display-Regular.otf */; };
87B66BF12667AF1C00B9A59A /* SF-Compact-Display-Light.otf in Resources */ = {isa = PBXBuildFile; fileRef = 87B66BF02667AF1900B9A59A /* SF-Compact-Display-Light.otf */; };
87C171ED25FF79CC00DA3464 /* LocalConfig.plist in Resources */ = {isa = PBXBuildFile; fileRef = 87C171E925FF79CC00DA3464 /* LocalConfig.plist */; };
87C171F425FF7A4000DA3464 /* PopularCitiesManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 87C171F325FF7A4000DA3464 /* PopularCitiesManager.swift */; };
87C1724925FF94F400DA3464 /* ConfigManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 87C1724825FF94F400DA3464 /* ConfigManager.swift */; };
......@@ -248,6 +251,9 @@
6B543196B99BA697763514F6 /* Pods_1Weather.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_1Weather.framework; sourceTree = BUILT_PRODUCTS_DIR; };
7082B26061BEBA910124DD8A /* Pods-OneWeatherNotificationServiceExtension.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-OneWeatherNotificationServiceExtension.debug.xcconfig"; path = "Target Support Files/Pods-OneWeatherNotificationServiceExtension/Pods-OneWeatherNotificationServiceExtension.debug.xcconfig"; sourceTree = "<group>"; };
871EA87D239E6F89F6F8818E /* Pods_OneWeatherNotificationServiceExtension.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_OneWeatherNotificationServiceExtension.framework; sourceTree = BUILT_PRODUCTS_DIR; };
87B66BEA2667A44F00B9A59A /* SF-Compact-Display-Semibold.otf */ = {isa = PBXFileReference; lastKnownFileType = file; path = "SF-Compact-Display-Semibold.otf"; sourceTree = "<group>"; };
87B66BEB2667A44F00B9A59A /* SF-Compact-Display-Regular.otf */ = {isa = PBXFileReference; lastKnownFileType = file; path = "SF-Compact-Display-Regular.otf"; sourceTree = "<group>"; };
87B66BF02667AF1900B9A59A /* SF-Compact-Display-Light.otf */ = {isa = PBXFileReference; lastKnownFileType = file; path = "SF-Compact-Display-Light.otf"; sourceTree = "<group>"; };
87C171E925FF79CC00DA3464 /* LocalConfig.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = LocalConfig.plist; sourceTree = "<group>"; };
87C171F325FF7A4000DA3464 /* PopularCitiesManager.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PopularCitiesManager.swift; sourceTree = "<group>"; };
87C1724825FF94F400DA3464 /* ConfigManager.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ConfigManager.swift; sourceTree = "<group>"; };
......@@ -983,6 +989,9 @@
CDD0F1E3257240F300CF5017 /* Fonts */ = {
isa = PBXGroup;
children = (
87B66BF02667AF1900B9A59A /* SF-Compact-Display-Light.otf */,
87B66BEB2667A44F00B9A59A /* SF-Compact-Display-Regular.otf */,
87B66BEA2667A44F00B9A59A /* SF-Compact-Display-Semibold.otf */,
CDD0F1E42572425200CF5017 /* SF-Pro.ttf */,
);
path = Fonts;
......@@ -1347,7 +1356,10 @@
87C171ED25FF79CC00DA3464 /* LocalConfig.plist in Resources */,
CE376C98261EE484000B1159 /* LaunchScreen.storyboard in Resources */,
CE13B817262480B3007CBD4D /* NativeBannerView.xib in Resources */,
87B66BEC2667A45800B9A59A /* SF-Compact-Display-Semibold.otf in Resources */,
CE13B88F26248A77007CBD4D /* GoogleService-Info-Staging.plist in Resources */,
87B66BF12667AF1C00B9A59A /* SF-Compact-Display-Light.otf in Resources */,
87B66BED2667A45B00B9A59A /* SF-Compact-Display-Regular.otf in Resources */,
CE13B88E26248A77007CBD4D /* GoogleService-Info-Production.plist in Resources */,
CD1237CC255D5C5C00C98139 /* Assets.xcassets in Resources */,
CD822FFA25D6890900A05501 /* OneWeatherColorsAsset.xcassets in Resources */,
......
......@@ -13,6 +13,23 @@ class NativeBannerView: GADNativeAdView {
@IBOutlet weak var sponsoredLabel: UILabel!
@IBOutlet weak var adChoicesViewCustomOutlet: GADAdChoicesView!
var headlineLabel: UILabel? {
headlineView as? UILabel
}
var advertiserLabel: UILabel? {
advertiserView as? UILabel
}
var iconImageView: UIImageView? {
iconView as? UIImageView
}
var callToActionLabel: UILabel? {
callToActionView as? UILabel
}
class func instantiateWithXib() -> NativeBannerView? {
let nib = UINib(nibName: "\(NativeBannerView.self)", bundle: nil)
let bView = nib.instantiate(withOwner: self, options: nil).first as? NativeBannerView
......@@ -22,15 +39,25 @@ class NativeBannerView: GADNativeAdView {
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
callToActionLabel?.backgroundColor = currentTheme.nativeAdCallToActionColor
callToActionLabel?.layer.cornerRadius = 2
callToActionLabel?.clipsToBounds = true
headlineLabel?.textColor = currentTheme.primaryTextColor
advertiserLabel?.textColor = currentTheme.primaryTextColor
self.adChoicesView = self.adChoicesViewCustomOutlet
sponsoredLabel.text = "ads.native.sponsored".localized()
sponsoredLabel.textColor = currentTheme.primaryTextColor
setupFonts()
}
private func setupFonts() {
callToActionLabel?.font = AppFont.SFCompactDisplay.regular(size: 10)
sponsoredLabel.font = AppFont.SFCompactDisplay.regular(size: 10)
headlineLabel?.font = AppFont.SFCompactDisplay.semibold(size: 18)
advertiserLabel?.font = AppFont.SFCompactDisplay.regular(size: 12)
callToActionLabel?.font = AppFont.SFCompactDisplay.light(size: 10)
}
var nativeAdItem: NativeAdItem? {
......@@ -44,10 +71,10 @@ class NativeBannerView: GADNativeAdView {
}
private func setupView() {
(headlineView as? UILabel)?.text = nativeAd?.headline
(iconView as? UIImageView)?.image = nativeAd?.icon?.image
(advertiserView as? UILabel)?.text = nativeAd?.advertiser
(callToActionView as? UILabel)?.text = nativeAd?.callToAction
headlineLabel?.text = nativeAd?.headline
iconImageView?.image = nativeAd?.icon?.image
advertiserLabel?.text = nativeAd?.advertiser
callToActionLabel?.text = nativeAd?.callToAction
setupPostXib()
}
......
......@@ -393,6 +393,9 @@
<key>UIAppFonts</key>
<array>
<string>SF-Pro.ttf</string>
<string>SF-Compact-Display-Light.otf</string>
<string>SF-Compact-Display-Regular.otf</string>
<string>SF-Compact-Display-Semibold.otf</string>
</array>
<key>UIApplicationSupportsIndirectInputEvents</key>
<true/>
......
......@@ -8,10 +8,10 @@
import UIKit
public struct AppFont {
private static func fontDescriptor(size:CGFloat, weight:UIFont.Weight) -> UIFontDescriptor {
private static func fontDescriptor(family: String, size:CGFloat, weight:UIFont.Weight) -> UIFontDescriptor {
let traitsDict = [UIFontDescriptor.TraitKey.weight: weight]
let descriptor = UIFontDescriptor(fontAttributes: [UIFontDescriptor.AttributeName.size : size,
UIFontDescriptor.AttributeName.family : "SF Pro",
UIFontDescriptor.AttributeName.family : family,
UIFontDescriptor.AttributeName.traits : traitsDict
])
......@@ -25,7 +25,7 @@ public struct AppFont {
if let cached = fontCache[weigth]?[size] {
return cached
}
let descriptor = AppFont.fontDescriptor(size: size, weight: weigth)
let descriptor = AppFont.fontDescriptor(family: "SF Pro", size: size, weight: weigth)
let font = UIFont(descriptor: descriptor, size: size)
if fontCache[weigth] == nil {
fontCache[weigth] = [size: font]
......@@ -52,4 +52,35 @@ public struct AppFont {
font(weigth: .semibold, size: size)
}
}
public struct SFCompactDisplay {
private static var fontCache = [UIFont.Weight: [CGFloat: UIFont]]()
static func font(weigth: UIFont.Weight, size: CGFloat) -> UIFont {
if let cached = fontCache[weigth]?[size] {
return cached
}
let descriptor = AppFont.fontDescriptor(family: "SF Compact Display", size: size, weight: weigth)
let font = UIFont(descriptor: descriptor, size: size)
if fontCache[weigth] == nil {
fontCache[weigth] = [size: font]
}
else {
fontCache[weigth]![size] = font
}
return font
}
static func light(size: CGFloat) -> UIFont {
font(weigth: .light, size: size)
}
static func regular(size: CGFloat) -> UIFont {
font(weigth: .regular, size: size)
}
static func semibold(size: CGFloat) -> UIFont {
font(weigth: .semibold, size: size)
}
}
}
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