Digital ACT-191 ONEAPP-10586 story: updated symbolType to use as String, camelCase applied to footnoteItems
This commit is contained in:
parent
e22b64095b
commit
09351db136
@ -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.
|
/// Enum used to describe the width of a fixed value or percentage of parent's width.
|
||||||
public enum Width {
|
public enum Width {
|
||||||
case percentage(CGFloat)
|
case percentage(CGFloat)
|
||||||
@ -111,8 +90,8 @@ open class Footnote: View {
|
|||||||
/// If hideSymbol true, the component will show text without symbol.
|
/// If hideSymbol true, the component will show text without symbol.
|
||||||
open var hideSymbol: Bool = false { didSet { setNeedsUpdate() } }
|
open var hideSymbol: Bool = false { didSet { setNeedsUpdate() } }
|
||||||
|
|
||||||
/// Size of the component. The default size is Micro.
|
/// symbol type will be shown for the footnote item. The default symbolType is 'asterisk'.
|
||||||
open var symbolType: SymbolType = .defaultValue { didSet { setNeedsUpdate() } }
|
open var symbolType: String = "*" { didSet { setNeedsUpdate() } }
|
||||||
|
|
||||||
/// Text of the footnote item.
|
/// Text of the footnote item.
|
||||||
open var text: String? { didSet { setNeedsUpdate() } }
|
open var text: String? { didSet { setNeedsUpdate() } }
|
||||||
@ -232,7 +211,7 @@ open class Footnote: View {
|
|||||||
|
|
||||||
// Update symbolLabel
|
// Update symbolLabel
|
||||||
symbolWidthConstraint?.isActive = false
|
symbolWidthConstraint?.isActive = false
|
||||||
symbolLabel.text = hideSymbol ? "" : symbolType.text
|
symbolLabel.text = hideSymbol ? "" : symbolType
|
||||||
symbolLabel.textColor = kind.colorConfiguration.getColor(self)
|
symbolLabel.textColor = kind.colorConfiguration.getColor(self)
|
||||||
symbolLabel.textStyle = size.textStyle.regular
|
symbolLabel.textStyle = size.textStyle.regular
|
||||||
symbolLabel.surface = surface
|
symbolLabel.surface = surface
|
||||||
|
|||||||
@ -42,7 +42,7 @@ open class FootnoteGroup: View {
|
|||||||
// MARK: - Public Properties
|
// MARK: - Public Properties
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
/// Array of ``Footnote`` for the Footnote items.
|
/// 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.
|
/// 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.
|
/// 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() {
|
open override func setDefaults() {
|
||||||
super.setDefaults()
|
super.setDefaults()
|
||||||
width = nil
|
width = nil
|
||||||
footnoteitems = []
|
footnoteItems = []
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Resets to default settings.
|
/// 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.
|
// symbol containers are as wide as the widest symbol container in the group.
|
||||||
var symbolMaxWidth = 0.0
|
var symbolMaxWidth = 0.0
|
||||||
if footnoteitems.count > 0 {
|
if footnoteItems.count > 0 {
|
||||||
for index in 0...footnoteitems.count - 1 {
|
for index in 0...footnoteItems.count - 1 {
|
||||||
let footnote: Footnote = footnoteitems[index]
|
let footnote: Footnote = footnoteItems[index]
|
||||||
let separatorWidth = Label().with { $0.text = footnote.symbolType.text; $0.sizeToFit() }.intrinsicContentSize.width
|
let separatorWidth = Label().with { $0.text = footnote.symbolType; $0.sizeToFit() }.intrinsicContentSize.width
|
||||||
symbolMaxWidth = separatorWidth > symbolMaxWidth ? separatorWidth : symbolMaxWidth
|
symbolMaxWidth = separatorWidth > symbolMaxWidth ? separatorWidth : symbolMaxWidth
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
stackView.subviews.forEach{$0.removeFromSuperview()}
|
stackView.subviews.forEach{$0.removeFromSuperview()}
|
||||||
// add symbol label, text label to stack.
|
// add symbol label, text label to stack.
|
||||||
if footnoteitems.count > 0 {
|
if footnoteItems.count > 0 {
|
||||||
for index in 0...footnoteitems.count - 1 {
|
for index in 0...footnoteItems.count - 1 {
|
||||||
let footnote: Footnote = footnoteitems[index]
|
let footnote: Footnote = footnoteItems[index]
|
||||||
footnote.symbolWiderWidth = symbolMaxWidth
|
footnote.symbolWiderWidth = symbolMaxWidth
|
||||||
footnote.surface = surface
|
footnote.surface = surface
|
||||||
stackView.addArrangedSubview(footnote)
|
stackView.addArrangedSubview(footnote)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user