Digital ACT-191 ONEAPP-10928 story: Modal to be displayed at full screen if fullScreenDialog true

This commit is contained in:
Vasavi Kanamarlapudi 2024-09-27 18:11:54 +05:30
parent 08be77242d
commit 81725ffdeb
4 changed files with 20 additions and 18 deletions

View File

@ -30,7 +30,7 @@ open class Modal: Control, ModalLaunchable {
public required init?(coder: NSCoder) {
super.init(coder: coder)
}
//--------------------------------------------------
// MARK: - Private Properties
//--------------------------------------------------
@ -53,8 +53,8 @@ open class Modal: Control, ModalLaunchable {
///// Array of Buttonable Views that are shown as Modal Footer. Primary and Close button data for modal button group.
open var buttonData: [ButtonBase]? { didSet { setNeedsUpdate() } }
///// If provided, the Modal Dialog will render at full screen.
///// If provided, the Modal has the option to be displayed at full screen.
open var fullScreenDialog: Bool = false { didSet { setNeedsUpdate() } }
//--------------------------------------------------
@ -105,7 +105,8 @@ open class Modal: Control, ModalLaunchable {
title: title,
content: content,
contentView: contentView,
buttonData: buttonData),
buttonData: buttonData,
fullScreenDialog: fullScreenDialog),
presenter: self)
}

View File

