Merge branch 'mbruce/bugfix' into 'develop'

rename class for docs

See merge request BPHV_MIPS/vds_ios!302
This commit is contained in:
Bruce, Matt R 2024-09-19 19:35:37 +00:00
commit e77bbea163
4 changed files with 27 additions and 52 deletions

View File

@ -43,13 +43,14 @@ open class SelectorItemBase<Selector: SelectorBase>: Control, Errorable, Changea
private var mainStackView = UIStackView().with { private var mainStackView = UIStackView().with {
$0.translatesAutoresizingMaskIntoConstraints = false $0.translatesAutoresizingMaskIntoConstraints = false
$0.alignment = .top $0.alignment = .fill
$0.axis = .vertical $0.axis = .vertical
} }
private var selectorStackView = UIStackView().with { private var selectorStackView = UIStackView().with {
$0.translatesAutoresizingMaskIntoConstraints = false $0.translatesAutoresizingMaskIntoConstraints = false
$0.alignment = .top $0.alignment = .fill
$0.axis = .horizontal $0.axis = .horizontal
} }
@ -171,10 +172,16 @@ open class SelectorItemBase<Selector: SelectorBase>: Control, Errorable, Changea
isAccessibilityElement = false isAccessibilityElement = false
addSubview(mainStackView) addSubview(mainStackView)
mainStackView.isUserInteractionEnabled = false //wrap the selectorView in a view that won't stretch it
//do this by not pinning the bottom
let selectorViewWrapper = UIView().with { $0.translatesAutoresizingMaskIntoConstraints = false }
selectorViewWrapper.addSubview(selectorView)
selectorView.pinTop().pinLeading().pinTrailing().pinBottomLessThanOrEqualTo()
mainStackView.isUserInteractionEnabled = false
mainStackView.addArrangedSubview(selectorStackView) mainStackView.addArrangedSubview(selectorStackView)
mainStackView.addArrangedSubview(errorLabel) mainStackView.addArrangedSubview(errorLabel)
selectorStackView.addArrangedSubview(selectorView) selectorStackView.addArrangedSubview(selectorViewWrapper)
selectorStackView.addArrangedSubview(selectorLabelStackView) selectorStackView.addArrangedSubview(selectorLabelStackView)
selectorLabelStackView.addArrangedSubview(label) selectorLabelStackView.addArrangedSubview(label)
selectorLabelStackView.addArrangedSubview(childLabel) selectorLabelStackView.addArrangedSubview(childLabel)

View File

@ -63,7 +63,7 @@ open class FootnoteGroup: View {
} else { } else {
_width = nil _width = nil
} }
setNeedsUpdate() updateContainerWidth()
} }
} }
@ -83,7 +83,7 @@ open class FootnoteGroup: View {
//-------------------------------------------------- //--------------------------------------------------
// MARK: - Configuration Properties // MARK: - Configuration Properties
//-------------------------------------------------- //--------------------------------------------------
internal var maxWidth: CGFloat { frame.size.width } internal var maxWidth: CGFloat { horizontalPinnedWidth() ?? (superview?.frame.size.width ?? frame.size.width) }
internal var minWidth: CGFloat { containerSize.width } internal var minWidth: CGFloat { containerSize.width }
internal var containerSize: CGSize { CGSize(width: 55, height: 44) } internal var containerSize: CGSize { CGSize(width: 55, height: 44) }
@ -91,8 +91,6 @@ open class FootnoteGroup: View {
// MARK: - Constraints // MARK: - Constraints
//-------------------------------------------------- //--------------------------------------------------
internal var widthConstraint: NSLayoutConstraint? internal var widthConstraint: NSLayoutConstraint?
internal var trailingEqualsConstraint: NSLayoutConstraint?
internal var trailingLessThanEqualsConstraint: NSLayoutConstraint?
//-------------------------------------------------- //--------------------------------------------------
// MARK: - Overrides // MARK: - Overrides
@ -104,12 +102,8 @@ open class FootnoteGroup: View {
// add footnote item stackview. // add footnote item stackview.
addSubview(stackView) addSubview(stackView)
stackView.pinTop().pinBottom().pinLeading() stackView.pinToSuperView()
trailingEqualsConstraint = stackView.pinTrailing(anchor: trailingAnchor) widthConstraint = widthAnchor.constraint(equalToConstant: 0).deactivate()
// width constraints
trailingLessThanEqualsConstraint = stackView.pinTrailingLessThanOrEqualTo(anchor: trailingAnchor)?.deactivate()
widthConstraint = stackView.widthAnchor.constraint(equalToConstant: 0).deactivate()
} }
open override func setDefaults() { open override func setDefaults() {
@ -117,18 +111,7 @@ open class FootnoteGroup: View {
width = nil width = nil
footnoteItems = [] footnoteItems = []
} }
/// Resets to default settings.
open override func reset() {
super.reset()
}
/// Used to make changes to the View based off a change events or from local properties.
open override func updateView() {
super.updateView()
updateContainerWidth()
}
internal func updateFootnoteItems() { internal func updateFootnoteItems() {
// 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
@ -151,10 +134,11 @@ open class FootnoteGroup: View {
stackView.addArrangedSubview(footnote) stackView.addArrangedSubview(footnote)
} }
} }
/// Update container width after updating content. /// Update container width after updating content.
internal func updateContainerWidth() { internal func updateContainerWidth() {
var newWidth = 0.0 var newWidth = 0.0
switch width { switch width {
case .percentage(let percentage): case .percentage(let percentage):
newWidth = max(maxWidth * ((percentage) / 100), minWidth) newWidth = max(maxWidth * ((percentage) / 100), minWidth)
@ -162,20 +146,15 @@ open class FootnoteGroup: View {
case .value(let value): case .value(let value):
newWidth = value > maxWidth ? maxWidth : value newWidth = value > maxWidth ? maxWidth : value
case nil: case nil: break
newWidth = maxWidth
} }
widthConstraint?.deactivate() widthConstraint?.deactivate()
trailingLessThanEqualsConstraint?.deactivate()
trailingEqualsConstraint?.deactivate()
if newWidth > minWidth && newWidth < maxWidth { if newWidth > minWidth && newWidth < maxWidth {
widthConstraint?.constant = newWidth widthConstraint?.constant = newWidth
widthConstraint?.activate() widthConstraint?.activate()
trailingLessThanEqualsConstraint?.activate()
} else {
trailingEqualsConstraint?.activate()
} }
} }
} }

