refactored typograpicalStyle to textStyle
Signed-off-by: Matt Bruce <matt.bruce@verizon.com>
This commit is contained in:
parent
669e0d7625
commit
443636b723
@ -29,7 +29,7 @@ public class Badge: View, Accessable {
|
||||
$0.adjustsFontSizeToFitWidth = false
|
||||
$0.lineBreakMode = .byTruncatingTail
|
||||
$0.textPosition = .left
|
||||
$0.typograpicalStyle = .BoldBodySmall
|
||||
$0.textStyle = .BoldBodySmall
|
||||
}
|
||||
|
||||
//--------------------------------------------------
|
||||
@ -86,7 +86,7 @@ public class Badge: View, Accessable {
|
||||
label.reset()
|
||||
label.lineBreakMode = .byTruncatingTail
|
||||
label.textPosition = .left
|
||||
label.typograpicalStyle = .BoldBodySmall
|
||||
label.textStyle = .BoldBodySmall
|
||||
|
||||
fillColor = .red
|
||||
text = ""
|
||||
|
||||
@ -42,7 +42,7 @@ open class Button: ButtonBase, Useable {
|
||||
textColorConfiguration.getColor(self)
|
||||
}
|
||||
|
||||
open override var typograpicalStyle: TypographicalStyle {
|
||||
open override var textStyle: TypographicalStyle {
|
||||
size == .large ? TypographicalStyle.BoldBodyLarge : TypographicalStyle.BoldBodySmall
|
||||
}
|
||||
|
||||
|
||||
@ -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 }
|
||||
|
||||
@ -149,7 +149,7 @@ open class ButtonBase: UIButton, Buttonable, Handlerable, ViewProtocol, Resettab
|
||||
// MARK: - PRIVATE
|
||||
//--------------------------------------------------
|
||||
private func updateLabel() {
|
||||
let font = typograpicalStyle.font
|
||||
let font = textStyle.font
|
||||
|
||||
//clear the arrays holding actions
|
||||
accessibilityCustomActions = []
|
||||
@ -163,8 +163,8 @@ open class ButtonBase: UIButton, Buttonable, Handlerable, ViewProtocol, Resettab
|
||||
let entireRange = NSRange(location: 0, length: mutableText.length)
|
||||
|
||||
//set letterSpacing
|
||||
if typograpicalStyle.letterSpacing > 0.0 {
|
||||
mutableText.addAttribute(.kern, value: typograpicalStyle.letterSpacing, range: entireRange)
|
||||
if textStyle.letterSpacing > 0.0 {
|
||||
mutableText.addAttribute(.kern, value: textStyle.letterSpacing, range: entireRange)
|
||||
}
|
||||
|
||||
let paragraph = NSMutableParagraphStyle().with {
|
||||
@ -173,8 +173,8 @@ open class ButtonBase: UIButton, Buttonable, Handlerable, ViewProtocol, Resettab
|
||||
}
|
||||
|
||||
//set lineHeight
|
||||
if typograpicalStyle.lineHeight > 0.0 {
|
||||
let lineHeight = typograpicalStyle.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
|
||||
|
||||
@ -26,7 +26,7 @@ open class TextLink: ButtonBase {
|
||||
|
||||
open override var availableSizes: [ButtonSize] { [.large, .small] }
|
||||
|
||||
open override var typograpicalStyle: TypographicalStyle {
|
||||
open override var textStyle: TypographicalStyle {
|
||||
size == .large ? TypographicalStyle.BodyLarge : TypographicalStyle.BodySmall
|
||||
}
|
||||
|
||||
|
||||
@ -24,7 +24,7 @@ open class TextLinkCaret: ButtonBase {
|
||||
//--------------------------------------------------
|
||||
// MARK: - Private Properties
|
||||
//--------------------------------------------------
|
||||
open override var typograpicalStyle: TypographicalStyle {
|
||||
open override var textStyle: TypographicalStyle {
|
||||
TypographicalStyle.BoldBodyLarge
|
||||
}
|
||||
|
||||
|
||||
@ -76,19 +76,19 @@ open class CheckboxBase: Control, Accessable, DataTrackable, Errorable {
|
||||
private var label = Label().with {
|
||||
$0.setContentCompressionResistancePriority(.required, for: .vertical)
|
||||
$0.textPosition = .left
|
||||
$0.typograpicalStyle = .BoldBodyLarge
|
||||
$0.textStyle = .BoldBodyLarge
|
||||
}
|
||||
|
||||
private var childLabel = Label().with {
|
||||
$0.setContentCompressionResistancePriority(.required, for: .vertical)
|
||||
$0.textPosition = .left
|
||||
$0.typograpicalStyle = .BodyLarge
|
||||
$0.textStyle = .BodyLarge
|
||||
}
|
||||
|
||||
private var errorLabel = Label().with {
|
||||
$0.setContentCompressionResistancePriority(.required, for: .vertical)
|
||||
$0.textPosition = .left
|
||||
$0.typograpicalStyle = .BodyMedium
|
||||
$0.textStyle = .BodyMedium
|
||||
}
|
||||
|
||||
//--------------------------------------------------
|
||||
@ -272,9 +272,9 @@ open class CheckboxBase: Control, Accessable, DataTrackable, Errorable {
|
||||
childLabel.reset()
|
||||
errorLabel.reset()
|
||||
|
||||
label.typograpicalStyle = .BoldBodyLarge
|
||||
childLabel.typograpicalStyle = .BodyLarge
|
||||
errorLabel.typograpicalStyle = .BodyMedium
|
||||
label.textStyle = .BoldBodyLarge
|
||||
childLabel.textStyle = .BodyLarge
|
||||
errorLabel.textStyle = .BodyMedium
|
||||
|
||||
labelText = nil
|
||||
labelTextAttributes = nil
|
||||
|
||||
@ -33,7 +33,7 @@ public class Label: UILabel, Handlerable, ViewProtocol, Resettable {
|
||||
|
||||
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() }}
|
||||
|
||||
@ -103,7 +103,7 @@ public class Label: UILabel, Handlerable, ViewProtocol, Resettable {
|
||||
surface = .light
|
||||
disabled = false
|
||||
attributes = nil
|
||||
typograpicalStyle = .defaultStyle
|
||||
textStyle = .defaultStyle
|
||||
textPosition = .left
|
||||
text = nil
|
||||
attributedText = nil
|
||||
@ -120,7 +120,7 @@ public class Label: UILabel, Handlerable, ViewProtocol, Resettable {
|
||||
if !useAttributedText {
|
||||
textAlignment = textPosition.textAlignment
|
||||
textColor = textColorConfiguration.getColor(self)
|
||||
font = typograpicalStyle.font
|
||||
font = textStyle.font
|
||||
|
||||
if let text = text, let font = font, let textColor = textColor {
|
||||
//clear the arrays holding actions
|
||||
@ -169,13 +169,13 @@ public class Label: UILabel, Handlerable, ViewProtocol, Resettable {
|
||||
let entireRange = NSRange(location: 0, length: attributedString.length)
|
||||
|
||||
//set letterSpacing
|
||||
if typograpicalStyle.letterSpacing > 0.0 {
|
||||
attributedString.addAttribute(.kern, value: typograpicalStyle.letterSpacing, range: entireRange)
|
||||
if textStyle.letterSpacing > 0.0 {
|
||||
attributedString.addAttribute(.kern, value: textStyle.letterSpacing, range: entireRange)
|
||||
}
|
||||
|
||||
//set lineHeight
|
||||
if typograpicalStyle.lineHeight > 0.0 {
|
||||
let lineHeight = typograpicalStyle.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 {
|
||||
|
||||
@ -70,19 +70,19 @@ open class RadioBoxBase: Control, Accessable, DataTrackable{
|
||||
private var textLabel = Label().with {
|
||||
$0.setContentCompressionResistancePriority(.required, for: .vertical)
|
||||
$0.textPosition = .left
|
||||
$0.typograpicalStyle = .BoldBodyLarge
|
||||
$0.textStyle = .BoldBodyLarge
|
||||
}
|
||||
|
||||
private var subTextLabel = Label().with {
|
||||
$0.setContentCompressionResistancePriority(.required, for: .vertical)
|
||||
$0.textPosition = .left
|
||||
$0.typograpicalStyle = .BodyLarge
|
||||
$0.textStyle = .BodyLarge
|
||||
}
|
||||
|
||||
private var subTextRightLabel = Label().with {
|
||||
$0.setContentCompressionResistancePriority(.required, for: .vertical)
|
||||
$0.textPosition = .right
|
||||
$0.typograpicalStyle = .BodyLarge
|
||||
$0.textStyle = .BodyLarge
|
||||
}
|
||||
|
||||
//--------------------------------------------------
|
||||
@ -226,9 +226,9 @@ open class RadioBoxBase: Control, Accessable, DataTrackable{
|
||||
subTextLabel.reset()
|
||||
subTextRightLabel.reset()
|
||||
|
||||
textLabel.typograpicalStyle = .BoldBodyLarge
|
||||
subTextLabel.typograpicalStyle = .BodyLarge
|
||||
subTextRightLabel.typograpicalStyle = .BodyLarge
|
||||
textLabel.textStyle = .BoldBodyLarge
|
||||
subTextLabel.textStyle = .BodyLarge
|
||||
subTextRightLabel.textStyle = .BodyLarge
|
||||
|
||||
text = "Default Text"
|
||||
textAttributes = nil
|
||||
|
||||
@ -83,19 +83,19 @@ open class RadioButtonBase: Control, Accessable, DataTrackable, Errorable {
|
||||
private var label = Label().with {
|
||||
$0.setContentCompressionResistancePriority(.required, for: .vertical)
|
||||
$0.textPosition = .left
|
||||
$0.typograpicalStyle = .BoldBodyLarge
|
||||
$0.textStyle = .BoldBodyLarge
|
||||
}
|
||||
|
||||
private var childLabel = Label().with {
|
||||
$0.setContentCompressionResistancePriority(.required, for: .vertical)
|
||||
$0.textPosition = .left
|
||||
$0.typograpicalStyle = .BodyLarge
|
||||
$0.textStyle = .BodyLarge
|
||||
}
|
||||
|
||||
private var errorLabel = Label().with {
|
||||
$0.setContentCompressionResistancePriority(.required, for: .vertical)
|
||||
$0.textPosition = .left
|
||||
$0.typograpicalStyle = .BodyMedium
|
||||
$0.textStyle = .BodyMedium
|
||||
}
|
||||
|
||||
//--------------------------------------------------
|
||||
@ -269,9 +269,9 @@ open class RadioButtonBase: Control, Accessable, DataTrackable, Errorable {
|
||||
childLabel.reset()
|
||||
errorLabel.reset()
|
||||
|
||||
label.typograpicalStyle = .BoldBodyLarge
|
||||
childLabel.typograpicalStyle = .BodyLarge
|
||||
errorLabel.typograpicalStyle = .BodyMedium
|
||||
label.textStyle = .BoldBodyLarge
|
||||
childLabel.textStyle = .BodyLarge
|
||||
errorLabel.textStyle = .BodyMedium
|
||||
|
||||
labelText = nil
|
||||
labelTextAttributes = nil
|
||||
|
||||
@ -117,7 +117,7 @@ public class RadioSwatchGroupBase<HandlerType: RadioSwatchBase>: SelectorGroupSe
|
||||
|
||||
open override func updateView() {
|
||||
label.textPosition = .left
|
||||
label.typograpicalStyle = .BodySmall
|
||||
label.textStyle = .BodySmall
|
||||
label.text = selectedHandler?.text ?? " "
|
||||
label.surface = surface
|
||||
label.disabled = disabled
|
||||
|
||||
@ -50,19 +50,19 @@ open class EntryField: Control, Accessable {
|
||||
$0.setContentCompressionResistancePriority(.required, for: .vertical)
|
||||
$0.attributes = []
|
||||
$0.textPosition = .left
|
||||
$0.typograpicalStyle = .BodySmall
|
||||
$0.textStyle = .BodySmall
|
||||
}
|
||||
|
||||
internal var errorLabel = Label().with {
|
||||
$0.setContentCompressionResistancePriority(.required, for: .vertical)
|
||||
$0.textPosition = .left
|
||||
$0.typograpicalStyle = .BodySmall
|
||||
$0.textStyle = .BodySmall
|
||||
}
|
||||
|
||||
internal var helperLabel = Label().with {
|
||||
$0.setContentCompressionResistancePriority(.required, for: .vertical)
|
||||
$0.textPosition = .left
|
||||
$0.typograpicalStyle = .BodySmall
|
||||
$0.textStyle = .BodySmall
|
||||
}
|
||||
|
||||
internal var containerView: UIView = {
|
||||
@ -249,7 +249,7 @@ open class EntryField: Control, Accessable {
|
||||
let title = Label().with {
|
||||
$0.setContentCompressionResistancePriority(.required, for: .vertical)
|
||||
$0.textPosition = .left
|
||||
$0.typograpicalStyle = .BoldBodySmall
|
||||
$0.textStyle = .BoldBodySmall
|
||||
$0.text = tooltipTitle
|
||||
$0.surface = surface
|
||||
$0.disabled = disabled
|
||||
@ -258,7 +258,7 @@ open class EntryField: Control, Accessable {
|
||||
let content = Label().with {
|
||||
$0.setContentCompressionResistancePriority(.required, for: .vertical)
|
||||
$0.textPosition = .left
|
||||
$0.typograpicalStyle = .BoldBodySmall
|
||||
$0.textStyle = .BoldBodySmall
|
||||
$0.text = tooltipContent
|
||||
$0.surface = surface
|
||||
$0.disabled = disabled
|
||||
@ -283,11 +283,11 @@ open class EntryField: Control, Accessable {
|
||||
helperLabel.reset()
|
||||
|
||||
titleLabel.textPosition = .left
|
||||
titleLabel.typograpicalStyle = .BodySmall
|
||||
titleLabel.textStyle = .BodySmall
|
||||
errorLabel.textPosition = .left
|
||||
errorLabel.typograpicalStyle = .BodySmall
|
||||
errorLabel.textStyle = .BodySmall
|
||||
helperLabel.textPosition = .left
|
||||
helperLabel.typograpicalStyle = .BodySmall
|
||||
helperLabel.textStyle = .BodySmall
|
||||
|
||||
labelText = nil
|
||||
helperText = nil
|
||||
|
||||
@ -95,7 +95,7 @@ public class InputField: EntryField, UITextFieldDelegate {
|
||||
private var successLabel = Label().with {
|
||||
$0.setContentCompressionResistancePriority(.required, for: .vertical)
|
||||
$0.textPosition = .left
|
||||
$0.typograpicalStyle = .BodySmall
|
||||
$0.textStyle = .BodySmall
|
||||
}
|
||||
|
||||
private var textField = UITextField().with {
|
||||
@ -147,7 +147,7 @@ public class InputField: EntryField, UITextFieldDelegate {
|
||||
|
||||
successLabel.reset()
|
||||
successLabel.textPosition = .left
|
||||
successLabel.typograpicalStyle = .BodySmall
|
||||
successLabel.textStyle = .BodySmall
|
||||
|
||||
type = .text
|
||||
showSuccess = false
|
||||
|
||||
@ -245,7 +245,7 @@ open class TitleLockup: View {
|
||||
if let eyebrowModel, !eyebrowModel.text.isEmpty {
|
||||
eyebrowTextIsEmpty = false
|
||||
eyebrowLabel.textPosition = allLabelsTextPosition
|
||||
eyebrowLabel.typograpicalStyle = otherTextStyle.value
|
||||
eyebrowLabel.textStyle = otherTextStyle.value
|
||||
eyebrowLabel.text = eyebrowModel.text
|
||||
eyebrowLabel.attributes = eyebrowModel.textAttributes
|
||||
eyebrowLabel.numberOfLines = eyebrowModel.numberOfLines
|
||||
@ -257,7 +257,7 @@ open class TitleLockup: View {
|
||||
if let titleModel, !titleModel.text.isEmpty {
|
||||
titleTextIsEmpty = false
|
||||
titleLabel.textPosition = allLabelsTextPosition
|
||||
titleLabel.typograpicalStyle = titleModel.textStyle.value
|
||||
titleLabel.textStyle = titleModel.textStyle.value
|
||||
titleLabel.text = titleModel.text
|
||||
titleLabel.attributes = titleModel.textAttributes
|
||||
titleLabel.numberOfLines = titleModel.numberOfLines
|
||||
@ -269,7 +269,7 @@ open class TitleLockup: View {
|
||||
if let subTitleModel, !subTitleModel.text.isEmpty {
|
||||
subTitleTextIsEmpty = false
|
||||
subTitleLabel.textPosition = allLabelsTextPosition
|
||||
subTitleLabel.typograpicalStyle = otherTextStyle.value
|
||||
subTitleLabel.textStyle = otherTextStyle.value
|
||||
subTitleLabel.text = subTitleModel.text
|
||||
subTitleLabel.attributes = subTitleModel.textAttributes
|
||||
subTitleLabel.numberOfLines = subTitleModel.numberOfLines
|
||||
|
||||
@ -102,7 +102,7 @@ open class ToggleBase: Control, Accessable, DataTrackable {
|
||||
$0.setSurfaceColors(VDSColor.elementsPrimaryOndark, VDSColor.elementsPrimaryOndark, forState: .selected)
|
||||
}
|
||||
|
||||
private var typograpicalStyle: TypographicalStyle {
|
||||
private var textStyle: TypographicalStyle {
|
||||
if textSize == .small {
|
||||
if textWeight == .bold {
|
||||
return .BoldBodySmall
|
||||
@ -225,7 +225,7 @@ open class ToggleBase: Control, Accessable, DataTrackable {
|
||||
|
||||
if showText {
|
||||
label.textPosition = textPosition == .left ? .left : .right
|
||||
label.typograpicalStyle = typograpicalStyle
|
||||
label.textStyle = textStyle
|
||||
label.text = isOn ? onText : offText
|
||||
label.surface = surface
|
||||
label.disabled = disabled
|
||||
|
||||
Loading…
Reference in New Issue
Block a user