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;
|
ASSETCATALOG_COMPILER_INCLUDE_ALL_APPICON_ASSETS = NO;
|
||||||
CODE_SIGN_IDENTITY = "Apple Development";
|
CODE_SIGN_IDENTITY = "Apple Development";
|
||||||
CODE_SIGN_STYLE = Automatic;
|
CODE_SIGN_STYLE = Automatic;
|
||||||
CURRENT_PROJECT_VERSION = 24;
|
CURRENT_PROJECT_VERSION = 25;
|
||||||
DEVELOPMENT_TEAM = FCMA4QKS77;
|
DEVELOPMENT_TEAM = FCMA4QKS77;
|
||||||
GENERATE_INFOPLIST_FILE = YES;
|
GENERATE_INFOPLIST_FILE = YES;
|
||||||
INFOPLIST_FILE = VDSSample/Info.plist;
|
INFOPLIST_FILE = VDSSample/Info.plist;
|
||||||
@ -691,7 +691,7 @@
|
|||||||
ASSETCATALOG_COMPILER_INCLUDE_ALL_APPICON_ASSETS = NO;
|
ASSETCATALOG_COMPILER_INCLUDE_ALL_APPICON_ASSETS = NO;
|
||||||
CODE_SIGN_IDENTITY = "Apple Development";
|
CODE_SIGN_IDENTITY = "Apple Development";
|
||||||
CODE_SIGN_STYLE = Automatic;
|
CODE_SIGN_STYLE = Automatic;
|
||||||
CURRENT_PROJECT_VERSION = 24;
|
CURRENT_PROJECT_VERSION = 25;
|
||||||
DEVELOPMENT_TEAM = FCMA4QKS77;
|
DEVELOPMENT_TEAM = FCMA4QKS77;
|
||||||
GENERATE_INFOPLIST_FILE = YES;
|
GENERATE_INFOPLIST_FILE = YES;
|
||||||
INFOPLIST_FILE = VDSSample/Info.plist;
|
INFOPLIST_FILE = VDSSample/Info.plist;
|
||||||
|
|||||||
@ -53,6 +53,7 @@ public class FormSection: UIStackView {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let label = Label().with {
|
let label = Label().with {
|
||||||
|
$0.tag = 1
|
||||||
$0.text = label
|
$0.text = label
|
||||||
$0.textStyle = .bodyLarge
|
$0.textStyle = .bodyLarge
|
||||||
}
|
}
|
||||||
|
|||||||
@ -27,20 +27,30 @@ class LabelViewController: BaseViewController<Label> {
|
|||||||
FontCategoryPickerSelectorView(title: "",
|
FontCategoryPickerSelectorView(title: "",
|
||||||
picker: self.picker)
|
picker: self.picker)
|
||||||
}()
|
}()
|
||||||
|
var lineheightRange = Slider()
|
||||||
|
var lineSpacingRange = Slider()
|
||||||
|
var baselineOffsetRange = Slider()
|
||||||
|
var currentStyle: TextStyle!
|
||||||
var boldSwitch = Toggle()
|
var boldSwitch = Toggle()
|
||||||
var disabledSwitch = Toggle()
|
var disabledSwitch = Toggle()
|
||||||
var textField = TextField()
|
var textField = TextField()
|
||||||
private var isBold: Bool = false
|
private var isBold: Bool = false
|
||||||
|
var lineHeightLabel = UILabel().with { $0.translatesAutoresizingMaskIntoConstraints = false; $0.lineBreakMode = .byWordWrapping; $0.numberOfLines = 0}
|
||||||
override func viewDidLoad() {
|
override func viewDidLoad() {
|
||||||
super.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()
|
setupPicker()
|
||||||
setupModel()
|
setupModel()
|
||||||
}
|
}
|
||||||
|
var defaultLineHeightLabel: UILabel?
|
||||||
|
|
||||||
override func allTextFields() -> [TextField]? { [textField] }
|
override func allTextFields() -> [TextField]? { [textField] }
|
||||||
|
|
||||||
override func setupForm(){
|
override func setupForm(){
|
||||||
@ -51,6 +61,10 @@ class LabelViewController: BaseViewController<Label> {
|
|||||||
addFormRow(label: "Text Position", view: textPositionPickerSelectorView)
|
addFormRow(label: "Text Position", view: textPositionPickerSelectorView)
|
||||||
addFormRow(label: "Font Category", view: fontCategoryPickerSelectorView)
|
addFormRow(label: "Font Category", view: fontCategoryPickerSelectorView)
|
||||||
addFormRow(label: "Text Size", view: textSizePickerSelectorView)
|
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)
|
addFormRow(label: "Text", view: textField)
|
||||||
|
|
||||||
disabledSwitch.onChange = { [weak self] sender in
|
disabledSwitch.onChange = { [weak self] sender in
|
||||||
@ -68,12 +82,61 @@ class LabelViewController: BaseViewController<Label> {
|
|||||||
.textPublisher
|
.textPublisher
|
||||||
.sink { [weak self] text in
|
.sink { [weak self] text in
|
||||||
self?.component.text = text
|
self?.component.text = text
|
||||||
|
self?.lineHeightLabel.text = text
|
||||||
}.store(in: &subscribers)
|
}.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() {
|
func setupModel() {
|
||||||
component.text = "Label Component"
|
component.text = "Label Component"
|
||||||
component.textStyle = .featureSmall
|
component.textStyle = .featureSmall
|
||||||
|
lineHeightLabel.text = component.text
|
||||||
|
lineHeightLabel.font = component.textStyle.font
|
||||||
|
|
||||||
//setup UI
|
//setup UI
|
||||||
surfacePickerSelectorView.text = component.surface.rawValue
|
surfacePickerSelectorView.text = component.surface.rawValue
|
||||||
@ -86,8 +149,15 @@ class LabelViewController: BaseViewController<Label> {
|
|||||||
fontCategoryPickerSelectorView.text = "Feature"
|
fontCategoryPickerSelectorView.text = "Feature"
|
||||||
textSize = .small
|
textSize = .small
|
||||||
textSizePickerSelectorView.text = "Small"
|
textSizePickerSelectorView.text = "Small"
|
||||||
|
updateLabelStyle()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override func showDebug(show: Bool) {
|
||||||
|
super.showDebug(show: show)
|
||||||
|
lineHeightLabel.debugBorder(show: show)
|
||||||
|
}
|
||||||
|
|
||||||
//Picker
|
//Picker
|
||||||
private var fontCategory: TextStyle.FontCategory = .feature {
|
private var fontCategory: TextStyle.FontCategory = .feature {
|
||||||
didSet {
|
didSet {
|
||||||
@ -113,6 +183,13 @@ class LabelViewController: BaseViewController<Label> {
|
|||||||
func updateLabelStyle(){
|
func updateLabelStyle(){
|
||||||
if let style = fontCategory.style(for: textSize, isBold: isBold) {
|
if let style = fontCategory.style(for: textSize, isBold: isBold) {
|
||||||
component.textStyle = style
|
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