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