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 var minWidthInlineLabel = 102.0
|
||||||
internal override var minWidth: CGFloat { showInlineLabel ? minWidthInlineLabel : minWidthDefault }
|
internal override var minWidth: CGFloat { showInlineLabel ? minWidthInlineLabel : minWidthDefault }
|
||||||
internal override var maxWidth: CGFloat {
|
internal override var maxWidth: CGFloat {
|
||||||
let frameWidth = frame.size.width
|
let frameWidth = constrainedWidth
|
||||||
return helperTextPlacement == .right ? (frameWidth - horizontalStackView.spacing) / 2 : frameWidth
|
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.
|
/// 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
|
// 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 minWidth: CGFloat { containerSize.width }
|
||||||
internal var containerSize: CGSize { CGSize(width: 55, height: 44) }
|
internal var containerSize: CGSize { CGSize(width: 55, height: 44) }
|
||||||
|
|
||||||
|
|||||||
@ -152,7 +152,7 @@ open class FootnoteItem: View {
|
|||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
// MARK: - Configuration Properties
|
// 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 minWidth: CGFloat { containerSize.width }
|
||||||
internal var containerSize: CGSize { CGSize(width: 45, height: 44) }
|
internal var containerSize: CGSize { CGSize(width: 45, height: 44) }
|
||||||
|
|
||||||
|
|||||||
@ -331,8 +331,6 @@ open class InputStepper: EntryFieldBase<Int> {
|
|||||||
|
|
||||||
stepperWidthConstraint?.deactivate()
|
stepperWidthConstraint?.deactivate()
|
||||||
widthConstraint?.deactivate()
|
widthConstraint?.deactivate()
|
||||||
trailingLessThanEqualsConstraint?.deactivate()
|
|
||||||
trailingEqualsConstraint?.deactivate()
|
|
||||||
|
|
||||||
var widthConstraintConstant: CGFloat?
|
var widthConstraintConstant: CGFloat?
|
||||||
|
|
||||||
@ -350,9 +348,6 @@ open class InputStepper: EntryFieldBase<Int> {
|
|||||||
if let widthConstraintConstant {
|
if let widthConstraintConstant {
|
||||||
widthConstraint?.constant = widthConstraintConstant
|
widthConstraint?.constant = widthConstraintConstant
|
||||||
widthConstraint?.activate()
|
widthConstraint?.activate()
|
||||||
trailingLessThanEqualsConstraint?.activate()
|
|
||||||
} else {
|
|
||||||
trailingEqualsConstraint?.activate()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update Edge insets if size changes applied.
|
// Update Edge insets if size changes applied.
|
||||||
|
|||||||
@ -105,14 +105,12 @@ open class EntryFieldBase<ValueType>: Control, Changeable, FormFieldInternalVali
|
|||||||
// MARK: - Constraints
|
// MARK: - Constraints
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
internal var widthConstraint: NSLayoutConstraint?
|
internal var widthConstraint: NSLayoutConstraint?
|
||||||
internal var trailingEqualsConstraint: NSLayoutConstraint?
|
|
||||||
internal var trailingLessThanEqualsConstraint: NSLayoutConstraint?
|
|
||||||
|
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
// MARK: - Configuration Properties
|
// MARK: - Configuration Properties
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
// Sizes are from InVision design specs.
|
// 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 minWidth: CGFloat { containerSize.width }
|
||||||
internal var containerSize: CGSize { CGSize(width: minWidth, height: 44) }
|
internal var containerSize: CGSize { CGSize(width: minWidth, height: 44) }
|
||||||
|
|
||||||
@ -258,15 +256,9 @@ open class EntryFieldBase<ValueType>: Control, Changeable, FormFieldInternalVali
|
|||||||
|
|
||||||
let layoutGuide = UILayoutGuide()
|
let layoutGuide = UILayoutGuide()
|
||||||
addLayoutGuide(layoutGuide)
|
addLayoutGuide(layoutGuide)
|
||||||
layoutGuide
|
layoutGuide.pinToSuperView()
|
||||||
.pinTop()
|
|
||||||
.pinLeading()
|
|
||||||
.pinBottom()
|
|
||||||
|
|
||||||
trailingEqualsConstraint = layoutGuide.pinTrailing(anchor: trailingAnchor)
|
|
||||||
|
|
||||||
// width constraints
|
// width constraints
|
||||||
trailingLessThanEqualsConstraint = layoutGuide.pinTrailingLessThanOrEqualTo(anchor: trailingAnchor)?.deactivate()
|
|
||||||
widthConstraint = layoutGuide.widthAnchor.constraint(equalToConstant: 0).deactivate()
|
widthConstraint = layoutGuide.widthAnchor.constraint(equalToConstant: 0).deactivate()
|
||||||
|
|
||||||
// Add mainStackView to the view
|
// Add mainStackView to the view
|
||||||
@ -552,15 +544,10 @@ open class EntryFieldBase<ValueType>: Control, Changeable, FormFieldInternalVali
|
|||||||
|
|
||||||
internal func updateContainerWidth() {
|
internal func updateContainerWidth() {
|
||||||
widthConstraint?.deactivate()
|
widthConstraint?.deactivate()
|
||||||
trailingLessThanEqualsConstraint?.deactivate()
|
|
||||||
trailingEqualsConstraint?.deactivate()
|
|
||||||
|
|
||||||
if let width, width >= minWidth, width <= maxWidth {
|
if let width, width >= minWidth, width <= maxWidth {
|
||||||
widthConstraint?.constant = width
|
widthConstraint?.constant = width
|
||||||
widthConstraint?.activate()
|
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 minWidth: CGFloat { fieldType.handler().minWidth }
|
||||||
internal override var maxWidth: CGFloat {
|
internal override var maxWidth: CGFloat {
|
||||||
let frameWidth = frame.size.width
|
let frameWidth = constrainedWidth
|
||||||
return helperTextPlacement == .right ? (frameWidth - horizontalStackView.spacing) / 2 : frameWidth
|
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.
|
/// 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() {
|
internal override func updateContainerWidth() {
|
||||||
widthConstraint?.deactivate()
|
widthConstraint?.deactivate()
|
||||||
trailingLessThanEqualsConstraint?.deactivate()
|
|
||||||
trailingEqualsConstraint?.deactivate()
|
|
||||||
|
|
||||||
//see if there is a widthPercentage and follow the same pattern as done for "width"
|
//see if there is a widthPercentage and follow the same pattern as done for "width"
|
||||||
let currentWidth = (horizontalPinnedWidth() ?? 0) * (widthPercentage ?? 0)
|
let currentWidth = (horizontalPinnedWidth() ?? 0) * (widthPercentage ?? 0)
|
||||||
if currentWidth >= minWidth, currentWidth <= maxWidth {
|
if currentWidth >= minWidth, currentWidth <= maxWidth {
|
||||||
widthConstraint?.constant = currentWidth
|
widthConstraint?.constant = currentWidth
|
||||||
widthConstraint?.activate()
|
widthConstraint?.activate()
|
||||||
trailingLessThanEqualsConstraint?.activate()
|
|
||||||
} else {
|
} else {
|
||||||
super.updateContainerWidth()
|
super.updateContainerWidth()
|
||||||
}
|
}
|
||||||
|
|||||||
@ -647,7 +647,14 @@ public enum LayoutDistribution: String, CaseIterable {
|
|||||||
case fillProportionally
|
case fillProportionally
|
||||||
}
|
}
|
||||||
|
|
||||||
|
extension LayoutConstraintable where Self: UIView {
|
||||||
|
public var constrainedWidth: CGFloat {
|
||||||
|
horizontalPinnedWidth() ?? (superview?.frame.size.width ?? frame.size.width)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
extension LayoutConstraintable {
|
extension LayoutConstraintable {
|
||||||
|
|
||||||
public func removeConstraints() {
|
public func removeConstraints() {
|
||||||
guard let view = self as? UIView, let superview = view.superview else { return }
|
guard let view = self as? UIView, let superview = view.superview else { return }
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user