Commit 5f4c203c by Demid Merzlyakov

IOS-73: correct fonts for native ads.

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