Skip to content

Commit

Permalink
chore(MisticaCatalog): IOS-10314 include custom fonts in mistica cata…
Browse files Browse the repository at this point in the history
…log app (#376)

* IOS-10314 include custom fonts in Mistica Catalog app

* Run swiftformat

* IOS-10314 included fonts for exhaustive use cases

* Run swiftformat

* IOS-10314 modified implementacion for brand font style configuration and added telefonica and tu font

* Run swiftformat

* IOS-10314 fix font implementation issues

* Run swiftformat

* IOS-10314 fix telefonica font name

* Run swiftformat

---------

Co-authored-by: L-Trujillo26 <[email protected]>
  • Loading branch information
L-Trujillo26 and L-Trujillo26 authored Jul 12, 2024
1 parent ecfc7fa commit 3bff3a6
Show file tree
Hide file tree
Showing 14 changed files with 166 additions and 0 deletions.
52 changes: 52 additions & 0 deletions MisticaCatalog/MisticaCatalog.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,17 @@
18E485A6287F19EB0052A6F2 /* UICatalogHeaderViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 18E48577287F19EB0052A6F2 /* UICatalogHeaderViewController.swift */; };
392E03DC28C6153C0081780B /* UICatalogSheetViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 392E03DB28C6153C0081780B /* UICatalogSheetViewController.swift */; };
3968C75E28C9E19600561194 /* UIStepperTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3968C75D28C9E19600561194 /* UIStepperTableViewCell.swift */; };
84038E0A2C38382E003E90F6 /* Telefonica Sans Regular.otf in Resources */ = {isa = PBXBuildFile; fileRef = 84038E092C38382E003E90F6 /* Telefonica Sans Regular.otf */; };
84126F772C2C00C500ECA607 /* VivoTypeLight.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 84126F712C2C00C500ECA607 /* VivoTypeLight.ttf */; };
84126F782C2C00C500ECA607 /* VivoTypeRegular.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 84126F722C2C00C500ECA607 /* VivoTypeRegular.ttf */; };
84126F792C2C00C500ECA607 /* OnAir-Medium.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 84126F732C2C00C500ECA607 /* OnAir-Medium.ttf */; };
84126F7A2C2C00C500ECA607 /* OnAir-Regular.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 84126F742C2C00C500ECA607 /* OnAir-Regular.ttf */; };
84126F7B2C2C00C500ECA607 /* VivoTypeBold.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 84126F752C2C00C500ECA607 /* VivoTypeBold.ttf */; };
84126F7C2C2C00C500ECA607 /* OnAir-Light.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 84126F762C2C00C500ECA607 /* OnAir-Light.ttf */; };
843681FE2C36E48B007B30C4 /* BrandStyle+FontMapping.swift in Sources */ = {isa = PBXBuildFile; fileRef = 843681FD2C36E48B007B30C4 /* BrandStyle+FontMapping.swift */; };
84388C212C380B78007606B3 /* OnAir-Bold.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 84388C202C380B78007606B3 /* OnAir-Bold.ttf */; };
84388C232C380E0D007606B3 /* Telefonica Sans DemiBold.otf in Resources */ = {isa = PBXBuildFile; fileRef = 84388C222C380E0D007606B3 /* Telefonica Sans DemiBold.otf */; };
8462A7A62C34176400BE8E96 /* Telefonica Sans Light.otf in Resources */ = {isa = PBXBuildFile; fileRef = 8462A7A32C34176400BE8E96 /* Telefonica Sans Light.otf */; };
B8EE89F22614B57600F79386 /* AppCenterDistribute in Frameworks */ = {isa = PBXBuildFile; productRef = B8EE89F12614B57600F79386 /* AppCenterDistribute */; };
B8F9902C2546C98600DFBFE9 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = B8F98FFE2546C98600DFBFE9 /* LaunchScreen.storyboard */; };
B8F990302546C98700DFBFE9 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = B8F990032546C98600DFBFE9 /* Assets.xcassets */; };
Expand Down Expand Up @@ -124,6 +135,17 @@
18E48577287F19EB0052A6F2 /* UICatalogHeaderViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = UICatalogHeaderViewController.swift; sourceTree = "<group>"; };
392E03DB28C6153C0081780B /* UICatalogSheetViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UICatalogSheetViewController.swift; sourceTree = "<group>"; };
3968C75D28C9E19600561194 /* UIStepperTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UIStepperTableViewCell.swift; sourceTree = "<group>"; };
84038E092C38382E003E90F6 /* Telefonica Sans Regular.otf */ = {isa = PBXFileReference; lastKnownFileType = file; path = "Telefonica Sans Regular.otf"; sourceTree = "<group>"; };
84126F712C2C00C500ECA607 /* VivoTypeLight.ttf */ = {isa = PBXFileReference; lastKnownFileType = file; path = VivoTypeLight.ttf; sourceTree = "<group>"; };
84126F722C2C00C500ECA607 /* VivoTypeRegular.ttf */ = {isa = PBXFileReference; lastKnownFileType = file; path = VivoTypeRegular.ttf; sourceTree = "<group>"; };
84126F732C2C00C500ECA607 /* OnAir-Medium.ttf */ = {isa = PBXFileReference; lastKnownFileType = file; path = "OnAir-Medium.ttf"; sourceTree = "<group>"; };
84126F742C2C00C500ECA607 /* OnAir-Regular.ttf */ = {isa = PBXFileReference; lastKnownFileType = file; path = "OnAir-Regular.ttf"; sourceTree = "<group>"; };
84126F752C2C00C500ECA607 /* VivoTypeBold.ttf */ = {isa = PBXFileReference; lastKnownFileType = file; path = VivoTypeBold.ttf; sourceTree = "<group>"; };
84126F762C2C00C500ECA607 /* OnAir-Light.ttf */ = {isa = PBXFileReference; lastKnownFileType = file; path = "OnAir-Light.ttf"; sourceTree = "<group>"; };
843681FD2C36E48B007B30C4 /* BrandStyle+FontMapping.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "BrandStyle+FontMapping.swift"; sourceTree = "<group>"; wrapsLines = 0; };
84388C202C380B78007606B3 /* OnAir-Bold.ttf */ = {isa = PBXFileReference; lastKnownFileType = file; path = "OnAir-Bold.ttf"; sourceTree = "<group>"; };
84388C222C380E0D007606B3 /* Telefonica Sans DemiBold.otf */ = {isa = PBXFileReference; lastKnownFileType = file; path = "Telefonica Sans DemiBold.otf"; sourceTree = "<group>"; };
8462A7A32C34176400BE8E96 /* Telefonica Sans Light.otf */ = {isa = PBXFileReference; lastKnownFileType = file; path = "Telefonica Sans Light.otf"; sourceTree = "<group>"; };
B8E161F92546EF9500DA3743 /* mistica-ios */ = {isa = PBXFileReference; lastKnownFileType = folder; name = "mistica-ios"; path = ..; sourceTree = "<group>"; };
B8F98FEA2546C95600DFBFE9 /* MisticaCatalog.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = MisticaCatalog.app; sourceTree = BUILT_PRODUCTS_DIR; };
B8F98FFE2546C98600DFBFE9 /* LaunchScreen.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; path = LaunchScreen.storyboard; sourceTree = "<group>"; };
Expand Down Expand Up @@ -239,6 +261,23 @@
path = Components;
sourceTree = "<group>";
};
84126F702C2C001800ECA607 /* Resources */ = {
isa = PBXGroup;
children = (
84126F762C2C00C500ECA607 /* OnAir-Light.ttf */,
84126F732C2C00C500ECA607 /* OnAir-Medium.ttf */,
84126F742C2C00C500ECA607 /* OnAir-Regular.ttf */,
84388C202C380B78007606B3 /* OnAir-Bold.ttf */,
84126F712C2C00C500ECA607 /* VivoTypeLight.ttf */,
84126F722C2C00C500ECA607 /* VivoTypeRegular.ttf */,
84126F752C2C00C500ECA607 /* VivoTypeBold.ttf */,
8462A7A32C34176400BE8E96 /* Telefonica Sans Light.otf */,
84038E092C38382E003E90F6 /* Telefonica Sans Regular.otf */,
84388C222C380E0D007606B3 /* Telefonica Sans DemiBold.otf */,
);
path = Resources;
sourceTree = "<group>";
};
B8E161F82546EF8300DA3743 /* Packages */ = {
isa = PBXGroup;
children = (
Expand All @@ -252,6 +291,7 @@
children = (
B8F98FFD2546C98600DFBFE9 /* Source */,
B8F990552546C99300DFBFE9 /* SupportFiles */,
84126F702C2C001800ECA607 /* Resources */,
B8E161F82546EF8300DA3743 /* Packages */,
B8F98FEB2546C95600DFBFE9 /* Products */,
B8F990612546CAA500DFBFE9 /* Frameworks */,
Expand Down Expand Up @@ -313,6 +353,7 @@
B8F9900D2546C98600DFBFE9 /* Optional+Utils.swift */,
B8F9900E2546C98600DFBFE9 /* UIImage+Utils.swift */,
B8F9900F2546C98600DFBFE9 /* Bundle+MisticaCatalog.swift */,
843681FD2C36E48B007B30C4 /* BrandStyle+FontMapping.swift */,
);
path = Extensions;
sourceTree = "<group>";
Expand Down Expand Up @@ -412,8 +453,18 @@
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
84126F7B2C2C00C500ECA607 /* VivoTypeBold.ttf in Resources */,
84388C212C380B78007606B3 /* OnAir-Bold.ttf in Resources */,
84388C232C380E0D007606B3 /* Telefonica Sans DemiBold.otf in Resources */,
84038E0A2C38382E003E90F6 /* Telefonica Sans Regular.otf in Resources */,
84126F7C2C2C00C500ECA607 /* OnAir-Light.ttf in Resources */,
B8F990302546C98700DFBFE9 /* Assets.xcassets in Resources */,
B8F9902C2546C98600DFBFE9 /* LaunchScreen.storyboard in Resources */,
84126F772C2C00C500ECA607 /* VivoTypeLight.ttf in Resources */,
8462A7A62C34176400BE8E96 /* Telefonica Sans Light.otf in Resources */,
84126F792C2C00C500ECA607 /* OnAir-Medium.ttf in Resources */,
84126F782C2C00C500ECA607 /* VivoTypeRegular.ttf in Resources */,
84126F7A2C2C00C500ECA607 /* OnAir-Regular.ttf in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -472,6 +523,7 @@
18E4858B287F19EB0052A6F2 /* TagCatalogView.swift in Sources */,
18E485A6287F19EB0052A6F2 /* UICatalogHeaderViewController.swift in Sources */,
B8F990362546C98700DFBFE9 /* UITableViewCell+Utils.swift in Sources */,
843681FE2C36E48B007B30C4 /* BrandStyle+FontMapping.swift in Sources */,
18E48593287F19EB0052A6F2 /* UICatalogEmptyStateViewController.swift in Sources */,
B8F990332546C98700DFBFE9 /* UIView+Utils.swift in Sources */,
18E4858A287F19EB0052A6F2 /* BadgeCatalogView.swift in Sources */,
Expand Down
Binary file added MisticaCatalog/Resources/OnAir-Bold.ttf
Binary file not shown.
Binary file added MisticaCatalog/Resources/OnAir-Light.ttf
Binary file not shown.
Binary file added MisticaCatalog/Resources/OnAir-Medium.ttf
Binary file not shown.
Binary file added MisticaCatalog/Resources/OnAir-Regular.ttf
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added MisticaCatalog/Resources/VivoTypeBold.ttf
Binary file not shown.
Binary file added MisticaCatalog/Resources/VivoTypeLight.ttf
Binary file not shown.
Binary file added MisticaCatalog/Resources/VivoTypeRegular.ttf
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
//
// BrandStyle+FontMapping.swift
//
// Made with ❤️ by Novum
//
// Copyright © Telefonica. All rights reserved.
//

import Mistica
import SwiftUI
import UIKit

extension BrandStyle {
// A computed property that returns the corresponding FontMapping for the brand style.
var fontMapping: FontMapping? {
switch self {
case .vivoNew:
return FontMapping(
lightFont: "VivoType-Light",
mediumFont: "VivoType-Bold",
boldFont: "VivoType-Bold",
defaultFont: "VivoType-Regular"
)
case .o2, .o2New, .movistar:
return FontMapping(
lightFont: "OnAir-Light",
mediumFont: "OnAir",
boldFont: "OnAir-Bold",
defaultFont: "OnAir-Regular"
)

case .telefonica, .tu:
return FontMapping(
lightFont: "TeleSans-Light",
mediumFont: "TeleSans-DemiBold",
boldFont: "TeleSans-DemiBold",
defaultFont: "TeleSans-Regular"
)
case .vivo, .blau, .custom:
return nil
}
}
}

// A struct representing a mapping of font names to different font weights.
struct FontMapping {
let lightFont: String
let mediumFont: String
let boldFont: String
let defaultFont: String

/// Returns the font name for the specified weight.
///
/// Parameter weight: The `Font.Weight` for which to get the font name.
/// Returns: The font name corresponding to the given weight.
func fontName(for weight: Font.Weight) -> String {
switch weight {
case .light, .ultraLight, .thin:
return lightFont
case .medium:
return mediumFont
case .bold, .semibold, .black, .heavy:
return boldFont
default:
return defaultFont
}
}

/// Returns the font name for the specified weight.
///
/// Parameter weight: The `UIFont.Weight` for which to get the font name.
/// Returns: The font name corresponding to the given weight.
func UIfontName(for weight: UIFont.Weight) -> String {
switch weight {
case .light, .ultraLight, .thin:
return lightFont
case .medium:
return mediumFont
case .bold, .semibold, .black, .heavy:
return boldFont
default:
return defaultFont
}
}
}
16 changes: 16 additions & 0 deletions MisticaCatalog/Source/MisticaCatalogApp.swift
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,11 @@ struct MisticaCatalogApp: App {
.misticaTabViewStyle()
.onAppear {
setUpAppearance()
configureFontStyle(for: brands[selectedBrandIndex])
}
.onChange(of: selectedBrandIndex, perform: { selectedBrandIndex in
MisticaConfig.brandStyle = brands[selectedBrandIndex]
configureFontStyle(for: brands[selectedBrandIndex])
withAnimation { reloadId = UUID() }
})
.id(reloadId)
Expand Down Expand Up @@ -101,6 +103,20 @@ struct MisticaCatalogApp: App {
UINavigationBar.appearance().scrollEdgeAppearance = appearance
UINavigationBar.appearance().tintColor = .misticaCatalogTint | .white
}

func configureFontStyle(for brandStyle: BrandStyle) {
if let mapping = brandStyle.fontMapping {
FontStyle.fontNameForWeight = { weight in
mapping.fontName(for: weight)
}
FontStyle.uiFontNameForWeight = { weight in
mapping.UIfontName(for: weight)
}
} else {
FontStyle.fontNameForWeight = nil
FontStyle.uiFontNameForWeight = nil
}
}
}

extension UIColor {
Expand Down
13 changes: 13 additions & 0 deletions MisticaCatalog/SupportFiles/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,19 @@
<string>$(CURRENT_PROJECT_VERSION)</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>UIAppFonts</key>
<array>
<string>OnAir-Light.ttf</string>
<string>OnAir-Medium.ttf</string>
<string>OnAir-Regular.ttf</string>
<string>OnAir-Bold.ttf</string>
<string>VivoTypeBold.ttf</string>
<string>VivoTypeLight.ttf</string>
<string>VivoTypeRegular.ttf</string>
<string>Telefonica Sans Light.otf</string>
<string>Telefonica Sans Regular.otf</string>
<string>Telefonica Sans DemiBold.otf</string>
</array>
<key>UIApplicationSceneManifest</key>
<dict>
<key>UIApplicationSupportsMultipleScenes</key>
Expand Down

0 comments on commit 3bff3a6

Please sign in to comment.