updated version, added in extra Label setters
Signed-off-by: Matt Bruce <matt.bruce@verizon.com>
This commit is contained in:
parent
384a82b1d2
commit
606b06798e
@ -659,7 +659,7 @@
|
||||
ASSETCATALOG_COMPILER_INCLUDE_ALL_APPICON_ASSETS = NO;
|
||||
CODE_SIGN_IDENTITY = "Apple Development";
|
||||
CODE_SIGN_STYLE = Automatic;
|
||||
CURRENT_PROJECT_VERSION = 24;
|
||||
CURRENT_PROJECT_VERSION = 25;
|
||||
DEVELOPMENT_TEAM = FCMA4QKS77;
|
||||
GENERATE_INFOPLIST_FILE = YES;
|
||||
INFOPLIST_FILE = VDSSample/Info.plist;
|
||||
@ -691,7 +691,7 @@
|
||||
ASSETCATALOG_COMPILER_INCLUDE_ALL_APPICON_ASSETS = NO;
|
||||
CODE_SIGN_IDENTITY = "Apple Development";
|
||||
CODE_SIGN_STYLE = Automatic;
|
||||
CURRENT_PROJECT_VERSION = 24;
|
||||
CURRENT_PROJECT_VERSION = 25;
|
||||
DEVELOPMENT_TEAM = FCMA4QKS77;
|
||||
GENERATE_INFOPLIST_FILE = YES;
|
||||
INFOPLIST_FILE = VDSSample/Info.plist;
|
||||
|
||||
@ -53,6 +53,7 @@ public class FormSection: UIStackView {
|
||||
}
|
||||
|
||||
let label = Label().with {
|
||||
$0.tag = 1
|
||||
$0.text = label
|
||||
$0.textStyle = .bodyLarge
|
||||
}
|
||||
|
||||
@ -27,20 +27,30 @@ class LabelViewController: BaseViewController<Label> {
|
||||
FontCategoryPickerSelectorView(title: "",
|
||||
picker: self.picker)
|
||||
}()
|
||||
|
||||
var lineheightRange = Slider()
|
||||
var lineSpacingRange = Slider()
|
||||
var baselineOffsetRange = Slider()
|
||||
var currentStyle: TextStyle!
|
||||
var boldSwitch = Toggle()
|
||||
var disabledSwitch = Toggle()
|
||||
var textField = TextField()
|
||||
private var isBold: Bool = false
|
||||
|
||||
var lineHeightLabel = UILabel().with { $0.translatesAutoresizingMaskIntoConstraints = false; $0.lineBreakMode = .byWordWrapping; $0.numberOfLines = 0}
|
||||
override func viewDidLoad() {
|
||||
super.viewDidLoad()
|
||||
addContentTopView(view: component)
|
||||
let stack = UIStackView()
|
||||
stack.axis = .vertical
|
||||
stack.spacing = 10
|
||||
stack.addArrangedSubview(component)
|
||||
stack.addArrangedSubview(lineHeightLabel)
|
||||
|
||||
addContentTopView(view: stack)
|
||||
|
||||
setupPicker()
|
||||
setupModel()
|
||||
}
|
||||
|
||||
var defaultLineHeightLabel: UILabel?
|
||||
|
||||
override func allTextFields() -> [TextField]? { [textField] }
|
||||
|
||||
override func setupForm(){
|
||||
@ -51,6 +61,10 @@ class LabelViewController: BaseViewController<Label> {
|
||||
addFormRow(label: "Text Position", view: textPositionPickerSelectorView)
|
||||
addFormRow(label: "Font Category", view: fontCategoryPickerSelectorView)
|
||||
addFormRow(label: "Text Size", view: textSizePickerSelectorView)
|
||||
let view = addFormRow(label: "Line Height", view: lineheightRange)
|
||||
addFormRow(label: "Line Spacing", view: lineSpacingRange)
|
||||
addFormRow(label: "Baseline Offset", view: baselineOffsetRange)
|
||||
defaultLineHeightLabel = view.viewWithTag(1) as? UILabel
|
||||
addFormRow(label: "Text", view: textField)
|
||||
|
||||
disabledSwitch.onChange = { [weak self] sender in
|
||||
@ -68,12 +82,61 @@ class LabelViewController: BaseViewController<Label> {
|
||||
.textPublisher
|
||||
.sink { [weak self] text in
|
||||
self?.component.text = text
|
||||
self?.lineHeightLabel.text = text
|
||||
}.store(in: &subscribers)
|
||||
|
||||
lineheightRange.maximumValue = 20.0
|
||||
lineheightRange.minimumValue = 0.0
|
||||
lineheightRange.value = 2.0
|
||||
lineheightRange.publisher(for: .valueChanged).sink(receiveValue: { [weak self] slider in
|
||||
guard let self else { return }
|
||||
let textStyle = self.component.textStyle
|
||||
self.component.textStyle = TextStyle(rawValue: textStyle.rawValue,
|
||||
fontFace: textStyle.fontFace,
|
||||
pointSize: textStyle.pointSize,
|
||||
lineHeight: CGFloat(slider.value),
|
||||
letterSpacing: textStyle.letterSpacing)
|
||||
}).store(in: &subscribers)
|
||||
|
||||
lineSpacingRange.maximumValue = 80.0
|
||||
lineSpacingRange.minimumValue = 0.0
|
||||
lineSpacingRange.value = 0.0
|
||||
lineSpacingRange.publisher(for: .valueChanged).sink(receiveValue: { [weak self] slider in
|
||||
guard let self else { return }
|
||||
let textStyle = self.component.textStyle
|
||||
self.component.textStyle = TextStyle(rawValue: textStyle.rawValue,
|
||||
fontFace: textStyle.fontFace,
|
||||
pointSize: textStyle.pointSize,
|
||||
lineHeight: textStyle.lineHeight,
|
||||
letterSpacing: textStyle.letterSpacing,
|
||||
lineSpacing: CGFloat(slider.value),
|
||||
baselineOffset: textStyle.baselineOffset
|
||||
)
|
||||
}).store(in: &subscribers)
|
||||
|
||||
baselineOffsetRange.maximumValue = 100
|
||||
baselineOffsetRange.minimumValue = -100
|
||||
baselineOffsetRange.value = 0.0
|
||||
baselineOffsetRange.publisher(for: .valueChanged).sink(receiveValue: { [weak self] slider in
|
||||
guard let self else { return }
|
||||
let textStyle = self.component.textStyle
|
||||
self.component.textStyle = TextStyle(rawValue: textStyle.rawValue,
|
||||
fontFace: textStyle.fontFace,
|
||||
pointSize: textStyle.pointSize,
|
||||
lineHeight: textStyle.lineHeight,
|
||||
letterSpacing: textStyle.letterSpacing,
|
||||
lineSpacing: textStyle.lineSpacing,
|
||||
baselineOffset: CGFloat(slider.value)
|
||||
)
|
||||
}).store(in: &subscribers)
|
||||
|
||||
}
|
||||
|
||||
func setupModel() {
|
||||
component.text = "Label Component"
|
||||
component.textStyle = .featureSmall
|
||||
lineHeightLabel.text = component.text
|
||||
lineHeightLabel.font = component.textStyle.font
|
||||
|
||||
//setup UI
|
||||
surfacePickerSelectorView.text = component.surface.rawValue
|
||||
@ -86,8 +149,15 @@ class LabelViewController: BaseViewController<Label> {
|
||||
fontCategoryPickerSelectorView.text = "Feature"
|
||||
textSize = .small
|
||||
textSizePickerSelectorView.text = "Small"
|
||||
updateLabelStyle()
|
||||
|
||||
}
|
||||
|
||||
override func showDebug(show: Bool) {
|
||||
super.showDebug(show: show)
|
||||
lineHeightLabel.debugBorder(show: show)
|
||||
}
|
||||
|
||||
//Picker
|
||||
private var fontCategory: TextStyle.FontCategory = .feature {
|
||||
didSet {
|
||||
@ -113,6 +183,13 @@ class LabelViewController: BaseViewController<Label> {
|
||||
func updateLabelStyle(){
|
||||
if let style = fontCategory.style(for: textSize, isBold: isBold) {
|
||||
component.textStyle = style
|
||||
currentStyle = style
|
||||
let defaultLineHeight = style.font.lineHeight
|
||||
lineHeightLabel.font = style.font
|
||||
lineheightRange.maximumValue = Float(defaultLineHeight) * 1.50
|
||||
lineheightRange.minimumValue = Float(defaultLineHeight) * 0.50
|
||||
lineheightRange.value = Float(style.lineHeight)
|
||||
defaultLineHeightLabel?.text = "Line Height - d:\(defaultLineHeight) s:\(currentStyle.lineHeight)"
|
||||
}
|
||||
}
|
||||
|
||||
@ -135,3 +212,4 @@ class LabelViewController: BaseViewController<Label> {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user