Digital ACT-191 ONEAPP-10586 story: updated symbolType to use as String, camelCase applied to footnoteItems

This commit is contained in:
Vasavi Kanamarlapudi 2024-09-12 13:26:06 +05:30
parent e22b64095b
commit 09351db136
2 changed files with 12 additions and 33 deletions

View File

@ -72,27 +72,6 @@ open class Footnote: View {
}
}
/// Enum used to describe the symboldType of component.
public enum SymbolType: String, DefaultValuing, CaseIterable {
case asterisk
case doubleAsterisk
case character
public static var defaultValue: Self { .asterisk }
/// TextStyle relative to Size.
public var text: String {
switch self {
case .asterisk:
return "*"
case .doubleAsterisk:
return "**"
case .character:
return "1."
}
}
}
/// Enum used to describe the width of a fixed value or percentage of parent's width.
public enum Width {
case percentage(CGFloat)
@ -111,8 +90,8 @@ open class Footnote: View {
/// If hideSymbol true, the component will show text without symbol.
open var hideSymbol: Bool = false { didSet { setNeedsUpdate() } }
/// Size of the component. The default size is Micro.
open var symbolType: SymbolType = .defaultValue { didSet { setNeedsUpdate() } }
/// symbol type will be shown for the footnote item. The default symbolType is 'asterisk'.
open var symbolType: String = "*" { didSet { setNeedsUpdate() } }
/// Text of the footnote item.
open var text: String? { didSet { setNeedsUpdate() } }
@ -232,7 +211,7 @@ open class Footnote: View {
// Update symbolLabel
symbolWidthConstraint?.isActive = false
symbolLabel.text = hideSymbol ? "" : symbolType.text
symbolLabel.text = hideSymbol ? "" : symbolType
symbolLabel.textColor = kind.colorConfiguration.getColor(self)
symbolLabel.textStyle = size.textStyle.regular
symbolLabel.surface = surface

View File

@ -42,7 +42,7 @@ open class FootnoteGroup: View {
// MARK: - Public Properties
//--------------------------------------------------
/// Array of ``Footnote`` for the Footnote items.
open var footnoteitems: [Footnote] = [] { didSet { setNeedsUpdate() } }
open var footnoteItems: [Footnote] = [] { didSet { setNeedsUpdate() } }
/// Any percentage or pixel value and cannot exceed container size.
/// If there is a width that is larger than container size, the footnote will resize to container's width.
@ -116,7 +116,7 @@ open class FootnoteGroup: View {
open override func setDefaults() {
super.setDefaults()
width = nil
footnoteitems = []
footnoteItems = []
}
/// Resets to default settings.
@ -131,19 +131,19 @@ open class FootnoteGroup: View {
// symbol containers are as wide as the widest symbol container in the group.
var symbolMaxWidth = 0.0
if footnoteitems.count > 0 {
for index in 0...footnoteitems.count - 1 {
let footnote: Footnote = footnoteitems[index]
let separatorWidth = Label().with { $0.text = footnote.symbolType.text; $0.sizeToFit() }.intrinsicContentSize.width
if footnoteItems.count > 0 {
for index in 0...footnoteItems.count - 1 {
let footnote: Footnote = footnoteItems[index]
let separatorWidth = Label().with { $0.text = footnote.symbolType; $0.sizeToFit() }.intrinsicContentSize.width
symbolMaxWidth = separatorWidth > symbolMaxWidth ? separatorWidth : symbolMaxWidth
}
}
stackView.subviews.forEach{$0.removeFromSuperview()}
// add symbol label, text label to stack.
if footnoteitems.count > 0 {
for index in 0...footnoteitems.count - 1 {
let footnote: Footnote = footnoteitems[index]
if footnoteItems.count > 0 {
for index in 0...footnoteItems.count - 1 {
let footnote: Footnote = footnoteItems[index]
footnote.symbolWiderWidth = symbolMaxWidth
footnote.surface = surface
stackView.addArrangedSubview(footnote)