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