Digital ACT-191 ONEAPP-9314 story: bold configuration, refactored strikethrough
This commit is contained in:
parent
8f7581d0d6
commit
7ae5f9853d
@ -53,7 +53,7 @@ open class PriceLockup: View {
|
||||
}
|
||||
}
|
||||
|
||||
/// Enum type describing size of PriceLockup.
|
||||
/// Enum that represents the size availble for PriceLockup.
|
||||
public enum Size: String, CaseIterable {
|
||||
case xxxsmall
|
||||
case xxsmall
|
||||
@ -153,43 +153,43 @@ open class PriceLockup: View {
|
||||
//--------------------------------------------------
|
||||
internal var containerSize: CGSize { CGSize(width: 45, height: 44) }
|
||||
|
||||
private var sizeTextStyle: VDS.TextStyle {
|
||||
private var textStyle: TextStyle.StandardStyle {
|
||||
switch (size, textPosition) {
|
||||
case (.xxxsmall, .preDelimiter), (.xxxsmall, .postDelimiter):
|
||||
return TextStyle.micro
|
||||
return .micro
|
||||
|
||||
case (.xxsmall, .preDelimiter), (.xxsmall, .postDelimiter):
|
||||
return TextStyle.bodySmall
|
||||
return .bodySmall
|
||||
|
||||
case (.xsmall, .preDelimiter), (.xsmall, .postDelimiter):
|
||||
return TextStyle.bodyMedium
|
||||
return .bodyMedium
|
||||
|
||||
case (.small, .preDelimiter), (.small, .postDelimiter):
|
||||
return TextStyle.bodyLarge
|
||||
return .bodyLarge
|
||||
|
||||
case (.medium, .preDelimiter):
|
||||
return UIDevice.isIPad ? TextStyle.titleSmall : TextStyle.titleMedium
|
||||
return UIDevice.isIPad ? .titleSmall : .titleMedium
|
||||
|
||||
case (.medium, .postDelimiter):
|
||||
return TextStyle.bodyLarge
|
||||
return .bodyLarge
|
||||
|
||||
case (.large, .preDelimiter):
|
||||
return UIDevice.isIPad ? TextStyle.titleMedium : TextStyle.titleLarge
|
||||
return UIDevice.isIPad ? .titleMedium : .titleLarge
|
||||
|
||||
case (.large, .postDelimiter):
|
||||
return UIDevice.isIPad ? TextStyle.titleSmall : TextStyle.titleMedium
|
||||
return UIDevice.isIPad ? .titleSmall : .titleMedium
|
||||
|
||||
case (.xlarge, .preDelimiter):
|
||||
return UIDevice.isIPad ? TextStyle.titleLarge : TextStyle.titleXLarge
|
||||
return UIDevice.isIPad ? .titleLarge : .titleXLarge
|
||||
|
||||
case (.xlarge, .postDelimiter):
|
||||
return UIDevice.isIPad ? TextStyle.titleMedium : TextStyle.titleLarge
|
||||
return UIDevice.isIPad ? .titleMedium : .titleLarge
|
||||
|
||||
case (.xxlarge, .preDelimiter):
|
||||
return UIDevice.isIPad ? TextStyle.titleXLarge : TextStyle.featureSmall
|
||||
return UIDevice.isIPad ? .titleXLarge : .featureSmall
|
||||
|
||||
case (.xxlarge, .postDelimiter):
|
||||
return UIDevice.isIPad ? TextStyle.titleLarge : TextStyle.titleXLarge
|
||||
return UIDevice.isIPad ? .titleLarge : .titleXLarge
|
||||
}
|
||||
}
|
||||
|
||||
@ -245,17 +245,17 @@ open class PriceLockup: View {
|
||||
|
||||
// strike applies only when uniformSize true. Does not apply a strikethrough format to leading, trailing, and superscript text.
|
||||
attributes.append(TextStyleLabelAttribute(location: 0,
|
||||
length: priceLockupLabel.text.count,
|
||||
textStyle: sizeTextStyle,
|
||||
textPosition: .left))
|
||||
length: priceLockupLabel.text.count,
|
||||
textStyle: bold ? textStyle.bold : textStyle.regular,
|
||||
textPosition: .left))
|
||||
attributes.append(StrikeThroughLabelAttribute(location:strikethroughLocation, length: strikethroughLength))
|
||||
} else if uniformSize {
|
||||
|
||||
// currency and value have the same font text style as delimeter, term, trailing text and superscript.
|
||||
attributes.append(TextStyleLabelAttribute(location: 0,
|
||||
length: priceLockupLabel.text.count,
|
||||
textStyle: sizeTextStyle,
|
||||
textPosition: .left))
|
||||
length: priceLockupLabel.text.count,
|
||||
textStyle: bold ? textStyle.bold : textStyle.regular,
|
||||
textPosition: .left))
|
||||
} else {
|
||||
|
||||
// size updates relative to predelimiter, postdelimiter
|
||||
@ -263,13 +263,13 @@ open class PriceLockup: View {
|
||||
textPosition = .preDelimiter
|
||||
attributes.append(TextStyleLabelAttribute(location: 0,
|
||||
length: delimiterIndex,
|
||||
textStyle: sizeTextStyle,
|
||||
textStyle: bold ? textStyle.bold : textStyle.regular,
|
||||
textPosition: .left))
|
||||
|
||||
|
||||
textPosition = .postDelimiter
|
||||
attributes.append(TextStyleLabelAttribute(location: delimiterIndex,
|
||||
length: priceLockupLabel.text.count-delimiterIndex,
|
||||
textStyle: sizeTextStyle,
|
||||
textStyle: bold ? textStyle.bold : textStyle.regular,
|
||||
textPosition: .left))
|
||||
}
|
||||
}
|
||||
@ -281,13 +281,14 @@ open class PriceLockup: View {
|
||||
let space = " "
|
||||
let delimiter = "/"
|
||||
delimiterIndex = 0
|
||||
strikethroughLength = 0
|
||||
let currency: String = hideCurrency ? "" : "$"
|
||||
if let leadingStr = leadingText {
|
||||
text = text + leadingStr + space
|
||||
delimiterIndex = delimiterIndex + leadingStr.count + space.count
|
||||
}
|
||||
strikethroughLocation = delimiterIndex
|
||||
if let value = price {
|
||||
strikethroughLocation = delimiterIndex
|
||||
let valueStr = "\(value.clean)"
|
||||
text = text + currency + valueStr
|
||||
delimiterIndex = delimiterIndex + valueStr.count + currency.count
|
||||
|
||||
Loading…
Reference in New Issue
Block a user