Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ios 10314-include custom fonts in mistica catalog app #376

Merged
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 48 additions & 0 deletions MisticaCatalog/MisticaCatalog.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,16 @@
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 */; };
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 */; };
8462A7A42C34176400BE8E96 /* Telefonica Sans Regular.otf in Resources */ = {isa = PBXBuildFile; fileRef = 8462A7A12C34176400BE8E96 /* Telefonica Sans Regular.otf */; };
8462A7A52C34176400BE8E96 /* Telefonica Sans Bold.otf in Resources */ = {isa = PBXBuildFile; fileRef = 8462A7A22C34176400BE8E96 /* Telefonica Sans Bold.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 +134,16 @@
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>"; };
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; };
8462A7A12C34176400BE8E96 /* Telefonica Sans Regular.otf */ = {isa = PBXFileReference; lastKnownFileType = file; path = "Telefonica Sans Regular.otf"; sourceTree = "<group>"; };
8462A7A22C34176400BE8E96 /* Telefonica Sans Bold.otf */ = {isa = PBXFileReference; lastKnownFileType = file; path = "Telefonica Sans Bold.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 +259,22 @@
path = Components;
sourceTree = "<group>";
};
84126F702C2C001800ECA607 /* Resources */ = {
isa = PBXGroup;
children = (
84126F762C2C00C500ECA607 /* OnAir-Light.ttf */,
84126F732C2C00C500ECA607 /* OnAir-Medium.ttf */,
84126F742C2C00C500ECA607 /* OnAir-Regular.ttf */,
84126F752C2C00C500ECA607 /* VivoTypeBold.ttf */,
84126F712C2C00C500ECA607 /* VivoTypeLight.ttf */,
84126F722C2C00C500ECA607 /* VivoTypeRegular.ttf */,
8462A7A22C34176400BE8E96 /* Telefonica Sans Bold.otf */,
8462A7A32C34176400BE8E96 /* Telefonica Sans Light.otf */,
8462A7A12C34176400BE8E96 /* Telefonica Sans Regular.otf */,
);
path = Resources;
sourceTree = "<group>";
};
B8E161F82546EF8300DA3743 /* Packages */ = {
isa = PBXGroup;
children = (
Expand All @@ -252,6 +288,7 @@
children = (
B8F98FFD2546C98600DFBFE9 /* Source */,
B8F990552546C99300DFBFE9 /* SupportFiles */,
84126F702C2C001800ECA607 /* Resources */,
B8E161F82546EF8300DA3743 /* Packages */,
B8F98FEB2546C95600DFBFE9 /* Products */,
B8F990612546CAA500DFBFE9 /* Frameworks */,
Expand Down Expand Up @@ -313,6 +350,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 +450,17 @@
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
84126F7B2C2C00C500ECA607 /* VivoTypeBold.ttf in Resources */,
84126F7C2C2C00C500ECA607 /* OnAir-Light.ttf in Resources */,
B8F990302546C98700DFBFE9 /* Assets.xcassets in Resources */,
8462A7A42C34176400BE8E96 /* Telefonica Sans Regular.otf 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 */,
8462A7A52C34176400BE8E96 /* Telefonica Sans Bold.otf in Resources */,
84126F782C2C00C500ECA607 /* VivoTypeRegular.ttf in Resources */,
84126F7A2C2C00C500ECA607 /* OnAir-Regular.ttf in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -472,6 +519,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-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.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please, use DemiBold instead of Bold font weight

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I followed the documentation from Mistica's readme for the implementation of the Telefonica font.
https://github.com/Telefonica/mistica-ios/tree/main/Sources/MisticaCommon/Fonts

However, the brand documentation indicates, as you mentioned, using DemiBold, but it also indicates using Medium. In which cases should I choose the different font types?
Captura de pantalla 2024-07-05 a las 14 01 48

https://brandfactory.telefonica.com/document/483#/nuestra-identidad-visual/tipografia

Copy link
Contributor Author

@L-Trujillo26 L-Trujillo26 Jul 5, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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,90 @@
//
// 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",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't this OnAir-Bold font missing in MisticaCatalog/Resources/ and in the Info.plist UIAppFonts property?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done ! thanks

defaultFont: "OnAir-Regular"
)

case .telefonica, .tu:
return FontMapping(
lightFont: "Telefonica Sans Light",
mediumFont: "Telefonica Sans Bold",
boldFont: "Telefonica Sans Bold",
defaultFont: "Telefonica Sans 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
}
}
}
15 changes: 15 additions & 0 deletions MisticaCatalog/Source/MisticaCatalogApp.swift
yceballost marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ struct MisticaCatalogApp: App {
}
.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 +102,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
12 changes: 12 additions & 0 deletions MisticaCatalog/SupportFiles/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,18 @@
<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>VivoTypeBold.ttf</string>
<string>VivoTypeLight.ttf</string>
<string>VivoTypeRegular.ttf</string>
<string>Telefonica Sans Light.otf</string>
<string>Telefonica Sans Bold.otf</string>
<string>Telefonica Sans Regular.otf</string>
</array>
<key>UIApplicationSceneManifest</key>
<dict>
<key>UIApplicationSupportsMultipleScenes</key>
Expand Down
Loading