Digital ACT-191 ONEAPP-10928 story: Modal to be displayed at full screen if fullScreenDialog true
This commit is contained in:
parent
08be77242d
commit
81725ffdeb
@ -30,7 +30,7 @@ open class Modal: Control, ModalLaunchable {
|
|||||||
public required init?(coder: NSCoder) {
|
public required init?(coder: NSCoder) {
|
||||||
super.init(coder: coder)
|
super.init(coder: coder)
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
// MARK: - Private Properties
|
// 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.
|
///// 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() } }
|
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() } }
|
open var fullScreenDialog: Bool = false { didSet { setNeedsUpdate() } }
|
||||||
|
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
@ -105,7 +105,8 @@ open class Modal: Control, ModalLaunchable {
|
|||||||
title: title,
|
title: title,
|
||||||
content: content,
|
content: content,
|
||||||
contentView: contentView,
|
contentView: contentView,
|
||||||
buttonData: buttonData),
|
buttonData: buttonData,
|
||||||
|
fullScreenDialog: fullScreenDialog),
|
||||||
presenter: self)
|
presenter: self)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -81,9 +81,6 @@ open class ModalDialog: View, UIScrollViewDelegate, ParentViewProtocol {
|
|||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
// MARK: - Configuration
|
// 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
|
// Min height content area 136 px. Total window height 232 px
|
||||||
private var minHeight: CGFloat = 232.0
|
private var minHeight: CGFloat = 232.0
|
||||||
|
|
||||||
@ -116,6 +113,7 @@ open class ModalDialog: View, UIScrollViewDelegate, ParentViewProtocol {
|
|||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
private var contentStackViewBottomConstraint: NSLayoutConstraint?
|
private var contentStackViewBottomConstraint: NSLayoutConstraint?
|
||||||
private var heightConstraint: NSLayoutConstraint?
|
private var heightConstraint: NSLayoutConstraint?
|
||||||
|
private var widthConstraint: NSLayoutConstraint?
|
||||||
|
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
// MARK: - Overrides
|
// MARK: - Overrides
|
||||||
@ -126,13 +124,13 @@ open class ModalDialog: View, UIScrollViewDelegate, ParentViewProtocol {
|
|||||||
|
|
||||||
// Max Width: 70% of viewport width.
|
// Max Width: 70% of viewport width.
|
||||||
// Maximum width is only applied to a provided width and not to the default.
|
// 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.
|
// 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
|
// 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
|
// 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.
|
// 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
|
titleLabel.accessibilityTraits = .header
|
||||||
layer.cornerRadius = 12
|
layer.cornerRadius = 12
|
||||||
@ -149,14 +147,12 @@ open class ModalDialog: View, UIScrollViewDelegate, ParentViewProtocol {
|
|||||||
addSubview(buttonGroupData)
|
addSubview(buttonGroupData)
|
||||||
self.bringSubviewToFront(closeCrossButton)
|
self.bringSubviewToFront(closeCrossButton)
|
||||||
|
|
||||||
let crossTopSpace = UIDevice.isIPad ? 0 : VDSLayout.space12X
|
let crossTopSpace = UIDevice.isIPad && !modalModel.fullScreenDialog ? 0 : VDSLayout.space12X
|
||||||
let scrollTopSpace = UIDevice.isIPad ? containerViewInset : (crossTopSpace + closeCrossButtonSize)
|
let scrollTopSpace = UIDevice.isIPad && !modalModel.fullScreenDialog ? containerViewInset : (crossTopSpace + closeCrossButtonSize)
|
||||||
let contentTrailingSpace = UIDevice.isIPad ? (containerViewInset/2) - 6 : containerViewInset
|
let contentTrailingSpace = UIDevice.isIPad ? (containerViewInset/2) - 6 : containerViewInset
|
||||||
|
|
||||||
// Activate constraints
|
// Activate constraints
|
||||||
NSLayoutConstraint.activate([
|
NSLayoutConstraint.activate([
|
||||||
widthAnchor.constraint(equalToConstant: maxWidth),
|
|
||||||
|
|
||||||
// Constraints for the closeCrossButton
|
// Constraints for the closeCrossButton
|
||||||
closeCrossButton.topAnchor.constraint(equalTo: topAnchor, constant: crossTopSpace),
|
closeCrossButton.topAnchor.constraint(equalTo: topAnchor, constant: crossTopSpace),
|
||||||
closeCrossButton.leadingAnchor.constraint(greaterThanOrEqualTo: leadingAnchor),
|
closeCrossButton.leadingAnchor.constraint(greaterThanOrEqualTo: leadingAnchor),
|
||||||
@ -173,7 +169,6 @@ open class ModalDialog: View, UIScrollViewDelegate, ParentViewProtocol {
|
|||||||
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: buttonGroupData.topAnchor, constant: -contentLabelBottomSpace),
|
scrollView.bottomAnchor.constraint(equalTo: buttonGroupData.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),
|
||||||
@ -187,14 +182,16 @@ open class ModalDialog: View, UIScrollViewDelegate, ParentViewProtocol {
|
|||||||
contentStackViewBottomConstraint?.activate()
|
contentStackViewBottomConstraint?.activate()
|
||||||
heightConstraint = heightAnchor.constraint(equalToConstant: maxHeight)
|
heightConstraint = heightAnchor.constraint(equalToConstant: maxHeight)
|
||||||
heightConstraint?.activate()
|
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.
|
/// 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()
|
||||||
|
|
||||||
maxWidth = UIDevice.isIPad ? UIScreen.main.bounds.size.width * (70/100) : UIScreen.main.bounds.size.width
|
maxWidth = UIDevice.isIPad && !modalModel.fullScreenDialog ? 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
|
maxHeight = UIDevice.isIPad && !modalModel.fullScreenDialog ? UIScreen.main.bounds.size.height * (70/100) : UIScreen.main.bounds.size.height
|
||||||
|
|
||||||
// Update surface and background
|
// Update surface and background
|
||||||
backgroundColor = backgroundColorConfiguration.getColor(self)
|
backgroundColor = backgroundColorConfiguration.getColor(self)
|
||||||
@ -252,6 +249,7 @@ open class ModalDialog: View, UIScrollViewDelegate, ParentViewProtocol {
|
|||||||
contentStackView.layoutIfNeeded()
|
contentStackView.layoutIfNeeded()
|
||||||
scrollView.setNeedsLayout()
|
scrollView.setNeedsLayout()
|
||||||
scrollView.layoutIfNeeded()
|
scrollView.layoutIfNeeded()
|
||||||
|
widthConstraint?.constant = maxWidth
|
||||||
heightConstraint?.constant = maxHeight
|
heightConstraint?.constant = maxHeight
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -19,7 +19,7 @@ extension ModalLaunchable {
|
|||||||
$0.surface = surface
|
$0.surface = surface
|
||||||
$0.modalModel = modalModel
|
$0.modalModel = modalModel
|
||||||
$0.presenter = presenter
|
$0.presenter = presenter
|
||||||
$0.modalPresentationStyle = UIDevice.isIPad ? .overCurrentContext : .fullScreen
|
$0.modalPresentationStyle = UIDevice.isIPad && !modalModel.fullScreenDialog ? .overCurrentContext : .fullScreen
|
||||||
$0.modalTransitionStyle = .crossDissolve
|
$0.modalTransitionStyle = .crossDissolve
|
||||||
}
|
}
|
||||||
presenting.present(modalViewController, animated: true)
|
presenting.present(modalViewController, animated: true)
|
||||||
|
|||||||
@ -20,11 +20,13 @@ extension Modal {
|
|||||||
public var accessibleText: String?
|
public var accessibleText: String?
|
||||||
public var contentViewAlignment: UIStackView.Alignment?
|
public var contentViewAlignment: UIStackView.Alignment?
|
||||||
public var buttonData: [ButtonBase]?
|
public var buttonData: [ButtonBase]?
|
||||||
|
public var fullScreenDialog: Bool
|
||||||
public init(closeButtonText: String = "Close",
|
public init(closeButtonText: String = "Close",
|
||||||
title: String? = nil,
|
title: String? = nil,
|
||||||
content: String? = nil,
|
content: String? = nil,
|
||||||
contentView: UIView? = nil,
|
contentView: UIView? = nil,
|
||||||
buttonData: [ButtonBase]? = nil,
|
buttonData: [ButtonBase]? = nil,
|
||||||
|
fullScreenDialog: Bool = false,
|
||||||
accessibleText: String? = "Modal",
|
accessibleText: String? = "Modal",
|
||||||
contentViewAlignment: UIStackView.Alignment = .leading) {
|
contentViewAlignment: UIStackView.Alignment = .leading) {
|
||||||
self.closeButtonText = closeButtonText
|
self.closeButtonText = closeButtonText
|
||||||
@ -34,6 +36,7 @@ extension Modal {
|
|||||||
self.accessibleText = accessibleText
|
self.accessibleText = accessibleText
|
||||||
self.contentViewAlignment = contentViewAlignment
|
self.contentViewAlignment = contentViewAlignment
|
||||||
self.buttonData = buttonData
|
self.buttonData = buttonData
|
||||||
|
self.fullScreenDialog = fullScreenDialog
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user