refactored method into base
Signed-off-by: Matt Bruce <matt.bruce@verizon.com>
This commit is contained in:
parent
02315048fd
commit
b7ef70820d
@ -52,35 +52,12 @@ class LabelViewController: BaseViewController<Label> {
|
|||||||
var scaledMode: Bool { component.useScaledFont && TextStyle.canScaleFonts }
|
var scaledMode: Bool { component.useScaledFont && TextStyle.canScaleFonts }
|
||||||
var baseStyle: TextStyle! {
|
var baseStyle: TextStyle! {
|
||||||
didSet {
|
didSet {
|
||||||
baseStyleLabel.text = descriptionFor(style: baseStyle)
|
baseStyleLabel.text = descriptionFor(style: baseStyle,
|
||||||
|
useScaledLineHeight: useScaledLineHeight.isOn,
|
||||||
|
scaledMode: scaledMode)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func descriptionFor(style: TextStyle) -> String {
|
|
||||||
let scaledFont = style.font.scaledFont
|
|
||||||
var customizedDesc: String = "Name: \(style.rawValue) \nFont Face-Weight: \(style.font.fontName)"
|
|
||||||
customizedDesc += "\nVDS LetterSpacing: \(style.letterSpacing)"
|
|
||||||
if scaledMode {
|
|
||||||
customizedDesc += "\nVDS PointSize: \(style.pointSize.rounded())"
|
|
||||||
customizedDesc += "\n* iOS PointSize: \(scaledFont.pointSize.rounded())"
|
|
||||||
} else {
|
|
||||||
customizedDesc += "\n* VDS PointSize: \(style.pointSize.rounded())"
|
|
||||||
}
|
|
||||||
if scaledMode {
|
|
||||||
if useScaledLineHeight.isOn {
|
|
||||||
customizedDesc += "\nVDS LineHeight: \(style.lineHeight)"
|
|
||||||
customizedDesc += "\n* VDS Ratio LineHeight: \(style.scaledLineHeight)"
|
|
||||||
} else {
|
|
||||||
customizedDesc += "\n* VDS LineHeight: \(style.lineHeight)"
|
|
||||||
}
|
|
||||||
customizedDesc += "\niOS LineHeight: \(scaledFont.lineHeight.rounded())"
|
|
||||||
} else {
|
|
||||||
customizedDesc += "\n* VDS LineHeight: \(style.lineHeight)"
|
|
||||||
customizedDesc += "\niOS LineHeight: \(style.font.lineHeight.rounded())"
|
|
||||||
}
|
|
||||||
return customizedDesc
|
|
||||||
}
|
|
||||||
|
|
||||||
var currentStyle: TextStyle! {
|
var currentStyle: TextStyle! {
|
||||||
didSet {
|
didSet {
|
||||||
//--------------------------------------------------------------
|
//--------------------------------------------------------------
|
||||||
@ -106,8 +83,13 @@ class LabelViewController: BaseViewController<Label> {
|
|||||||
private var isBold: Bool = false
|
private var isBold: Bool = false
|
||||||
|
|
||||||
fileprivate func updateStyleLabel() {
|
fileprivate func updateStyleLabel() {
|
||||||
baseStyleLabel.text = descriptionFor(style: baseStyle)
|
baseStyleLabel.text = descriptionFor(style: baseStyle,
|
||||||
currentStyleLabel.text = descriptionFor(style: currentStyle)
|
useScaledLineHeight: useScaledLineHeight.isOn,
|
||||||
|
scaledMode: scaledMode)
|
||||||
|
|
||||||
|
currentStyleLabel.text = descriptionFor(style: currentStyle,
|
||||||
|
useScaledLineHeight: useScaledLineHeight.isOn,
|
||||||
|
scaledMode: scaledMode)
|
||||||
}
|
}
|
||||||
|
|
||||||
override func setup() {
|
override func setup() {
|
||||||
@ -349,3 +331,31 @@ extension LabelViewController: ComponentSampleable {
|
|||||||
return ComponentSample(component: component)
|
return ComponentSample(component: component)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
extension BaseViewController {
|
||||||
|
func descriptionFor(style: TextStyle, useScaledLineHeight: Bool = false, scaledMode: Bool) -> String {
|
||||||
|
let scaledFont = style.font.scaledFont
|
||||||
|
var customizedDesc: String = "Name: \(style.rawValue) \nFont Face-Weight: \(style.font.fontName)"
|
||||||
|
customizedDesc += "\nVDS LetterSpacing: \(style.letterSpacing)"
|
||||||
|
if scaledMode {
|
||||||
|
customizedDesc += "\nVDS PointSize: \(style.pointSize.rounded())"
|
||||||
|
customizedDesc += "\n* iOS PointSize: \(scaledFont.pointSize.rounded())"
|
||||||
|
} else {
|
||||||
|
customizedDesc += "\n* VDS PointSize: \(style.pointSize.rounded())"
|
||||||
|
}
|
||||||
|
if scaledMode {
|
||||||
|
if useScaledLineHeight {
|
||||||
|
customizedDesc += "\nVDS LineHeight: \(style.lineHeight)"
|
||||||
|
customizedDesc += "\n* VDS Ratio LineHeight: \(style.scaledLineHeight)"
|
||||||
|
} else {
|
||||||
|
customizedDesc += "\n* VDS LineHeight: \(style.lineHeight)"
|
||||||
|
}
|
||||||
|
customizedDesc += "\niOS LineHeight: \(scaledFont.lineHeight.rounded())"
|
||||||
|
} else {
|
||||||
|
customizedDesc += "\n* VDS LineHeight: \(style.lineHeight)"
|
||||||
|
customizedDesc += "\niOS LineHeight: \(style.font.lineHeight.rounded())"
|
||||||
|
}
|
||||||
|
return customizedDesc
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user