updated defaults into initializers
update all initializers to look the same Signed-off-by: Matt Bruce <matt.bruce@verizon.com>
This commit is contained in:
parent
92c8c1073f
commit
19a7ba5627
@ -20,6 +20,10 @@ public class Badge: View, Accessable {
|
||||
|
||||
private var label = Label().with {
|
||||
$0.setContentCompressionResistancePriority(.required, for: .vertical)
|
||||
$0.adjustsFontSizeToFitWidth = false
|
||||
$0.lineBreakMode = .byTruncatingTail
|
||||
$0.textPosition = .left
|
||||
$0.typograpicalStyle = .BoldBodySmall
|
||||
}
|
||||
|
||||
//--------------------------------------------------
|
||||
@ -64,8 +68,6 @@ public class Badge: View, Accessable {
|
||||
addSubview(label)
|
||||
|
||||
layer.cornerRadius = 2
|
||||
label.adjustsFontSizeToFitWidth = false
|
||||
label.lineBreakMode = .byTruncatingTail
|
||||
|
||||
label.leadingAnchor.constraint(equalTo: leadingAnchor, constant: 4).isActive = true
|
||||
label.topAnchor.constraint(equalTo: topAnchor, constant: 2).isActive = true
|
||||
@ -75,6 +77,7 @@ public class Badge: View, Accessable {
|
||||
maxWidthConstraint = label.widthAnchor.constraint(lessThanOrEqualToConstant: 100)
|
||||
minWidthConstraint = label.widthAnchor.constraint(greaterThanOrEqualToConstant: 23)
|
||||
minWidthConstraint?.isActive = true
|
||||
|
||||
}
|
||||
|
||||
public override func reset() {
|
||||
@ -162,10 +165,9 @@ public class Badge: View, Accessable {
|
||||
//--------------------------------------------------
|
||||
open override func updateView() {
|
||||
backgroundColor = backgroundColor()
|
||||
|
||||
label.textColorConfiguration = textColorConfiguration()
|
||||
label.numberOfLines = numberOfLines
|
||||
label.textPosition = .left
|
||||
label.typograpicalStyle = .BoldBodySmall
|
||||
label.text = text
|
||||
label.surface = surface
|
||||
label.disabled = disabled
|
||||
|
||||
@ -55,49 +55,47 @@ open class CheckboxBase: Control, Accessable, DataTrackable, BinaryColorable, Er
|
||||
return true
|
||||
}
|
||||
|
||||
private var mainStackView: UIStackView = {
|
||||
return UIStackView().with {
|
||||
$0.translatesAutoresizingMaskIntoConstraints = false
|
||||
$0.alignment = .top
|
||||
$0.axis = .vertical
|
||||
}
|
||||
}()
|
||||
private var mainStackView = UIStackView().with {
|
||||
$0.translatesAutoresizingMaskIntoConstraints = false
|
||||
$0.alignment = .top
|
||||
$0.axis = .vertical
|
||||
}
|
||||
|
||||
private var selectorStackView: UIStackView = {
|
||||
return UIStackView().with {
|
||||
$0.translatesAutoresizingMaskIntoConstraints = false
|
||||
$0.alignment = .top
|
||||
$0.axis = .horizontal
|
||||
}
|
||||
}()
|
||||
private var selectorStackView = UIStackView().with {
|
||||
$0.translatesAutoresizingMaskIntoConstraints = false
|
||||
$0.alignment = .top
|
||||
$0.axis = .horizontal
|
||||
}
|
||||
|
||||
private var selectorLabelStackView: UIStackView = {
|
||||
return UIStackView().with {
|
||||
$0.translatesAutoresizingMaskIntoConstraints = false
|
||||
$0.axis = .vertical
|
||||
}
|
||||
}()
|
||||
private var selectorLabelStackView = UIStackView().with {
|
||||
$0.translatesAutoresizingMaskIntoConstraints = false
|
||||
$0.axis = .vertical
|
||||
}
|
||||
|
||||
private var primaryLabel = Label().with {
|
||||
$0.setContentCompressionResistancePriority(.required, for: .vertical)
|
||||
$0.textPosition = .left
|
||||
$0.typograpicalStyle = .BoldBodyLarge
|
||||
}
|
||||
|
||||
private var secondaryLabel = Label().with {
|
||||
$0.setContentCompressionResistancePriority(.required, for: .vertical)
|
||||
$0.textPosition = .left
|
||||
$0.typograpicalStyle = .BodyLarge
|
||||
}
|
||||
|
||||
private var errorLabel = Label().with {
|
||||
$0.setContentCompressionResistancePriority(.required, for: .vertical)
|
||||
$0.textPosition = .left
|
||||
$0.typograpicalStyle = .BodyMedium
|
||||
}
|
||||
|
||||
//--------------------------------------------------
|
||||
// MARK: - Public Properties
|
||||
//--------------------------------------------------
|
||||
public var selectorView: UIView = {
|
||||
return UIView().with {
|
||||
$0.translatesAutoresizingMaskIntoConstraints = false
|
||||
}
|
||||
}()
|
||||
public var selectorView = UIView().with {
|
||||
$0.translatesAutoresizingMaskIntoConstraints = false
|
||||
}
|
||||
|
||||
//can't bind to @Proxy
|
||||
open override var isSelected: Bool { didSet { didChange() }}
|
||||
@ -206,8 +204,6 @@ open class CheckboxBase: Control, Accessable, DataTrackable, BinaryColorable, Er
|
||||
//add the stackview to hold the 2 labels
|
||||
//top label
|
||||
if let labelText {
|
||||
primaryLabel.textPosition = .left
|
||||
primaryLabel.typograpicalStyle = .BoldBodyLarge
|
||||
primaryLabel.surface = surface
|
||||
primaryLabel.disabled = disabled
|
||||
primaryLabel.attributes = labelTextAttributes
|
||||
@ -222,8 +218,6 @@ open class CheckboxBase: Control, Accessable, DataTrackable, BinaryColorable, Er
|
||||
|
||||
//bottom label
|
||||
if let childText {
|
||||
secondaryLabel.textPosition = .left
|
||||
secondaryLabel.typograpicalStyle = .BodyLarge
|
||||
secondaryLabel.text = childText
|
||||
secondaryLabel.surface = surface
|
||||
secondaryLabel.disabled = disabled
|
||||
@ -248,8 +242,6 @@ open class CheckboxBase: Control, Accessable, DataTrackable, BinaryColorable, Er
|
||||
|
||||
//either add/remove the error from the main stack
|
||||
if let errorText, shouldShowError {
|
||||
errorLabel.textPosition = .left
|
||||
errorLabel.typograpicalStyle = .BodyMedium
|
||||
errorLabel.text = errorText
|
||||
errorLabel.surface = surface
|
||||
errorLabel.disabled = disabled
|
||||
|
||||
@ -46,50 +46,51 @@ open class RadioBoxBase: Control, BinaryColorable, Accessable, DataTrackable{
|
||||
//--------------------------------------------------
|
||||
// MARK: - Private Properties
|
||||
//--------------------------------------------------
|
||||
private var mainStackView: UIStackView = {
|
||||
return UIStackView().with {
|
||||
$0.translatesAutoresizingMaskIntoConstraints = false
|
||||
$0.alignment = .top
|
||||
$0.axis = .vertical
|
||||
$0.spacing = 0
|
||||
}
|
||||
}()
|
||||
private var mainStackView = UIStackView().with {
|
||||
$0.translatesAutoresizingMaskIntoConstraints = false
|
||||
$0.alignment = .top
|
||||
$0.axis = .vertical
|
||||
$0.spacing = 0
|
||||
}
|
||||
|
||||
private var selectorStackView: UIStackView = {
|
||||
return UIStackView().with {
|
||||
$0.translatesAutoresizingMaskIntoConstraints = false
|
||||
$0.alignment = .top
|
||||
$0.axis = .horizontal
|
||||
}
|
||||
}()
|
||||
private var selectorStackView = UIStackView().with {
|
||||
$0.translatesAutoresizingMaskIntoConstraints = false
|
||||
$0.alignment = .top
|
||||
$0.axis = .horizontal
|
||||
$0.spacing = 12
|
||||
}
|
||||
|
||||
private var selectorLeftLabelStackView: UIStackView = {
|
||||
return UIStackView().with {
|
||||
$0.translatesAutoresizingMaskIntoConstraints = false
|
||||
$0.axis = .vertical
|
||||
}
|
||||
}()
|
||||
private var selectorLeftLabelStackView = UIStackView().with {
|
||||
$0.translatesAutoresizingMaskIntoConstraints = false
|
||||
$0.axis = .vertical
|
||||
$0.spacing = 4
|
||||
$0.isHidden = false
|
||||
}
|
||||
|
||||
private var textLabel = Label().with {
|
||||
$0.setContentCompressionResistancePriority(.required, for: .vertical)
|
||||
$0.textPosition = .left
|
||||
$0.typograpicalStyle = .BoldBodyLarge
|
||||
}
|
||||
|
||||
private var subTextLabel = Label().with {
|
||||
$0.setContentCompressionResistancePriority(.required, for: .vertical)
|
||||
$0.textPosition = .left
|
||||
$0.typograpicalStyle = .BodyLarge
|
||||
}
|
||||
|
||||
private var subTextRightLabel = Label().with {
|
||||
$0.setContentCompressionResistancePriority(.required, for: .vertical)
|
||||
$0.textPosition = .right
|
||||
$0.typograpicalStyle = .BodyLarge
|
||||
}
|
||||
|
||||
//--------------------------------------------------
|
||||
// MARK: - Public Properties
|
||||
//--------------------------------------------------
|
||||
public var selectorView: UIView = {
|
||||
return UIView().with {
|
||||
$0.translatesAutoresizingMaskIntoConstraints = false
|
||||
}
|
||||
}()
|
||||
public var selectorView = UIView().with {
|
||||
$0.translatesAutoresizingMaskIntoConstraints = false
|
||||
}
|
||||
|
||||
open var text: String = "Default Text" { didSet { didChange() }}
|
||||
|
||||
@ -177,10 +178,6 @@ open class RadioBoxBase: Control, BinaryColorable, Accessable, DataTrackable{
|
||||
selectorLeftLabelStackView.addArrangedSubview(textLabel)
|
||||
selectorLeftLabelStackView.addArrangedSubview(subTextLabel)
|
||||
|
||||
selectorStackView.spacing = 12
|
||||
selectorLeftLabelStackView.spacing = 4
|
||||
selectorLeftLabelStackView.isHidden = false
|
||||
|
||||
updateSelector()
|
||||
|
||||
selectorView.topAnchor.constraint(equalTo: topAnchor).isActive = true
|
||||
@ -192,15 +189,12 @@ open class RadioBoxBase: Control, BinaryColorable, Accessable, DataTrackable{
|
||||
mainStackView.leadingAnchor.constraint(equalTo: selectorView.leadingAnchor, constant: 16).isActive = true
|
||||
mainStackView.trailingAnchor.constraint(equalTo: selectorView.trailingAnchor, constant: -16).isActive = true
|
||||
mainStackView.bottomAnchor.constraint(equalTo: selectorView.bottomAnchor, constant: -16).isActive = true
|
||||
|
||||
}
|
||||
|
||||
func updateLabels() {
|
||||
|
||||
//add the stackview to hold the 2 labels
|
||||
//text label
|
||||
textLabel.textPosition = .left
|
||||
textLabel.typograpicalStyle = .BoldBodyLarge
|
||||
textLabel.text = text
|
||||
textLabel.surface = surface
|
||||
textLabel.disabled = disabled
|
||||
@ -208,8 +202,6 @@ open class RadioBoxBase: Control, BinaryColorable, Accessable, DataTrackable{
|
||||
|
||||
//subText label
|
||||
if let subText {
|
||||
subTextLabel.textPosition = .left
|
||||
subTextLabel.typograpicalStyle = .BodyLarge
|
||||
subTextLabel.text = subText
|
||||
subTextLabel.surface = surface
|
||||
subTextLabel.disabled = disabled
|
||||
@ -225,8 +217,6 @@ open class RadioBoxBase: Control, BinaryColorable, Accessable, DataTrackable{
|
||||
|
||||
//subTextRight label
|
||||
if let subTextRight {
|
||||
subTextRightLabel.textPosition = .right
|
||||
subTextRightLabel.typograpicalStyle = .BodyLarge
|
||||
subTextRightLabel.text = subTextRight
|
||||
subTextRightLabel.surface = surface
|
||||
subTextRightLabel.disabled = disabled
|
||||
|
||||
@ -63,28 +63,22 @@ open class RadioButtonBase: Control, Accessable, DataTrackable, BinaryColorable,
|
||||
return true
|
||||
}
|
||||
|
||||
private var mainStackView: UIStackView = {
|
||||
return UIStackView().with {
|
||||
$0.translatesAutoresizingMaskIntoConstraints = false
|
||||
$0.alignment = .top
|
||||
$0.axis = .vertical
|
||||
}
|
||||
}()
|
||||
private var mainStackView = UIStackView().with {
|
||||
$0.translatesAutoresizingMaskIntoConstraints = false
|
||||
$0.alignment = .top
|
||||
$0.axis = .vertical
|
||||
}
|
||||
|
||||
private var selectorStackView: UIStackView = {
|
||||
return UIStackView().with {
|
||||
$0.translatesAutoresizingMaskIntoConstraints = false
|
||||
$0.alignment = .top
|
||||
$0.axis = .horizontal
|
||||
}
|
||||
}()
|
||||
private var selectorStackView = UIStackView().with {
|
||||
$0.translatesAutoresizingMaskIntoConstraints = false
|
||||
$0.alignment = .top
|
||||
$0.axis = .horizontal
|
||||
}
|
||||
|
||||
private var selectorLabelStackView: UIStackView = {
|
||||
return UIStackView().with {
|
||||
$0.translatesAutoresizingMaskIntoConstraints = false
|
||||
$0.axis = .vertical
|
||||
}
|
||||
}()
|
||||
private var selectorLabelStackView = UIStackView().with {
|
||||
$0.translatesAutoresizingMaskIntoConstraints = false
|
||||
$0.axis = .vertical
|
||||
}
|
||||
|
||||
private var primaryLabel = Label().with {
|
||||
$0.setContentCompressionResistancePriority(.required, for: .vertical)
|
||||
@ -101,11 +95,9 @@ open class RadioButtonBase: Control, Accessable, DataTrackable, BinaryColorable,
|
||||
//--------------------------------------------------
|
||||
// MARK: - Public Properties
|
||||
//--------------------------------------------------
|
||||
public var selectorView: UIView = {
|
||||
return UIView().with {
|
||||
$0.translatesAutoresizingMaskIntoConstraints = false
|
||||
}
|
||||
}()
|
||||
public var selectorView = UIView().with {
|
||||
$0.translatesAutoresizingMaskIntoConstraints = false
|
||||
}
|
||||
|
||||
open var labelText: String? { didSet { didChange() }}
|
||||
|
||||
@ -202,6 +194,15 @@ open class RadioButtonBase: Control, Accessable, DataTrackable, BinaryColorable,
|
||||
mainStackView.trailingAnchor.constraint(equalTo: trailingAnchor).isActive = true
|
||||
mainStackView.bottomAnchor.constraint(equalTo: bottomAnchor).isActive = true
|
||||
|
||||
//defaults
|
||||
primaryLabel.textPosition = .left
|
||||
primaryLabel.typograpicalStyle = .BoldBodyLarge
|
||||
|
||||
secondaryLabel.textPosition = .left
|
||||
secondaryLabel.typograpicalStyle = .BodyLarge
|
||||
|
||||
errorLabel.textPosition = .left
|
||||
errorLabel.typograpicalStyle = .BodyMedium
|
||||
}
|
||||
|
||||
func updateLabels() {
|
||||
@ -211,8 +212,6 @@ open class RadioButtonBase: Control, Accessable, DataTrackable, BinaryColorable,
|
||||
//add the stackview to hold the 2 labels
|
||||
//top label
|
||||
if let labelText {
|
||||
primaryLabel.textPosition = .left
|
||||
primaryLabel.typograpicalStyle = .BoldBodyLarge
|
||||
primaryLabel.text = labelText
|
||||
primaryLabel.surface = surface
|
||||
primaryLabel.disabled = disabled
|
||||
@ -228,8 +227,6 @@ open class RadioButtonBase: Control, Accessable, DataTrackable, BinaryColorable,
|
||||
|
||||
//bottom label
|
||||
if let childText {
|
||||
secondaryLabel.textPosition = .left
|
||||
secondaryLabel.typograpicalStyle = .BodyLarge
|
||||
secondaryLabel.text = childText
|
||||
secondaryLabel.surface = surface
|
||||
secondaryLabel.disabled = disabled
|
||||
@ -254,8 +251,6 @@ open class RadioButtonBase: Control, Accessable, DataTrackable, BinaryColorable,
|
||||
|
||||
//either add/remove the error from the main stack
|
||||
if let errorText, shouldShowError {
|
||||
errorLabel.textPosition = .left
|
||||
errorLabel.typograpicalStyle = .BodyMedium
|
||||
errorLabel.text = errorText
|
||||
errorLabel.surface = surface
|
||||
errorLabel.disabled = disabled
|
||||
@ -367,9 +362,9 @@ open class RadioButtonBase: Control, Accessable, DataTrackable, BinaryColorable,
|
||||
if shapeLayer == nil {
|
||||
let selectedBounds = radioButtonSelectedSize
|
||||
let bezierPath = UIBezierPath(ovalIn: CGRect(x: (bounds.width - selectedBounds.width) / 2,
|
||||
y: (bounds.height - selectedBounds.height) / 2,
|
||||
y: (bounds.height - selectedBounds.height) / 2,
|
||||
width: radioButtonSelectedSize.width,
|
||||
height: radioButtonSelectedSize.height))
|
||||
height: radioButtonSelectedSize.height))
|
||||
let shapeLayer = CAShapeLayer()
|
||||
self.shapeLayer = shapeLayer
|
||||
shapeLayer.frame = bounds
|
||||
|
||||
@ -43,18 +43,14 @@ open class RadioSwatchBase: Control, Accessable, DataTrackable, BinaryColorable
|
||||
//--------------------------------------------------
|
||||
// MARK: - Public Properties
|
||||
//--------------------------------------------------
|
||||
public var selectorView: UIView = {
|
||||
return UIView().with {
|
||||
$0.translatesAutoresizingMaskIntoConstraints = false
|
||||
}
|
||||
}()
|
||||
public var selectorView = UIView().with {
|
||||
$0.translatesAutoresizingMaskIntoConstraints = false
|
||||
}
|
||||
|
||||
public var fillView: UIImageView = {
|
||||
return UIImageView().with {
|
||||
$0.translatesAutoresizingMaskIntoConstraints = false
|
||||
$0.contentMode = .scaleAspectFit
|
||||
}
|
||||
}()
|
||||
public var fillView = UIImageView().with {
|
||||
$0.translatesAutoresizingMaskIntoConstraints = false
|
||||
$0.contentMode = .scaleAspectFit
|
||||
}
|
||||
|
||||
open var fillImage: UIImage? { didSet { didChange() }}
|
||||
|
||||
|
||||
@ -62,30 +62,24 @@ open class ToggleBase: Control, Accessable, DataTrackable, BinaryColorable {
|
||||
//--------------------------------------------------
|
||||
// MARK: - Private Properties
|
||||
//--------------------------------------------------
|
||||
private var stackView: UIStackView = {
|
||||
return UIStackView().with {
|
||||
$0.translatesAutoresizingMaskIntoConstraints = false
|
||||
$0.axis = .horizontal
|
||||
$0.distribution = .fill
|
||||
}
|
||||
}()
|
||||
private var stackView = UIStackView().with {
|
||||
$0.translatesAutoresizingMaskIntoConstraints = false
|
||||
$0.axis = .horizontal
|
||||
$0.distribution = .fill
|
||||
}
|
||||
|
||||
private var label = Label().with {
|
||||
$0.setContentCompressionResistancePriority(.required, for: .vertical)
|
||||
}
|
||||
|
||||
private var toggleView: UIView = {
|
||||
return UIView().with {
|
||||
$0.translatesAutoresizingMaskIntoConstraints = false
|
||||
}
|
||||
}()
|
||||
private var toggleView = UIView().with {
|
||||
$0.translatesAutoresizingMaskIntoConstraints = false
|
||||
}
|
||||
|
||||
private var knobView: UIView = {
|
||||
return UIView().with {
|
||||
$0.translatesAutoresizingMaskIntoConstraints = false
|
||||
$0.backgroundColor = .white
|
||||
}
|
||||
}()
|
||||
private var knobView = UIView().with {
|
||||
$0.translatesAutoresizingMaskIntoConstraints = false
|
||||
$0.backgroundColor = .white
|
||||
}
|
||||
|
||||
//--------------------------------------------------
|
||||
// MARK: - Configuration Properties
|
||||
|
||||
Loading…
Reference in New Issue
Block a user