put back to NotificationXBUttonModel
Signed-off-by: Matt Bruce <matt.bruce@verizon.com>
This commit is contained in:
parent
2e1bb7358f
commit
89e6ea43d0
@ -19,7 +19,7 @@ open class CollapsableNotificationModel: NotificationMoleculeModel {
|
||||
public var collapseTime: Int = 5
|
||||
public var initiallyCollapsed = false
|
||||
|
||||
public init(with topLabel: LabelModel, headline: LabelModel, style: NotificationMoleculeModel.Style = .success, backgroundColor: Color? = nil, topAction: ActionModelProtocol? = nil, collapseTime: Int? = nil, body: LabelModel? = nil, button: ButtonModel? = nil, closeButton: ButtonModel? = nil) {
|
||||
public init(with topLabel: LabelModel, headline: LabelModel, style: NotificationMoleculeModel.Style = .success, backgroundColor: Color? = nil, topAction: ActionModelProtocol? = nil, collapseTime: Int? = nil, body: LabelModel? = nil, button: ButtonModel? = nil, closeButton: NotificationXButtonModel? = nil) {
|
||||
self.topLabel = topLabel
|
||||
self.topAction = topAction
|
||||
if let collapseTime = collapseTime {
|
||||
|
||||
@ -47,7 +47,7 @@ open class NotificationMoleculeModel: ContainerModel, MoleculeModelProtocol {
|
||||
public var body: LabelModel?
|
||||
public var button: ButtonModel?
|
||||
public var secondaryButton: ButtonModel?
|
||||
public var closeButton: ButtonModel?
|
||||
public var closeButton: NotificationXButtonModel?
|
||||
public var style: Style = .success
|
||||
public var inverted: Bool = false
|
||||
|
||||
@ -55,7 +55,7 @@ open class NotificationMoleculeModel: ContainerModel, MoleculeModelProtocol {
|
||||
// MARK: - Initializer
|
||||
//--------------------------------------------------
|
||||
|
||||
public init(with headline: LabelModel, style: NotificationMoleculeModel.Style = .success, backgroundColor: Color? = nil, body: LabelModel? = nil, button: ButtonModel? = nil, secondaryButton: ButtonModel? = nil, closeButton: ButtonModel? = nil) {
|
||||
public init(with headline: LabelModel, style: NotificationMoleculeModel.Style = .success, backgroundColor: Color? = nil, body: LabelModel? = nil, button: ButtonModel? = nil, secondaryButton: ButtonModel? = nil, closeButton: NotificationXButtonModel? = nil) {
|
||||
self.headline = headline
|
||||
self.style = style
|
||||
self.backgroundColor = backgroundColor
|
||||
@ -103,7 +103,7 @@ open class NotificationMoleculeModel: ContainerModel, MoleculeModelProtocol {
|
||||
body = try typeContainer.decodeIfPresent(LabelModel.self, forKey: .body)
|
||||
button = try typeContainer.decodeIfPresent(ButtonModel.self, forKey: .button)
|
||||
secondaryButton = try typeContainer.decodeIfPresent(ButtonModel.self, forKey: .secondaryButton)
|
||||
closeButton = try typeContainer.decodeIfPresent(ButtonModel.self, forKey: .closeButton)
|
||||
closeButton = try typeContainer.decodeIfPresent(NotificationXButtonModel.self, forKey: .closeButton)
|
||||
inverted = try typeContainer.decodeIfPresent(Bool.self, forKey: .inverted) ?? false
|
||||
if let style = try typeContainer.decodeIfPresent(NotificationMoleculeModel.Style.self, forKey: .style) {
|
||||
self.style = style
|
||||
@ -130,18 +130,3 @@ extension NotificationMoleculeModel {
|
||||
inverted ? .dark : .light
|
||||
}
|
||||
}
|
||||
|
||||
extension ButtonModel {
|
||||
public func toNotficationButtonModel(delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) -> VDS.Notification.ButtonModel {
|
||||
return .init(text: title, onClick: { [weak self] _ in
|
||||
guard let self else { return }
|
||||
self.onClick(delegateObject: delegateObject, additionalData)
|
||||
})
|
||||
}
|
||||
|
||||
public func onClick(delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) {
|
||||
Task(priority: .userInitiated) {
|
||||
try await (delegateObject?.actionDelegate as? ActionDelegateProtocol)?.performAction(with: action, additionalData: MVMCoreUIActionHandler.add(sourceModel: self, to: additionalData), delegateObject: delegateObject)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user