Digital ACT-191 ONEAPP-9314 story: added missed comments
This commit is contained in:
parent
1bd58256f7
commit
e5d9f77d3d
@ -99,24 +99,24 @@ open class PriceLockup: View {
|
|||||||
|
|
||||||
/// Currency - If hideCurrency true, the component will render without currency.
|
/// Currency - If hideCurrency true, the component will render without currency.
|
||||||
open var hideCurrency: Bool = false { didSet { setNeedsUpdate() } }
|
open var hideCurrency: Bool = false { didSet { setNeedsUpdate() } }
|
||||||
|
|
||||||
/// Leading text for the component.
|
/// Leading text for the component.
|
||||||
open var leadingText: String? { didSet { setNeedsUpdate() } }
|
open var leadingText: String? { didSet { setNeedsUpdate() } }
|
||||||
|
|
||||||
/// Value rendered for the component.
|
/// Value rendered for the component.
|
||||||
open var price: Float? { didSet { setNeedsUpdate() } }
|
open var price: Float? { didSet { setNeedsUpdate() } }
|
||||||
|
|
||||||
/// Color to the component. The default kind is primary.
|
/// Color to the component. The default kind is primary.
|
||||||
open var kind: Kind = Kind.defaultValue { didSet { setNeedsUpdate() } }
|
open var kind: Kind = Kind.defaultValue { didSet { setNeedsUpdate() } }
|
||||||
|
|
||||||
/// Size of the component. It varies by size and viewport(mobile/Tablet).
|
/// Size of the component. It varies by size and viewport(mobile/Tablet).
|
||||||
/// The default size is medium with viewport mobile.
|
/// The default size is medium with viewport mobile.
|
||||||
open var size: Size = Size.defaultValue { didSet { setNeedsUpdate() } }
|
open var size: Size = Size.defaultValue { didSet { setNeedsUpdate() } }
|
||||||
|
|
||||||
/// If true, the component with a strikethrough. It applies only when uniformSize is true.
|
/// If true, the component with a strikethrough. It applies only when uniformSize is true.
|
||||||
/// Does not apply a strikethrough format to leading and trailing text.
|
/// Does not apply a strikethrough format to leading and trailing text.
|
||||||
open var strikethrough: Bool = false { didSet { setNeedsUpdate() } }
|
open var strikethrough: Bool = false { didSet { setNeedsUpdate() } }
|
||||||
|
|
||||||
/// Term text for the component. The default term is 'month'.
|
/// Term text for the component. The default term is 'month'.
|
||||||
/// Superscript placement can vary when term and delimeter are "none".
|
/// Superscript placement can vary when term and delimeter are "none".
|
||||||
open var term: Term = Term.defaultValue { didSet { setNeedsUpdate() } }
|
open var term: Term = Term.defaultValue { didSet { setNeedsUpdate() } }
|
||||||
@ -130,7 +130,7 @@ open class PriceLockup: View {
|
|||||||
/// If true, currency and value have the same font text style as delimeter, term label and superscript.
|
/// If true, currency and value have the same font text style as delimeter, term label and superscript.
|
||||||
/// This will render the pricing and term sections as a uniform size.
|
/// This will render the pricing and term sections as a uniform size.
|
||||||
open var uniformSize: Bool = false { didSet { setNeedsUpdate() } }
|
open var uniformSize: Bool = false { didSet { setNeedsUpdate() } }
|
||||||
|
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
// MARK: - Private Properties
|
// MARK: - Private Properties
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
@ -142,7 +142,7 @@ open class PriceLockup: View {
|
|||||||
internal var delimiterIndex = 0
|
internal var delimiterIndex = 0
|
||||||
internal var strikethroughLocation = 0
|
internal var strikethroughLocation = 0
|
||||||
internal var strikethroughLength = 0
|
internal var strikethroughLength = 0
|
||||||
|
|
||||||
internal var textPosition:TextPosition = .preDelimiter
|
internal var textPosition:TextPosition = .preDelimiter
|
||||||
enum TextPosition: String, CaseIterable {
|
enum TextPosition: String, CaseIterable {
|
||||||
case preDelimiter, postDelimiter
|
case preDelimiter, postDelimiter
|
||||||
@ -152,7 +152,8 @@ open class PriceLockup: View {
|
|||||||
// MARK: - Configuration Properties
|
// MARK: - Configuration Properties
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
internal var containerSize: CGSize { CGSize(width: 45, height: 44) }
|
internal var containerSize: CGSize { CGSize(width: 45, height: 44) }
|
||||||
|
|
||||||
|
// TextStyle for the size.
|
||||||
private var textStyle: TextStyle.StandardStyle {
|
private var textStyle: TextStyle.StandardStyle {
|
||||||
switch (size, textPosition) {
|
switch (size, textPosition) {
|
||||||
case (.xxxsmall, .preDelimiter), (.xxxsmall, .postDelimiter):
|
case (.xxxsmall, .preDelimiter), (.xxxsmall, .postDelimiter):
|
||||||
@ -175,19 +176,19 @@ open class PriceLockup: View {
|
|||||||
|
|
||||||
case (.large, .preDelimiter):
|
case (.large, .preDelimiter):
|
||||||
return UIDevice.isIPad ? .titleMedium : .titleLarge
|
return UIDevice.isIPad ? .titleMedium : .titleLarge
|
||||||
|
|
||||||
case (.large, .postDelimiter):
|
case (.large, .postDelimiter):
|
||||||
return UIDevice.isIPad ? .titleSmall : .titleMedium
|
return UIDevice.isIPad ? .titleSmall : .titleMedium
|
||||||
|
|
||||||
case (.xlarge, .preDelimiter):
|
case (.xlarge, .preDelimiter):
|
||||||
return UIDevice.isIPad ? .titleLarge : .titleXLarge
|
return UIDevice.isIPad ? .titleLarge : .titleXLarge
|
||||||
|
|
||||||
case (.xlarge, .postDelimiter):
|
case (.xlarge, .postDelimiter):
|
||||||
return UIDevice.isIPad ? .titleMedium : .titleLarge
|
return UIDevice.isIPad ? .titleMedium : .titleLarge
|
||||||
|
|
||||||
case (.xxlarge, .preDelimiter):
|
case (.xxlarge, .preDelimiter):
|
||||||
return UIDevice.isIPad ? .titleXLarge : .featureSmall
|
return UIDevice.isIPad ? .titleXLarge : .featureSmall
|
||||||
|
|
||||||
case (.xxlarge, .postDelimiter):
|
case (.xxlarge, .postDelimiter):
|
||||||
return UIDevice.isIPad ? .titleLarge : .titleXLarge
|
return UIDevice.isIPad ? .titleLarge : .titleXLarge
|
||||||
}
|
}
|
||||||
@ -204,11 +205,11 @@ open class PriceLockup: View {
|
|||||||
addSubview(priceLockupLabel)
|
addSubview(priceLockupLabel)
|
||||||
priceLockupLabel.pinToSuperView()
|
priceLockupLabel.pinToSuperView()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Used to make changes to the View based off a change events or from local properties.
|
/// Used to make changes to the View based off a change events or from local properties.
|
||||||
open override func updateView() {
|
open override func updateView() {
|
||||||
super.updateView()
|
super.updateView()
|
||||||
|
|
||||||
priceLockupLabel.text = fetchText()
|
priceLockupLabel.text = fetchText()
|
||||||
priceLockupLabel.surface = surface
|
priceLockupLabel.surface = surface
|
||||||
|
|
||||||
@ -224,10 +225,11 @@ open class PriceLockup: View {
|
|||||||
shouldUpdateView = true
|
shouldUpdateView = true
|
||||||
setNeedsUpdate()
|
setNeedsUpdate()
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
// MARK: - Private Methods
|
// MARK: - Private Methods
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
|
// Update PriceLockup text attributes
|
||||||
func updateLabelAttributes() {
|
func updateLabelAttributes() {
|
||||||
var attributes: [any LabelAttributeModel] = []
|
var attributes: [any LabelAttributeModel] = []
|
||||||
attributes.append(ColorLabelAttribute(location: 0,
|
attributes.append(ColorLabelAttribute(location: 0,
|
||||||
@ -242,6 +244,7 @@ open class PriceLockup: View {
|
|||||||
textStyle: bold ? textStyle.bold : textStyle.regular,
|
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.
|
||||||
@ -249,6 +252,7 @@ open class PriceLockup: View {
|
|||||||
length: priceLockupLabel.text.count,
|
length: priceLockupLabel.text.count,
|
||||||
textStyle: bold ? textStyle.bold : textStyle.regular,
|
textStyle: bold ? textStyle.bold : textStyle.regular,
|
||||||
textPosition: .left))
|
textPosition: .left))
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
// size updates relative to predelimiter, postdelimiter
|
// size updates relative to predelimiter, postdelimiter
|
||||||
@ -269,6 +273,7 @@ open class PriceLockup: View {
|
|||||||
priceLockupLabel.attributes = attributes
|
priceLockupLabel.attributes = attributes
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Get text for PriceLockup.
|
||||||
open func fetchText() -> String {
|
open func fetchText() -> String {
|
||||||
var text : String = ""
|
var text : String = ""
|
||||||
let space = " "
|
let space = " "
|
||||||
@ -302,6 +307,6 @@ open class PriceLockup: View {
|
|||||||
extension Float {
|
extension Float {
|
||||||
// remove a decimal from a float if the decimal is equal to 0
|
// remove a decimal from a float if the decimal is equal to 0
|
||||||
var clean: String {
|
var clean: String {
|
||||||
return self.truncatingRemainder(dividingBy: 1) == 0 ? String(format: "%.0f", self) : String(self)
|
return self.truncatingRemainder(dividingBy: 1) == 0 ? String(format: "%.0f", self) : String(self)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user