refactored

Signed-off-by: Matt Bruce <matt.bruce@verizon.com>
This commit is contained in:
Matt Bruce 2022-07-28 11:17:43 -05:00
parent 20895847ed
commit 2eac9edc24
6 changed files with 185 additions and 348 deletions

View File

@ -27,8 +27,6 @@
EA3361C328902D960071C351 /* VDSToggle.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA3361C228902D960071C351 /* VDSToggle.swift */; }; EA3361C328902D960071C351 /* VDSToggle.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA3361C228902D960071C351 /* VDSToggle.swift */; };
EA3361C5289030FC0071C351 /* Accessable.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA3361C4289030FC0071C351 /* Accessable.swift */; }; EA3361C5289030FC0071C351 /* Accessable.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA3361C4289030FC0071C351 /* Accessable.swift */; };
EA3361C9289054C50071C351 /* Surfaceable.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA3361C8289054C50071C351 /* Surfaceable.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 */; }; EA3361F42891D5290071C351 /* VDSTypographyTokens.xcframework in Frameworks */ = {isa = PBXBuildFile; fileRef = EA3361F32891D5290071C351 /* VDSTypographyTokens.xcframework */; };
EA3362042891E14D0071C351 /* VerizonNHGeTX-Bold.otf in Resources */ = {isa = PBXBuildFile; fileRef = EA3362002891E14C0071C351 /* VerizonNHGeTX-Bold.otf */; }; 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 */; }; 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>"; }; 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>"; }; 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>"; }; 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>"; }; 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>"; }; 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>"; }; EA3362012891E14D0071C351 /* VerizonNHGeDS-Bold.otf */ = {isa = PBXFileReference; lastKnownFileType = file; path = "VerizonNHGeDS-Bold.otf"; sourceTree = "<group>"; };
@ -223,8 +219,6 @@
children = ( children = (
EA33622F2891EB4A0071C351 /* VDSFonts.swift */, EA33622F2891EB4A0071C351 /* VDSFonts.swift */,
EA3362312891F2ED0071C351 /* VDSFontStyles.swift */, EA3362312891F2ED0071C351 /* VDSFontStyles.swift */,
EA3361E02891D1110071C351 /* TypographyProtocol.swift */,
EA3361E22891D1860071C351 /* FontWeight.swift */,
EA33622B2891E73B0071C351 /* FontProtocol.swift */, EA33622B2891E73B0071C351 /* FontProtocol.swift */,
); );
path = Typography; path = Typography;
@ -375,10 +369,8 @@
EA336171288B19200071C351 /* VDS.docc in Sources */, EA336171288B19200071C351 /* VDS.docc in Sources */,
EA3361AA288B25E40071C351 /* Disabling.swift in Sources */, EA3361AA288B25E40071C351 /* Disabling.swift in Sources */,
EA3361B6288B2A410071C351 /* Control.swift in Sources */, EA3361B6288B2A410071C351 /* Control.swift in Sources */,
EA3361E32891D1860071C351 /* FontWeight.swift in Sources */,
EA3361B1288B26490071C351 /* Invertable.swift in Sources */, EA3361B1288B26490071C351 /* Invertable.swift in Sources */,
EA3361AD288B26190071C351 /* DataTrackable.swift in Sources */, EA3361AD288B26190071C351 /* DataTrackable.swift in Sources */,
EA3361E12891D1110071C351 /* TypographyProtocol.swift in Sources */,
EA3362302891EB4A0071C351 /* VDSFonts.swift in Sources */, EA3362302891EB4A0071C351 /* VDSFonts.swift in Sources */,
EA3361B8288B2AAA0071C351 /* ViewProtocol.swift in Sources */, EA3361B8288B2AAA0071C351 /* ViewProtocol.swift in Sources */,
EA3361BF288B2EA60071C351 /* Modelable.swift in Sources */, EA3361BF288B2EA60071C351 /* Modelable.swift in Sources */,

View File

@ -51,15 +51,15 @@ import VDSColorTokens
showText ? 12 : 0 showText ? 12 : 0
} }
private var textPosition: VDSToggle.TextPosition { private var textPosition: VDSTextPosition {
return model?.textPosition ?? .left return model?.textPosition ?? .left
} }
private var textSize: VDSToggle.TextSize { private var fontSize: VDSFontSize {
return model?.textSize ?? .small return model?.fontSize ?? .small
} }
private var fontWeight: Typography.FontWeight { private var fontWeight: VDSFontWeight {
return model?.fontWeight ?? .regular return model?.fontWeight ?? .regular
} }
@ -400,12 +400,11 @@ import VDSColorTokens
isAnimated = true isAnimated = true
isEnabled = !model.disabled isEnabled = !model.disabled
if model.fontWeight == .regular { guard let font = try? VDSFontStyle.font(for: .body, fontWeight: model.fontWeight, fontSize: model.fontSize) else {
label.font = model.textSize == .small ? VDSFontStyles.Body.Regular.small : VDSFontStyles.Body.Regular.large return
} else {
label.font = model.textSize == .small ? VDSFontStyles.Body.Bold.small : VDSFontStyles.Body.Bold.large
} }
label.font = font
} }
} }

View File

