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 */; };
|
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 */,
|
||||||
|
|||||||
@ -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
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -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 }
|
||||||
}
|
}
|
||||||
|
|||||||
@ -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 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 {
|
||||||
private enum AvailableSize{
|
case .regular: return "Regular"
|
||||||
case xlarge, large, medium, small, xsmall
|
case .bold: return "Bold"
|
||||||
}
|
}
|
||||||
|
}
|
||||||
private static func getFont(vdsFont: VDSFonts, size: AvailableSize) -> UIFont {
|
}
|
||||||
switch size {
|
|
||||||
case .xlarge:
|
public enum VDSTextPosition: String, Codable {
|
||||||
return vdsFont.font(ofSize: UIDevice.isIPad ? VDSTypography.fontSizeFeature144 : VDSTypography.fontSizeFeature96)
|
case left, right, center
|
||||||
case .large:
|
|
||||||
return vdsFont.font(ofSize: UIDevice.isIPad ? VDSTypography.fontSizeFeature128 : VDSTypography.fontSizeFeature80)
|
var textAlignment: NSTextAlignment {
|
||||||
case .medium:
|
switch self {
|
||||||
return vdsFont.font(ofSize: UIDevice.isIPad ? VDSTypography.fontSizeFeature96 : VDSTypography.fontSizeFeature64)
|
case .left:
|
||||||
case .small:
|
return NSTextAlignment.left
|
||||||
return vdsFont.font(ofSize: UIDevice.isIPad ? VDSTypography.fontSizeFeature80 : VDSTypography.fontSizeFeature48)
|
case .right:
|
||||||
case .xsmall:
|
return NSTextAlignment.right
|
||||||
return vdsFont.font(ofSize: UIDevice.isIPad ? VDSTypography.fontSizeFeature64 : VDSTypography.fontSizeFeature40)
|
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 enum VDSFontCategory: String, Codable {
|
||||||
public static let medium = getFont(vdsFont: VDSFonts.dsBold, size: .medium)
|
case feature
|
||||||
public static let small = getFont(vdsFont: VDSFonts.dsBold, size: .small)
|
case title
|
||||||
public static let xsmall = getFont(vdsFont: VDSFonts.dsBold, size: .xsmall)
|
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 enum VDSFontSize: String, Codable {
|
||||||
public static let medium = getFont(vdsFont: VDSFonts.dsRegular, size: .medium)
|
case xxlarge
|
||||||
public static let small = getFont(vdsFont: VDSFonts.dsRegular, size: .small)
|
case xlarge
|
||||||
public static let xsmall = getFont(vdsFont: VDSFonts.dsRegular, size: .xsmall)
|
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 {
|
public var fontFace: VDSFonts {
|
||||||
|
switch self {
|
||||||
private enum AvailableSize{
|
case .BoldFeatureXLarge,
|
||||||
case xxlarge, xlarge, large, medium, small
|
.BoldFeatureLarge,
|
||||||
}
|
.BoldFeatureMedium,
|
||||||
|
.BoldFeatureSmall,
|
||||||
private static func getFont(vdsFont: VDSFonts, size: AvailableSize) -> UIFont {
|
.BoldFeatureXSmall,
|
||||||
switch size {
|
.BoldTitle2XLarge,
|
||||||
case .xxlarge:
|
.BoldTitleXLarge,
|
||||||
return vdsFont.font(ofSize: UIDevice.isIPad ? VDSTypography.fontSizeTitle64 : VDSTypography.fontSizeTitle40)
|
.BoldTitleLarge,
|
||||||
case .xlarge:
|
.BoldTitleMedium,
|
||||||
return vdsFont.font(ofSize: UIDevice.isIPad ? VDSTypography.fontSizeTitle48 : VDSTypography.fontSizeTitle32)
|
.BoldTitleSmall,
|
||||||
case .large:
|
.BoldBodyLarge,
|
||||||
return vdsFont.font(ofSize: UIDevice.isIPad ? VDSTypography.fontSizeTitle32 : VDSTypography.fontSizeTitle24)
|
.BoldBodyMedium,
|
||||||
case .medium:
|
.BoldBodySmall:
|
||||||
return vdsFont.font(ofSize: UIDevice.isIPad ? VDSTypography.fontSizeTitle24 : VDSTypography.fontSizeTitle20)
|
return .dsBold
|
||||||
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)
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
case .RegularFeatureXLarge,
|
||||||
|
.RegularFeatureLarge,
|
||||||
public enum Body {
|
.RegularFeatureMedium,
|
||||||
|
.RegularFeatureSmall,
|
||||||
private enum AvailableSize{
|
.RegularFeatureXSmall,
|
||||||
case large, medium, small
|
.RegularTitle2XLarge,
|
||||||
}
|
.RegularTitleXLarge,
|
||||||
|
.RegularTitleLarge,
|
||||||
private static func getFont(vdsFont: VDSFonts, size: AvailableSize) -> UIFont {
|
.RegularTitleMedium,
|
||||||
switch size {
|
.RegularTitleSmall,
|
||||||
case .large:
|
.RegularBodyLarge,
|
||||||
return vdsFont.font(ofSize: VDSTypography.fontSizeBody16)
|
.RegularBodyMedium,
|
||||||
case .medium:
|
.RegularBodySmall:
|
||||||
return vdsFont.font(ofSize: VDSTypography.fontSizeBody14)
|
return .dsRegular
|
||||||
case .small:
|
|
||||||
return vdsFont.font(ofSize: VDSTypography.fontSizeBody12)
|
case .BoldMicro:
|
||||||
}
|
return .txBold
|
||||||
}
|
|
||||||
|
case .RegularMicro:
|
||||||
public enum Bold {
|
return .txRegular
|
||||||
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 {
|
public var font: UIFont {
|
||||||
private static func getFont(vdsFont: VDSFonts) -> UIFont {
|
return fontFace.font(ofSize: pointSize)
|
||||||
return vdsFont.font(ofSize: VDSTypography.fontSizeMicro11)
|
}
|
||||||
}
|
|
||||||
|
public var superScriptFont: UIFont {
|
||||||
public static var bold: UIFont {
|
return fontFace.font(ofSize: pointSize / 2)
|
||||||
return getFont(vdsFont: .txBold)
|
}
|
||||||
}
|
|
||||||
|
public static func font(for category: VDSFontCategory, fontWeight: VDSFontWeight, fontSize: VDSFontSize, isSuperScript: Bool = false) throws -> UIFont {
|
||||||
public static var regular: UIFont {
|
let fontName = "\(fontWeight.titleCase)\(category.titleCase)\(fontSize.titleCase)"
|
||||||
return getFont(vdsFont: .txRegular)
|
guard let fontStyle = VDSFontStyle(rawValue: fontName) else {
|
||||||
|
throw VDSFontStyle.Error.fontNotFound
|
||||||
}
|
}
|
||||||
|
return fontStyle.font
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user