refactored typograpicalStyle to textStyle

Signed-off-by: Matt Bruce <matt.bruce@verizon.com>
This commit is contained in:
Matt Bruce 2023-01-13 13:36:53 -06:00
parent 669e0d7625
commit 443636b723
14 changed files with 52 additions and 52 deletions

View File

@ -29,7 +29,7 @@ public class Badge: View, Accessable {
$0.adjustsFontSizeToFitWidth = false $0.adjustsFontSizeToFitWidth = false
$0.lineBreakMode = .byTruncatingTail $0.lineBreakMode = .byTruncatingTail
$0.textPosition = .left $0.textPosition = .left
$0.typograpicalStyle = .BoldBodySmall $0.textStyle = .BoldBodySmall
} }
//-------------------------------------------------- //--------------------------------------------------
@ -86,7 +86,7 @@ public class Badge: View, Accessable {
label.reset() label.reset()
label.lineBreakMode = .byTruncatingTail label.lineBreakMode = .byTruncatingTail
label.textPosition = .left label.textPosition = .left
label.typograpicalStyle = .BoldBodySmall label.textStyle = .BoldBodySmall
fillColor = .red fillColor = .red
text = "" text = ""

View File

@ -42,7 +42,7 @@ open class Button: ButtonBase, Useable {
textColorConfiguration.getColor(self) textColorConfiguration.getColor(self)
} }
open override var typograpicalStyle: TypographicalStyle { open override var textStyle: TypographicalStyle {
size == .large ? TypographicalStyle.BoldBodyLarge : TypographicalStyle.BoldBodySmall size == .large ? TypographicalStyle.BoldBodyLarge : TypographicalStyle.BoldBodySmall
} }

View File

