added dynamic lineHeight
Signed-off-by: Matt Bruce <matt.bruce@verizon.com>
This commit is contained in:
parent
ab074a1cad
commit
49bae9c706
@ -59,25 +59,40 @@ open class BadgeIndicator: View {
|
|||||||
case medium = "Medium"
|
case medium = "Medium"
|
||||||
case small = "Small"
|
case small = "Small"
|
||||||
|
|
||||||
public var padding: CGFloat {
|
public var inset: CGFloat {
|
||||||
|
return textStyle.pointSize * 0.3333
|
||||||
|
// switch self {
|
||||||
|
// case .xxlarge:
|
||||||
|
// return 8
|
||||||
|
// case .xlarge:
|
||||||
|
// return 6
|
||||||
|
// case .large:
|
||||||
|
// return 6
|
||||||
|
// case .medium:
|
||||||
|
// return 6
|
||||||
|
// case .small:
|
||||||
|
// return 4
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
|
||||||
|
public var lineHeight: CGFloat {
|
||||||
switch self {
|
switch self {
|
||||||
case .xxlarge:
|
case .xxlarge:
|
||||||
return 8
|
return 29
|
||||||
case .xlarge:
|
case .xlarge:
|
||||||
return 6
|
return 24
|
||||||
case .large:
|
case .large:
|
||||||
return 6
|
return 20
|
||||||
case .medium:
|
case .medium:
|
||||||
return 6
|
return 18
|
||||||
case .small:
|
case .small:
|
||||||
return 4
|
return 16
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public var textStyle: TextStyle {
|
public var textStyle: TextStyle {
|
||||||
let style = TextStyle.bodySmall
|
let style = TextStyle.bodySmall
|
||||||
var pointSize: CGFloat = VDSTypography.fontSizeBody12
|
var pointSize: CGFloat = VDSTypography.fontSizeBody12
|
||||||
|
|
||||||
switch self {
|
switch self {
|
||||||
case .xxlarge:
|
case .xxlarge:
|
||||||
pointSize = VDSTypography.fontSizeTitle24
|
pointSize = VDSTypography.fontSizeTitle24
|
||||||
@ -95,11 +110,21 @@ open class BadgeIndicator: View {
|
|||||||
pointSize = VDSTypography.fontSizeBody12
|
pointSize = VDSTypography.fontSizeBody12
|
||||||
|
|
||||||
}
|
}
|
||||||
|
// var ratio: CGFloat = 1.3333 // less than 14
|
||||||
|
// if pointSize > 13 && pointSize < 16 {
|
||||||
|
// ratio = 1.28
|
||||||
|
// } else if pointSize > 15 && pointSize < 19 {
|
||||||
|
// ratio = 1.25
|
||||||
|
// } else if pointSize > 19 {
|
||||||
|
// ratio = 1.20
|
||||||
|
// }
|
||||||
|
|
||||||
|
let calculatedLineHeight = pointSize * 1.265//ratio
|
||||||
|
print("lineHeight\noriginal: \(lineHeight)\ncalculated:\(calculatedLineHeight)")
|
||||||
return TextStyle(rawValue: "\(self.rawValue)BadgeIndicator",
|
return TextStyle(rawValue: "\(self.rawValue)BadgeIndicator",
|
||||||
fontFace: style.fontFace,
|
fontFace: style.fontFace,
|
||||||
pointSize: pointSize,
|
pointSize: pointSize,
|
||||||
lineHeight: pointSize * (16.0 / 12.0),
|
lineHeight: calculatedLineHeight,
|
||||||
letterSpacing: style.letterSpacing)
|
letterSpacing: style.letterSpacing)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -242,7 +267,7 @@ open class BadgeIndicator: View {
|
|||||||
backgroundColor = backgroundColorConfiguration.getColor(self)
|
backgroundColor = backgroundColorConfiguration.getColor(self)
|
||||||
|
|
||||||
label.useAttributedText = true
|
label.useAttributedText = true
|
||||||
label.edgeInset = .init(top: 0, left: textSize.padding, bottom: 0, right: textSize.padding)
|
label.edgeInset = .init(top: 0, left: textSize.inset, bottom: 0, right: textSize.inset)
|
||||||
label.font = textSize.textStyle.font
|
label.font = textSize.textStyle.font
|
||||||
label.textColor = textColorConfiguration.getColor(self)
|
label.textColor = textColorConfiguration.getColor(self)
|
||||||
label.textColorConfiguration = textColorConfiguration.eraseToAnyColorable()
|
label.textColorConfiguration = textColorConfiguration.eraseToAnyColorable()
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user