Merge branch 'feature/badgeIndicator' into 'develop'
updated See merge request BPHV_MIPS/vds_ios!83
This commit is contained in:
commit
bf709c4f5c
@ -37,7 +37,7 @@
|
|||||||
EA3362072891E14D0071C351 /* VerizonNHGeDS-Regular.otf in Resources */ = {isa = PBXBuildFile; fileRef = EA3362032891E14D0071C351 /* VerizonNHGeDS-Regular.otf */; };
|
EA3362072891E14D0071C351 /* VerizonNHGeDS-Regular.otf in Resources */ = {isa = PBXBuildFile; fileRef = EA3362032891E14D0071C351 /* VerizonNHGeDS-Regular.otf */; };
|
||||||
EA33622C2891E73B0071C351 /* FontProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA33622B2891E73B0071C351 /* FontProtocol.swift */; };
|
EA33622C2891E73B0071C351 /* FontProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA33622B2891E73B0071C351 /* FontProtocol.swift */; };
|
||||||
EA33622E2891EA3C0071C351 /* DispatchQueue+Once.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA33622D2891EA3C0071C351 /* DispatchQueue+Once.swift */; };
|
EA33622E2891EA3C0071C351 /* DispatchQueue+Once.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA33622D2891EA3C0071C351 /* DispatchQueue+Once.swift */; };
|
||||||
EA3362302891EB4A0071C351 /* Fonts.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA33622F2891EB4A0071C351 /* Fonts.swift */; };
|
EA3362302891EB4A0071C351 /* Font.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA33622F2891EB4A0071C351 /* Font.swift */; };
|
||||||
EA33623E2892EE950071C351 /* UIDevice.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA33623D2892EE950071C351 /* UIDevice.swift */; };
|
EA33623E2892EE950071C351 /* UIDevice.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA33623D2892EE950071C351 /* UIDevice.swift */; };
|
||||||
EA3362402892EF6C0071C351 /* Label.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA33623F2892EF6B0071C351 /* Label.swift */; };
|
EA3362402892EF6C0071C351 /* Label.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA33623F2892EF6B0071C351 /* Label.swift */; };
|
||||||
EA33624728931B050071C351 /* Initable.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA33624628931B050071C351 /* Initable.swift */; };
|
EA33624728931B050071C351 /* Initable.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA33624628931B050071C351 /* Initable.swift */; };
|
||||||
@ -170,7 +170,7 @@
|
|||||||
EA3362032891E14D0071C351 /* VerizonNHGeDS-Regular.otf */ = {isa = PBXFileReference; lastKnownFileType = file; path = "VerizonNHGeDS-Regular.otf"; sourceTree = "<group>"; };
|
EA3362032891E14D0071C351 /* VerizonNHGeDS-Regular.otf */ = {isa = PBXFileReference; lastKnownFileType = file; path = "VerizonNHGeDS-Regular.otf"; sourceTree = "<group>"; };
|
||||||
EA33622B2891E73B0071C351 /* FontProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FontProtocol.swift; sourceTree = "<group>"; };
|
EA33622B2891E73B0071C351 /* FontProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FontProtocol.swift; sourceTree = "<group>"; };
|
||||||
EA33622D2891EA3C0071C351 /* DispatchQueue+Once.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "DispatchQueue+Once.swift"; sourceTree = "<group>"; };
|
EA33622D2891EA3C0071C351 /* DispatchQueue+Once.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "DispatchQueue+Once.swift"; sourceTree = "<group>"; };
|
||||||
EA33622F2891EB4A0071C351 /* Fonts.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Fonts.swift; sourceTree = "<group>"; };
|
EA33622F2891EB4A0071C351 /* Font.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Font.swift; sourceTree = "<group>"; };
|
||||||
EA33623D2892EE950071C351 /* UIDevice.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UIDevice.swift; sourceTree = "<group>"; };
|
EA33623D2892EE950071C351 /* UIDevice.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UIDevice.swift; sourceTree = "<group>"; };
|
||||||
EA33623F2892EF6B0071C351 /* Label.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Label.swift; sourceTree = "<group>"; };
|
EA33623F2892EF6B0071C351 /* Label.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Label.swift; sourceTree = "<group>"; };
|
||||||
EA33624628931B050071C351 /* Initable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Initable.swift; sourceTree = "<group>"; };
|
EA33624628931B050071C351 /* Initable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Initable.swift; sourceTree = "<group>"; };
|
||||||
@ -497,7 +497,7 @@
|
|||||||
EA3361DF2891D0F10071C351 /* Fonts */ = {
|
EA3361DF2891D0F10071C351 /* Fonts */ = {
|
||||||
isa = PBXGroup;
|
isa = PBXGroup;
|
||||||
children = (
|
children = (
|
||||||
EA33622F2891EB4A0071C351 /* Fonts.swift */,
|
EA33622F2891EB4A0071C351 /* Font.swift */,
|
||||||
EA33622B2891E73B0071C351 /* FontProtocol.swift */,
|
EA33622B2891E73B0071C351 /* FontProtocol.swift */,
|
||||||
);
|
);
|
||||||
path = Fonts;
|
path = Fonts;
|
||||||
@ -945,7 +945,7 @@
|
|||||||
EA33623E2892EE950071C351 /* UIDevice.swift in Sources */,
|
EA33623E2892EE950071C351 /* UIDevice.swift in Sources */,
|
||||||
EA985C692971B90B00F2FF2E /* IconSize.swift in Sources */,
|
EA985C692971B90B00F2FF2E /* IconSize.swift in Sources */,
|
||||||
EA985C672970C21600F2FF2E /* VDSLayout.swift in Sources */,
|
EA985C672970C21600F2FF2E /* VDSLayout.swift in Sources */,
|
||||||
EA3362302891EB4A0071C351 /* Fonts.swift in Sources */,
|
EA3362302891EB4A0071C351 /* Font.swift in Sources */,
|
||||||
EAF7F0AD289B142900B287F5 /* StrikeThroughLabelAttribute.swift in Sources */,
|
EAF7F0AD289B142900B287F5 /* StrikeThroughLabelAttribute.swift in Sources */,
|
||||||
EAB5FEF12927F4AA00998C17 /* SelfSizingCollectionView.swift in Sources */,
|
EAB5FEF12927F4AA00998C17 /* SelfSizingCollectionView.swift in Sources */,
|
||||||
EA3361B8288B2AAA0071C351 /* ViewProtocol.swift in Sources */,
|
EA3361B8288B2AAA0071C351 /* ViewProtocol.swift in Sources */,
|
||||||
|
|||||||
@ -52,80 +52,56 @@ open class BadgeIndicator: View {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum TextSize: String, CaseIterable {
|
public enum Size: String, CaseIterable {
|
||||||
case xxlarge = "2XLarge"
|
case xxlarge = "2XLarge"
|
||||||
case xlarge = "XLarge"
|
case xlarge = "XLarge"
|
||||||
case large = "Large"
|
case large = "Large"
|
||||||
case medium = "Medium"
|
case medium = "Medium"
|
||||||
case small = "Small"
|
case small = "Small"
|
||||||
|
|
||||||
public var inset: CGFloat {
|
|
||||||
return textStyle.pointSize * 0.3333
|
|
||||||
// switch self {
|
|
||||||
// case .xxlarge:
|
|
||||||
// return 8
|
|
||||||
// case .xlarge:
|
|
||||||
// return 6
|
|
||||||
// case .large:
|
|
||||||
// return 6
|
|
||||||
// case .medium:
|
|
||||||
// return 6
|
|
||||||
// case .small:
|
|
||||||
// return 4
|
|
||||||
// }
|
|
||||||
}
|
|
||||||
|
|
||||||
public var lineHeight: CGFloat {
|
|
||||||
switch self {
|
|
||||||
case .xxlarge:
|
|
||||||
return 29
|
|
||||||
case .xlarge:
|
|
||||||
return 24
|
|
||||||
case .large:
|
|
||||||
return 20
|
|
||||||
case .medium:
|
|
||||||
return 18
|
|
||||||
case .small:
|
|
||||||
return 16
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public var textStyle: TextStyle {
|
public var textStyle: TextStyle {
|
||||||
let style = TextStyle.bodySmall
|
let style = TextStyle.bodySmall
|
||||||
var pointSize: CGFloat = VDSTypography.fontSizeBody12
|
var pointSize: CGFloat = VDSTypography.fontSizeBody12
|
||||||
|
var letterSpacing: CGFloat = 0.0
|
||||||
switch self {
|
switch self {
|
||||||
case .xxlarge:
|
case .xxlarge:
|
||||||
pointSize = VDSTypography.fontSizeTitle24
|
pointSize = VDSTypography.fontSizeTitle24
|
||||||
|
letterSpacing = VDSTypography.letterSpacingWide
|
||||||
|
|
||||||
case .xlarge:
|
case .xlarge:
|
||||||
pointSize = VDSTypography.fontSizeTitle20
|
pointSize = VDSTypography.fontSizeTitle20
|
||||||
|
|
||||||
case .large:
|
case .large:
|
||||||
pointSize = VDSTypography.fontSizeBody16
|
pointSize = VDSTypography.fontSizeBody16
|
||||||
|
letterSpacing = VDSTypography.letterSpacingWide
|
||||||
|
|
||||||
case .medium:
|
case .medium:
|
||||||
pointSize = VDSTypography.fontSizeBody14
|
pointSize = VDSTypography.fontSizeBody14
|
||||||
|
letterSpacing = VDSTypography.letterSpacingWide
|
||||||
case .small:
|
case .small:
|
||||||
pointSize = VDSTypography.fontSizeBody12
|
pointSize = VDSTypography.fontSizeBody12
|
||||||
|
|
||||||
}
|
}
|
||||||
// var ratio: CGFloat = 1.3333 // less than 14
|
|
||||||
// if pointSize > 13 && pointSize < 16 {
|
|
||||||
// ratio = 1.28
|
|
||||||
// } else if pointSize > 15 && pointSize < 19 {
|
|
||||||
// ratio = 1.25
|
|
||||||
// } else if pointSize > 19 {
|
|
||||||
// ratio = 1.20
|
|
||||||
// }
|
|
||||||
|
|
||||||
let calculatedLineHeight = pointSize * 1.265//ratio
|
|
||||||
print("lineHeight\noriginal: \(lineHeight)\ncalculated:\(calculatedLineHeight)")
|
|
||||||
return TextStyle(rawValue: "\(self.rawValue)BadgeIndicator",
|
return TextStyle(rawValue: "\(self.rawValue)BadgeIndicator",
|
||||||
fontFace: style.fontFace,
|
fontFace: style.fontFace,
|
||||||
pointSize: pointSize,
|
pointSize: pointSize,
|
||||||
lineHeight: calculatedLineHeight,
|
lineHeight: 0,
|
||||||
letterSpacing: style.letterSpacing)
|
letterSpacing: letterSpacing)
|
||||||
|
}
|
||||||
|
|
||||||
|
public var edgeInset: UIEdgeInsets {
|
||||||
|
var horizontalPadding: CGFloat = VDSLayout.Spacing.space1X.value
|
||||||
|
let verticalPadding: CGFloat = 0
|
||||||
|
|
||||||
|
switch self {
|
||||||
|
case .xxlarge:
|
||||||
|
horizontalPadding = VDSLayout.Spacing.space2X.value
|
||||||
|
case .xlarge, .large,.medium:
|
||||||
|
horizontalPadding = 6.0
|
||||||
|
case .small:
|
||||||
|
break
|
||||||
|
}
|
||||||
|
return .init(top: verticalPadding, left: horizontalPadding, bottom: verticalPadding, right: horizontalPadding)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -171,7 +147,13 @@ open class BadgeIndicator: View {
|
|||||||
|
|
||||||
open var leadingCharacter: String? { didSet { setNeedsUpdate() }}
|
open var leadingCharacter: String? { didSet { setNeedsUpdate() }}
|
||||||
|
|
||||||
open var textSize: TextSize = .xxlarge { didSet { setNeedsUpdate() }}
|
open var size: Size = .xxlarge { didSet { setNeedsUpdate() }}
|
||||||
|
|
||||||
|
open var dotSize: CGFloat? { didSet { setNeedsUpdate() }}
|
||||||
|
|
||||||
|
open var verticalPadding: CGFloat? { didSet { setNeedsUpdate() }}
|
||||||
|
|
||||||
|
open var horitonalPadding: CGFloat? { didSet { setNeedsUpdate() }}
|
||||||
|
|
||||||
open var hideDot: Bool = false { didSet { setNeedsUpdate() }}
|
open var hideDot: Bool = false { didSet { setNeedsUpdate() }}
|
||||||
|
|
||||||
@ -179,31 +161,56 @@ open class BadgeIndicator: View {
|
|||||||
|
|
||||||
open var maxDigits: MaxDigits = .two { didSet { setNeedsUpdate() }}
|
open var maxDigits: MaxDigits = .two { didSet { setNeedsUpdate() }}
|
||||||
|
|
||||||
|
open var width: CGFloat? { didSet { setNeedsUpdate() }}
|
||||||
|
|
||||||
|
open var height: CGFloat? { didSet { setNeedsUpdate() }}
|
||||||
|
|
||||||
|
//--------------------------------------------------
|
||||||
|
// MARK: - Private Properties
|
||||||
|
//--------------------------------------------------
|
||||||
|
private let borderWidth: CGFloat = 1.0
|
||||||
|
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
// MARK: - Constraints
|
// MARK: - Constraints
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
private var labelWidthConstraint: NSLayoutConstraint?
|
private let badgeView = View()
|
||||||
private var labelHeightConstraint: NSLayoutConstraint?
|
private var badgeSize: CGFloat { max(16.0, size.textStyle.font.lineHeight) }
|
||||||
private var defaultBadgeSize: CGFloat = 16
|
private var widthConstraint: NSLayoutConstraint?
|
||||||
|
private var heightConstraint: NSLayoutConstraint?
|
||||||
|
private var labelContraints = NSLayoutConstraint.Container()
|
||||||
|
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
// MARK: - Lifecycle
|
// MARK: - Lifecycle
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
|
|
||||||
open override func setup() {
|
open override func setup() {
|
||||||
super.setup()
|
super.setup()
|
||||||
|
|
||||||
|
addSubview(badgeView)
|
||||||
|
badgeView.addSubview(label)
|
||||||
accessibilityElements = [label]
|
accessibilityElements = [label]
|
||||||
|
|
||||||
addSubview(label)
|
heightConstraint = badgeView.heightAnchor.constraint(greaterThanOrEqualToConstant: badgeSize)
|
||||||
label.pinToSuperView()
|
heightConstraint?.isActive = true
|
||||||
|
|
||||||
|
widthConstraint = badgeView.widthAnchor.constraint(greaterThanOrEqualToConstant: badgeSize)
|
||||||
|
widthConstraint?.isActive = true
|
||||||
|
|
||||||
|
//we are insetting the padding to compensate for the border
|
||||||
NSLayoutConstraint.activate([
|
NSLayoutConstraint.activate([
|
||||||
label.centerXAnchor.constraint(equalTo: centerXAnchor),
|
badgeView.topAnchor.constraint(equalTo: topAnchor, constant: borderWidth),
|
||||||
label.centerYAnchor.constraint(equalTo: centerYAnchor)
|
badgeView.bottomAnchor.constraint(equalTo: bottomAnchor, constant: -borderWidth),
|
||||||
])
|
badgeView.leadingAnchor.constraint(equalTo: leadingAnchor, constant: borderWidth),
|
||||||
|
badgeView.trailingAnchor.constraint(equalTo: trailingAnchor, constant: -borderWidth)])
|
||||||
labelWidthConstraint = label.widthGreaterThanEqualTo(constant: defaultBadgeSize).activate()
|
|
||||||
labelHeightConstraint = label.heightGreaterThanEqualTo(constant: defaultBadgeSize).activate()
|
labelContraints.topConstraint = label.pinTopGreaterThanOrEqualTo(anchor: badgeView.topAnchor)
|
||||||
|
labelContraints.bottomConstraint = label.pinBottomGreaterThanOrEqualTo(anchor: badgeView.bottomAnchor)
|
||||||
|
labelContraints.leadingConstraint = label.pinLeadingGreaterThanOrEqualTo(anchor: badgeView.leadingAnchor)
|
||||||
|
labelContraints.trailingConstraint = label.pinTrailingGreaterThanOrEqualTo(anchor: badgeView.trailingAnchor)
|
||||||
|
label.centerXAnchor.constraint(equalTo: badgeView.centerXAnchor).isActive = true
|
||||||
|
label.centerYAnchor.constraint(equalTo: badgeView.centerYAnchor).isActive = true
|
||||||
|
labelContraints.isActive = true
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
open override func reset() {
|
open override func reset() {
|
||||||
@ -217,6 +224,19 @@ open class BadgeIndicator: View {
|
|||||||
shouldUpdateView = true
|
shouldUpdateView = true
|
||||||
setNeedsUpdate()
|
setNeedsUpdate()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private var labelEdgeInset: UIEdgeInsets {
|
||||||
|
var newInset = size.edgeInset
|
||||||
|
if let verticalPadding, let horitonalPadding {
|
||||||
|
newInset = .init(top: verticalPadding, left: horitonalPadding, bottom: verticalPadding, right: horitonalPadding)
|
||||||
|
} else if let verticalPadding {
|
||||||
|
newInset = .init(top: verticalPadding, left: newInset.left, bottom: verticalPadding, right: newInset.right)
|
||||||
|
} else if let horitonalPadding {
|
||||||
|
newInset = .init(top: newInset.top, left: horitonalPadding, bottom: newInset.bottom, right: horitonalPadding)
|
||||||
|
}
|
||||||
|
|
||||||
|
return newInset
|
||||||
|
}
|
||||||
|
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
// MARK: - Configuration
|
// MARK: - Configuration
|
||||||
@ -264,12 +284,32 @@ open class BadgeIndicator: View {
|
|||||||
open override func updateView() {
|
open override func updateView() {
|
||||||
updateTextColorConfig()
|
updateTextColorConfig()
|
||||||
|
|
||||||
backgroundColor = backgroundColorConfiguration.getColor(self)
|
badgeView.backgroundColor = backgroundColorConfiguration.getColor(self)
|
||||||
|
|
||||||
label.useAttributedText = true
|
//height width
|
||||||
label.edgeInset = .init(top: 0, left: textSize.inset, bottom: 0, right: textSize.inset)
|
heightConstraint?.isActive = false
|
||||||
label.font = textSize.textStyle.font
|
widthConstraint?.isActive = false
|
||||||
label.textColor = textColorConfiguration.getColor(self)
|
if let width, let height, height > badgeSize, width > badgeSize, height <= width {
|
||||||
|
heightConstraint = badgeView.heightAnchor.constraint(equalToConstant: height)
|
||||||
|
widthConstraint = badgeView.widthAnchor.constraint(equalToConstant: width)
|
||||||
|
} else {
|
||||||
|
heightConstraint = badgeView.heightAnchor.constraint(greaterThanOrEqualToConstant: badgeSize)
|
||||||
|
widthConstraint = badgeView.widthAnchor.constraint(greaterThanOrEqualToConstant: badgeSize)
|
||||||
|
}
|
||||||
|
heightConstraint?.isActive = true
|
||||||
|
widthConstraint?.isActive = true
|
||||||
|
|
||||||
|
//label constraints
|
||||||
|
let insets = labelEdgeInset
|
||||||
|
labelContraints.isActive = false
|
||||||
|
labelContraints.topConstraint?.constant = insets.top
|
||||||
|
labelContraints.bottomConstraint?.constant = -insets.bottom
|
||||||
|
labelContraints.leadingConstraint?.constant = insets.left
|
||||||
|
labelContraints.trailingConstraint?.constant = -insets.right
|
||||||
|
labelContraints.isActive = true
|
||||||
|
|
||||||
|
//label properties
|
||||||
|
label.textStyle = size.textStyle
|
||||||
label.textColorConfiguration = textColorConfiguration.eraseToAnyColorable()
|
label.textColorConfiguration = textColorConfiguration.eraseToAnyColorable()
|
||||||
label.text = getText()
|
label.text = getText()
|
||||||
label.surface = surface
|
label.surface = surface
|
||||||
@ -308,33 +348,42 @@ open class BadgeIndicator: View {
|
|||||||
|
|
||||||
open override func layoutSubviews() {
|
open override func layoutSubviews() {
|
||||||
super.layoutSubviews()
|
super.layoutSubviews()
|
||||||
let size = textSize.textStyle.lineHeight
|
|
||||||
labelWidthConstraint?.constant = size
|
|
||||||
labelHeightConstraint?.constant = size
|
|
||||||
layer.cornerRadius = frame.size.height / 2
|
|
||||||
|
|
||||||
|
//update the cornerRadius
|
||||||
|
badgeView.layer.cornerRadius = badgeView.frame.size.height / 2
|
||||||
|
layer.cornerRadius = frame.size.height / 2
|
||||||
|
|
||||||
|
//border
|
||||||
if hideBorder {
|
if hideBorder {
|
||||||
layer.borderWidth = 0
|
layer.borderWidth = 0
|
||||||
} else {
|
} else {
|
||||||
|
layer.borderWidth = borderWidth
|
||||||
layer.borderColor = borderColorConfiguration.getColor(surface).cgColor
|
layer.borderColor = borderColorConfiguration.getColor(surface).cgColor
|
||||||
layer.borderWidth = 1
|
|
||||||
}
|
}
|
||||||
|
|
||||||
layer.remove(layerName: "dot")
|
//dot
|
||||||
|
badgeView.layer.remove(layerName: "dot")
|
||||||
if kind == .simple && !hideDot {
|
if kind == .simple && !hideDot {
|
||||||
let dotSize: CGFloat = bounds.width * 0.1875
|
//frame for the dot to sit inside
|
||||||
|
let frame = badgeView.frame
|
||||||
|
|
||||||
|
//default calculation if a dotSize isn't given
|
||||||
|
var dot: CGFloat = frame.width * 0.1875
|
||||||
|
if let dotSize, dotSize < frame.width, dotSize < frame.height {
|
||||||
|
dot = dotSize
|
||||||
|
}
|
||||||
|
|
||||||
|
//get the center of the frame
|
||||||
|
let centerX = (frame.width - dot) / 2.0
|
||||||
|
let centerY = (frame.height - dot) / 2.0
|
||||||
|
|
||||||
|
//create the layer to draw the dot
|
||||||
let dotLayer = CAShapeLayer()
|
let dotLayer = CAShapeLayer()
|
||||||
dotLayer.name = "dot"
|
dotLayer.name = "dot"
|
||||||
|
dotLayer.frame = .init(x: centerX, y: centerY, width: dot, height: dot)
|
||||||
let centerX = (bounds.width - dotSize) / 2.0
|
dotLayer.path = UIBezierPath(ovalIn: .init(origin: .zero, size: .init(width: dot, height: dot))).cgPath
|
||||||
let centerY = (bounds.width - dotSize) / 2.0
|
|
||||||
|
|
||||||
dotLayer.frame = .init(x: centerX, y: centerY, width: dotSize, height: dotSize)
|
|
||||||
dotLayer.path = UIBezierPath(ovalIn: .init(origin: .zero, size: .init(width: dotSize, height: dotSize))).cgPath
|
|
||||||
dotLayer.fillColor = textColorConfiguration.getColor(self).cgColor
|
dotLayer.fillColor = textColorConfiguration.getColor(self).cgColor
|
||||||
|
badgeView.layer.addSublayer(dotLayer)
|
||||||
layer.addSublayer(dotLayer)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -169,42 +169,16 @@ open class ButtonBase: UIButton, Buttonable, Handlerable, ViewProtocol, Resettab
|
|||||||
// MARK: - PRIVATE
|
// MARK: - PRIVATE
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
private func updateLabel() {
|
private func updateLabel() {
|
||||||
let font = textStyle.font
|
|
||||||
|
|
||||||
//clear the arrays holding actions
|
//clear the arrays holding actions
|
||||||
accessibilityCustomActions = []
|
accessibilityCustomActions = []
|
||||||
|
|
||||||
//create the primary string
|
//create the primary string
|
||||||
let startingAttributes = [NSAttributedString.Key.font: font, NSAttributedString.Key.foregroundColor: textColor]
|
let mutableText = NSMutableAttributedString.mutableText(for: text ?? "No Text",
|
||||||
let mutableText = NSMutableAttributedString(string: text ?? "No Text", attributes: startingAttributes)
|
textStyle: textStyle,
|
||||||
|
textColor: textColor,
|
||||||
//set the local lineHeight/lineSpacing attributes
|
alignment: titleLabel?.textAlignment ?? .center,
|
||||||
//get the range
|
lineBreakMode: titleLabel?.lineBreakMode ?? .byTruncatingTail)
|
||||||
let entireRange = NSRange(location: 0, length: mutableText.length)
|
|
||||||
|
|
||||||
//set letterSpacing
|
|
||||||
if textStyle.letterSpacing > 0.0 {
|
|
||||||
mutableText.addAttribute(.kern, value: textStyle.letterSpacing, range: entireRange)
|
|
||||||
}
|
|
||||||
|
|
||||||
let paragraph = NSMutableParagraphStyle().with {
|
|
||||||
$0.alignment = titleLabel?.textAlignment ?? .center
|
|
||||||
$0.lineBreakMode = titleLabel?.lineBreakMode ?? .byTruncatingTail
|
|
||||||
}
|
|
||||||
|
|
||||||
//set lineHeight
|
|
||||||
if textStyle.lineHeight > 0.0 {
|
|
||||||
let lineHeight = textStyle.lineHeight
|
|
||||||
let adjustment = lineHeight > font.lineHeight ? 2.0 : 1.0
|
|
||||||
let baselineOffset = (lineHeight - font.lineHeight) / 2.0 / adjustment
|
|
||||||
paragraph.maximumLineHeight = lineHeight
|
|
||||||
paragraph.minimumLineHeight = lineHeight
|
|
||||||
mutableText.addAttribute(.baselineOffset, value: baselineOffset, range: entireRange)
|
|
||||||
mutableText.addAttribute( .paragraphStyle, value: paragraph, range: entireRange)
|
|
||||||
|
|
||||||
} else {
|
|
||||||
mutableText.addAttribute( .paragraphStyle, value: paragraph, range: entireRange)
|
|
||||||
}
|
|
||||||
|
|
||||||
if let attributes = attributes {
|
if let attributes = attributes {
|
||||||
//loop through the models attributes
|
//loop through the models attributes
|
||||||
|
|||||||
@ -38,15 +38,7 @@ open class Label: UILabel, Handlerable, ViewProtocol, Resettable, UserInfoable {
|
|||||||
open var textPosition: TextPosition = .left { didSet { setNeedsUpdate() }}
|
open var textPosition: TextPosition = .left { didSet { setNeedsUpdate() }}
|
||||||
|
|
||||||
open var userInfo = [String: Primitive]()
|
open var userInfo = [String: Primitive]()
|
||||||
|
|
||||||
open var edgeInset: UIEdgeInsets = .zero {
|
|
||||||
didSet {
|
|
||||||
setNeedsUpdate()
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
override open var text: String? {
|
override open var text: String? {
|
||||||
didSet {
|
didSet {
|
||||||
attributes = nil
|
attributes = nil
|
||||||
@ -118,20 +110,15 @@ open class Label: UILabel, Handlerable, ViewProtocol, Resettable, UserInfoable {
|
|||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
open func updateView() {
|
open func updateView() {
|
||||||
if !useAttributedText {
|
if !useAttributedText {
|
||||||
textAlignment = textPosition.textAlignment
|
if let text = text {
|
||||||
textColor = textColorConfiguration.getColor(self)
|
|
||||||
font = textStyle.font
|
|
||||||
|
|
||||||
if let text = text, let font = font, let textColor = textColor {
|
|
||||||
accessibilityCustomActions = []
|
accessibilityCustomActions = []
|
||||||
|
|
||||||
//clear the arrays holding actions
|
|
||||||
//create the primary string
|
//create the primary string
|
||||||
let startingAttributes = [NSAttributedString.Key.font: font, NSAttributedString.Key.foregroundColor: textColor]
|
let mutableText = NSMutableAttributedString.mutableText(for: text,
|
||||||
let mutableText = NSMutableAttributedString(string: text, attributes: startingAttributes)
|
textStyle: textStyle,
|
||||||
|
textColor: textColorConfiguration.getColor(self),
|
||||||
//set the local lineHeight/lineSpacing attributes
|
alignment: textPosition.textAlignment,
|
||||||
setStyleAttributes(attributedString: mutableText)
|
lineBreakMode: lineBreakMode)
|
||||||
|
|
||||||
applyAttributes(mutableText)
|
applyAttributes(mutableText)
|
||||||
|
|
||||||
@ -168,48 +155,7 @@ open class Label: UILabel, Handlerable, ViewProtocol, Resettable, UserInfoable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private func setStyleAttributes(attributedString: NSMutableAttributedString) {
|
|
||||||
//get the range
|
|
||||||
let entireRange = NSRange(location: 0, length: attributedString.length)
|
|
||||||
|
|
||||||
//set letterSpacing
|
|
||||||
if textStyle.letterSpacing > 0.0 {
|
|
||||||
attributedString.addAttribute(.kern, value: textStyle.letterSpacing, range: entireRange)
|
|
||||||
}
|
|
||||||
|
|
||||||
//set lineHeight
|
|
||||||
if textStyle.lineHeight > 0.0 {
|
|
||||||
let lineHeight = textStyle.lineHeight
|
|
||||||
let adjustment = lineHeight > font.lineHeight ? 2.0 : 1.0
|
|
||||||
let baselineOffset = (lineHeight - font.lineHeight) / 2.0 / adjustment
|
|
||||||
let paragraph = NSMutableParagraphStyle().with {
|
|
||||||
$0.maximumLineHeight = lineHeight
|
|
||||||
$0.minimumLineHeight = lineHeight
|
|
||||||
$0.alignment = textPosition.textAlignment
|
|
||||||
$0.lineBreakMode = lineBreakMode
|
|
||||||
}
|
|
||||||
attributedString.addAttribute(.baselineOffset, value: baselineOffset, range: entireRange)
|
|
||||||
attributedString.addAttribute( .paragraphStyle, value: paragraph, range: entireRange)
|
|
||||||
|
|
||||||
} else if textPosition != .left {
|
|
||||||
let paragraph = NSMutableParagraphStyle().with {
|
|
||||||
$0.alignment = textPosition.textAlignment
|
|
||||||
$0.lineBreakMode = lineBreakMode
|
|
||||||
}
|
|
||||||
attributedString.addAttribute( .paragraphStyle, value: paragraph, range: entireRange)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
open override func drawText(in rect: CGRect) {
|
|
||||||
super.drawText(in: rect.inset(by: edgeInset))
|
|
||||||
}
|
|
||||||
|
|
||||||
open override var intrinsicContentSize: CGSize {
|
|
||||||
let size = super.intrinsicContentSize
|
|
||||||
return CGSize(width: size.width + edgeInset.left + edgeInset.right, height: size.height + edgeInset.top + edgeInset.bottom)
|
|
||||||
}
|
|
||||||
|
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
// MARK: - Actionable
|
// MARK: - Actionable
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
|
|||||||
@ -17,3 +17,33 @@ extension NSAttributedString {
|
|||||||
return NSAttributedString(attachment: spacerAttachment)
|
return NSAttributedString(attachment: spacerAttachment)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
extension NSMutableAttributedString {
|
||||||
|
public static func mutableText(for text: String, textStyle: TextStyle, textColor: UIColor, alignment: NSTextAlignment = .left, lineBreakMode: NSLineBreakMode) -> NSMutableAttributedString {
|
||||||
|
let startingAttributes = [NSAttributedString.Key.font: textStyle.font, NSAttributedString.Key.foregroundColor: textColor]
|
||||||
|
let attributedString = NSMutableAttributedString(string: text, attributes: startingAttributes)
|
||||||
|
|
||||||
|
//get the range
|
||||||
|
let entireRange = NSRange(location: 0, length: attributedString.length)
|
||||||
|
|
||||||
|
//set letterSpacing
|
||||||
|
if textStyle.letterSpacing > 0.0 {
|
||||||
|
attributedString.addAttribute(.kern, value: textStyle.letterSpacing, range: entireRange)
|
||||||
|
}
|
||||||
|
|
||||||
|
let paragraph = NSMutableParagraphStyle()
|
||||||
|
paragraph.alignment = alignment
|
||||||
|
paragraph.lineBreakMode = lineBreakMode
|
||||||
|
|
||||||
|
//set lineHeight
|
||||||
|
if textStyle.lineHeight > 0.0 {
|
||||||
|
let lineHeight = textStyle.lineHeight
|
||||||
|
paragraph.maximumLineHeight = lineHeight
|
||||||
|
paragraph.minimumLineHeight = lineHeight
|
||||||
|
}
|
||||||
|
|
||||||
|
attributedString.addAttribute( .paragraphStyle, value: paragraph, range: entireRange)
|
||||||
|
|
||||||
|
return attributedString
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@ -339,6 +339,17 @@ extension NSLayoutConstraint {
|
|||||||
public var widthConstraint: NSLayoutConstraint?
|
public var widthConstraint: NSLayoutConstraint?
|
||||||
public var heightConstraint: NSLayoutConstraint?
|
public var heightConstraint: NSLayoutConstraint?
|
||||||
|
|
||||||
|
public var isActive: Bool = false {
|
||||||
|
didSet{
|
||||||
|
topConstraint?.isActive = isActive
|
||||||
|
bottomConstraint?.isActive = isActive
|
||||||
|
leadingConstraint?.isActive = isActive
|
||||||
|
trailingConstraint?.isActive = isActive
|
||||||
|
heightConstraint?.isActive = isActive
|
||||||
|
widthConstraint?.isActive = isActive
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public init(){}
|
public init(){}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -7,7 +7,7 @@
|
|||||||
|
|
||||||
import Foundation
|
import Foundation
|
||||||
|
|
||||||
public enum Fonts: String, FontProtocol {
|
public enum Font: String, FontProtocol {
|
||||||
case dsBold
|
case dsBold
|
||||||
case dsRegular
|
case dsRegular
|
||||||
case dsLight
|
case dsLight
|
||||||
@ -1,4 +1,8 @@
|
|||||||
1.0.23
|
1.0.25
|
||||||
|
=======
|
||||||
|
- Added Size, Width, Height, Horizontal/Vertical Padding + more to Badge Indicator
|
||||||
|
|
||||||
|
1.0.24
|
||||||
=======
|
=======
|
||||||
- Added Badge Indicator
|
- Added Badge Indicator
|
||||||
- Refactored the TextStyle system to support Badge Indicator
|
- Refactored the TextStyle system to support Badge Indicator
|
||||||
|
|||||||
@ -28,7 +28,7 @@ public struct TextStyle: Equatable, RawRepresentable {
|
|||||||
public let pointSize: CGFloat
|
public let pointSize: CGFloat
|
||||||
public let lineHeight: CGFloat
|
public let lineHeight: CGFloat
|
||||||
public let letterSpacing: CGFloat
|
public let letterSpacing: CGFloat
|
||||||
public let fontFace: Fonts
|
public let fontFace: Font
|
||||||
|
|
||||||
public init?(rawValue: String) {
|
public init?(rawValue: String) {
|
||||||
guard let style = TextStyle.textStyle(for: rawValue) else { return nil }
|
guard let style = TextStyle.textStyle(for: rawValue) else { return nil }
|
||||||
@ -39,7 +39,7 @@ public struct TextStyle: Equatable, RawRepresentable {
|
|||||||
self.fontFace = style.fontFace
|
self.fontFace = style.fontFace
|
||||||
}
|
}
|
||||||
|
|
||||||
public init(rawValue: String, fontFace: Fonts, pointSize: CGFloat, lineHeight: CGFloat, letterSpacing: CGFloat) {
|
public init(rawValue: String, fontFace: Font, pointSize: CGFloat = 0.0, lineHeight: CGFloat = 0.0, letterSpacing: CGFloat = 0.0) {
|
||||||
self.rawValue = rawValue
|
self.rawValue = rawValue
|
||||||
self.fontFace = fontFace
|
self.fontFace = fontFace
|
||||||
self.pointSize = pointSize
|
self.pointSize = pointSize
|
||||||
@ -48,6 +48,9 @@ public struct TextStyle: Equatable, RawRepresentable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
extension VDSTypography {
|
||||||
|
public static let letterSpacingSemiWide: CGFloat = 0.25
|
||||||
|
}
|
||||||
//MARK: Definitions
|
//MARK: Definitions
|
||||||
extension TextStyle {
|
extension TextStyle {
|
||||||
|
|
||||||
@ -56,169 +59,169 @@ extension TextStyle {
|
|||||||
fontFace: .dsLight,
|
fontFace: .dsLight,
|
||||||
pointSize: UIDevice.isIPad ? VDSTypography.fontSizeFeature144 : VDSTypography.fontSizeFeature96,
|
pointSize: UIDevice.isIPad ? VDSTypography.fontSizeFeature144 : VDSTypography.fontSizeFeature96,
|
||||||
lineHeight: UIDevice.isIPad ? VDSTypography.lineHeightFeature136 : VDSTypography.lineHeightFeature88,
|
lineHeight: UIDevice.isIPad ? VDSTypography.lineHeightFeature136 : VDSTypography.lineHeightFeature88,
|
||||||
letterSpacing: 0.25)
|
letterSpacing: VDSTypography.letterSpacingSemiWide)
|
||||||
|
|
||||||
public static let boldFeatureXLarge = TextStyle(rawValue: "boldFeatureXLarge",
|
public static let boldFeatureXLarge = TextStyle(rawValue: "boldFeatureXLarge",
|
||||||
fontFace: .dsBold,
|
fontFace: .dsBold,
|
||||||
pointSize: UIDevice.isIPad ? VDSTypography.fontSizeFeature144 : VDSTypography.fontSizeFeature96,
|
pointSize: UIDevice.isIPad ? VDSTypography.fontSizeFeature144 : VDSTypography.fontSizeFeature96,
|
||||||
lineHeight: UIDevice.isIPad ? VDSTypography.lineHeightFeature136 : VDSTypography.lineHeightFeature88,
|
lineHeight: UIDevice.isIPad ? VDSTypography.lineHeightFeature136 : VDSTypography.lineHeightFeature88,
|
||||||
letterSpacing: 0.25)
|
letterSpacing: 0)
|
||||||
|
|
||||||
public static let featureLarge = TextStyle(rawValue: "featureLarge",
|
public static let featureLarge = TextStyle(rawValue: "featureLarge",
|
||||||
fontFace: .dsLight,
|
fontFace: .dsLight,
|
||||||
pointSize: UIDevice.isIPad ? VDSTypography.fontSizeFeature128 : VDSTypography.fontSizeFeature80,
|
pointSize: UIDevice.isIPad ? VDSTypography.fontSizeFeature128 : VDSTypography.fontSizeFeature80,
|
||||||
lineHeight: UIDevice.isIPad ? VDSTypography.lineHeightFeature120 : VDSTypography.lineHeightFeature76,
|
lineHeight: UIDevice.isIPad ? VDSTypography.lineHeightFeature120 : VDSTypography.lineHeightFeature76,
|
||||||
letterSpacing: 0.25)
|
letterSpacing: VDSTypography.letterSpacingSemiWide)
|
||||||
|
|
||||||
public static let boldFeatureLarge = TextStyle(rawValue: "boldFeatureLarge",
|
public static let boldFeatureLarge = TextStyle(rawValue: "boldFeatureLarge",
|
||||||
fontFace: .dsBold,
|
fontFace: .dsBold,
|
||||||
pointSize: UIDevice.isIPad ? VDSTypography.fontSizeFeature128 : VDSTypography.fontSizeFeature80,
|
pointSize: UIDevice.isIPad ? VDSTypography.fontSizeFeature128 : VDSTypography.fontSizeFeature80,
|
||||||
lineHeight: UIDevice.isIPad ? VDSTypography.lineHeightFeature120 : VDSTypography.lineHeightFeature76,
|
lineHeight: UIDevice.isIPad ? VDSTypography.lineHeightFeature120 : VDSTypography.lineHeightFeature76,
|
||||||
letterSpacing: 0.25)
|
letterSpacing: 0)
|
||||||
|
|
||||||
public static let featureMedium = TextStyle(rawValue: "featureMedium",
|
public static let featureMedium = TextStyle(rawValue: "featureMedium",
|
||||||
fontFace: .dsLight,
|
fontFace: .dsLight,
|
||||||
pointSize: UIDevice.isIPad ? VDSTypography.fontSizeFeature96 : VDSTypography.fontSizeFeature64,
|
pointSize: UIDevice.isIPad ? VDSTypography.fontSizeFeature96 : VDSTypography.fontSizeFeature64,
|
||||||
lineHeight: UIDevice.isIPad ? VDSTypography.lineHeightFeature88 : VDSTypography.lineHeightFeature64,
|
lineHeight: UIDevice.isIPad ? VDSTypography.lineHeightFeature88 : VDSTypography.lineHeightFeature64,
|
||||||
letterSpacing: 0.25)
|
letterSpacing: VDSTypography.letterSpacingSemiWide)
|
||||||
|
|
||||||
public static let boldFeatureMedium = TextStyle(rawValue: "boldFeatureMedium",
|
public static let boldFeatureMedium = TextStyle(rawValue: "boldFeatureMedium",
|
||||||
fontFace: .dsBold,
|
fontFace: .dsBold,
|
||||||
pointSize: UIDevice.isIPad ? VDSTypography.fontSizeFeature96 : VDSTypography.fontSizeFeature64,
|
pointSize: UIDevice.isIPad ? VDSTypography.fontSizeFeature96 : VDSTypography.fontSizeFeature64,
|
||||||
lineHeight: UIDevice.isIPad ? VDSTypography.lineHeightFeature88 : VDSTypography.lineHeightFeature64,
|
lineHeight: UIDevice.isIPad ? VDSTypography.lineHeightFeature88 : VDSTypography.lineHeightFeature64,
|
||||||
letterSpacing: 0.25)
|
letterSpacing: 0)
|
||||||
|
|
||||||
public static let featureSmall = TextStyle(rawValue: "featureSmall",
|
public static let featureSmall = TextStyle(rawValue: "featureSmall",
|
||||||
fontFace: .dsLight,
|
fontFace: .dsLight,
|
||||||
pointSize: UIDevice.isIPad ? VDSTypography.fontSizeFeature80 : VDSTypography.fontSizeFeature48,
|
pointSize: UIDevice.isIPad ? VDSTypography.fontSizeFeature80 : VDSTypography.fontSizeFeature48,
|
||||||
lineHeight: UIDevice.isIPad ? VDSTypography.lineHeightFeature76 : VDSTypography.lineHeightFeature48,
|
lineHeight: UIDevice.isIPad ? VDSTypography.lineHeightFeature76 : VDSTypography.lineHeightFeature48,
|
||||||
letterSpacing: 0.25)
|
letterSpacing: VDSTypography.letterSpacingSemiWide)
|
||||||
|
|
||||||
public static let boldFeatureSmall = TextStyle(rawValue: "boldFeatureSmall",
|
public static let boldFeatureSmall = TextStyle(rawValue: "boldFeatureSmall",
|
||||||
fontFace: .dsBold,
|
fontFace: .dsBold,
|
||||||
pointSize: UIDevice.isIPad ? VDSTypography.fontSizeFeature80 : VDSTypography.fontSizeFeature48,
|
pointSize: UIDevice.isIPad ? VDSTypography.fontSizeFeature80 : VDSTypography.fontSizeFeature48,
|
||||||
lineHeight: UIDevice.isIPad ? VDSTypography.lineHeightFeature76 : VDSTypography.lineHeightFeature48,
|
lineHeight: UIDevice.isIPad ? VDSTypography.lineHeightFeature76 : VDSTypography.lineHeightFeature48,
|
||||||
letterSpacing: 0.25)
|
letterSpacing: 0)
|
||||||
|
|
||||||
public static let featureXSmall = TextStyle(rawValue: "featureXSmall",
|
public static let featureXSmall = TextStyle(rawValue: "featureXSmall",
|
||||||
fontFace: .dsLight,
|
fontFace: .dsLight,
|
||||||
pointSize: UIDevice.isIPad ? VDSTypography.fontSizeFeature64 : VDSTypography.fontSizeFeature40,
|
pointSize: UIDevice.isIPad ? VDSTypography.fontSizeFeature64 : VDSTypography.fontSizeFeature40,
|
||||||
lineHeight: UIDevice.isIPad ? VDSTypography.lineHeightFeature64 : VDSTypography.lineHeightFeature40,
|
lineHeight: UIDevice.isIPad ? VDSTypography.lineHeightFeature64 : VDSTypography.lineHeightFeature40,
|
||||||
letterSpacing: 0.25)
|
letterSpacing: VDSTypography.letterSpacingSemiWide)
|
||||||
|
|
||||||
public static let boldFeatureXSmall = TextStyle(rawValue: "boldFeatureXSmall",
|
public static let boldFeatureXSmall = TextStyle(rawValue: "boldFeatureXSmall",
|
||||||
fontFace: .dsBold,
|
fontFace: .dsBold,
|
||||||
pointSize: UIDevice.isIPad ? VDSTypography.fontSizeFeature64 : VDSTypography.fontSizeFeature40,
|
pointSize: UIDevice.isIPad ? VDSTypography.fontSizeFeature64 : VDSTypography.fontSizeFeature40,
|
||||||
lineHeight: UIDevice.isIPad ? VDSTypography.lineHeightFeature64 : VDSTypography.lineHeightFeature40,
|
lineHeight: UIDevice.isIPad ? VDSTypography.lineHeightFeature64 : VDSTypography.lineHeightFeature40,
|
||||||
letterSpacing: 0.25)
|
letterSpacing: 0)
|
||||||
|
|
||||||
public static let title2XLarge = TextStyle(rawValue: "title2XLarge",
|
public static let title2XLarge = TextStyle(rawValue: "title2XLarge",
|
||||||
fontFace: .dsLight,
|
fontFace: .dsLight,
|
||||||
pointSize: UIDevice.isIPad ? VDSTypography.fontSizeTitle64 : VDSTypography.fontSizeTitle40,
|
pointSize: UIDevice.isIPad ? VDSTypography.fontSizeTitle64 : VDSTypography.fontSizeTitle40,
|
||||||
lineHeight: UIDevice.isIPad ? VDSTypography.lineHeightTitle64 : VDSTypography.lineHeightTitle40,
|
lineHeight: UIDevice.isIPad ? VDSTypography.lineHeightTitle64 : VDSTypography.lineHeightTitle40,
|
||||||
letterSpacing: 0.25)
|
letterSpacing: VDSTypography.letterSpacingSemiWide)
|
||||||
|
|
||||||
public static let boldTitle2XLarge = TextStyle(rawValue: "boldTitle2XLarge",
|
public static let boldTitle2XLarge = TextStyle(rawValue: "boldTitle2XLarge",
|
||||||
fontFace: .dsBold,
|
fontFace: .dsBold,
|
||||||
pointSize: UIDevice.isIPad ? VDSTypography.fontSizeTitle64 : VDSTypography.fontSizeTitle40,
|
pointSize: UIDevice.isIPad ? VDSTypography.fontSizeTitle64 : VDSTypography.fontSizeTitle40,
|
||||||
lineHeight: UIDevice.isIPad ? VDSTypography.lineHeightTitle64 : VDSTypography.lineHeightTitle40,
|
lineHeight: UIDevice.isIPad ? VDSTypography.lineHeightTitle64 : VDSTypography.lineHeightTitle40,
|
||||||
letterSpacing: 0.25)
|
letterSpacing: 0)
|
||||||
|
|
||||||
public static let titleXLarge = TextStyle(rawValue: "titleXLarge",
|
public static let titleXLarge = TextStyle(rawValue: "titleXLarge",
|
||||||
fontFace: .dsLight,
|
fontFace: .dsLight,
|
||||||
pointSize: UIDevice.isIPad ? VDSTypography.fontSizeTitle48 : VDSTypography.fontSizeTitle32,
|
pointSize: UIDevice.isIPad ? VDSTypography.fontSizeTitle48 : VDSTypography.fontSizeTitle32,
|
||||||
lineHeight: UIDevice.isIPad ? VDSTypography.lineHeightTitle48 : VDSTypography.lineHeightTitle36,
|
lineHeight: UIDevice.isIPad ? VDSTypography.lineHeightTitle48 : VDSTypography.lineHeightTitle36,
|
||||||
letterSpacing: 0.25)
|
letterSpacing: VDSTypography.letterSpacingSemiWide)
|
||||||
|
|
||||||
public static let boldTitleXLarge = TextStyle(rawValue: "boldTitleXLarge",
|
public static let boldTitleXLarge = TextStyle(rawValue: "boldTitleXLarge",
|
||||||
fontFace: .dsBold,
|
fontFace: .dsBold,
|
||||||
pointSize: UIDevice.isIPad ? VDSTypography.fontSizeTitle48 : VDSTypography.fontSizeTitle32,
|
pointSize: UIDevice.isIPad ? VDSTypography.fontSizeTitle48 : VDSTypography.fontSizeTitle32,
|
||||||
lineHeight: UIDevice.isIPad ? VDSTypography.lineHeightTitle48 : VDSTypography.lineHeightTitle36,
|
lineHeight: UIDevice.isIPad ? VDSTypography.lineHeightTitle48 : VDSTypography.lineHeightTitle36,
|
||||||
letterSpacing: 0.25)
|
letterSpacing: 0)
|
||||||
|
|
||||||
public static let titleLarge = TextStyle(rawValue: "titleLarge",
|
public static let titleLarge = TextStyle(rawValue: "titleLarge",
|
||||||
fontFace: .dsLight,
|
fontFace: .dsLight,
|
||||||
pointSize: UIDevice.isIPad ? VDSTypography.fontSizeTitle32 : VDSTypography.fontSizeTitle24,
|
pointSize: UIDevice.isIPad ? VDSTypography.fontSizeTitle32 : VDSTypography.fontSizeTitle24,
|
||||||
lineHeight: UIDevice.isIPad ? VDSTypography.lineHeightTitle36 : VDSTypography.lineHeightTitle28,
|
lineHeight: UIDevice.isIPad ? VDSTypography.lineHeightTitle36 : VDSTypography.lineHeightTitle28,
|
||||||
letterSpacing: 0.25)
|
letterSpacing: VDSTypography.letterSpacingSemiWide)
|
||||||
|
|
||||||
public static let boldTitleLarge = TextStyle(rawValue: "boldTitleLarge",
|
public static let boldTitleLarge = TextStyle(rawValue: "boldTitleLarge",
|
||||||
fontFace: .dsBold,
|
fontFace: .dsBold,
|
||||||
pointSize: UIDevice.isIPad ? VDSTypography.fontSizeTitle32 : VDSTypography.fontSizeTitle24,
|
pointSize: UIDevice.isIPad ? VDSTypography.fontSizeTitle32 : VDSTypography.fontSizeTitle24,
|
||||||
lineHeight: UIDevice.isIPad ? VDSTypography.lineHeightTitle36 : VDSTypography.lineHeightTitle28,
|
lineHeight: UIDevice.isIPad ? VDSTypography.lineHeightTitle36 : VDSTypography.lineHeightTitle28,
|
||||||
letterSpacing: 0.25)
|
letterSpacing: 0)
|
||||||
|
|
||||||
public static let titleMedium = TextStyle(rawValue: "titleMedium",
|
public static let titleMedium = TextStyle(rawValue: "titleMedium",
|
||||||
fontFace: .dsLight,
|
fontFace: .dsLight,
|
||||||
pointSize: UIDevice.isIPad ? VDSTypography.fontSizeTitle24 : VDSTypography.fontSizeTitle20,
|
pointSize: UIDevice.isIPad ? VDSTypography.fontSizeTitle24 : VDSTypography.fontSizeTitle20,
|
||||||
lineHeight: UIDevice.isIPad ? VDSTypography.lineHeightTitle28 : VDSTypography.lineHeightTitle24,
|
lineHeight: UIDevice.isIPad ? VDSTypography.lineHeightTitle28 : VDSTypography.lineHeightTitle24,
|
||||||
letterSpacing: 0.25)
|
letterSpacing: 0)
|
||||||
|
|
||||||
public static let boldTitleMedium = TextStyle(rawValue: "boldTitleMedium",
|
public static let boldTitleMedium = TextStyle(rawValue: "boldTitleMedium",
|
||||||
fontFace: .dsBold,
|
fontFace: .dsBold,
|
||||||
pointSize: UIDevice.isIPad ? VDSTypography.fontSizeTitle24 : VDSTypography.fontSizeTitle20,
|
pointSize: UIDevice.isIPad ? VDSTypography.fontSizeTitle24 : VDSTypography.fontSizeTitle20,
|
||||||
lineHeight: UIDevice.isIPad ? VDSTypography.lineHeightTitle28 : VDSTypography.lineHeightTitle24,
|
lineHeight: UIDevice.isIPad ? VDSTypography.lineHeightTitle28 : VDSTypography.lineHeightTitle24,
|
||||||
letterSpacing: 0.25)
|
letterSpacing: 0)
|
||||||
|
|
||||||
public static let titleSmall = TextStyle(rawValue: "titleSmall",
|
public static let titleSmall = TextStyle(rawValue: "titleSmall",
|
||||||
fontFace: .dsLight,
|
fontFace: .dsLight,
|
||||||
pointSize: UIDevice.isIPad ? VDSTypography.fontSizeTitle20 : VDSTypography.fontSizeTitle16,
|
pointSize: UIDevice.isIPad ? VDSTypography.fontSizeTitle20 : VDSTypography.fontSizeTitle16,
|
||||||
lineHeight: UIDevice.isIPad ? VDSTypography.lineHeightTitle24 : VDSTypography.lineHeightTitle20,
|
lineHeight: UIDevice.isIPad ? VDSTypography.lineHeightTitle24 : VDSTypography.lineHeightTitle20,
|
||||||
letterSpacing: 0.25)
|
letterSpacing: 0)
|
||||||
|
|
||||||
public static let boldTitleSmall = TextStyle(rawValue: "boldTitleSmall",
|
public static let boldTitleSmall = TextStyle(rawValue: "boldTitleSmall",
|
||||||
fontFace: .dsBold,
|
fontFace: .dsBold,
|
||||||
pointSize: UIDevice.isIPad ? VDSTypography.fontSizeTitle20 : VDSTypography.fontSizeTitle16,
|
pointSize: UIDevice.isIPad ? VDSTypography.fontSizeTitle20 : VDSTypography.fontSizeTitle16,
|
||||||
lineHeight: UIDevice.isIPad ? VDSTypography.lineHeightTitle24 : VDSTypography.lineHeightTitle20,
|
lineHeight: UIDevice.isIPad ? VDSTypography.lineHeightTitle24 : VDSTypography.lineHeightTitle20,
|
||||||
letterSpacing: 0.25)
|
letterSpacing: 0)
|
||||||
|
|
||||||
public static let bodyLarge = TextStyle(rawValue: "bodyLarge",
|
public static let bodyLarge = TextStyle(rawValue: "bodyLarge",
|
||||||
fontFace: .dsRegular,
|
fontFace: .dsRegular,
|
||||||
pointSize: VDSTypography.fontSizeBody16,
|
pointSize: VDSTypography.fontSizeBody16,
|
||||||
lineHeight: VDSTypography.lineHeightBody20,
|
lineHeight: VDSTypography.lineHeightBody20,
|
||||||
letterSpacing: 0.5)
|
letterSpacing:VDSTypography.letterSpacingWide)
|
||||||
|
|
||||||
public static let boldBodyLarge = TextStyle(rawValue: "boldBodyLarge",
|
public static let boldBodyLarge = TextStyle(rawValue: "boldBodyLarge",
|
||||||
fontFace: .dsBold,
|
fontFace: .dsBold,
|
||||||
pointSize: VDSTypography.fontSizeBody16,
|
pointSize: VDSTypography.fontSizeBody16,
|
||||||
lineHeight: VDSTypography.lineHeightBody20,
|
lineHeight: VDSTypography.lineHeightBody20,
|
||||||
letterSpacing: 0.5)
|
letterSpacing: VDSTypography.letterSpacingWide)
|
||||||
|
|
||||||
public static let bodyMedium = TextStyle(rawValue: "bodyMedium",
|
public static let bodyMedium = TextStyle(rawValue: "bodyMedium",
|
||||||
fontFace: .dsRegular,
|
fontFace: .dsRegular,
|
||||||
pointSize: VDSTypography.fontSizeBody14,
|
pointSize: VDSTypography.fontSizeBody14,
|
||||||
lineHeight: VDSTypography.lineHeightBody18,
|
lineHeight: VDSTypography.lineHeightBody18,
|
||||||
letterSpacing: 0.5)
|
letterSpacing: VDSTypography.letterSpacingWide)
|
||||||
|
|
||||||
public static let boldBodyMedium = TextStyle(rawValue: "boldBodyMedium",
|
public static let boldBodyMedium = TextStyle(rawValue: "boldBodyMedium",
|
||||||
fontFace: .dsBold,
|
fontFace: .dsBold,
|
||||||
pointSize: VDSTypography.fontSizeBody14,
|
pointSize: VDSTypography.fontSizeBody14,
|
||||||
lineHeight: VDSTypography.lineHeightBody18,
|
lineHeight: VDSTypography.lineHeightBody18,
|
||||||
letterSpacing: 0.5)
|
letterSpacing: VDSTypography.letterSpacingWide)
|
||||||
|
|
||||||
public static let bodySmall = TextStyle(rawValue: "bodySmall",
|
public static let bodySmall = TextStyle(rawValue: "bodySmall",
|
||||||
fontFace: .dsRegular,
|
fontFace: .dsRegular,
|
||||||
pointSize: VDSTypography.fontSizeBody12,
|
pointSize: VDSTypography.fontSizeBody12,
|
||||||
lineHeight: VDSTypography.lineHeightBody16,
|
lineHeight: VDSTypography.lineHeightBody16,
|
||||||
letterSpacing: 0.25)
|
letterSpacing: 0)
|
||||||
|
|
||||||
public static let boldBodySmall = TextStyle(rawValue: "boldBodySmall",
|
public static let boldBodySmall = TextStyle(rawValue: "boldBodySmall",
|
||||||
fontFace: .dsBold,
|
fontFace: .dsBold,
|
||||||
pointSize: VDSTypography.fontSizeBody12,
|
pointSize: VDSTypography.fontSizeBody12,
|
||||||
lineHeight: VDSTypography.lineHeightBody16,
|
lineHeight: VDSTypography.lineHeightBody16,
|
||||||
letterSpacing: 0.5)
|
letterSpacing: 0)
|
||||||
|
|
||||||
public static let micro = TextStyle(rawValue: "micro",
|
public static let micro = TextStyle(rawValue: "micro",
|
||||||
fontFace: .dsRegular,
|
fontFace: .dsRegular,
|
||||||
pointSize: VDSTypography.fontSizeMicro11,
|
pointSize: VDSTypography.fontSizeMicro11,
|
||||||
lineHeight: VDSTypography.lineHeightMicro16,
|
lineHeight: VDSTypography.lineHeightMicro16,
|
||||||
letterSpacing: 0.25)
|
letterSpacing: 0)
|
||||||
|
|
||||||
public static let boldMicro = TextStyle(rawValue: "boldMicro",
|
public static let boldMicro = TextStyle(rawValue: "boldMicro",
|
||||||
fontFace: .dsBold,
|
fontFace: .dsBold,
|
||||||
pointSize: VDSTypography.fontSizeMicro11,
|
pointSize: VDSTypography.fontSizeMicro11,
|
||||||
lineHeight: VDSTypography.lineHeightMicro16,
|
lineHeight: VDSTypography.lineHeightMicro16,
|
||||||
letterSpacing: 0.5)
|
letterSpacing: 0)
|
||||||
|
|
||||||
public static var allCases: [TextStyle] {
|
public static var allCases: [TextStyle] {
|
||||||
return [
|
return [
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user