comments and removed fullbleed
Signed-off-by: Matt Bruce <matt.bruce@verizon.com>
This commit is contained in:
parent
2a589b1e22
commit
02d39bbcf9
@ -93,12 +93,11 @@ open class Notification: View {
|
||||
}
|
||||
|
||||
private var minViewWidth: CGFloat {
|
||||
return fullBleed ? 320 : 288
|
||||
return 288
|
||||
}
|
||||
|
||||
///Max view width is for Tablet
|
||||
private var maxViewWidth: CGFloat {
|
||||
return fullBleed ? 1272 : 1232
|
||||
return 1232
|
||||
}
|
||||
|
||||
internal var onCloseSubscriber: AnyCancellable?
|
||||
@ -112,47 +111,58 @@ open class Notification: View {
|
||||
//--------------------------------------------------
|
||||
// MARK: - Public Properties
|
||||
//--------------------------------------------------
|
||||
|
||||
/// Icon used for denoting type.
|
||||
open var typeIcon = Icon().with {
|
||||
$0.name = .infoBold
|
||||
$0.size = UIDevice.isIPad ? .medium : .small
|
||||
}
|
||||
|
||||
/// Icon used for the close.
|
||||
open var closeButton = Icon().with {
|
||||
$0.name = .close
|
||||
$0.size = UIDevice.isIPad ? .medium : .small
|
||||
}
|
||||
|
||||
/// Label used to show title.
|
||||
open var titleLabel = Label().with {
|
||||
$0.textStyle = UIDevice.isIPad ? .boldBodyLarge : .boldBodySmall
|
||||
}
|
||||
|
||||
/// Label used to show subTitle.
|
||||
open var subTitleLabel = Label().with {
|
||||
$0.textStyle = UIDevice.isIPad ? .bodyLarge : .bodySmall
|
||||
}
|
||||
|
||||
open var buttonsView = ButtonGroup().with {
|
||||
/// ButtonGroup to house the 2 optional buttons, primaryButton and secondaryButotn
|
||||
open var buttonGroup = ButtonGroup().with {
|
||||
$0.alignment = .left
|
||||
}
|
||||
|
||||
//Text
|
||||
/// Text that will go into the titleLabel.
|
||||
open var title: String = "" { didSet{setNeedsUpdate()}}
|
||||
|
||||
/// Text that will go into the subTitleLabel.
|
||||
open var subTitle: String? { didSet{setNeedsUpdate()}}
|
||||
|
||||
//Buttons
|
||||
/// Button model representing the primaryButton.
|
||||
open var primaryButtonModel: ButtonModel? { didSet{setNeedsUpdate()}}
|
||||
|
||||
/// Button used for the primary action.
|
||||
open var primaryButton = Button().with {
|
||||
$0.size = .small
|
||||
$0.use = .secondary
|
||||
}
|
||||
|
||||
/// Button model representing the secondaryButton.
|
||||
open var secondaryButtonModel: ButtonModel? { didSet{setNeedsUpdate()}}
|
||||
|
||||
/// Button used for the secondary action.
|
||||
open var secondaryButton = Button().with {
|
||||
$0.size = .small
|
||||
$0.use = .secondary
|
||||
}
|
||||
|
||||
/// Completion Block for a close click event.
|
||||
open var onCloseClick: ((Notification)->())? {
|
||||
didSet {
|
||||
if let onCloseClick {
|
||||
@ -166,19 +176,19 @@ open class Notification: View {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// If true, will hide the close button.
|
||||
open var hideCloseButton: Bool = false { didSet{setNeedsUpdate()}}
|
||||
|
||||
/// Add this attribute determine your type of Notification.
|
||||
open var type: Style = .info { didSet{setNeedsUpdate()}}
|
||||
|
||||
open var fullBleed: Bool = false { didSet {setNeedsUpdate()}}
|
||||
|
||||
var _layout: Layout = .vertical
|
||||
open var layout: Layout {
|
||||
set {
|
||||
if !UIDevice.isIPad, newValue == .horizontal { return }
|
||||
_layout = newValue
|
||||
buttonsView.alignment = _layout == .horizontal ? .center : .left
|
||||
buttonGroup.alignment = _layout == .horizontal ? .center : .left
|
||||
setNeedsUpdate()
|
||||
}
|
||||
get { _layout }
|
||||
@ -241,8 +251,8 @@ open class Notification: View {
|
||||
subTitleLabel.reset()
|
||||
subTitleLabel.textStyle = UIDevice.isIPad ? .bodyLarge : .bodySmall
|
||||
|
||||
buttonsView.reset()
|
||||
buttonsView.alignment = .left
|
||||
buttonGroup.reset()
|
||||
buttonGroup.alignment = .left
|
||||
|
||||
primaryButtonModel = nil
|
||||
secondaryButtonModel = nil
|
||||
@ -257,7 +267,6 @@ open class Notification: View {
|
||||
|
||||
layout = .vertical
|
||||
hideCloseButton = false
|
||||
fullBleed = false
|
||||
|
||||
shouldUpdateView = true
|
||||
setNeedsUpdate()
|
||||
@ -323,15 +332,15 @@ open class Notification: View {
|
||||
|
||||
if buttons.isEmpty {
|
||||
labelsView.setCustomSpacing(0, after: subTitleLabel)
|
||||
buttonsView.removeFromSuperview()
|
||||
buttonGroup.removeFromSuperview()
|
||||
} else {
|
||||
labelsView.setCustomSpacing(VDSLayout.Spacing.space3X.value, after: subTitleLabel)
|
||||
|
||||
buttonsView.buttons = buttons
|
||||
buttonGroup.buttons = buttons
|
||||
labelButtonView.axis = layout == .vertical ? .vertical : .horizontal
|
||||
labelButtonView.addArrangedSubview(buttonsView)
|
||||
labelButtonView.addArrangedSubview(buttonGroup)
|
||||
|
||||
buttonsView
|
||||
buttonGroup
|
||||
.pinLeading()
|
||||
.pinTrailing()
|
||||
}
|
||||
@ -341,17 +350,7 @@ open class Notification: View {
|
||||
|
||||
maxWidthConstraint?.constant = maxViewWidth
|
||||
maxWidthConstraint?.isActive = UIDevice.isIPad
|
||||
|
||||
if leadingConstraint == nil, let superview {
|
||||
leadingConstraint = NSLayoutConstraint(item: self, attribute: .leading, relatedBy: .equal, toItem: superview, attribute: .leading, multiplier: 1, constant: 0)
|
||||
}
|
||||
|
||||
if trailingConstraint == nil, let superview {
|
||||
trailingConstraint = NSLayoutConstraint(item: superview, attribute: .trailing, relatedBy: .equal, toItem: self, attribute: .trailing, multiplier: 1, constant: 0)
|
||||
}
|
||||
|
||||
leadingConstraint?.isActive = fullBleed
|
||||
trailingConstraint?.isActive = fullBleed
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user