refactored to use tokens instead of hardcoded values

Signed-off-by: Matt Bruce <matt.bruce@verizon.com>
This commit is contained in:
Matt Bruce 2023-01-03 11:36:36 -06:00
parent 1191901787
commit 410ee5afdf
9 changed files with 21 additions and 19 deletions

View File

@ -67,7 +67,7 @@ public class Badge: View, Accessable {
isAccessibilityElement = true
accessibilityTraits = .staticText
layer.cornerRadius = 2
layer.cornerRadius = VDSFormControls.borderradius
addSubview(label)
label.pinToSuperView(.init(top: 2, left: 4, bottom: 2, right: 4))

View File

@ -146,7 +146,7 @@ open class Button: ButtonBase, Useable {
super.updateView()
let bgColor = backgroundColorConfiguration.getColor(self)
let borderColor = borderColorConfiguration.getColor(self)
let borderWidth = use == .secondary ? 1.0 : 0.0
let borderWidth = use == .secondary ? VDSFormControls.widthBorder : 0.0
let buttonHeight = size.height
let cornerRadius = size.cornerRadius
let minWidth = size.minimumWidth

View File

@ -371,8 +371,8 @@ open class CheckboxBase: Control, Accessable, DataTrackable, Errorable {
selectorView.backgroundColor = backgroundColor
selectorView.layer.borderColor = borderColor.cgColor
selectorView.layer.cornerRadius = 2.0
selectorView.layer.borderWidth = 1.0
selectorView.layer.cornerRadius = VDSFormControls.borderradius
selectorView.layer.borderWidth = VDSFormControls.widthBorder
if shapeLayer == nil {
let bounds = selectorView.bounds

View File

@ -281,10 +281,10 @@ open class RadioBoxBase: Control, Accessable, DataTrackable{
//--------------------------------------------------
// MARK: - Configuration Properties
//--------------------------------------------------
private var strikeThroughLineThickness: CGFloat = 1.0
private var selectorCornerRadius: CGFloat = 4.0
private var selectorBorderWidthSelected: CGFloat = 2.0
private var selectorBorderWidth: CGFloat = 1.0
private var strikeThroughLineThickness: CGFloat = VDSFormControls.widthBorder
private var selectorCornerRadius: CGFloat = VDSFormControls.borderradius
private var selectorBorderWidthSelected: CGFloat = VDSFormControls.widthBorder + VDSFormControls.widthBorder
private var selectorBorderWidth: CGFloat = VDSFormControls.widthBorder
private var backgroundColorConfiguration = ControlColorConfiguration().with {
$0.setSurfaceColors(VDSFormControlsColor.backgroundOnlight, VDSFormControlsColor.backgroundOndark, forState: .normal)
@ -311,7 +311,7 @@ open class RadioBoxBase: Control, Accessable, DataTrackable{
//get the colors
let backgroundColor = backgroundColorConfiguration.getColor(self)
let borderColor = borderColorConfiguration.getColor(self)
let borderWidth = isSelected || isHighlighted ? selectorBorderWidthSelected : selectorBorderWidth
let borderWidth = isSelected ? selectorBorderWidthSelected : selectorBorderWidth
selectorView.backgroundColor = backgroundColor
selectorView.layer.borderColor = borderColor.cgColor

View File

@ -373,7 +373,7 @@ open class RadioButtonBase: Control, Accessable, DataTrackable, Errorable {
selectorView.backgroundColor = backgroundColor
selectorView.layer.borderColor = borderColor.cgColor
selectorView.layer.cornerRadius = selectorView.bounds.width * 0.5
selectorView.layer.borderWidth = 1.0
selectorView.layer.borderWidth = VDSFormControls.widthBorder
if shapeLayer == nil {
let selectedBounds = radioButtonSelectedSize

View File

@ -162,8 +162,8 @@ open class RadioSwatchBase: Control, Accessable, DataTrackable {
//--------------------------------------------------
// MARK: - Configuration Properties
//--------------------------------------------------
private var strikeThroughLineThickness: CGFloat = 1.0
private var selectorBorderWidth: CGFloat = 1.0
private var strikeThroughLineThickness: CGFloat = VDSFormControls.widthBorder
private var selectorBorderWidth: CGFloat = VDSFormControls.widthBorder
public let swatchSize = CGSize(width: 48, height: 48)
public let fillSize = CGSize(width: 36, height: 36)
public let disabledAlpha = 0.5

View File

@ -285,8 +285,8 @@ open class EntryField: Control, Accessable {
containerView.backgroundColor = backgroundColorConfiguration.getColor(self)
containerView.layer.borderColor = borderColorConfiguration.getColor(self).cgColor
containerView.layer.borderWidth = 1
containerView.layer.cornerRadius = 4
containerView.layer.borderWidth = VDSFormControls.widthBorder
containerView.layer.cornerRadius = VDSFormControls.borderradius
updateTitleLabel()
updateErrorLabel()

View File

@ -7,6 +7,7 @@
import Foundation
import VDSColorTokens
import VDSFormControlsTokens
import UIKit
@objc(VDSTileContainer)
@ -181,8 +182,8 @@ open class TileContainer: Control {
//corner radius
layer.cornerRadius = cornerRadius
backgroundImageView.layer.cornerRadius = 8
highlightView.layer.cornerRadius = 8
backgroundImageView.layer.cornerRadius = cornerRadius
highlightView.layer.cornerRadius = cornerRadius
}
@ -194,7 +195,7 @@ open class TileContainer: Control {
//--------------------------------------------------
// MARK: - Configuration
//--------------------------------------------------
private let cornerRadius = 8.0
private let cornerRadius = VDSFormControls.borderradius * 2
private var backgroundColorConfig = BackgroundColorConfiguration()
@ -262,7 +263,7 @@ open class TileContainer: Control {
}
layer.borderColor = borderColorConfig.getColor(self).cgColor
layer.borderWidth = showBorder ? 1 : 0
layer.borderWidth = showBorder ? VDSFormControls.widthBorder : 0
containerTopConstraint?.constant = padding
containerLeadingConstraint?.constant = padding

View File

@ -7,6 +7,7 @@
import Foundation
import UIKit
import VDSFormControlsTokens
extension UIView {
public func pin(_ view: UIView, with edges: UIEdgeInsets = UIEdgeInsets.zero) {
@ -122,7 +123,7 @@ extension UIView {
public func debugBorder(show shouldShow: Bool = true, color: UIColor = .red) {
if shouldShow {
layer.borderColor = color.cgColor
layer.borderWidth = 1
layer.borderWidth = VDSFormControls.widthBorder
} else {
layer.borderColor = UIColor.clear.cgColor
layer.borderWidth = 0