@ -7,13 +7,9 @@
import Foundation import Foundation
import UIKit import UIKit
import VDSTypographyTokens
extension VDSToggle { extension VDSToggle {
public enum TextSize: String, Codable {
case small, large
}
public enum TextPosition: String, Codable { public enum TextPosition: String, Codable {
case left, right case left, right
} }
@ -23,9 +19,9 @@ public protocol VDSToggleModel: Surfaceable, FormFieldable, DataTrackable, Disab
var id: String? { get set } var id: String? { get set }
var showText: Bool { get set } var showText: Bool { get set }
var on: Bool { get set } var on: Bool { get set }
var textSize: VDSToggle.TextSize { get set } var fontSize: VDSFontSize { get set }
var textPosition: VDSToggle.TextPosition { get set } var textPosition: VDSTextPosition { get set }
var fontWeight: Typography.FontWeight { get set } var fontWeight: VDSFontWeight { get set }
var offText: String { get set } var offText: String { get set }
var onText: String { get set } var onText: String { get set }
} }

View File

@ -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
}
}

View File

@ -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)
// }
// }
//}

View File

@ -9,127 +9,192 @@ import Foundation
import UIKit import UIKit
import VDSTypographyTokens import VDSTypographyTokens
public struct VDSFontStyles { public enum VDSFontWeight: String, Codable {
case regular
case bold
public enum Feature { var titleCase: String {
switch self {
case .regular: return "Regular"
case .bold: return "Bold"
}
}
}
private enum AvailableSize{ public enum VDSTextPosition: String, Codable {
case xlarge, large, medium, small, xsmall 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 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 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
} }
private static func getFont(vdsFont: VDSFonts, size: AvailableSize) -> UIFont { case RegularFeatureXLarge
switch size { case BoldFeatureXLarge
case .xlarge: case RegularFeatureLarge
return vdsFont.font(ofSize: UIDevice.isIPad ? VDSTypography.fontSizeFeature144 : VDSTypography.fontSizeFeature96) case BoldFeatureLarge
case .large: case RegularFeatureMedium
return vdsFont.font(ofSize: UIDevice.isIPad ? VDSTypography.fontSizeFeature128 : VDSTypography.fontSizeFeature80) case BoldFeatureMedium
case .medium: case RegularFeatureSmall
return vdsFont.font(ofSize: UIDevice.isIPad ? VDSTypography.fontSizeFeature96 : VDSTypography.fontSizeFeature64) case BoldFeatureSmall
case .small: case RegularFeatureXSmall
return vdsFont.font(ofSize: UIDevice.isIPad ? VDSTypography.fontSizeFeature80 : VDSTypography.fontSizeFeature48) case BoldFeatureXSmall
case .xsmall:
return vdsFont.font(ofSize: UIDevice.isIPad ? VDSTypography.fontSizeFeature64 : VDSTypography.fontSizeFeature40) 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 Bold { public var fontFace: VDSFonts {
public static let xlarge = getFont(vdsFont: VDSFonts.dsBold, size: .xlarge) switch self {
public static let large = getFont(vdsFont: VDSFonts.dsBold, size: .large) case .BoldFeatureXLarge,
public static let medium = getFont(vdsFont: VDSFonts.dsBold, size: .medium) .BoldFeatureLarge,
public static let small = getFont(vdsFont: VDSFonts.dsBold, size: .small) .BoldFeatureMedium,
public static let xsmall = getFont(vdsFont: VDSFonts.dsBold, size: .xsmall) .BoldFeatureSmall,
} .BoldFeatureXSmall,
.BoldTitle2XLarge,
.BoldTitleXLarge,
.BoldTitleLarge,
.BoldTitleMedium,
.BoldTitleSmall,
.BoldBodyLarge,
.BoldBodyMedium,
.BoldBodySmall:
return .dsBold
public enum Regular { case .RegularFeatureXLarge,
public static let xlarge = getFont(vdsFont: VDSFonts.dsRegular, size: .xlarge) .RegularFeatureLarge,
public static let large = getFont(vdsFont: VDSFonts.dsRegular, size: .large) .RegularFeatureMedium,
public static let medium = getFont(vdsFont: VDSFonts.dsRegular, size: .medium) .RegularFeatureSmall,
public static let small = getFont(vdsFont: VDSFonts.dsRegular, size: .small) .RegularFeatureXSmall,
public static let xsmall = getFont(vdsFont: VDSFonts.dsRegular, size: .xsmall) .RegularTitle2XLarge,
.RegularTitleXLarge,
.RegularTitleLarge,
.RegularTitleMedium,
.RegularTitleSmall,
.RegularBodyLarge,
.RegularBodyMedium,
.RegularBodySmall:
return .dsRegular
case .BoldMicro:
return .txBold
case .RegularMicro:
return .txRegular
} }
} }
public enum Title { public var font: UIFont {
return fontFace.font(ofSize: pointSize)
private enum AvailableSize{
case xxlarge, xlarge, large, medium, small
} }
private static func getFont(vdsFont: VDSFonts, size: AvailableSize) -> UIFont { public var superScriptFont: UIFont {
switch size { return fontFace.font(ofSize: pointSize / 2)
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 func font(for category: VDSFontCategory, fontWeight: VDSFontWeight, fontSize: VDSFontSize, isSuperScript: Bool = false) throws -> UIFont {
public static let xxlarge = getFont(vdsFont: VDSFonts.dsBold, size: .xxlarge) let fontName = "\(fontWeight.titleCase)\(category.titleCase)\(fontSize.titleCase)"
public static let xlarge = getFont(vdsFont: VDSFonts.dsBold, size: .xlarge) guard let fontStyle = VDSFontStyle(rawValue: fontName) else {
public static let large = getFont(vdsFont: VDSFonts.dsBold, size: .large) throw VDSFontStyle.Error.fontNotFound
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 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)
}
}
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)
} }
return fontStyle.font
} }
} }