refactored
Signed-off-by: Matt Bruce <matt.bruce@verizon.com>
This commit is contained in:
parent
20895847ed
commit
2eac9edc24
@ -27,8 +27,6 @@
|
||||
EA3361C328902D960071C351 /* VDSToggle.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA3361C228902D960071C351 /* VDSToggle.swift */; };
|
||||
EA3361C5289030FC0071C351 /* Accessable.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA3361C4289030FC0071C351 /* Accessable.swift */; };
|
||||
EA3361C9289054C50071C351 /* Surfaceable.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA3361C8289054C50071C351 /* Surfaceable.swift */; };
|
||||
EA3361E12891D1110071C351 /* TypographyProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA3361E02891D1110071C351 /* TypographyProtocol.swift */; };
|
||||
EA3361E32891D1860071C351 /* FontWeight.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA3361E22891D1860071C351 /* FontWeight.swift */; };
|
||||
EA3361F42891D5290071C351 /* VDSTypographyTokens.xcframework in Frameworks */ = {isa = PBXBuildFile; fileRef = EA3361F32891D5290071C351 /* VDSTypographyTokens.xcframework */; };
|
||||
EA3362042891E14D0071C351 /* VerizonNHGeTX-Bold.otf in Resources */ = {isa = PBXBuildFile; fileRef = EA3362002891E14C0071C351 /* VerizonNHGeTX-Bold.otf */; };
|
||||
EA3362052891E14D0071C351 /* VerizonNHGeDS-Bold.otf in Resources */ = {isa = PBXBuildFile; fileRef = EA3362012891E14D0071C351 /* VerizonNHGeDS-Bold.otf */; };
|
||||
@ -72,8 +70,6 @@
|
||||
EA3361C228902D960071C351 /* VDSToggle.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VDSToggle.swift; sourceTree = "<group>"; };
|
||||
EA3361C4289030FC0071C351 /* Accessable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Accessable.swift; sourceTree = "<group>"; };
|
||||
EA3361C8289054C50071C351 /* Surfaceable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Surfaceable.swift; sourceTree = "<group>"; };
|
||||
EA3361E02891D1110071C351 /* TypographyProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TypographyProtocol.swift; sourceTree = "<group>"; };
|
||||
EA3361E22891D1860071C351 /* FontWeight.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FontWeight.swift; sourceTree = "<group>"; };
|
||||
EA3361F32891D5290071C351 /* VDSTypographyTokens.xcframework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcframework; name = VDSTypographyTokens.xcframework; path = ../SharedFrameworks/VDSTypographyTokens.xcframework; sourceTree = "<group>"; };
|
||||
EA3362002891E14C0071C351 /* VerizonNHGeTX-Bold.otf */ = {isa = PBXFileReference; lastKnownFileType = file; path = "VerizonNHGeTX-Bold.otf"; sourceTree = "<group>"; };
|
||||
EA3362012891E14D0071C351 /* VerizonNHGeDS-Bold.otf */ = {isa = PBXFileReference; lastKnownFileType = file; path = "VerizonNHGeDS-Bold.otf"; sourceTree = "<group>"; };
|
||||
@ -223,8 +219,6 @@
|
||||
children = (
|
||||
EA33622F2891EB4A0071C351 /* VDSFonts.swift */,
|
||||
EA3362312891F2ED0071C351 /* VDSFontStyles.swift */,
|
||||
EA3361E02891D1110071C351 /* TypographyProtocol.swift */,
|
||||
EA3361E22891D1860071C351 /* FontWeight.swift */,
|
||||
EA33622B2891E73B0071C351 /* FontProtocol.swift */,
|
||||
);
|
||||
path = Typography;
|
||||
@ -375,10 +369,8 @@
|
||||
EA336171288B19200071C351 /* VDS.docc in Sources */,
|
||||
EA3361AA288B25E40071C351 /* Disabling.swift in Sources */,
|
||||
EA3361B6288B2A410071C351 /* Control.swift in Sources */,
|
||||
EA3361E32891D1860071C351 /* FontWeight.swift in Sources */,
|
||||
EA3361B1288B26490071C351 /* Invertable.swift in Sources */,
|
||||
EA3361AD288B26190071C351 /* DataTrackable.swift in Sources */,
|
||||
EA3361E12891D1110071C351 /* TypographyProtocol.swift in Sources */,
|
||||
EA3362302891EB4A0071C351 /* VDSFonts.swift in Sources */,
|
||||
EA3361B8288B2AAA0071C351 /* ViewProtocol.swift in Sources */,
|
||||
EA3361BF288B2EA60071C351 /* Modelable.swift in Sources */,
|
||||
|
||||
@ -51,15 +51,15 @@ import VDSColorTokens
|
||||
showText ? 12 : 0
|
||||
}
|
||||
|
||||
private var textPosition: VDSToggle.TextPosition {
|
||||
private var textPosition: VDSTextPosition {
|
||||
return model?.textPosition ?? .left
|
||||
}
|
||||
|
||||
private var textSize: VDSToggle.TextSize {
|
||||
return model?.textSize ?? .small
|
||||
private var fontSize: VDSFontSize {
|
||||
return model?.fontSize ?? .small
|
||||
}
|
||||
|
||||
private var fontWeight: Typography.FontWeight {
|
||||
private var fontWeight: VDSFontWeight {
|
||||
return model?.fontWeight ?? .regular
|
||||
}
|
||||
|
||||
@ -400,12 +400,11 @@ import VDSColorTokens
|
||||
isAnimated = true
|
||||
isEnabled = !model.disabled
|
||||
|
||||
if model.fontWeight == .regular {
|
||||
label.font = model.textSize == .small ? VDSFontStyles.Body.Regular.small : VDSFontStyles.Body.Regular.large
|
||||
} else {
|
||||
label.font = model.textSize == .small ? VDSFontStyles.Body.Bold.small : VDSFontStyles.Body.Bold.large
|
||||
guard let font = try? VDSFontStyle.font(for: .body, fontWeight: model.fontWeight, fontSize: model.fontSize) else {
|
||||
return
|
||||
}
|
||||
|
||||
label.font = font
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -7,13 +7,9 @@
|
||||
|
||||
import Foundation
|
||||
import UIKit
|
||||
import VDSTypographyTokens
|
||||
|
||||
extension VDSToggle {
|
||||
|
||||
public enum TextSize: String, Codable {
|
||||
case small, large
|
||||
}
|
||||
|
||||
public enum TextPosition: String, Codable {
|
||||
case left, right
|
||||
}
|
||||
@ -23,9 +19,9 @@ public protocol VDSToggleModel: Surfaceable, FormFieldable, DataTrackable, Disab
|
||||
var id: String? { get set }
|
||||
var showText: Bool { get set }
|
||||
var on: Bool { get set }
|
||||
var textSize: VDSToggle.TextSize { get set }
|
||||
var textPosition: VDSToggle.TextPosition { get set }
|
||||
var fontWeight: Typography.FontWeight { get set }
|
||||
var fontSize: VDSFontSize { get set }
|
||||
var textPosition: VDSTextPosition { get set }
|
||||
var fontWeight: VDSFontWeight { get set }
|
||||
var offText: String { get set }
|
||||
var onText: String { get set }
|
||||
}
|
||||
|
||||
@ -1,23 +0,0 @@
|
||||
//
|
||||
// FontWeight.swift
|
||||
// VDS
|
||||
//
|
||||
// Created by Matt Bruce on 7/27/22.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import UIKit
|
||||
import VDSTypographyTokens
|
||||
|
||||
public struct Typography {
|
||||
|
||||
public enum FontWeight: String, Codable {
|
||||
case regular, bold
|
||||
}
|
||||
|
||||
public enum Letterspacing: String, Codable {
|
||||
case tight, wide
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -1,192 +0,0 @@
|
||||
//
|
||||
// TypographyProtocol.swift
|
||||
// VDS
|
||||
//
|
||||
// Created by Matt Bruce on 7/27/22.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import VDSTypographyTokens
|
||||
|
||||
public protocol XXLFontable {
|
||||
static var xxlBold: UIFont { get }
|
||||
static var xxlRegular: UIFont { get }
|
||||
}
|
||||
|
||||
public protocol XLFontable {
|
||||
static var xlBold: UIFont { get }
|
||||
static var xlRegular: UIFont { get }
|
||||
}
|
||||
|
||||
public protocol LargeFontable {
|
||||
static var largeBold: UIFont { get }
|
||||
static var largeRegular: UIFont { get }
|
||||
}
|
||||
|
||||
public protocol MediumFontable {
|
||||
static var mediumBold: UIFont { get }
|
||||
static var mediumRegular: UIFont { get }
|
||||
}
|
||||
|
||||
public protocol SmallFontable {
|
||||
static var smallBold: UIFont { get }
|
||||
static var smallRegular: UIFont { get }
|
||||
}
|
||||
|
||||
public protocol XSmallFontable {
|
||||
static var xsmallBold: UIFont { get }
|
||||
static var xsmallRegular: UIFont { get }
|
||||
}
|
||||
|
||||
public protocol FeatureTypograhyProtocol: XLFontable, LargeFontable, MediumFontable, SmallFontable, XSmallFontable {}
|
||||
|
||||
public protocol TitleTypograhyProtocol: XXLFontable, XLFontable, LargeFontable, MediumFontable, SmallFontable {}
|
||||
|
||||
public protocol BodyTypograhyProtocol: LargeFontable, MediumFontable, SmallFontable {}
|
||||
|
||||
public protocol MicroTypographyProtocol {
|
||||
static var bold: UIFont { get }
|
||||
static var regular: UIFont { get }
|
||||
}
|
||||
|
||||
//public struct VDSFontStyles {
|
||||
// public enum Feature: FeatureTypograhyProtocol {
|
||||
//
|
||||
// private static func getFont(vdsFont: VDSFonts, size: AvailableSize) -> UIFont {
|
||||
// switch size {
|
||||
// case .xlarge:
|
||||
// return vdsFont.font(ofSize: UIDevice.isIPad ? VDSTypography.fontSizeFeature144 : VDSTypography.fontSizeFeature96)
|
||||
// case .large:
|
||||
// return vdsFont.font(ofSize: UIDevice.isIPad ? VDSTypography.fontSizeFeature128 : VDSTypography.fontSizeFeature80)
|
||||
// case .medium:
|
||||
// return vdsFont.font(ofSize: UIDevice.isIPad ? VDSTypography.fontSizeFeature96 : VDSTypography.fontSizeFeature64)
|
||||
// case .small:
|
||||
// return vdsFont.font(ofSize: UIDevice.isIPad ? VDSTypography.fontSizeFeature80 : VDSTypography.fontSizeFeature48)
|
||||
// case .xsmall:
|
||||
// return vdsFont.font(ofSize: UIDevice.isIPad ? VDSTypography.fontSizeFeature64 : VDSTypography.fontSizeFeature40)
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// public static var xlBold: UIFont {
|
||||
// return VDSFonts.dsBold.font(ofSize: UIDevice.isIPad ? VDSTypography.fontSizeFeature144 : VDSTypography.fontSizeFeature96)
|
||||
// }
|
||||
//
|
||||
// public static var xlRegular: UIFont{
|
||||
// return VDSFonts.dsRegular.font(ofSize: UIDevice.isIPad ? VDSTypography.fontSizeFeature144 : VDSTypography.fontSizeFeature96)
|
||||
// }
|
||||
//
|
||||
// public static var largeBold: UIFont{
|
||||
// return VDSFonts.dsBold.font(ofSize: UIDevice.isIPad ? VDSTypography.fontSizeFeature128 : VDSTypography.fontSizeFeature80)
|
||||
// }
|
||||
//
|
||||
// public static var largeRegular: UIFont{
|
||||
// return VDSFonts.dsRegular.font(ofSize: UIDevice.isIPad ? VDSTypography.fontSizeFeature128 : VDSTypography.fontSizeFeature80)
|
||||
// }
|
||||
//
|
||||
// public static var mediumBold: UIFont{
|
||||
// return VDSFonts.dsBold.font(ofSize: UIDevice.isIPad ? VDSTypography.fontSizeFeature96 : VDSTypography.fontSizeFeature64)
|
||||
// }
|
||||
//
|
||||
// public static var mediumRegular: UIFont{
|
||||
// return VDSFonts.dsRegular.font(ofSize: UIDevice.isIPad ? VDSTypography.fontSizeFeature96 : VDSTypography.fontSizeFeature64)
|
||||
// }
|
||||
//
|
||||
// public static var smallBold: UIFont{
|
||||
// return VDSFonts.dsBold.font(ofSize: UIDevice.isIPad ? VDSTypography.fontSizeFeature80 : VDSTypography.fontSizeFeature48)
|
||||
// }
|
||||
//
|
||||
// public static var smallRegular: UIFont{
|
||||
// return VDSFonts.dsRegular.font(ofSize: UIDevice.isIPad ? VDSTypography.fontSizeFeature80 : VDSTypography.fontSizeFeature48)
|
||||
// }
|
||||
//
|
||||
// public static var xsmallBold: UIFont{
|
||||
// return VDSFonts.dsBold.font(ofSize: UIDevice.isIPad ? VDSTypography.fontSizeFeature64 : VDSTypography.fontSizeFeature40)
|
||||
// }
|
||||
//
|
||||
// public static var xsmallRegular: UIFont{
|
||||
// return VDSFonts.dsRegular.font(ofSize: UIDevice.isIPad ? VDSTypography.fontSizeFeature64 : VDSTypography.fontSizeFeature40)
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// public enum Title: TitleTypograhyProtocol {
|
||||
//
|
||||
// public static var xxlBold: UIFont {
|
||||
// return VDSFonts.dsBold.font(ofSize: UIDevice.isIPad ? VDSTypography.fontSizeTitle64 : VDSTypography.fontSizeTitle40)
|
||||
// }
|
||||
//
|
||||
// public static var xxlRegular: UIFont{
|
||||
// return VDSFonts.dsRegular.font(ofSize: UIDevice.isIPad ? VDSTypography.fontSizeTitle64 : VDSTypography.fontSizeTitle40)
|
||||
// }
|
||||
//
|
||||
// public static var xlBold: UIFont {
|
||||
// return VDSFonts.dsBold.font(ofSize: UIDevice.isIPad ? VDSTypography.fontSizeTitle48 : VDSTypography.fontSizeTitle32)
|
||||
// }
|
||||
//
|
||||
// public static var xlRegular: UIFont{
|
||||
// return VDSFonts.dsRegular.font(ofSize: UIDevice.isIPad ? VDSTypography.fontSizeTitle48 : VDSTypography.fontSizeTitle32)
|
||||
// }
|
||||
//
|
||||
// public static var largeBold: UIFont{
|
||||
// return VDSFonts.dsBold.font(ofSize: UIDevice.isIPad ? VDSTypography.fontSizeTitle32 : VDSTypography.fontSizeTitle24)
|
||||
// }
|
||||
//
|
||||
// public static var largeRegular: UIFont{
|
||||
// return VDSFonts.dsRegular.font(ofSize: UIDevice.isIPad ? VDSTypography.fontSizeTitle32 : VDSTypography.fontSizeTitle24)
|
||||
// }
|
||||
//
|
||||
// public static var mediumBold: UIFont{
|
||||
// return VDSFonts.dsBold.font(ofSize: UIDevice.isIPad ? VDSTypography.fontSizeTitle24 : VDSTypography.fontSizeTitle20)
|
||||
// }
|
||||
//
|
||||
// public static var mediumRegular: UIFont{
|
||||
// return VDSFonts.dsRegular.font(ofSize: UIDevice.isIPad ? VDSTypography.fontSizeTitle24 : VDSTypography.fontSizeTitle20)
|
||||
// }
|
||||
//
|
||||
// public static var smallBold: UIFont{
|
||||
// return VDSFonts.dsBold.font(ofSize: UIDevice.isIPad ? VDSTypography.fontSizeTitle20 : VDSTypography.fontSizeTitle16)
|
||||
// }
|
||||
//
|
||||
// public static var smallRegular: UIFont{
|
||||
// return VDSFonts.dsRegular.font(ofSize: UIDevice.isIPad ? VDSTypography.fontSizeTitle20 : VDSTypography.fontSizeTitle16)
|
||||
// }
|
||||
//
|
||||
// }
|
||||
//
|
||||
// public enum Body: BodyTypograhyProtocol {
|
||||
// public static var largeBold: UIFont {
|
||||
// return VDSFonts.dsBold.font(ofSize: VDSTypography.fontSizeBody16)
|
||||
// }
|
||||
//
|
||||
// public static var largeRegular: UIFont{
|
||||
// return VDSFonts.dsRegular.font(ofSize: VDSTypography.fontSizeBody16)
|
||||
// }
|
||||
//
|
||||
// public static var mediumBold: UIFont{
|
||||
// return VDSFonts.dsBold.font(ofSize: VDSTypography.fontSizeBody14)
|
||||
// }
|
||||
//
|
||||
// public static var mediumRegular: UIFont{
|
||||
// return VDSFonts.dsRegular.font(ofSize: VDSTypography.fontSizeBody14)
|
||||
// }
|
||||
//
|
||||
// public static var smallBold: UIFont{
|
||||
// return VDSFonts.dsBold.font(ofSize: VDSTypography.fontSizeBody12)
|
||||
// }
|
||||
//
|
||||
// public static var smallRegular: UIFont{
|
||||
// return VDSFonts.dsRegular.font(ofSize: VDSTypography.fontSizeBody12)
|
||||
// }
|
||||
//
|
||||
//
|
||||
// }
|
||||
//
|
||||
// public enum Micro: MicroTypographyProtocol {
|
||||
// public static var bold: UIFont {
|
||||
// return VDSFonts.txBold.font(ofSize: VDSTypography.fontSizeMicro11)
|
||||
// }
|
||||
//
|
||||
// public static var regular: UIFont {
|
||||
// return VDSFonts.txRegular.font(ofSize: VDSTypography.fontSizeMicro11)
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
@ -9,127 +9,192 @@ import Foundation
|
||||
import UIKit
|
||||
import VDSTypographyTokens
|
||||
|
||||
public struct VDSFontStyles {
|
||||
public enum VDSFontWeight: String, Codable {
|
||||
case regular
|
||||
case bold
|
||||
|
||||
public enum Feature {
|
||||
|
||||
private enum AvailableSize{
|
||||
case xlarge, large, medium, small, xsmall
|
||||
var titleCase: String {
|
||||
switch self {
|
||||
case .regular: return "Regular"
|
||||
case .bold: return "Bold"
|
||||
}
|
||||
|
||||
private static func getFont(vdsFont: VDSFonts, size: AvailableSize) -> UIFont {
|
||||
switch size {
|
||||
case .xlarge:
|
||||
return vdsFont.font(ofSize: UIDevice.isIPad ? VDSTypography.fontSizeFeature144 : VDSTypography.fontSizeFeature96)
|
||||
case .large:
|
||||
return vdsFont.font(ofSize: UIDevice.isIPad ? VDSTypography.fontSizeFeature128 : VDSTypography.fontSizeFeature80)
|
||||
case .medium:
|
||||
return vdsFont.font(ofSize: UIDevice.isIPad ? VDSTypography.fontSizeFeature96 : VDSTypography.fontSizeFeature64)
|
||||
case .small:
|
||||
return vdsFont.font(ofSize: UIDevice.isIPad ? VDSTypography.fontSizeFeature80 : VDSTypography.fontSizeFeature48)
|
||||
case .xsmall:
|
||||
return vdsFont.font(ofSize: UIDevice.isIPad ? VDSTypography.fontSizeFeature64 : VDSTypography.fontSizeFeature40)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public enum VDSTextPosition: String, Codable {
|
||||
case left, right, center
|
||||
|
||||
var textAlignment: NSTextAlignment {
|
||||
switch self {
|
||||
case .left:
|
||||
return NSTextAlignment.left
|
||||
case .right:
|
||||
return NSTextAlignment.right
|
||||
case .center:
|
||||
return NSTextAlignment.center
|
||||
}
|
||||
|
||||
public enum Bold {
|
||||
public static let xlarge = getFont(vdsFont: VDSFonts.dsBold, size: .xlarge)
|
||||
public static let large = getFont(vdsFont: VDSFonts.dsBold, size: .large)
|
||||
public static let medium = getFont(vdsFont: VDSFonts.dsBold, size: .medium)
|
||||
public static let small = getFont(vdsFont: VDSFonts.dsBold, size: .small)
|
||||
public static let xsmall = getFont(vdsFont: VDSFonts.dsBold, size: .xsmall)
|
||||
}
|
||||
}
|
||||
|
||||
public enum VDSFontCategory: String, Codable {
|
||||
case feature
|
||||
case title
|
||||
case body
|
||||
case micro
|
||||
|
||||
var titleCase: String {
|
||||
switch self {
|
||||
case .feature: return "Feature"
|
||||
case .title: return "Title"
|
||||
case .body: return "Body"
|
||||
case .micro: return "Micro"
|
||||
}
|
||||
|
||||
public enum Regular {
|
||||
public static let xlarge = getFont(vdsFont: VDSFonts.dsRegular, size: .xlarge)
|
||||
public static let large = getFont(vdsFont: VDSFonts.dsRegular, size: .large)
|
||||
public static let medium = getFont(vdsFont: VDSFonts.dsRegular, size: .medium)
|
||||
public static let small = getFont(vdsFont: VDSFonts.dsRegular, size: .small)
|
||||
public static let xsmall = getFont(vdsFont: VDSFonts.dsRegular, size: .xsmall)
|
||||
}
|
||||
}
|
||||
|
||||
public enum VDSFontSize: String, Codable {
|
||||
case xxlarge
|
||||
case xlarge
|
||||
case large
|
||||
case medium
|
||||
case small
|
||||
case xsmall
|
||||
|
||||
var titleCase: String {
|
||||
switch self {
|
||||
case .xxlarge: return "2XLarge"
|
||||
case .xlarge: return "XLarge"
|
||||
case .large: return "Large"
|
||||
case .medium: return "Medium"
|
||||
case .small: return "Small"
|
||||
case .xsmall: return "XSmall"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public enum VDSFontStyle: String, Codable {
|
||||
public enum Error: Swift.Error {
|
||||
case fontNotFound
|
||||
}
|
||||
|
||||
case RegularFeatureXLarge
|
||||
case BoldFeatureXLarge
|
||||
case RegularFeatureLarge
|
||||
case BoldFeatureLarge
|
||||
case RegularFeatureMedium
|
||||
case BoldFeatureMedium
|
||||
case RegularFeatureSmall
|
||||
case BoldFeatureSmall
|
||||
case RegularFeatureXSmall
|
||||
case BoldFeatureXSmall
|
||||
|
||||
case RegularTitle2XLarge
|
||||
case BoldTitle2XLarge
|
||||
case RegularTitleXLarge
|
||||
case BoldTitleXLarge
|
||||
case RegularTitleLarge
|
||||
case BoldTitleLarge
|
||||
case RegularTitleMedium
|
||||
case BoldTitleMedium
|
||||
case RegularTitleSmall
|
||||
case BoldTitleSmall
|
||||
|
||||
case RegularBodyLarge
|
||||
case BoldBodyLarge
|
||||
case RegularBodyMedium
|
||||
case BoldBodyMedium
|
||||
case RegularBodySmall
|
||||
case BoldBodySmall
|
||||
case RegularMicro
|
||||
case BoldMicro
|
||||
|
||||
public var pointSize: CGFloat {
|
||||
switch self {
|
||||
case .RegularFeatureXLarge, .BoldFeatureXLarge:
|
||||
return UIDevice.isIPad ? VDSTypography.fontSizeFeature144 : VDSTypography.fontSizeFeature96
|
||||
case .RegularFeatureLarge, .BoldFeatureLarge:
|
||||
return UIDevice.isIPad ? VDSTypography.fontSizeFeature128 : VDSTypography.fontSizeFeature80
|
||||
case .RegularFeatureMedium, .BoldFeatureMedium:
|
||||
return UIDevice.isIPad ? VDSTypography.fontSizeFeature96 : VDSTypography.fontSizeFeature64
|
||||
case .RegularFeatureSmall, .BoldFeatureSmall:
|
||||
return UIDevice.isIPad ? VDSTypography.fontSizeFeature80 : VDSTypography.fontSizeFeature48
|
||||
case .RegularFeatureXSmall, .BoldFeatureXSmall:
|
||||
return UIDevice.isIPad ? VDSTypography.fontSizeFeature64 : VDSTypography.fontSizeFeature40
|
||||
case .RegularTitle2XLarge, .BoldTitle2XLarge:
|
||||
return UIDevice.isIPad ? VDSTypography.fontSizeTitle64 : VDSTypography.fontSizeTitle40
|
||||
case .RegularTitleXLarge, .BoldTitleXLarge:
|
||||
return UIDevice.isIPad ? VDSTypography.fontSizeTitle48 : VDSTypography.fontSizeTitle32
|
||||
case .RegularTitleLarge, .BoldTitleLarge:
|
||||
return UIDevice.isIPad ? VDSTypography.fontSizeTitle32 : VDSTypography.fontSizeTitle24
|
||||
case .RegularTitleMedium, .BoldTitleMedium:
|
||||
return UIDevice.isIPad ? VDSTypography.fontSizeTitle24 : VDSTypography.fontSizeTitle20
|
||||
case .RegularTitleSmall, .BoldTitleSmall:
|
||||
return UIDevice.isIPad ? VDSTypography.fontSizeTitle20 : VDSTypography.fontSizeTitle16
|
||||
case .RegularBodyLarge, .BoldBodyLarge:
|
||||
return VDSTypography.fontSizeBody16
|
||||
case .RegularBodyMedium, .BoldBodyMedium:
|
||||
return VDSTypography.fontSizeBody14
|
||||
case .RegularBodySmall, .BoldBodySmall:
|
||||
return VDSTypography.fontSizeBody12
|
||||
case .RegularMicro, .BoldMicro:
|
||||
return VDSTypography.fontSizeMicro11
|
||||
}
|
||||
}
|
||||
|
||||
public enum Title {
|
||||
|
||||
private enum AvailableSize{
|
||||
case xxlarge, xlarge, large, medium, small
|
||||
}
|
||||
|
||||
private static func getFont(vdsFont: VDSFonts, size: AvailableSize) -> UIFont {
|
||||
switch size {
|
||||
case .xxlarge:
|
||||
return vdsFont.font(ofSize: UIDevice.isIPad ? VDSTypography.fontSizeTitle64 : VDSTypography.fontSizeTitle40)
|
||||
case .xlarge:
|
||||
return vdsFont.font(ofSize: UIDevice.isIPad ? VDSTypography.fontSizeTitle48 : VDSTypography.fontSizeTitle32)
|
||||
case .large:
|
||||
return vdsFont.font(ofSize: UIDevice.isIPad ? VDSTypography.fontSizeTitle32 : VDSTypography.fontSizeTitle24)
|
||||
case .medium:
|
||||
return vdsFont.font(ofSize: UIDevice.isIPad ? VDSTypography.fontSizeTitle24 : VDSTypography.fontSizeTitle20)
|
||||
case .small:
|
||||
return vdsFont.font(ofSize: UIDevice.isIPad ? VDSTypography.fontSizeTitle20 : VDSTypography.fontSizeTitle16)
|
||||
}
|
||||
}
|
||||
|
||||
public enum Bold {
|
||||
public static let xxlarge = getFont(vdsFont: VDSFonts.dsBold, size: .xxlarge)
|
||||
public static let xlarge = getFont(vdsFont: VDSFonts.dsBold, size: .xlarge)
|
||||
public static let large = getFont(vdsFont: VDSFonts.dsBold, size: .large)
|
||||
public static let medium = getFont(vdsFont: VDSFonts.dsBold, size: .medium)
|
||||
public static let small = getFont(vdsFont: VDSFonts.dsBold, size: .small)
|
||||
}
|
||||
|
||||
public enum Regular {
|
||||
public static let xxlarge = getFont(vdsFont: VDSFonts.dsBold, size: .xxlarge)
|
||||
public static let xlarge = getFont(vdsFont: VDSFonts.dsRegular, size: .xlarge)
|
||||
public static let large = getFont(vdsFont: VDSFonts.dsRegular, size: .large)
|
||||
public static let medium = getFont(vdsFont: VDSFonts.dsRegular, size: .medium)
|
||||
public static let small = getFont(vdsFont: VDSFonts.dsRegular, size: .small)
|
||||
}
|
||||
public var fontFace: VDSFonts {
|
||||
switch self {
|
||||
case .BoldFeatureXLarge,
|
||||
.BoldFeatureLarge,
|
||||
.BoldFeatureMedium,
|
||||
.BoldFeatureSmall,
|
||||
.BoldFeatureXSmall,
|
||||
.BoldTitle2XLarge,
|
||||
.BoldTitleXLarge,
|
||||
.BoldTitleLarge,
|
||||
.BoldTitleMedium,
|
||||
.BoldTitleSmall,
|
||||
.BoldBodyLarge,
|
||||
.BoldBodyMedium,
|
||||
.BoldBodySmall:
|
||||
return .dsBold
|
||||
|
||||
}
|
||||
|
||||
public enum Body {
|
||||
|
||||
private enum AvailableSize{
|
||||
case large, medium, small
|
||||
}
|
||||
|
||||
private static func getFont(vdsFont: VDSFonts, size: AvailableSize) -> UIFont {
|
||||
switch size {
|
||||
case .large:
|
||||
return vdsFont.font(ofSize: VDSTypography.fontSizeBody16)
|
||||
case .medium:
|
||||
return vdsFont.font(ofSize: VDSTypography.fontSizeBody14)
|
||||
case .small:
|
||||
return vdsFont.font(ofSize: VDSTypography.fontSizeBody12)
|
||||
}
|
||||
}
|
||||
|
||||
public enum Bold {
|
||||
public static let large = getFont(vdsFont: VDSFonts.dsBold, size: .large)
|
||||
public static let medium = getFont(vdsFont: VDSFonts.dsBold, size: .medium)
|
||||
public static let small = getFont(vdsFont: VDSFonts.dsBold, size: .small)
|
||||
}
|
||||
|
||||
public enum Regular {
|
||||
public static let large = getFont(vdsFont: VDSFonts.dsRegular, size: .large)
|
||||
public static let medium = getFont(vdsFont: VDSFonts.dsRegular, size: .medium)
|
||||
public static let small = getFont(vdsFont: VDSFonts.dsRegular, size: .small)
|
||||
case .RegularFeatureXLarge,
|
||||
.RegularFeatureLarge,
|
||||
.RegularFeatureMedium,
|
||||
.RegularFeatureSmall,
|
||||
.RegularFeatureXSmall,
|
||||
.RegularTitle2XLarge,
|
||||
.RegularTitleXLarge,
|
||||
.RegularTitleLarge,
|
||||
.RegularTitleMedium,
|
||||
.RegularTitleSmall,
|
||||
.RegularBodyLarge,
|
||||
.RegularBodyMedium,
|
||||
.RegularBodySmall:
|
||||
return .dsRegular
|
||||
|
||||
case .BoldMicro:
|
||||
return .txBold
|
||||
|
||||
case .RegularMicro:
|
||||
return .txRegular
|
||||
}
|
||||
}
|
||||
|
||||
public enum Micro: MicroTypographyProtocol {
|
||||
private static func getFont(vdsFont: VDSFonts) -> UIFont {
|
||||
return vdsFont.font(ofSize: VDSTypography.fontSizeMicro11)
|
||||
}
|
||||
|
||||
public static var bold: UIFont {
|
||||
return getFont(vdsFont: .txBold)
|
||||
}
|
||||
|
||||
public static var regular: UIFont {
|
||||
return getFont(vdsFont: .txRegular)
|
||||
public var font: UIFont {
|
||||
return fontFace.font(ofSize: pointSize)
|
||||
}
|
||||
|
||||
public var superScriptFont: UIFont {
|
||||
return fontFace.font(ofSize: pointSize / 2)
|
||||
}
|
||||
|
||||
public static func font(for category: VDSFontCategory, fontWeight: VDSFontWeight, fontSize: VDSFontSize, isSuperScript: Bool = false) throws -> UIFont {
|
||||
let fontName = "\(fontWeight.titleCase)\(category.titleCase)\(fontSize.titleCase)"
|
||||
guard let fontStyle = VDSFontStyle(rawValue: fontName) else {
|
||||
throw VDSFontStyle.Error.fontNotFound
|
||||
}
|
||||
return fontStyle.font
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user