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 Foundation
|
||||||
import UIKit
|
import UIKit
|
||||||
import VDSColorTokens
|
import VDSColorTokens
|
||||||
|
import Combine
|
||||||
|
|
||||||
@objc(VDSNotification)
|
@objc(VDSNotification)
|
||||||
/// A VDS Component that will render a view with information
|
/// A VDS Component that will render a view with information
|
||||||
@ -88,7 +89,7 @@ public class Notification: View {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//Text
|
//Text
|
||||||
open var titleText: String? { didSet{didChange()}}
|
open var titleText: String = "" { didSet{didChange()}}
|
||||||
|
|
||||||
open var subTitleText: String? { didSet{didChange()}}
|
open var subTitleText: String? { didSet{didChange()}}
|
||||||
|
|
||||||
@ -106,8 +107,20 @@ public class Notification: View {
|
|||||||
$0.use = .secondary
|
$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
|
// MARK: - Modal Properties
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
@ -164,11 +177,6 @@ public class Notification: View {
|
|||||||
mainStackView.addArrangedSubview(labelsView)
|
mainStackView.addArrangedSubview(labelsView)
|
||||||
mainStackView.addArrangedSubview(closeButton)
|
mainStackView.addArrangedSubview(closeButton)
|
||||||
|
|
||||||
closeButton.publisher(for: UITapGestureRecognizer()).sink { [weak self] _ in
|
|
||||||
guard let self else { return }
|
|
||||||
self.onCloseClick?(self)
|
|
||||||
}.store(in: &subscribers)
|
|
||||||
|
|
||||||
//labels
|
//labels
|
||||||
titleLabel.textColorConfiguration = textColorConfig.eraseToAnyColorable()
|
titleLabel.textColorConfiguration = textColorConfig.eraseToAnyColorable()
|
||||||
subTitleLabel.textColorConfiguration = textColorConfig.eraseToAnyColorable()
|
subTitleLabel.textColorConfiguration = textColorConfig.eraseToAnyColorable()
|
||||||
@ -209,7 +217,7 @@ public class Notification: View {
|
|||||||
titleLabel.surface = surface
|
titleLabel.surface = surface
|
||||||
subTitleLabel.surface = surface
|
subTitleLabel.surface = surface
|
||||||
|
|
||||||
if let titleText {
|
if !titleText.isEmpty {
|
||||||
titleLabel.text = titleText
|
titleLabel.text = titleText
|
||||||
labelsView.addArrangedSubview(titleLabel)
|
labelsView.addArrangedSubview(titleLabel)
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user