updated onCloseClick
Signed-off-by: Matt Bruce <matt.bruce@verizon.com>
This commit is contained in:
parent
94d44c5d54
commit
f164429ece
@ -8,6 +8,7 @@
|
||||
import Foundation
|
||||
import UIKit
|
||||
import VDSColorTokens
|
||||
import Combine
|
||||
|
||||
@objc(VDSNotification)
|
||||
/// A VDS Component that will render a view with information
|
||||
@ -88,7 +89,7 @@ public class Notification: View {
|
||||
}
|
||||
|
||||
//Text
|
||||
open var titleText: String? { didSet{didChange()}}
|
||||
open var titleText: String = "" { didSet{didChange()}}
|
||||
|
||||
open var subTitleText: String? { didSet{didChange()}}
|
||||
|
||||
@ -106,8 +107,20 @@ public class Notification: View {
|
||||
$0.use = .secondary
|
||||
}
|
||||
|
||||
open var onCloseClick: ((Notification)->())?
|
||||
|
||||
open var onCloseClick: ((Notification)->())? {
|
||||
didSet {
|
||||
if let onCloseClick {
|
||||
onCloseSubscriber = closeButton
|
||||
.publisher(for: UITapGestureRecognizer())
|
||||
.sink { _ in
|
||||
onCloseClick(self)
|
||||
}
|
||||
} else {
|
||||
onCloseSubscriber = nil
|
||||
}
|
||||
}
|
||||
}
|
||||
internal var onCloseSubscriber: AnyCancellable?
|
||||
//--------------------------------------------------
|
||||
// MARK: - Modal Properties
|
||||
//--------------------------------------------------
|
||||
@ -163,12 +176,7 @@ public class Notification: View {
|
||||
mainStackView.addArrangedSubview(typeIcon)
|
||||
mainStackView.addArrangedSubview(labelsView)
|
||||
mainStackView.addArrangedSubview(closeButton)
|
||||
|
||||
closeButton.publisher(for: UITapGestureRecognizer()).sink { [weak self] _ in
|
||||
guard let self else { return }
|
||||
self.onCloseClick?(self)
|
||||
}.store(in: &subscribers)
|
||||
|
||||
|
||||
//labels
|
||||
titleLabel.textColorConfiguration = textColorConfig.eraseToAnyColorable()
|
||||
subTitleLabel.textColorConfiguration = textColorConfig.eraseToAnyColorable()
|
||||
@ -209,7 +217,7 @@ public class Notification: View {
|
||||
titleLabel.surface = surface
|
||||
subTitleLabel.surface = surface
|
||||
|
||||
if let titleText {
|
||||
if !titleText.isEmpty {
|
||||
titleLabel.text = titleText
|
||||
labelsView.addArrangedSubview(titleLabel)
|
||||
} else {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user