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 {
|
private var minViewWidth: CGFloat {
|
||||||
return fullBleed ? 320 : 288
|
return 288
|
||||||
}
|
}
|
||||||
|
|
||||||
///Max view width is for Tablet
|
|
||||||
private var maxViewWidth: CGFloat {
|
private var maxViewWidth: CGFloat {
|
||||||
return fullBleed ? 1272 : 1232
|
return 1232
|
||||||
}
|
}
|
||||||
|
|
||||||
internal var onCloseSubscriber: AnyCancellable?
|
internal var onCloseSubscriber: AnyCancellable?
|
||||||
@ -112,47 +111,58 @@ open class Notification: View {
|
|||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
// MARK: - Public Properties
|
// MARK: - Public Properties
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
|
/// Icon used for denoting type.
|
||||||
open var typeIcon = Icon().with {
|
open var typeIcon = Icon().with {
|
||||||
$0.name = .infoBold
|
$0.name = .infoBold
|
||||||
$0.size = UIDevice.isIPad ? .medium : .small
|
$0.size = UIDevice.isIPad ? .medium : .small
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Icon used for the close.
|
||||||
open var closeButton = Icon().with {
|
open var closeButton = Icon().with {
|
||||||
$0.name = .close
|
$0.name = .close
|
||||||
$0.size = UIDevice.isIPad ? .medium : .small
|
$0.size = UIDevice.isIPad ? .medium : .small
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Label used to show title.
|
||||||
open var titleLabel = Label().with {
|
open var titleLabel = Label().with {
|
||||||
$0.textStyle = UIDevice.isIPad ? .boldBodyLarge : .boldBodySmall
|
$0.textStyle = UIDevice.isIPad ? .boldBodyLarge : .boldBodySmall
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Label used to show subTitle.
|
||||||
open var subTitleLabel = Label().with {
|
open var subTitleLabel = Label().with {
|
||||||
$0.textStyle = UIDevice.isIPad ? .bodyLarge : .bodySmall
|
$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
|
$0.alignment = .left
|
||||||
}
|
}
|
||||||
|
|
||||||
//Text
|
/// Text that will go into the titleLabel.
|
||||||
open var title: String = "" { didSet{setNeedsUpdate()}}
|
open var title: String = "" { didSet{setNeedsUpdate()}}
|
||||||
|
|
||||||
|
/// Text that will go into the subTitleLabel.
|
||||||
open var subTitle: String? { didSet{setNeedsUpdate()}}
|
open var subTitle: String? { didSet{setNeedsUpdate()}}
|
||||||
|
|
||||||
//Buttons
|
/// Button model representing the primaryButton.
|
||||||
open var primaryButtonModel: ButtonModel? { didSet{setNeedsUpdate()}}
|
open var primaryButtonModel: ButtonModel? { didSet{setNeedsUpdate()}}
|
||||||
|
|
||||||
|
/// Button used for the primary action.
|
||||||
open var primaryButton = Button().with {
|
open var primaryButton = Button().with {
|
||||||
$0.size = .small
|
$0.size = .small
|
||||||
$0.use = .secondary
|
$0.use = .secondary
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Button model representing the secondaryButton.
|
||||||
open var secondaryButtonModel: ButtonModel? { didSet{setNeedsUpdate()}}
|
open var secondaryButtonModel: ButtonModel? { didSet{setNeedsUpdate()}}
|
||||||
|
|
||||||
|
/// Button used for the secondary action.
|
||||||
open var secondaryButton = Button().with {
|
open var secondaryButton = Button().with {
|
||||||
$0.size = .small
|
$0.size = .small
|
||||||
$0.use = .secondary
|
$0.use = .secondary
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Completion Block for a close click event.
|
||||||
open var onCloseClick: ((Notification)->())? {
|
open var onCloseClick: ((Notification)->())? {
|
||||||
didSet {
|
didSet {
|
||||||
if let onCloseClick {
|
if let onCloseClick {
|
||||||
@ -167,18 +177,18 @@ open class Notification: View {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// If true, will hide the close button.
|
||||||
open var hideCloseButton: Bool = false { didSet{setNeedsUpdate()}}
|
open var hideCloseButton: Bool = false { didSet{setNeedsUpdate()}}
|
||||||
|
|
||||||
|
/// Add this attribute determine your type of Notification.
|
||||||
open var type: Style = .info { didSet{setNeedsUpdate()}}
|
open var type: Style = .info { didSet{setNeedsUpdate()}}
|
||||||
|
|
||||||
open var fullBleed: Bool = false { didSet {setNeedsUpdate()}}
|
|
||||||
|
|
||||||
var _layout: Layout = .vertical
|
var _layout: Layout = .vertical
|
||||||
open var layout: Layout {
|
open var layout: Layout {
|
||||||
set {
|
set {
|
||||||
if !UIDevice.isIPad, newValue == .horizontal { return }
|
if !UIDevice.isIPad, newValue == .horizontal { return }
|
||||||
_layout = newValue
|
_layout = newValue
|
||||||
buttonsView.alignment = _layout == .horizontal ? .center : .left
|
buttonGroup.alignment = _layout == .horizontal ? .center : .left
|
||||||
setNeedsUpdate()
|
setNeedsUpdate()
|
||||||
}
|
}
|
||||||
get { _layout }
|
get { _layout }
|
||||||
@ -241,8 +251,8 @@ open class Notification: View {
|
|||||||
subTitleLabel.reset()
|
subTitleLabel.reset()
|
||||||
subTitleLabel.textStyle = UIDevice.isIPad ? .bodyLarge : .bodySmall
|
subTitleLabel.textStyle = UIDevice.isIPad ? .bodyLarge : .bodySmall
|
||||||
|
|
||||||
buttonsView.reset()
|
buttonGroup.reset()
|
||||||
buttonsView.alignment = .left
|
buttonGroup.alignment = .left
|
||||||
|
|
||||||
primaryButtonModel = nil
|
primaryButtonModel = nil
|
||||||
secondaryButtonModel = nil
|
secondaryButtonModel = nil
|
||||||
@ -257,7 +267,6 @@ open class Notification: View {
|
|||||||
|
|
||||||
layout = .vertical
|
layout = .vertical
|
||||||
hideCloseButton = false
|
hideCloseButton = false
|
||||||
fullBleed = false
|
|
||||||
|
|
||||||
shouldUpdateView = true
|
shouldUpdateView = true
|
||||||
setNeedsUpdate()
|
setNeedsUpdate()
|
||||||
@ -323,15 +332,15 @@ open class Notification: View {
|
|||||||
|
|
||||||
if buttons.isEmpty {
|
if buttons.isEmpty {
|
||||||
labelsView.setCustomSpacing(0, after: subTitleLabel)
|
labelsView.setCustomSpacing(0, after: subTitleLabel)
|
||||||
buttonsView.removeFromSuperview()
|
buttonGroup.removeFromSuperview()
|
||||||
} else {
|
} else {
|
||||||
labelsView.setCustomSpacing(VDSLayout.Spacing.space3X.value, after: subTitleLabel)
|
labelsView.setCustomSpacing(VDSLayout.Spacing.space3X.value, after: subTitleLabel)
|
||||||
|
|
||||||
buttonsView.buttons = buttons
|
buttonGroup.buttons = buttons
|
||||||
labelButtonView.axis = layout == .vertical ? .vertical : .horizontal
|
labelButtonView.axis = layout == .vertical ? .vertical : .horizontal
|
||||||
labelButtonView.addArrangedSubview(buttonsView)
|
labelButtonView.addArrangedSubview(buttonGroup)
|
||||||
|
|
||||||
buttonsView
|
buttonGroup
|
||||||
.pinLeading()
|
.pinLeading()
|
||||||
.pinTrailing()
|
.pinTrailing()
|
||||||
}
|
}
|
||||||
@ -342,16 +351,6 @@ open class Notification: View {
|
|||||||
maxWidthConstraint?.constant = maxViewWidth
|
maxWidthConstraint?.constant = maxViewWidth
|
||||||
maxWidthConstraint?.isActive = UIDevice.isIPad
|
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