View File

@ -117,7 +117,7 @@ open class FootnoteItem: View {
} else { } else {
_width = nil _width = nil
} }
setNeedsUpdate() updateContainerWidth()
} }
} }
@ -152,7 +152,7 @@ open class FootnoteItem: View {
//-------------------------------------------------- //--------------------------------------------------
// MARK: - Configuration Properties // MARK: - Configuration Properties
//-------------------------------------------------- //--------------------------------------------------
internal var maxWidth: CGFloat { frame.size.width } internal var maxWidth: CGFloat { horizontalPinnedWidth() ?? (superview?.frame.size.width ?? frame.size.width) }
internal var minWidth: CGFloat { containerSize.width } internal var minWidth: CGFloat { containerSize.width }
internal var containerSize: CGSize { CGSize(width: 45, height: 44) } internal var containerSize: CGSize { CGSize(width: 45, height: 44) }
@ -161,8 +161,6 @@ open class FootnoteItem: View {
//-------------------------------------------------- //--------------------------------------------------
internal var symbolWidthConstraint: NSLayoutConstraint? internal var symbolWidthConstraint: NSLayoutConstraint?
internal var itemWidthConstraint: NSLayoutConstraint? internal var itemWidthConstraint: NSLayoutConstraint?
internal var trailingEqualsConstraint: NSLayoutConstraint?
internal var trailingLessThanEqualsConstraint: NSLayoutConstraint?
//-------------------------------------------------- //--------------------------------------------------
// MARK: - Overrides // MARK: - Overrides
@ -174,12 +172,10 @@ open class FootnoteItem: View {
// add footnote item stackview. // add footnote item stackview.
addSubview(itemStackView) addSubview(itemStackView)
itemStackView.pinTop().pinBottom().pinLeading() itemStackView.pinToSuperView()
trailingEqualsConstraint = itemStackView.pinTrailing(anchor: trailingAnchor)
// width constraints // width constraints
itemWidthConstraint = itemStackView.widthAnchor.constraint(equalToConstant: 0).deactivate() itemWidthConstraint = widthAnchor.constraint(equalToConstant: 0).deactivate()
trailingLessThanEqualsConstraint = itemStackView.pinTrailingLessThanOrEqualTo(anchor: trailingAnchor)?.deactivate()
// add symbol label, text label to stack. // add symbol label, text label to stack.
itemStackView.addArrangedSubview(symbolLabel) itemStackView.addArrangedSubview(symbolLabel)
@ -236,8 +232,6 @@ open class FootnoteItem: View {
attributes.append(TooltipLabelAttribute(surface: surface, model: tooltipModel, presenter: self)) attributes.append(TooltipLabelAttribute(surface: surface, model: tooltipModel, presenter: self))
textLabel.attributes = attributes textLabel.attributes = attributes
} }
updateContainerWidth()
} }
/// Update container width after updating content. /// Update container width after updating content.
@ -251,18 +245,13 @@ open class FootnoteItem: View {
newWidth = value > maxWidth ? maxWidth : value newWidth = value > maxWidth ? maxWidth : value
case nil: case nil:
newWidth = maxWidth break
} }
itemWidthConstraint?.deactivate() itemWidthConstraint?.deactivate()
trailingLessThanEqualsConstraint?.deactivate()
trailingEqualsConstraint?.deactivate()
if newWidth > minWidth && newWidth < maxWidth { if newWidth > minWidth && newWidth < maxWidth {
itemWidthConstraint?.constant = newWidth itemWidthConstraint?.constant = newWidth
itemWidthConstraint?.activate() itemWidthConstraint?.activate()
trailingLessThanEqualsConstraint?.activate()
} else {
trailingEqualsConstraint?.activate()
} }
} }
} }

View File

@ -32,7 +32,7 @@ Using the system allows designers and developers to collaborate more easily and
- ``CheckboxItem`` - ``CheckboxItem``
- ``CheckboxGroup`` - ``CheckboxGroup``
- ``DropdownSelect`` - ``DropdownSelect``
- ``Footnote`` - ``FootnoteItem``
- ``FootnoteGroup`` - ``FootnoteGroup``
- ``Icon`` - ``Icon``
- ``InputStepper`` - ``InputStepper``