@ -81,9 +81,6 @@ open class ModalDialog: View, UIScrollViewDelegate, ParentViewProtocol {
//--------------------------------------------------
// MARK: - Configuration
//--------------------------------------------------
// full width : viewport width
private var fullWidth: CGFloat = UIScreen.main.bounds.size.width
// Min height content area 136 px. Total window height 232 px
private var minHeight: CGFloat = 232.0
@ -116,6 +113,7 @@ open class ModalDialog: View, UIScrollViewDelegate, ParentViewProtocol {
//--------------------------------------------------
private var contentStackViewBottomConstraint: NSLayoutConstraint?
private var heightConstraint: NSLayoutConstraint?
private var widthConstraint: NSLayoutConstraint?
//--------------------------------------------------
// MARK: - Overrides
@ -126,13 +124,13 @@ open class ModalDialog: View, UIScrollViewDelegate, ParentViewProtocol {
// Max Width: 70% of viewport width.
// Maximum width is only applied to a provided width and not to the default.
maxWidth = UIDevice.isIPad ? fullWidth * (70/100): fullWidth
maxWidth = UIDevice.isIPad && !modalModel.fullScreenDialog ? UIScreen.main.bounds.size.width * (70/100): UIScreen.main.bounds.size.width
// Max Height: Total window height 70% of viewport height.
// For Tablet: By default the model's height is dynamic and is based on the amount of content
// it contains. it can expand between a minimum and maximum height. The minimum height is determined by the minimum
// height of the content area plus the top and bottom padding.
maxHeight = UIDevice.isIPad ? UIScreen.main.bounds.size.height * (70/100) : UIScreen.main.bounds.size.height
maxHeight = UIDevice.isIPad && !modalModel.fullScreenDialog ? UIScreen.main.bounds.size.height * (70/100) : UIScreen.main.bounds.size.height
titleLabel.accessibilityTraits = .header
layer.cornerRadius = 12
@ -149,14 +147,12 @@ open class ModalDialog: View, UIScrollViewDelegate, ParentViewProtocol {
addSubview(buttonGroupData)
self.bringSubviewToFront(closeCrossButton)
let crossTopSpace = UIDevice.isIPad ? 0 : VDSLayout.space12X
let scrollTopSpace = UIDevice.isIPad ? containerViewInset : (crossTopSpace + closeCrossButtonSize)
let crossTopSpace = UIDevice.isIPad && !modalModel.fullScreenDialog ? 0 : VDSLayout.space12X
let scrollTopSpace = UIDevice.isIPad && !modalModel.fullScreenDialog ? containerViewInset : (crossTopSpace + closeCrossButtonSize)
let contentTrailingSpace = UIDevice.isIPad ? (containerViewInset/2) - 6 : containerViewInset
// Activate constraints
NSLayoutConstraint.activate([
widthAnchor.constraint(equalToConstant: maxWidth),
// Constraints for the closeCrossButton
closeCrossButton.topAnchor.constraint(equalTo: topAnchor, constant: crossTopSpace),
closeCrossButton.leadingAnchor.constraint(greaterThanOrEqualTo: leadingAnchor),
@ -173,7 +169,6 @@ open class ModalDialog: View, UIScrollViewDelegate, ParentViewProtocol {
scrollView.leadingAnchor.constraint(equalTo: leadingAnchor, constant:containerViewInset),
scrollView.trailingAnchor.constraint(equalTo: trailingAnchor, constant: -contentTrailingSpace),
scrollView.bottomAnchor.constraint(equalTo: buttonGroupData.topAnchor, constant: -contentLabelBottomSpace),
scrollView.widthAnchor.constraint(equalToConstant: (maxWidth - (containerViewInset + contentTrailingSpace))),
// Constraints for the contentStackView
contentStackView.topAnchor.constraint(equalTo: scrollView.topAnchor),
@ -187,14 +182,16 @@ open class ModalDialog: View, UIScrollViewDelegate, ParentViewProtocol {
contentStackViewBottomConstraint?.activate()
heightConstraint = heightAnchor.constraint(equalToConstant: maxHeight)
heightConstraint?.activate()
widthConstraint = widthAnchor.constraint(equalToConstant: maxWidth)
widthConstraint?.activate()
}
/// Used to make changes to the View based off a change events or from local properties.
open override func updateView() {
super.updateView()
maxWidth = UIDevice.isIPad ? UIScreen.main.bounds.size.width * (70/100) : UIScreen.main.bounds.size.width
maxHeight = UIDevice.isIPad ? UIScreen.main.bounds.size.height * (70/100) : UIScreen.main.bounds.size.height
maxWidth = UIDevice.isIPad && !modalModel.fullScreenDialog ? UIScreen.main.bounds.size.width * (70/100) : UIScreen.main.bounds.size.width
maxHeight = UIDevice.isIPad && !modalModel.fullScreenDialog ? UIScreen.main.bounds.size.height * (70/100) : UIScreen.main.bounds.size.height
// Update surface and background
backgroundColor = backgroundColorConfiguration.getColor(self)
@ -252,6 +249,7 @@ open class ModalDialog: View, UIScrollViewDelegate, ParentViewProtocol {
contentStackView.layoutIfNeeded()
scrollView.setNeedsLayout()
scrollView.layoutIfNeeded()
widthConstraint?.constant = maxWidth
heightConstraint?.constant = maxHeight
}

View File

@ -19,7 +19,7 @@ extension ModalLaunchable {
$0.surface = surface
$0.modalModel = modalModel
$0.presenter = presenter
$0.modalPresentationStyle = UIDevice.isIPad ? .overCurrentContext : .fullScreen
$0.modalPresentationStyle = UIDevice.isIPad && !modalModel.fullScreenDialog ? .overCurrentContext : .fullScreen
$0.modalTransitionStyle = .crossDissolve
}
presenting.present(modalViewController, animated: true)

View File

@ -20,11 +20,13 @@ extension Modal {
public var accessibleText: String?
public var contentViewAlignment: UIStackView.Alignment?
public var buttonData: [ButtonBase]?
public var fullScreenDialog: Bool
public init(closeButtonText: String = "Close",
title: String? = nil,
content: String? = nil,
contentView: UIView? = nil,
buttonData: [ButtonBase]? = nil,
fullScreenDialog: Bool = false,
accessibleText: String? = "Modal",
contentViewAlignment: UIStackView.Alignment = .leading) {
self.closeButtonText = closeButtonText
@ -34,6 +36,7 @@ extension Modal {
self.accessibleText = accessibleText
self.contentViewAlignment = contentViewAlignment
self.buttonData = buttonData
self.fullScreenDialog = fullScreenDialog
}
}
}