removed vertical layout & max width constraint

This commit is contained in:
Krishna Kishore Bandaru 2024-03-08 11:33:07 +05:30
parent 8f320a9363
commit ee41a6555e

View File

@ -54,7 +54,8 @@ open class Notification: View {
} }
/// Enum used to describe the orientation of Notification. /// Enum used to describe the orientation of Notification.
public enum Layout: String, CaseIterable { /// Only horizontal orientation is supported for iPhone & iPad devices only.
private enum Layout: String, CaseIterable {
case vertical, horizontal case vertical, horizontal
} }
@ -176,7 +177,8 @@ open class Notification: View {
private var _layout: Layout = .vertical private var _layout: Layout = .vertical
/// Determines the orientation of buttons and text in the Notification. /// Determines the orientation of buttons and text in the Notification.
open var layout: Layout { /// Only horizontal orientation is supported for iPhone & iPad devices only.
private var layout: Layout {
set { set {
if !UIDevice.isIPad, newValue == .horizontal { return } if !UIDevice.isIPad, newValue == .horizontal { return }
_layout = newValue _layout = newValue
@ -398,18 +400,18 @@ open class Notification: View {
} }
private func setConstraints() { private func setConstraints() {
maxWidthConstraint?.deactivate()
labelViewAndButtonViewConstraint?.deactivate() labelViewAndButtonViewConstraint?.deactivate()
labelViewBottomConstraint?.deactivate() labelViewBottomConstraint?.deactivate()
buttonGroupCenterYConstraint?.deactivate() buttonGroupCenterYConstraint?.deactivate()
buttonGroupBottomConstraint?.deactivate() buttonGroupBottomConstraint?.deactivate()
maxWidthConstraint?.constant = maxViewWidth
maxWidthConstraint?.isActive = UIDevice.isIPad
labelViewAndButtonViewConstraint?.isActive = layout == .vertical && !buttonGroup.buttons.isEmpty labelViewAndButtonViewConstraint?.isActive = layout == .vertical && !buttonGroup.buttons.isEmpty
labelViewBottomConstraint?.isActive = layout == .horizontal || buttonGroup.buttons.isEmpty labelViewBottomConstraint?.isActive = layout == .horizontal || buttonGroup.buttons.isEmpty
buttonGroupCenterYConstraint?.isActive = layout == .horizontal buttonGroupCenterYConstraint?.isActive = layout == .horizontal
buttonGroupBottomConstraint?.isActive = layout == .vertical buttonGroupBottomConstraint?.isActive = layout == .vertical
typeIconWidthConstraint?.constant = typeIcon.size.dimensions.width typeIconWidthConstraint?.constant = typeIcon.size.dimensions.width
closeIconWidthConstraint?.constant = closeButton.size.dimensions.width closeIconWidthConstraint?.constant = closeButton.size.dimensions.width
//iPad 12.9 inches is more than the configured maxViewWidth(1232), verified with designer on the same. Suggested to remove max width constraint
//maxWidthConstraint?.constant = maxViewWidth
//maxWidthConstraint?.isActive = UIDevice.isIPad
} }
} }