141 lines
5.9 KiB
Swift
141 lines
5.9 KiB
Swift
//
|
|
// VDSFontStyles.swift
|
|
// VDS
|
|
//
|
|
// Created by Matt Bruce on 7/27/22.
|
|
//
|
|
|
|
import Foundation
|
|
import UIKit
|
|
import VDSTypographyTokens
|
|
|
|
public struct VDSFontStyles {
|
|
|
|
public enum Feature {
|
|
|
|
private enum AvailableSize{
|
|
case xlarge, large, medium, small, xsmall
|
|
}
|
|
|
|
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 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 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 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 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)
|
|
}
|
|
}
|
|
}
|
|
|
|
extension UIDevice {
|
|
static var isIPad: Bool {
|
|
UIDevice.current.userInterfaceIdiom == .pad
|
|
}
|
|
}
|