Digital ACT-191 ONEAPP-10928 story: resolved constraint conflicts
This commit is contained in:
parent
12ad80643d
commit
e71b94bc4f
@ -106,7 +106,7 @@ open class ModalDialog: View, UIScrollViewDelegate, ParentViewProtocol {
|
|||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
|
|
||||||
private let backgroundColorConfiguration = SurfaceColorConfiguration(VDSColor.backgroundPrimaryLight, VDSColor.backgroundPrimaryDark)
|
private let backgroundColorConfiguration = SurfaceColorConfiguration(VDSColor.backgroundPrimaryLight, VDSColor.backgroundPrimaryDark)
|
||||||
private let closeButtonTextColorConfiguration = SurfaceColorConfiguration(VDSColor.elementsPrimaryOnlight, VDSColor.elementsPrimaryOndark)
|
private let textColorConfiguration = SurfaceColorConfiguration(VDSColor.elementsPrimaryOnlight, VDSColor.elementsPrimaryOndark)
|
||||||
|
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
// MARK: - Constraints
|
// MARK: - Constraints
|
||||||
@ -146,10 +146,10 @@ open class ModalDialog: View, UIScrollViewDelegate, ParentViewProtocol {
|
|||||||
addSubview(closeButton)
|
addSubview(closeButton)
|
||||||
self.bringSubviewToFront(closeCrossButton)
|
self.bringSubviewToFront(closeCrossButton)
|
||||||
|
|
||||||
let contentTrailingSpace = UIDevice.isIPad ? containerViewInset/2 : containerViewInset
|
|
||||||
let crossTopSpace = UIDevice.isIPad ? 0 : VDSLayout.space12X
|
let crossTopSpace = UIDevice.isIPad ? 0 : VDSLayout.space12X
|
||||||
let scrollTopSpace = UIDevice.isIPad ? containerViewInset : (crossTopSpace + closeCrossButtonSize)
|
let scrollTopSpace = UIDevice.isIPad ? containerViewInset : (crossTopSpace + closeCrossButtonSize)
|
||||||
|
let contentTrailingSpace = UIDevice.isIPad ? (containerViewInset/2) - 6 : containerViewInset
|
||||||
|
|
||||||
// Activate constraints
|
// Activate constraints
|
||||||
NSLayoutConstraint.activate([
|
NSLayoutConstraint.activate([
|
||||||
widthAnchor.constraint(equalToConstant: maxWidth),
|
widthAnchor.constraint(equalToConstant: maxWidth),
|
||||||
@ -159,7 +159,6 @@ open class ModalDialog: View, UIScrollViewDelegate, ParentViewProtocol {
|
|||||||
closeCrossButton.leadingAnchor.constraint(greaterThanOrEqualTo: leadingAnchor),
|
closeCrossButton.leadingAnchor.constraint(greaterThanOrEqualTo: leadingAnchor),
|
||||||
closeCrossButton.trailingAnchor.constraint(equalTo: trailingAnchor),
|
closeCrossButton.trailingAnchor.constraint(equalTo: trailingAnchor),
|
||||||
closeCrossButton.heightAnchor.constraint(equalToConstant: closeCrossButtonSize),
|
closeCrossButton.heightAnchor.constraint(equalToConstant: closeCrossButtonSize),
|
||||||
closeCrossButton.widthAnchor.constraint(equalToConstant: closeCrossButtonSize),
|
|
||||||
|
|
||||||
// Constraints for the bottom button view
|
// Constraints for the bottom button view
|
||||||
closeButton.leadingAnchor.constraint(equalTo: leadingAnchor, constant:containerViewInset),
|
closeButton.leadingAnchor.constraint(equalTo: leadingAnchor, constant:containerViewInset),
|
||||||
@ -169,8 +168,9 @@ open class ModalDialog: View, UIScrollViewDelegate, ParentViewProtocol {
|
|||||||
// Constraints for the scrollView
|
// Constraints for the scrollView
|
||||||
scrollView.topAnchor.constraint(equalTo: topAnchor, constant: scrollTopSpace),
|
scrollView.topAnchor.constraint(equalTo: topAnchor, constant: scrollTopSpace),
|
||||||
scrollView.leadingAnchor.constraint(equalTo: leadingAnchor, constant:containerViewInset),
|
scrollView.leadingAnchor.constraint(equalTo: leadingAnchor, constant:containerViewInset),
|
||||||
scrollView.trailingAnchor.constraint(equalTo: trailingAnchor, constant: -(contentTrailingSpace)),
|
scrollView.trailingAnchor.constraint(equalTo: trailingAnchor, constant: -contentTrailingSpace),
|
||||||
scrollView.bottomAnchor.constraint(equalTo: closeButton.topAnchor, constant: -contentLabelBottomSpace),
|
scrollView.bottomAnchor.constraint(equalTo: closeButton.topAnchor, constant: -contentLabelBottomSpace),
|
||||||
|
scrollView.widthAnchor.constraint(equalToConstant: (maxWidth - (containerViewInset + contentTrailingSpace))),
|
||||||
|
|
||||||
// Constraints for the contentStackView
|
// Constraints for the contentStackView
|
||||||
contentStackView.topAnchor.constraint(equalTo: scrollView.topAnchor),
|
contentStackView.topAnchor.constraint(equalTo: scrollView.topAnchor),
|
||||||
@ -189,7 +189,11 @@ open class ModalDialog: View, UIScrollViewDelegate, ParentViewProtocol {
|
|||||||
/// Used to make changes to the View based off a change events or from local properties.
|
/// Used to make changes to the View based off a change events or from local properties.
|
||||||
open override func updateView() {
|
open override func updateView() {
|
||||||
super.updateView()
|
super.updateView()
|
||||||
|
|
||||||
|
heightConstraint?.deactivate()
|
||||||
|
maxWidth = UIScreen.main.bounds.size.width * (70/100)
|
||||||
|
maxHeight = UIScreen.main.bounds.size.height * (70/100)
|
||||||
|
|
||||||
// Update surface and background
|
// Update surface and background
|
||||||
backgroundColor = backgroundColorConfiguration.getColor(self)
|
backgroundColor = backgroundColorConfiguration.getColor(self)
|
||||||
scrollView.indicatorStyle = surface == .light ? .black : .white
|
scrollView.indicatorStyle = surface == .light ? .black : .white
|
||||||
@ -199,10 +203,12 @@ open class ModalDialog: View, UIScrollViewDelegate, ParentViewProtocol {
|
|||||||
contentLabel.surface = surface
|
contentLabel.surface = surface
|
||||||
|
|
||||||
// Re-arrange contentStack
|
// Re-arrange contentStack
|
||||||
contentStackView.arrangedSubviews.forEach { $0.removeFromSuperview() }
|
contentStackView.removeArrangedSubviews()
|
||||||
|
|
||||||
titleLabel.text = modalModel.title
|
titleLabel.text = modalModel.title
|
||||||
contentLabel.text = modalModel.content
|
contentLabel.text = modalModel.content
|
||||||
|
titleLabel.textColor = textColorConfiguration.getColor(self)
|
||||||
|
contentLabel.textColor = textColorConfiguration.getColor(self)
|
||||||
titleLabel.sizeToFit()
|
titleLabel.sizeToFit()
|
||||||
contentLabel.sizeToFit()
|
contentLabel.sizeToFit()
|
||||||
|
|
||||||
@ -232,9 +238,9 @@ open class ModalDialog: View, UIScrollViewDelegate, ParentViewProtocol {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Update closeButton
|
// Update closeButton
|
||||||
let closeButtonTextColor = closeButtonTextColorConfiguration.getColor(self)
|
let textColor = textColorConfiguration.getColor(self)
|
||||||
closeButton.setTitleColor(closeButtonTextColor, for: .normal)
|
closeButton.setTitleColor(textColor, for: .normal)
|
||||||
closeButton.setTitleColor(closeButtonTextColor, for: .highlighted)
|
closeButton.setTitleColor(textColor, for: .highlighted)
|
||||||
closeButton.setTitle(modalModel.closeButtonText, for: .normal)
|
closeButton.setTitle(modalModel.closeButtonText, for: .normal)
|
||||||
closeButton.accessibilityLabel = modalModel.closeButtonText
|
closeButton.accessibilityLabel = modalModel.closeButtonText
|
||||||
|
|
||||||
@ -243,6 +249,8 @@ open class ModalDialog: View, UIScrollViewDelegate, ParentViewProtocol {
|
|||||||
|
|
||||||
scrollView.setNeedsLayout()
|
scrollView.setNeedsLayout()
|
||||||
scrollView.layoutIfNeeded()
|
scrollView.layoutIfNeeded()
|
||||||
|
heightConstraint?.constant = maxHeight
|
||||||
|
heightConstraint?.activate()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Used to update any Accessibility properties.
|
/// Used to update any Accessibility properties.
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user