@ -66,7 +66,7 @@ open class ButtonBase: UIButton, Buttonable, Handlerable, ViewProtocol, Resettab
} }
} }
open var typograpicalStyle: TypographicalStyle { .defaultStyle } open var textStyle: TypographicalStyle { .defaultStyle }
open var textColor: UIColor { .black } open var textColor: UIColor { .black }
@ -149,7 +149,7 @@ open class ButtonBase: UIButton, Buttonable, Handlerable, ViewProtocol, Resettab
// MARK: - PRIVATE // MARK: - PRIVATE
//-------------------------------------------------- //--------------------------------------------------
private func updateLabel() { private func updateLabel() {
let font = typograpicalStyle.font let font = textStyle.font
//clear the arrays holding actions //clear the arrays holding actions
accessibilityCustomActions = [] accessibilityCustomActions = []
@ -163,8 +163,8 @@ open class ButtonBase: UIButton, Buttonable, Handlerable, ViewProtocol, Resettab
let entireRange = NSRange(location: 0, length: mutableText.length) let entireRange = NSRange(location: 0, length: mutableText.length)
//set letterSpacing //set letterSpacing
if typograpicalStyle.letterSpacing > 0.0 { if textStyle.letterSpacing > 0.0 {
mutableText.addAttribute(.kern, value: typograpicalStyle.letterSpacing, range: entireRange) mutableText.addAttribute(.kern, value: textStyle.letterSpacing, range: entireRange)
} }
let paragraph = NSMutableParagraphStyle().with { let paragraph = NSMutableParagraphStyle().with {
@ -173,8 +173,8 @@ open class ButtonBase: UIButton, Buttonable, Handlerable, ViewProtocol, Resettab
} }
//set lineHeight //set lineHeight
if typograpicalStyle.lineHeight > 0.0 { if textStyle.lineHeight > 0.0 {
let lineHeight = typograpicalStyle.lineHeight let lineHeight = textStyle.lineHeight
let adjustment = lineHeight > font.lineHeight ? 2.0 : 1.0 let adjustment = lineHeight > font.lineHeight ? 2.0 : 1.0
let baselineOffset = (lineHeight - font.lineHeight) / 2.0 / adjustment let baselineOffset = (lineHeight - font.lineHeight) / 2.0 / adjustment
paragraph.maximumLineHeight = lineHeight paragraph.maximumLineHeight = lineHeight

View File

@ -26,7 +26,7 @@ open class TextLink: ButtonBase {
open override var availableSizes: [ButtonSize] { [.large, .small] } open override var availableSizes: [ButtonSize] { [.large, .small] }
open override var typograpicalStyle: TypographicalStyle { open override var textStyle: TypographicalStyle {
size == .large ? TypographicalStyle.BodyLarge : TypographicalStyle.BodySmall size == .large ? TypographicalStyle.BodyLarge : TypographicalStyle.BodySmall
} }

View File

@ -24,7 +24,7 @@ open class TextLinkCaret: ButtonBase {
//-------------------------------------------------- //--------------------------------------------------
// MARK: - Private Properties // MARK: - Private Properties
//-------------------------------------------------- //--------------------------------------------------
open override var typograpicalStyle: TypographicalStyle { open override var textStyle: TypographicalStyle {
TypographicalStyle.BoldBodyLarge TypographicalStyle.BoldBodyLarge
} }

View File

@ -76,19 +76,19 @@ open class CheckboxBase: Control, Accessable, DataTrackable, Errorable {
private var label = Label().with { private var label = Label().with {
$0.setContentCompressionResistancePriority(.required, for: .vertical) $0.setContentCompressionResistancePriority(.required, for: .vertical)
$0.textPosition = .left $0.textPosition = .left
$0.typograpicalStyle = .BoldBodyLarge $0.textStyle = .BoldBodyLarge
} }
private var childLabel = Label().with { private var childLabel = Label().with {
$0.setContentCompressionResistancePriority(.required, for: .vertical) $0.setContentCompressionResistancePriority(.required, for: .vertical)
$0.textPosition = .left $0.textPosition = .left
$0.typograpicalStyle = .BodyLarge $0.textStyle = .BodyLarge
} }
private var errorLabel = Label().with { private var errorLabel = Label().with {
$0.setContentCompressionResistancePriority(.required, for: .vertical) $0.setContentCompressionResistancePriority(.required, for: .vertical)
$0.textPosition = .left $0.textPosition = .left
$0.typograpicalStyle = .BodyMedium $0.textStyle = .BodyMedium
} }
//-------------------------------------------------- //--------------------------------------------------
@ -272,9 +272,9 @@ open class CheckboxBase: Control, Accessable, DataTrackable, Errorable {
childLabel.reset() childLabel.reset()
errorLabel.reset() errorLabel.reset()
label.typograpicalStyle = .BoldBodyLarge label.textStyle = .BoldBodyLarge
childLabel.typograpicalStyle = .BodyLarge childLabel.textStyle = .BodyLarge
errorLabel.typograpicalStyle = .BodyMedium errorLabel.textStyle = .BodyMedium
labelText = nil labelText = nil
labelTextAttributes = nil labelTextAttributes = nil

View File

@ -33,7 +33,7 @@ public class Label: UILabel, Handlerable, ViewProtocol, Resettable {
open var attributes: [any LabelAttributeModel]? { didSet { didChange() }} open var attributes: [any LabelAttributeModel]? { didSet { didChange() }}
open var typograpicalStyle: TypographicalStyle = .defaultStyle { didSet { didChange() }} open var textStyle: TypographicalStyle = .defaultStyle { didSet { didChange() }}
open var textPosition: TextPosition = .left { didSet { didChange() }} open var textPosition: TextPosition = .left { didSet { didChange() }}
@ -103,7 +103,7 @@ public class Label: UILabel, Handlerable, ViewProtocol, Resettable {
surface = .light surface = .light
disabled = false disabled = false
attributes = nil attributes = nil
typograpicalStyle = .defaultStyle textStyle = .defaultStyle
textPosition = .left textPosition = .left
text = nil text = nil
attributedText = nil attributedText = nil
@ -120,7 +120,7 @@ public class Label: UILabel, Handlerable, ViewProtocol, Resettable {
if !useAttributedText { if !useAttributedText {
textAlignment = textPosition.textAlignment textAlignment = textPosition.textAlignment
textColor = textColorConfiguration.getColor(self) textColor = textColorConfiguration.getColor(self)
font = typograpicalStyle.font font = textStyle.font
if let text = text, let font = font, let textColor = textColor { if let text = text, let font = font, let textColor = textColor {
//clear the arrays holding actions //clear the arrays holding actions
@ -169,13 +169,13 @@ public class Label: UILabel, Handlerable, ViewProtocol, Resettable {
let entireRange = NSRange(location: 0, length: attributedString.length) let entireRange = NSRange(location: 0, length: attributedString.length)
//set letterSpacing //set letterSpacing
if typograpicalStyle.letterSpacing > 0.0 { if textStyle.letterSpacing > 0.0 {
attributedString.addAttribute(.kern, value: typograpicalStyle.letterSpacing, range: entireRange) attributedString.addAttribute(.kern, value: textStyle.letterSpacing, range: entireRange)
} }
//set lineHeight //set lineHeight
if typograpicalStyle.lineHeight > 0.0 { if textStyle.lineHeight > 0.0 {
let lineHeight = typograpicalStyle.lineHeight let lineHeight = textStyle.lineHeight
let adjustment = lineHeight > font.lineHeight ? 2.0 : 1.0 let adjustment = lineHeight > font.lineHeight ? 2.0 : 1.0
let baselineOffset = (lineHeight - font.lineHeight) / 2.0 / adjustment let baselineOffset = (lineHeight - font.lineHeight) / 2.0 / adjustment
let paragraph = NSMutableParagraphStyle().with { let paragraph = NSMutableParagraphStyle().with {

View File

@ -70,19 +70,19 @@ open class RadioBoxBase: Control, Accessable, DataTrackable{
private var textLabel = Label().with { private var textLabel = Label().with {
$0.setContentCompressionResistancePriority(.required, for: .vertical) $0.setContentCompressionResistancePriority(.required, for: .vertical)
$0.textPosition = .left $0.textPosition = .left
$0.typograpicalStyle = .BoldBodyLarge $0.textStyle = .BoldBodyLarge
} }
private var subTextLabel = Label().with { private var subTextLabel = Label().with {
$0.setContentCompressionResistancePriority(.required, for: .vertical) $0.setContentCompressionResistancePriority(.required, for: .vertical)
$0.textPosition = .left $0.textPosition = .left
$0.typograpicalStyle = .BodyLarge $0.textStyle = .BodyLarge
} }
private var subTextRightLabel = Label().with { private var subTextRightLabel = Label().with {
$0.setContentCompressionResistancePriority(.required, for: .vertical) $0.setContentCompressionResistancePriority(.required, for: .vertical)
$0.textPosition = .right $0.textPosition = .right
$0.typograpicalStyle = .BodyLarge $0.textStyle = .BodyLarge
} }
//-------------------------------------------------- //--------------------------------------------------
@ -226,9 +226,9 @@ open class RadioBoxBase: Control, Accessable, DataTrackable{
subTextLabel.reset() subTextLabel.reset()
subTextRightLabel.reset() subTextRightLabel.reset()
textLabel.typograpicalStyle = .BoldBodyLarge textLabel.textStyle = .BoldBodyLarge
subTextLabel.typograpicalStyle = .BodyLarge subTextLabel.textStyle = .BodyLarge
subTextRightLabel.typograpicalStyle = .BodyLarge subTextRightLabel.textStyle = .BodyLarge
text = "Default Text" text = "Default Text"
textAttributes = nil textAttributes = nil

View File

@ -83,19 +83,19 @@ open class RadioButtonBase: Control, Accessable, DataTrackable, Errorable {
private var label = Label().with { private var label = Label().with {
$0.setContentCompressionResistancePriority(.required, for: .vertical) $0.setContentCompressionResistancePriority(.required, for: .vertical)
$0.textPosition = .left $0.textPosition = .left
$0.typograpicalStyle = .BoldBodyLarge $0.textStyle = .BoldBodyLarge
} }
private var childLabel = Label().with { private var childLabel = Label().with {
$0.setContentCompressionResistancePriority(.required, for: .vertical) $0.setContentCompressionResistancePriority(.required, for: .vertical)
$0.textPosition = .left $0.textPosition = .left
$0.typograpicalStyle = .BodyLarge $0.textStyle = .BodyLarge
} }
private var errorLabel = Label().with { private var errorLabel = Label().with {
$0.setContentCompressionResistancePriority(.required, for: .vertical) $0.setContentCompressionResistancePriority(.required, for: .vertical)
$0.textPosition = .left $0.textPosition = .left
$0.typograpicalStyle = .BodyMedium $0.textStyle = .BodyMedium
} }
//-------------------------------------------------- //--------------------------------------------------
@ -269,9 +269,9 @@ open class RadioButtonBase: Control, Accessable, DataTrackable, Errorable {
childLabel.reset() childLabel.reset()
errorLabel.reset() errorLabel.reset()
label.typograpicalStyle = .BoldBodyLarge label.textStyle = .BoldBodyLarge
childLabel.typograpicalStyle = .BodyLarge childLabel.textStyle = .BodyLarge
errorLabel.typograpicalStyle = .BodyMedium errorLabel.textStyle = .BodyMedium
labelText = nil labelText = nil
labelTextAttributes = nil labelTextAttributes = nil

View File

@ -117,7 +117,7 @@ public class RadioSwatchGroupBase<HandlerType: RadioSwatchBase>: SelectorGroupSe
open override func updateView() { open override func updateView() {
label.textPosition = .left label.textPosition = .left
label.typograpicalStyle = .BodySmall label.textStyle = .BodySmall
label.text = selectedHandler?.text ?? " " label.text = selectedHandler?.text ?? " "
label.surface = surface label.surface = surface
label.disabled = disabled label.disabled = disabled

View File

@ -50,19 +50,19 @@ open class EntryField: Control, Accessable {
$0.setContentCompressionResistancePriority(.required, for: .vertical) $0.setContentCompressionResistancePriority(.required, for: .vertical)
$0.attributes = [] $0.attributes = []
$0.textPosition = .left $0.textPosition = .left
$0.typograpicalStyle = .BodySmall $0.textStyle = .BodySmall
} }
internal var errorLabel = Label().with { internal var errorLabel = Label().with {
$0.setContentCompressionResistancePriority(.required, for: .vertical) $0.setContentCompressionResistancePriority(.required, for: .vertical)
$0.textPosition = .left $0.textPosition = .left
$0.typograpicalStyle = .BodySmall $0.textStyle = .BodySmall
} }
internal var helperLabel = Label().with { internal var helperLabel = Label().with {
$0.setContentCompressionResistancePriority(.required, for: .vertical) $0.setContentCompressionResistancePriority(.required, for: .vertical)
$0.textPosition = .left $0.textPosition = .left
$0.typograpicalStyle = .BodySmall $0.textStyle = .BodySmall
} }
internal var containerView: UIView = { internal var containerView: UIView = {
@ -249,7 +249,7 @@ open class EntryField: Control, Accessable {
let title = Label().with { let title = Label().with {
$0.setContentCompressionResistancePriority(.required, for: .vertical) $0.setContentCompressionResistancePriority(.required, for: .vertical)
$0.textPosition = .left $0.textPosition = .left
$0.typograpicalStyle = .BoldBodySmall $0.textStyle = .BoldBodySmall
$0.text = tooltipTitle $0.text = tooltipTitle
$0.surface = surface $0.surface = surface
$0.disabled = disabled $0.disabled = disabled
@ -258,7 +258,7 @@ open class EntryField: Control, Accessable {
let content = Label().with { let content = Label().with {
$0.setContentCompressionResistancePriority(.required, for: .vertical) $0.setContentCompressionResistancePriority(.required, for: .vertical)
$0.textPosition = .left $0.textPosition = .left
$0.typograpicalStyle = .BoldBodySmall $0.textStyle = .BoldBodySmall
$0.text = tooltipContent $0.text = tooltipContent
$0.surface = surface $0.surface = surface
$0.disabled = disabled $0.disabled = disabled
@ -283,11 +283,11 @@ open class EntryField: Control, Accessable {
helperLabel.reset() helperLabel.reset()
titleLabel.textPosition = .left titleLabel.textPosition = .left
titleLabel.typograpicalStyle = .BodySmall titleLabel.textStyle = .BodySmall
errorLabel.textPosition = .left errorLabel.textPosition = .left
errorLabel.typograpicalStyle = .BodySmall errorLabel.textStyle = .BodySmall
helperLabel.textPosition = .left helperLabel.textPosition = .left
helperLabel.typograpicalStyle = .BodySmall helperLabel.textStyle = .BodySmall
labelText = nil labelText = nil
helperText = nil helperText = nil

View File

@ -95,7 +95,7 @@ public class InputField: EntryField, UITextFieldDelegate {
private var successLabel = Label().with { private var successLabel = Label().with {
$0.setContentCompressionResistancePriority(.required, for: .vertical) $0.setContentCompressionResistancePriority(.required, for: .vertical)
$0.textPosition = .left $0.textPosition = .left
$0.typograpicalStyle = .BodySmall $0.textStyle = .BodySmall
} }
private var textField = UITextField().with { private var textField = UITextField().with {
@ -147,7 +147,7 @@ public class InputField: EntryField, UITextFieldDelegate {
successLabel.reset() successLabel.reset()
successLabel.textPosition = .left successLabel.textPosition = .left
successLabel.typograpicalStyle = .BodySmall successLabel.textStyle = .BodySmall
type = .text type = .text
showSuccess = false showSuccess = false

View File

@ -245,7 +245,7 @@ open class TitleLockup: View {
if let eyebrowModel, !eyebrowModel.text.isEmpty { if let eyebrowModel, !eyebrowModel.text.isEmpty {
eyebrowTextIsEmpty = false eyebrowTextIsEmpty = false
eyebrowLabel.textPosition = allLabelsTextPosition eyebrowLabel.textPosition = allLabelsTextPosition
eyebrowLabel.typograpicalStyle = otherTextStyle.value eyebrowLabel.textStyle = otherTextStyle.value
eyebrowLabel.text = eyebrowModel.text eyebrowLabel.text = eyebrowModel.text
eyebrowLabel.attributes = eyebrowModel.textAttributes eyebrowLabel.attributes = eyebrowModel.textAttributes
eyebrowLabel.numberOfLines = eyebrowModel.numberOfLines eyebrowLabel.numberOfLines = eyebrowModel.numberOfLines
@ -257,7 +257,7 @@ open class TitleLockup: View {
if let titleModel, !titleModel.text.isEmpty { if let titleModel, !titleModel.text.isEmpty {
titleTextIsEmpty = false titleTextIsEmpty = false
titleLabel.textPosition = allLabelsTextPosition titleLabel.textPosition = allLabelsTextPosition
titleLabel.typograpicalStyle = titleModel.textStyle.value titleLabel.textStyle = titleModel.textStyle.value
titleLabel.text = titleModel.text titleLabel.text = titleModel.text
titleLabel.attributes = titleModel.textAttributes titleLabel.attributes = titleModel.textAttributes
titleLabel.numberOfLines = titleModel.numberOfLines titleLabel.numberOfLines = titleModel.numberOfLines
@ -269,7 +269,7 @@ open class TitleLockup: View {
if let subTitleModel, !subTitleModel.text.isEmpty { if let subTitleModel, !subTitleModel.text.isEmpty {
subTitleTextIsEmpty = false subTitleTextIsEmpty = false
subTitleLabel.textPosition = allLabelsTextPosition subTitleLabel.textPosition = allLabelsTextPosition
subTitleLabel.typograpicalStyle = otherTextStyle.value subTitleLabel.textStyle = otherTextStyle.value
subTitleLabel.text = subTitleModel.text subTitleLabel.text = subTitleModel.text
subTitleLabel.attributes = subTitleModel.textAttributes subTitleLabel.attributes = subTitleModel.textAttributes
subTitleLabel.numberOfLines = subTitleModel.numberOfLines subTitleLabel.numberOfLines = subTitleModel.numberOfLines

View File

@ -102,7 +102,7 @@ open class ToggleBase: Control, Accessable, DataTrackable {
$0.setSurfaceColors(VDSColor.elementsPrimaryOndark, VDSColor.elementsPrimaryOndark, forState: .selected) $0.setSurfaceColors(VDSColor.elementsPrimaryOndark, VDSColor.elementsPrimaryOndark, forState: .selected)
} }
private var typograpicalStyle: TypographicalStyle { private var textStyle: TypographicalStyle {
if textSize == .small { if textSize == .small {
if textWeight == .bold { if textWeight == .bold {
return .BoldBodySmall return .BoldBodySmall
@ -225,7 +225,7 @@ open class ToggleBase: Control, Accessable, DataTrackable {
if showText { if showText {
label.textPosition = textPosition == .left ? .left : .right label.textPosition = textPosition == .left ? .left : .right
label.typograpicalStyle = typograpicalStyle label.textStyle = textStyle
label.text = isOn ? onText : offText label.text = isOn ? onText : offText
label.surface = surface label.surface = surface
label.disabled = disabled label.disabled = disabled