refactored to use extension
Signed-off-by: Matt Bruce <matt.bruce@verizon.com>
This commit is contained in:
parent
469200270a
commit
945fbc05dc
@ -126,7 +126,7 @@ open class BadgeIndicator: View {
|
||||
case .small:
|
||||
break
|
||||
}
|
||||
return .init(top: verticalPadding, left: horizontalPadding, bottom: verticalPadding, right: horizontalPadding)
|
||||
return .axis(horizontal: horizontalPadding, vertical: verticalPadding)
|
||||
}
|
||||
|
||||
}
|
||||
@ -193,7 +193,7 @@ open class BadgeIndicator: View {
|
||||
open var verticalPadding: CGFloat? { didSet { setNeedsUpdate() } }
|
||||
|
||||
/// Sets the padding at the left/right of the label.
|
||||
open var horitonalPadding: CGFloat? { didSet { setNeedsUpdate() } }
|
||||
open var horizontalPadding: CGFloat? { didSet { setNeedsUpdate() } }
|
||||
|
||||
/// Hides the dot when you are in Kind.simple mode.
|
||||
open var hideDot: Bool = false { didSet { setNeedsUpdate() } }
|
||||
@ -217,12 +217,13 @@ open class BadgeIndicator: View {
|
||||
private var badgeSize: CGFloat { max(minSize, size.textStyle.font.lineHeight) }
|
||||
private var labelEdgeInset: UIEdgeInsets {
|
||||
var newInset = size.edgeInset
|
||||
if let verticalPadding, let horitonalPadding {
|
||||
newInset = .init(top: verticalPadding, left: horitonalPadding, bottom: verticalPadding, right: horitonalPadding)
|
||||
if let verticalPadding, let horizontalPadding {
|
||||
newInset = .init(top: verticalPadding, left: horizontalPadding, bottom: verticalPadding, right: horizontalPadding)
|
||||
newInset = .axis(horizontal: horizontalPadding, vertical: verticalPadding)
|
||||
} else if let verticalPadding {
|
||||
newInset = .init(top: verticalPadding, left: newInset.left, bottom: verticalPadding, right: newInset.right)
|
||||
} else if let horitonalPadding {
|
||||
newInset = .init(top: newInset.top, left: horitonalPadding, bottom: newInset.bottom, right: horitonalPadding)
|
||||
} else if let horizontalPadding {
|
||||
newInset = .init(top: newInset.top, left: horizontalPadding, bottom: newInset.bottom, right: horizontalPadding)
|
||||
}
|
||||
|
||||
return newInset
|
||||
|
||||
@ -231,7 +231,7 @@ open class Notification: View {
|
||||
.pinBottom(0, .defaultHigh)
|
||||
|
||||
addSubview(mainStackView)
|
||||
mainStackView.pin(layoutGuide, with: .init(top: edgeSpacing, left: edgeSpacing, bottom: edgeSpacing, right: edgeSpacing))
|
||||
mainStackView.pin(layoutGuide, with: .uniform(edgeSpacing))
|
||||
|
||||
NSLayoutConstraint.activate([
|
||||
layoutGuide.heightAnchor.constraint(greaterThanOrEqualToConstant: minViewHeight),
|
||||
|
||||
@ -200,7 +200,7 @@ open class RadioBoxItem: Control, Changeable, FormFieldable {
|
||||
.pinTrailing(0, .defaultHigh)
|
||||
.pinBottom(0, .defaultHigh)
|
||||
|
||||
mainStackView.pinToSuperView(.init(top: 16, left: 16, bottom: 16, right: 16))
|
||||
mainStackView.pinToSuperView(.uniform(16))
|
||||
}
|
||||
|
||||
/// Resets to default settings.
|
||||
|
||||
@ -189,10 +189,12 @@ open class EntryFieldBase: Control, Changeable {
|
||||
|
||||
//create the wrapping view
|
||||
heightConstraint = containerView.heightAnchor.constraint(greaterThanOrEqualToConstant: containerSize.height)
|
||||
widthConstraint?.priority = .defaultHigh
|
||||
heightConstraint?.isActive = true
|
||||
|
||||
widthConstraint = containerView.widthAnchor.constraint(equalToConstant: 0)
|
||||
|
||||
widthConstraint?.priority = .defaultHigh
|
||||
|
||||
//get the container this is what is color
|
||||
//border, internal, etc...
|
||||
let container = getContainer()
|
||||
@ -201,7 +203,7 @@ open class EntryFieldBase: Control, Changeable {
|
||||
//this is the horizontal stack that contains
|
||||
//the left, InputContainer, Icons, Buttons
|
||||
container.addSubview(containerStackView)
|
||||
containerStackView.pinToSuperView(.init(top: 12, left: 12, bottom: 12, right: 12))
|
||||
containerStackView.pinToSuperView(.uniform(12))
|
||||
|
||||
//add the view to add input fields
|
||||
containerStackView.addArrangedSubview(controlContainerView)
|
||||
@ -218,9 +220,9 @@ open class EntryFieldBase: Control, Changeable {
|
||||
|
||||
stackView
|
||||
.pinTop()
|
||||
.pinBottom()
|
||||
.pinLeading()
|
||||
.trailingAnchor.constraint(lessThanOrEqualTo: trailingAnchor).isActive = true
|
||||
.pinTrailing(0, .defaultHigh)
|
||||
.pinBottom(0, .defaultHigh)
|
||||
|
||||
titleLabel.textColorConfiguration = primaryColorConfiguration.eraseToAnyColorable()
|
||||
errorLabel.textColorConfiguration = primaryColorConfiguration.eraseToAnyColorable()
|
||||
|
||||
@ -17,79 +17,79 @@ extension TextStyle {
|
||||
fontFace: .edsBold,
|
||||
pointSize: UIDevice.isIPad ? VDSTypography.fontSizeFeature144 : VDSTypography.fontSizeFeature96,
|
||||
lineHeight: UIDevice.isIPad ? VDSTypography.lineHeightFeature136 : VDSTypography.lineHeightFeature88,
|
||||
edgeInsets: .init(bottom: UIDevice.isIPad ? -6: -4))
|
||||
edgeInsets: .bottom(UIDevice.isIPad ? -6: -4))
|
||||
|
||||
public static let featureXLarge = TextStyle(rawValue: "featureXLarge",
|
||||
fontFace: .dsLight,
|
||||
pointSize: UIDevice.isIPad ? VDSTypography.fontSizeFeature144 : VDSTypography.fontSizeFeature96,
|
||||
lineHeight: UIDevice.isIPad ? VDSTypography.lineHeightFeature136 : VDSTypography.lineHeightFeature88,
|
||||
letterSpacing: VDSTypography.letterSpacingSemiWide,
|
||||
edgeInsets: .init(bottom: UIDevice.isIPad ? -6: -4))
|
||||
edgeInsets: .bottom(UIDevice.isIPad ? -6: -4))
|
||||
|
||||
public static let boldFeatureLarge = TextStyle(rawValue: "boldFeatureLarge",
|
||||
fontFace: .edsBold,
|
||||
pointSize: UIDevice.isIPad ? VDSTypography.fontSizeFeature128 : VDSTypography.fontSizeFeature80,
|
||||
lineHeight: UIDevice.isIPad ? VDSTypography.lineHeightFeature120 : VDSTypography.lineHeightFeature76,
|
||||
edgeInsets: .init(bottom: UIDevice.isIPad ? -6: -2))
|
||||
edgeInsets: .bottom(UIDevice.isIPad ? -6: -2))
|
||||
|
||||
public static let featureLarge = TextStyle(rawValue: "featureLarge",
|
||||
fontFace: .dsLight,
|
||||
pointSize: UIDevice.isIPad ? VDSTypography.fontSizeFeature128 : VDSTypography.fontSizeFeature80,
|
||||
lineHeight: UIDevice.isIPad ? VDSTypography.lineHeightFeature120 : VDSTypography.lineHeightFeature76,
|
||||
letterSpacing: VDSTypography.letterSpacingSemiWide,
|
||||
edgeInsets: .init(bottom: UIDevice.isIPad ? -6: -2))
|
||||
edgeInsets: .bottom(UIDevice.isIPad ? -6: -2))
|
||||
|
||||
public static let boldFeatureMedium = TextStyle(rawValue: "boldFeatureMedium",
|
||||
fontFace: .edsBold,
|
||||
pointSize: UIDevice.isIPad ? VDSTypography.fontSizeFeature96 : VDSTypography.fontSizeFeature64,
|
||||
lineHeight: UIDevice.isIPad ? VDSTypography.lineHeightFeature88 : VDSTypography.lineHeightFeature64,
|
||||
edgeInsets: .init(bottom: UIDevice.isIPad ? -4: -2))
|
||||
edgeInsets: .bottom(UIDevice.isIPad ? -4: -2))
|
||||
|
||||
public static let featureMedium = TextStyle(rawValue: "featureMedium",
|
||||
fontFace: .dsLight,
|
||||
pointSize: UIDevice.isIPad ? VDSTypography.fontSizeFeature96 : VDSTypography.fontSizeFeature64,
|
||||
lineHeight: UIDevice.isIPad ? VDSTypography.lineHeightFeature88 : VDSTypography.lineHeightFeature64,
|
||||
letterSpacing: VDSTypography.letterSpacingSemiWide,
|
||||
edgeInsets: .init(bottom: UIDevice.isIPad ? -4: -2))
|
||||
edgeInsets: .bottom(UIDevice.isIPad ? -4: -2))
|
||||
|
||||
public static let boldFeatureSmall = TextStyle(rawValue: "boldFeatureSmall",
|
||||
fontFace: .edsBold,
|
||||
pointSize: UIDevice.isIPad ? VDSTypography.fontSizeFeature80 : VDSTypography.fontSizeFeature48,
|
||||
lineHeight: UIDevice.isIPad ? VDSTypography.lineHeightFeature76 : VDSTypography.lineHeightFeature48,
|
||||
edgeInsets: .init(bottom: UIDevice.isIPad ? -2: 0))
|
||||
edgeInsets: .bottom(UIDevice.isIPad ? -2: 0))
|
||||
|
||||
public static let featureSmall = TextStyle(rawValue: "featureSmall",
|
||||
fontFace: .dsLight,
|
||||
pointSize: UIDevice.isIPad ? VDSTypography.fontSizeFeature80 : VDSTypography.fontSizeFeature48,
|
||||
lineHeight: UIDevice.isIPad ? VDSTypography.lineHeightFeature76 : VDSTypography.lineHeightFeature48,
|
||||
letterSpacing: VDSTypography.letterSpacingSemiWide,
|
||||
edgeInsets: .init(bottom: UIDevice.isIPad ? -2: 0))
|
||||
edgeInsets: .bottom(UIDevice.isIPad ? -2: 0))
|
||||
|
||||
public static let boldFeatureXSmall = TextStyle(rawValue: "boldFeatureXSmall",
|
||||
fontFace: .edsBold,
|
||||
pointSize: UIDevice.isIPad ? VDSTypography.fontSizeFeature64 : VDSTypography.fontSizeFeature40,
|
||||
lineHeight: UIDevice.isIPad ? VDSTypography.lineHeightFeature64 : VDSTypography.lineHeightFeature40,
|
||||
edgeInsets: .init(bottom: UIDevice.isIPad ? -2: 0))
|
||||
edgeInsets: .bottom(UIDevice.isIPad ? -2: 0))
|
||||
|
||||
public static let featureXSmall = TextStyle(rawValue: "featureXSmall",
|
||||
fontFace: .dsLight,
|
||||
pointSize: UIDevice.isIPad ? VDSTypography.fontSizeFeature64 : VDSTypography.fontSizeFeature40,
|
||||
lineHeight: UIDevice.isIPad ? VDSTypography.lineHeightFeature64 : VDSTypography.lineHeightFeature40,
|
||||
letterSpacing: VDSTypography.letterSpacingSemiWide,
|
||||
edgeInsets: .init(bottom: UIDevice.isIPad ? -2: 0))
|
||||
edgeInsets: .bottom(UIDevice.isIPad ? -2: 0))
|
||||
|
||||
public static let boldTitle2XLarge = TextStyle(rawValue: "boldTitle2XLarge",
|
||||
fontFace: .edsBold,
|
||||
pointSize: UIDevice.isIPad ? VDSTypography.fontSizeTitle64 : VDSTypography.fontSizeTitle40,
|
||||
lineHeight: UIDevice.isIPad ? VDSTypography.lineHeightTitle64 : VDSTypography.lineHeightTitle40,
|
||||
edgeInsets: .init(bottom: UIDevice.isIPad ? -2: 0))
|
||||
edgeInsets: .bottom(UIDevice.isIPad ? -2: 0))
|
||||
|
||||
public static let title2XLarge = TextStyle(rawValue: "title2XLarge",
|
||||
fontFace: .dsLight,
|
||||
pointSize: UIDevice.isIPad ? VDSTypography.fontSizeTitle64 : VDSTypography.fontSizeTitle40,
|
||||
lineHeight: UIDevice.isIPad ? VDSTypography.lineHeightTitle64 : VDSTypography.lineHeightTitle40,
|
||||
letterSpacing: VDSTypography.letterSpacingSemiWide,
|
||||
edgeInsets: .init(bottom: UIDevice.isIPad ? -2: 0))
|
||||
edgeInsets: .bottom(UIDevice.isIPad ? -2: 0))
|
||||
|
||||
public static let boldTitleXLarge = TextStyle(rawValue: "boldTitleXLarge",
|
||||
fontFace: .edsBold,
|
||||
@ -211,12 +211,6 @@ extension TextStyle {
|
||||
}
|
||||
}
|
||||
|
||||
extension UIEdgeInsets {
|
||||
public init(bottom: CGFloat) {
|
||||
self.init(top: 0, left: 0, bottom: bottom, right: 0)
|
||||
}
|
||||
}
|
||||
|
||||
extension TextStyle {
|
||||
/// Enum used to describe the naming convention for the Typography.
|
||||
public enum StandardStyle: String, CaseIterable {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user