Merge branch 'mbruce/bugfix' into 'develop'
Width Updates See merge request BPHV_MIPS/vds_ios!303
This commit is contained in:
commit
cb37d80f65
@ -61,8 +61,9 @@ open class DropdownSelect: EntryFieldBase<String> {
|
||||
internal var minWidthInlineLabel = 102.0
|
||||
internal override var minWidth: CGFloat { showInlineLabel ? minWidthInlineLabel : minWidthDefault }
|
||||
internal override var maxWidth: CGFloat {
|
||||
let frameWidth = frame.size.width
|
||||
return helperTextPlacement == .right ? (frameWidth - horizontalStackView.spacing) / 2 : frameWidth
|
||||
let frameWidth = constrainedWidth
|
||||
let halfWidth = (frameWidth - horizontalStackView.spacing) / 2
|
||||
return helperTextPlacement == .right && halfWidth > minWidth * 2 ? halfWidth : frameWidth
|
||||
}
|
||||
|
||||
/// The is used for the for adding the helperLabel to the right of the containerView.
|
||||
|
||||
@ -83,7 +83,7 @@ open class FootnoteGroup: View {
|
||||
//--------------------------------------------------
|
||||
// MARK: - Configuration Properties
|
||||
//--------------------------------------------------
|
||||
internal var maxWidth: CGFloat { horizontalPinnedWidth() ?? (superview?.frame.size.width ?? frame.size.width) }
|
||||
internal var maxWidth: CGFloat { constrainedWidth }
|
||||
internal var minWidth: CGFloat { containerSize.width }
|
||||
internal var containerSize: CGSize { CGSize(width: 55, height: 44) }
|
||||
|
||||
|
||||
@ -152,7 +152,7 @@ open class FootnoteItem: View {
|
||||
//--------------------------------------------------
|
||||
// MARK: - Configuration Properties
|
||||
//--------------------------------------------------
|
||||
internal var maxWidth: CGFloat { horizontalPinnedWidth() ?? (superview?.frame.size.width ?? frame.size.width) }
|
||||
internal var maxWidth: CGFloat { constrainedWidth }
|
||||
internal var minWidth: CGFloat { containerSize.width }
|
||||
internal var containerSize: CGSize { CGSize(width: 45, height: 44) }
|
||||
|
||||
|
||||
@ -331,9 +331,7 @@ open class InputStepper: EntryFieldBase<Int> {
|
||||
|
||||
stepperWidthConstraint?.deactivate()
|
||||
widthConstraint?.deactivate()
|
||||
trailingLessThanEqualsConstraint?.deactivate()
|
||||
trailingEqualsConstraint?.deactivate()
|
||||
|
||||
|
||||
var widthConstraintConstant: CGFloat?
|
||||
|
||||
if let widthPercentage, let superWidth = horizontalPinnedWidth() {
|
||||
@ -350,9 +348,6 @@ open class InputStepper: EntryFieldBase<Int> {
|
||||
if let widthConstraintConstant {
|
||||
widthConstraint?.constant = widthConstraintConstant
|
||||
widthConstraint?.activate()
|
||||
trailingLessThanEqualsConstraint?.activate()
|
||||
} else {
|
||||
trailingEqualsConstraint?.activate()
|
||||
}
|
||||
|
||||
// Update Edge insets if size changes applied.
|
||||
|
||||
@ -105,14 +105,12 @@ open class EntryFieldBase<ValueType>: Control, Changeable, FormFieldInternalVali
|
||||
// MARK: - Constraints
|
||||
//--------------------------------------------------
|
||||
internal var widthConstraint: NSLayoutConstraint?
|
||||
internal var trailingEqualsConstraint: NSLayoutConstraint?
|
||||
internal var trailingLessThanEqualsConstraint: NSLayoutConstraint?
|
||||
|
||||
|
||||
//--------------------------------------------------
|
||||
// MARK: - Configuration Properties
|
||||
//--------------------------------------------------
|
||||
// Sizes are from InVision design specs.
|
||||
internal var maxWidth: CGFloat { frame.size.width }
|
||||
internal var maxWidth: CGFloat { constrainedWidth }
|
||||
internal var minWidth: CGFloat { containerSize.width }
|
||||
internal var containerSize: CGSize { CGSize(width: minWidth, height: 44) }
|
||||
|
||||
@ -258,15 +256,9 @@ open class EntryFieldBase<ValueType>: Control, Changeable, FormFieldInternalVali
|
||||
|
||||
let layoutGuide = UILayoutGuide()
|
||||
addLayoutGuide(layoutGuide)
|
||||
layoutGuide
|
||||
.pinTop()
|
||||
.pinLeading()
|
||||
.pinBottom()
|
||||
|
||||
trailingEqualsConstraint = layoutGuide.pinTrailing(anchor: trailingAnchor)
|
||||
layoutGuide.pinToSuperView()
|
||||
|
||||
// width constraints
|
||||
trailingLessThanEqualsConstraint = layoutGuide.pinTrailingLessThanOrEqualTo(anchor: trailingAnchor)?.deactivate()
|
||||
widthConstraint = layoutGuide.widthAnchor.constraint(equalToConstant: 0).deactivate()
|
||||
|
||||
// Add mainStackView to the view
|
||||
@ -549,18 +541,13 @@ open class EntryFieldBase<ValueType>: Control, Changeable, FormFieldInternalVali
|
||||
containerView.layer.borderWidth = VDSFormControls.borderWidth
|
||||
containerView.layer.cornerRadius = VDSFormControls.borderRadius
|
||||
}
|
||||
|
||||
|
||||
internal func updateContainerWidth() {
|
||||
widthConstraint?.deactivate()
|
||||
trailingLessThanEqualsConstraint?.deactivate()
|
||||
trailingEqualsConstraint?.deactivate()
|
||||
|
||||
|
||||
if let width, width >= minWidth, width <= maxWidth {
|
||||
widthConstraint?.constant = width
|
||||
widthConstraint?.activate()
|
||||
trailingLessThanEqualsConstraint?.activate()
|
||||
} else {
|
||||
trailingEqualsConstraint?.activate()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -47,8 +47,9 @@ open class InputField: EntryFieldBase<String> {
|
||||
|
||||
internal override var minWidth: CGFloat { fieldType.handler().minWidth }
|
||||
internal override var maxWidth: CGFloat {
|
||||
let frameWidth = frame.size.width
|
||||
return helperTextPlacement == .right ? (frameWidth - horizontalStackView.spacing) / 2 : frameWidth
|
||||
let frameWidth = constrainedWidth
|
||||
let halfWidth = (frameWidth - horizontalStackView.spacing) / 2
|
||||
return helperTextPlacement == .right && halfWidth > minWidth * 2 ? halfWidth : frameWidth
|
||||
}
|
||||
|
||||
/// The is used for the for adding the helperLabel to the right of the containerView.
|
||||
@ -320,15 +321,12 @@ open class InputField: EntryFieldBase<String> {
|
||||
|
||||
internal override func updateContainerWidth() {
|
||||
widthConstraint?.deactivate()
|
||||
trailingLessThanEqualsConstraint?.deactivate()
|
||||
trailingEqualsConstraint?.deactivate()
|
||||
|
||||
//see if there is a widthPercentage and follow the same pattern as done for "width"
|
||||
let currentWidth = (horizontalPinnedWidth() ?? 0) * (widthPercentage ?? 0)
|
||||
if currentWidth >= minWidth, currentWidth <= maxWidth {
|
||||
widthConstraint?.constant = currentWidth
|
||||
widthConstraint?.activate()
|
||||
trailingLessThanEqualsConstraint?.activate()
|
||||
} else {
|
||||
super.updateContainerWidth()
|
||||
}
|
||||
|
||||
@ -647,7 +647,14 @@ public enum LayoutDistribution: String, CaseIterable {
|
||||
case fillProportionally
|
||||
}
|
||||
|
||||
extension LayoutConstraintable where Self: UIView {
|
||||
public var constrainedWidth: CGFloat {
|
||||
horizontalPinnedWidth() ?? (superview?.frame.size.width ?? frame.size.width)
|
||||
}
|
||||
}
|
||||
|
||||
extension LayoutConstraintable {
|
||||
|
||||
public func removeConstraints() {
|
||||
guard let view = self as? UIView, let superview = view.superview else { return }
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user