updated version
fixed issue with keyboard in label not having a minus sign added helpers in Label for looking at scaled mode added min lineheight Signed-off-by: Matt Bruce <matt.bruce@verizon.com>
This commit is contained in:
parent
7c2836be6d
commit
27b0740b0c
@ -675,7 +675,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 = 31;
|
CURRENT_PROJECT_VERSION = 32;
|
||||||
DEVELOPMENT_TEAM = FCMA4QKS77;
|
DEVELOPMENT_TEAM = FCMA4QKS77;
|
||||||
GENERATE_INFOPLIST_FILE = YES;
|
GENERATE_INFOPLIST_FILE = YES;
|
||||||
INFOPLIST_FILE = VDSSample/Info.plist;
|
INFOPLIST_FILE = VDSSample/Info.plist;
|
||||||
@ -707,7 +707,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 = 31;
|
CURRENT_PROJECT_VERSION = 32;
|
||||||
DEVELOPMENT_TEAM = FCMA4QKS77;
|
DEVELOPMENT_TEAM = FCMA4QKS77;
|
||||||
GENERATE_INFOPLIST_FILE = YES;
|
GENERATE_INFOPLIST_FILE = YES;
|
||||||
INFOPLIST_FILE = VDSSample/Info.plist;
|
INFOPLIST_FILE = VDSSample/Info.plist;
|
||||||
|
|||||||
@ -79,20 +79,25 @@ public class NumericField: TextField {
|
|||||||
|
|
||||||
public override func setup() {
|
public override func setup() {
|
||||||
super.setup()
|
super.setup()
|
||||||
let keypadToolbar: UIToolbar = UIToolbar()
|
let keypadToolbar: UIToolbar = UIToolbar().with { $0.tintColor = .white; $0.backgroundColor = .white }
|
||||||
|
|
||||||
// add a done button to the numberpad
|
// add a done button to the numberpad
|
||||||
keypadToolbar.items=[
|
keypadToolbar.items=[
|
||||||
UIBarButtonItem(barButtonSystemItem: UIBarButtonItem.SystemItem.flexibleSpace, target: self, action: nil),
|
UIBarButtonItem(barButtonSystemItem: UIBarButtonItem.SystemItem.flexibleSpace, target: self, action: nil),
|
||||||
UIBarButtonItem(title: "Done", style: UIBarButtonItem.Style.done, target: self, action: #selector(shouldResign))
|
UIBarButtonItem(title: " - (minus sign)", style: .done, target: self, action: #selector(insertMinus)).with { $0.tintColor = .black},
|
||||||
|
UIBarButtonItem(title: "Done", style: UIBarButtonItem.Style.done, target: self, action: #selector(shouldResign)).with { $0.tintColor = .black}
|
||||||
]
|
]
|
||||||
keypadToolbar.sizeToFit()
|
keypadToolbar.sizeToFit()
|
||||||
|
|
||||||
// add a toolbar with a done button above the number pad
|
// add a toolbar with a done button above the number pad
|
||||||
inputAccessoryView = keypadToolbar
|
inputAccessoryView = keypadToolbar
|
||||||
keyboardType = .numberPad
|
keyboardType = .decimalPad
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@objc public func insertMinus() {
|
||||||
|
insertText("-")
|
||||||
|
}
|
||||||
|
|
||||||
public var number: NSNumber? {
|
public var number: NSNumber? {
|
||||||
guard let text, let foundNumber = NumberFormatter().number(from: text) else { return nil }
|
guard let text, let foundNumber = NumberFormatter().number(from: text) else { return nil }
|
||||||
return foundNumber
|
return foundNumber
|
||||||
|
|||||||
@ -30,6 +30,7 @@ class LabelViewController: BaseViewController<Label> {
|
|||||||
//------------------------------------
|
//------------------------------------
|
||||||
//testing only remove later
|
//testing only remove later
|
||||||
//------------------------------------
|
//------------------------------------
|
||||||
|
var useMinimumLineHeight = Toggle()
|
||||||
var pointSizeRange = Slider().with {
|
var pointSizeRange = Slider().with {
|
||||||
$0.minimumValue = 5
|
$0.minimumValue = 5
|
||||||
$0.value = 0
|
$0.value = 0
|
||||||
@ -47,25 +48,26 @@ class LabelViewController: BaseViewController<Label> {
|
|||||||
$0.value = 0
|
$0.value = 0
|
||||||
}
|
}
|
||||||
//------------------------------------
|
//------------------------------------
|
||||||
|
var scaledMode: Bool { component.useScaledFont && TextStyle.canScaleFonts }
|
||||||
var baseStyle: TextStyle!
|
var baseStyle: TextStyle!
|
||||||
var currentStyle: TextStyle! {
|
var currentStyle: TextStyle! {
|
||||||
didSet {
|
didSet {
|
||||||
//--------------------------------------------------------------
|
//--------------------------------------------------------------
|
||||||
#warning("testing only remove later")
|
#warning("testing only remove later")
|
||||||
//--------------------------------------------------------------
|
//--------------------------------------------------------------
|
||||||
let lineheight = component.useScaledFont ? currentStyle.scaledLineHeight : currentStyle.lineHeight
|
let lineheight = scaledMode ? currentStyle.scaledLineHeight : currentStyle.lineHeight
|
||||||
let lineheightText = component.useScaledFont ? "\(baseStyle.lineHeight.rounded()) sc\(currentStyle.scaledLineHeight)" : "\(baseStyle.lineHeight.rounded())"
|
let lineheightText = scaledMode ? "\(baseStyle.lineHeight.rounded()) sc\(currentStyle.scaledLineHeight)" : "\(baseStyle.lineHeight.rounded())"
|
||||||
|
|
||||||
pointSizeRange.value = Float(currentStyle.pointSize)
|
pointSizeRange.value = Float(currentStyle.pointSize)
|
||||||
pointSizeRange.maximumValue = Float(baseStyle.pointSize * 1.50)
|
pointSizeRange.maximumValue = Float(baseStyle.pointSize * 1.50)
|
||||||
lineheightRange.value = Float(lineheight)
|
lineheightRange.value = Float(lineheight)
|
||||||
lineheightRange.maximumValue = Float((component.useScaledFont ? baseStyle.scaledLineHeight : lineheight) * 1.50)
|
lineheightRange.maximumValue = Float((scaledMode ? baseStyle.scaledLineHeight : lineheight) * 1.50)
|
||||||
lineheightRange.minimumValue = 1
|
lineheightRange.minimumValue = 1
|
||||||
|
|
||||||
topInsetRange.value = Float(currentStyle.edgeInsets.top)
|
topInsetRange.value = Float(currentStyle.edgeInsets.top)
|
||||||
bottomInsetRange.value = Float(currentStyle.edgeInsets.bottom)
|
bottomInsetRange.value = Float(currentStyle.edgeInsets.bottom)
|
||||||
defaultLineHeightLabel?.text = "Line Height - iOS:\(Int(currentFont.lineHeight.rounded())) VDS:\(lineheightText)"
|
defaultLineHeightLabel?.text = "Line Height - iOS:\(Int(currentFont.lineHeight.rounded())) VDS:\(lineheightText)"
|
||||||
let text = component.useScaledFont ? "iOS: \(Int(currentFont.pointSize.rounded()))" : ""
|
let text = scaledMode ? "iOS: \(Int(currentFont.pointSize.rounded()))" : ""
|
||||||
defaultPointLabel?.text = "Font Size - \(text) VDS:\(currentStyle.pointSize.rounded())"
|
defaultPointLabel?.text = "Font Size - \(text) VDS:\(currentStyle.pointSize.rounded())"
|
||||||
//--------------------------------------------------------------
|
//--------------------------------------------------------------
|
||||||
}
|
}
|
||||||
@ -147,6 +149,7 @@ class LabelViewController: BaseViewController<Label> {
|
|||||||
let testingSection = FormSection()
|
let testingSection = FormSection()
|
||||||
testingSection.title = "Temporary Settings"
|
testingSection.title = "Temporary Settings"
|
||||||
testingSection.addFormRow(label: "Calculated", view: calculatedLabel)
|
testingSection.addFormRow(label: "Calculated", view: calculatedLabel)
|
||||||
|
testingSection.addFormRow(label: "Min LineHeight", view: useMinimumLineHeight)
|
||||||
let pointView = testingSection.addFormRow(label: "Font Size", view: pointSizeRange)
|
let pointView = testingSection.addFormRow(label: "Font Size", view: pointSizeRange)
|
||||||
let view = testingSection.addFormRow(label: "Line Height", view: lineheightRange)
|
let view = testingSection.addFormRow(label: "Line Height", view: lineheightRange)
|
||||||
testingSection.addFormRow(label: "Top Inset", view: topInsetRange)
|
testingSection.addFormRow(label: "Top Inset", view: topInsetRange)
|
||||||
@ -155,6 +158,13 @@ class LabelViewController: BaseViewController<Label> {
|
|||||||
defaultPointLabel = pointView.viewWithTag(1) as? Label
|
defaultPointLabel = pointView.viewWithTag(1) as? Label
|
||||||
append(section: testingSection)
|
append(section: testingSection)
|
||||||
|
|
||||||
|
useMinimumLineHeight
|
||||||
|
.publisher(for: .valueChanged)
|
||||||
|
.sink { [weak self] toggle in
|
||||||
|
NSMutableAttributedString.useMinimumLineHeight = toggle.isOn
|
||||||
|
self?.component.setNeedsUpdate()
|
||||||
|
}.store(in: &subscribers)
|
||||||
|
|
||||||
pointSizeRange.publisher(for: .valueChanged).sink(receiveValue: { [weak self] slider in
|
pointSizeRange.publisher(for: .valueChanged).sink(receiveValue: { [weak self] slider in
|
||||||
guard let self else { return }
|
guard let self else { return }
|
||||||
let textStyle = self.component.textStyle
|
let textStyle = self.component.textStyle
|
||||||
@ -257,7 +267,8 @@ class LabelViewController: BaseViewController<Label> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var currentFont: UIFont {
|
var currentFont: UIFont {
|
||||||
component.useScaledFont ? currentStyle.font.scaledFont : currentStyle.font
|
|
||||||
|
scaledMode ? currentStyle.font.scaledFont : currentStyle.font
|
||||||
}
|
}
|
||||||
|
|
||||||
func updateLabelStyle(){
|
func updateLabelStyle(){
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user