Merge branch 'mbruce/bugfix' into 'develop'
rename class for docs See merge request BPHV_MIPS/vds_ios!302
This commit is contained in:
commit
e77bbea163
@ -43,13 +43,14 @@ open class SelectorItemBase<Selector: SelectorBase>: Control, Errorable, Changea
|
||||
|
||||
private var mainStackView = UIStackView().with {
|
||||
$0.translatesAutoresizingMaskIntoConstraints = false
|
||||
$0.alignment = .top
|
||||
$0.alignment = .fill
|
||||
$0.axis = .vertical
|
||||
}
|
||||
|
||||
private var selectorStackView = UIStackView().with {
|
||||
$0.translatesAutoresizingMaskIntoConstraints = false
|
||||
$0.alignment = .top
|
||||
$0.alignment = .fill
|
||||
|
||||
$0.axis = .horizontal
|
||||
}
|
||||
|
||||
@ -171,10 +172,16 @@ open class SelectorItemBase<Selector: SelectorBase>: Control, Errorable, Changea
|
||||
isAccessibilityElement = false
|
||||
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(errorLabel)
|
||||
selectorStackView.addArrangedSubview(selectorView)
|
||||
selectorStackView.addArrangedSubview(selectorViewWrapper)
|
||||
selectorStackView.addArrangedSubview(selectorLabelStackView)
|
||||
selectorLabelStackView.addArrangedSubview(label)
|
||||
selectorLabelStackView.addArrangedSubview(childLabel)
|
||||
|
||||
@ -63,7 +63,7 @@ open class FootnoteGroup: View {
|
||||
} else {
|
||||
_width = nil
|
||||
}
|
||||
setNeedsUpdate()
|
||||
updateContainerWidth()
|
||||
}
|
||||
}
|
||||
|
||||
@ -83,7 +83,7 @@ open class FootnoteGroup: View {
|
||||
//--------------------------------------------------
|
||||
// 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 containerSize: CGSize { CGSize(width: 55, height: 44) }
|
||||
|
||||
@ -91,8 +91,6 @@ open class FootnoteGroup: View {
|
||||
// MARK: - Constraints
|
||||
//--------------------------------------------------
|
||||
internal var widthConstraint: NSLayoutConstraint?
|
||||
internal var trailingEqualsConstraint: NSLayoutConstraint?
|
||||
internal var trailingLessThanEqualsConstraint: NSLayoutConstraint?
|
||||
|
||||
//--------------------------------------------------
|
||||
// MARK: - Overrides
|
||||
@ -104,12 +102,8 @@ open class FootnoteGroup: View {
|
||||
|
||||
// add footnote item stackview.
|
||||
addSubview(stackView)
|
||||
stackView.pinTop().pinBottom().pinLeading()
|
||||
trailingEqualsConstraint = stackView.pinTrailing(anchor: trailingAnchor)
|
||||
|
||||
// width constraints
|
||||
trailingLessThanEqualsConstraint = stackView.pinTrailingLessThanOrEqualTo(anchor: trailingAnchor)?.deactivate()
|
||||
widthConstraint = stackView.widthAnchor.constraint(equalToConstant: 0).deactivate()
|
||||
stackView.pinToSuperView()
|
||||
widthConstraint = widthAnchor.constraint(equalToConstant: 0).deactivate()
|
||||
}
|
||||
|
||||
open override func setDefaults() {
|
||||
@ -117,18 +111,7 @@ open class FootnoteGroup: View {
|
||||
width = nil
|
||||
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() {
|
||||
// symbol containers are as wide as the widest symbol container in the group.
|
||||
var symbolMaxWidth = 0.0
|
||||
@ -151,10 +134,11 @@ open class FootnoteGroup: View {
|
||||
stackView.addArrangedSubview(footnote)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// Update container width after updating content.
|
||||
internal func updateContainerWidth() {
|
||||
var newWidth = 0.0
|
||||
|
||||
switch width {
|
||||
case .percentage(let percentage):
|
||||
newWidth = max(maxWidth * ((percentage) / 100), minWidth)
|
||||
@ -162,20 +146,15 @@ open class FootnoteGroup: View {
|
||||
case .value(let value):
|
||||
newWidth = value > maxWidth ? maxWidth : value
|
||||
|
||||
case nil:
|
||||
newWidth = maxWidth
|
||||
case nil: break
|
||||
|
||||
}
|
||||
|
||||
widthConstraint?.deactivate()
|
||||
trailingLessThanEqualsConstraint?.deactivate()
|
||||
trailingEqualsConstraint?.deactivate()
|
||||
|
||||
if newWidth > minWidth && newWidth < maxWidth {
|
||||
widthConstraint?.constant = newWidth
|
||||
widthConstraint?.activate()
|
||||
trailingLessThanEqualsConstraint?.activate()
|
||||
} else {
|
||||
trailingEqualsConstraint?.activate()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -117,7 +117,7 @@ open class FootnoteItem: View {
|
||||
} else {
|
||||
_width = nil
|
||||
}
|
||||
setNeedsUpdate()
|
||||
updateContainerWidth()
|
||||
}
|
||||
}
|
||||
|
||||
@ -152,7 +152,7 @@ open class FootnoteItem: View {
|
||||
//--------------------------------------------------
|
||||
// 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 containerSize: CGSize { CGSize(width: 45, height: 44) }
|
||||
|
||||
@ -161,8 +161,6 @@ open class FootnoteItem: View {
|
||||
//--------------------------------------------------
|
||||
internal var symbolWidthConstraint: NSLayoutConstraint?
|
||||
internal var itemWidthConstraint: NSLayoutConstraint?
|
||||
internal var trailingEqualsConstraint: NSLayoutConstraint?
|
||||
internal var trailingLessThanEqualsConstraint: NSLayoutConstraint?
|
||||
|
||||
//--------------------------------------------------
|
||||
// MARK: - Overrides
|
||||
@ -174,12 +172,10 @@ open class FootnoteItem: View {
|
||||
|
||||
// add footnote item stackview.
|
||||
addSubview(itemStackView)
|
||||
itemStackView.pinTop().pinBottom().pinLeading()
|
||||
trailingEqualsConstraint = itemStackView.pinTrailing(anchor: trailingAnchor)
|
||||
itemStackView.pinToSuperView()
|
||||
|
||||
// width constraints
|
||||
itemWidthConstraint = itemStackView.widthAnchor.constraint(equalToConstant: 0).deactivate()
|
||||
trailingLessThanEqualsConstraint = itemStackView.pinTrailingLessThanOrEqualTo(anchor: trailingAnchor)?.deactivate()
|
||||
itemWidthConstraint = widthAnchor.constraint(equalToConstant: 0).deactivate()
|
||||
|
||||
// add symbol label, text label to stack.
|
||||
itemStackView.addArrangedSubview(symbolLabel)
|
||||
@ -236,8 +232,6 @@ open class FootnoteItem: View {
|
||||
attributes.append(TooltipLabelAttribute(surface: surface, model: tooltipModel, presenter: self))
|
||||
textLabel.attributes = attributes
|
||||
}
|
||||
|
||||
updateContainerWidth()
|
||||
}
|
||||
|
||||
/// Update container width after updating content.
|
||||
@ -251,18 +245,13 @@ open class FootnoteItem: View {
|
||||
newWidth = value > maxWidth ? maxWidth : value
|
||||
|
||||
case nil:
|
||||
newWidth = maxWidth
|
||||
}
|
||||
break
|
||||
}
|
||||
itemWidthConstraint?.deactivate()
|
||||
trailingLessThanEqualsConstraint?.deactivate()
|
||||
trailingEqualsConstraint?.deactivate()
|
||||
|
||||
if newWidth > minWidth && newWidth < maxWidth {
|
||||
itemWidthConstraint?.constant = newWidth
|
||||
itemWidthConstraint?.activate()
|
||||
trailingLessThanEqualsConstraint?.activate()
|
||||
} else {
|
||||
trailingEqualsConstraint?.activate()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -32,7 +32,7 @@ Using the system allows designers and developers to collaborate more easily and
|
||||
- ``CheckboxItem``
|
||||
- ``CheckboxGroup``
|
||||
- ``DropdownSelect``
|
||||
- ``Footnote``
|
||||
- ``FootnoteItem``
|
||||
- ``FootnoteGroup``
|
||||
- ``Icon``
|
||||
- ``InputStepper``
|
||||
|
||||
Loading…
Reference in New Issue
Block a user