-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(MisticaCatalog): IOS-10314 include custom fonts in mistica cata…
…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
1 parent
ecfc7fa
commit 3bff3a6
Showing
14 changed files
with
166 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
85 changes: 85 additions & 0 deletions
85
MisticaCatalog/Source/Common/Extensions/BrandStyle+FontMapping.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters