diff --git a/MVMCoreUI/Atomic/Actions/AlertModel.swift b/MVMCoreUI/Atomic/Actions/AlertModel.swift index 889000fa..7eb88109 100644 --- a/MVMCoreUI/Atomic/Actions/AlertModel.swift +++ b/MVMCoreUI/Atomic/Actions/AlertModel.swift @@ -64,7 +64,7 @@ public struct AlertButtonModel: Codable { } } -public struct AlertModel: Codable, AlertModelProtocol { +public struct AlertModel: Codable, Identifiable, AlertModelProtocol { //-------------------------------------------------- // MARK: - Properties @@ -75,6 +75,7 @@ public struct AlertModel: Codable, AlertModelProtocol { public var preferredStyle: UIAlertController.Style = .alert public var buttonModels: [AlertButtonModel] public var analyticsData: JSONValueDictionary? + public var id: String public var delegateObject: DelegateObject? @@ -99,12 +100,13 @@ public struct AlertModel: Codable, AlertModelProtocol { // MARK: - Init //-------------------------------------------------- - public init(title: String? = nil, message: String? = nil, buttonModels: [AlertButtonModel] = [], style: UIAlertController.Style = .alert, delegateObject: DelegateObject? = nil) { + public init(title: String? = nil, message: String? = nil, buttonModels: [AlertButtonModel] = [], style: UIAlertController.Style = .alert, delegateObject: DelegateObject? = nil, id: String = UUID().uuidString) { self.title = title self.message = message self.buttonModels = buttonModels self.preferredStyle = style self.delegateObject = delegateObject + self.id = id } //-------------------------------------------------- @@ -117,6 +119,7 @@ public struct AlertModel: Codable, AlertModelProtocol { case alertActions case style case analyticsData + case id } //-------------------------------------------------- @@ -134,6 +137,7 @@ public struct AlertModel: Codable, AlertModelProtocol { if let style = try typeContainer.decodeIfPresent(String.self, forKey: .style) { self.preferredStyle = UIAlertController.Style(rawValue: style) } + id = try typeContainer.decodeIfPresent(String.self, forKey: .id) ?? UUID().uuidString } public func encode(to encoder: Encoder) throws { @@ -143,6 +147,7 @@ public struct AlertModel: Codable, AlertModelProtocol { try container.encodeIfPresent(buttonModels, forKey: .alertActions) try container.encode(preferredStyle.rawValueString, forKey: .style) try container.encodeIfPresent(analyticsData, forKey: .analyticsData) + try container.encode(id, forKey: .id) } }