This commit is contained in:
Kevin G Christiano 2020-07-16 17:07:04 -04:00
parent 2022a65ef0
commit 2daf72e1c8

View File

@ -10,21 +10,38 @@ import UIKit
public class AlertButtonModel: Codable {
//--------------------------------------------------
// MARK: - Properties
//--------------------------------------------------
public var title: String
public var action: ActionModelProtocol
public var style: UIAlertAction.Style = .default
//--------------------------------------------------
// MARK: - Initializer
//--------------------------------------------------
public init(_ title: String,_ action: ActionModelProtocol,_ style: UIAlertAction.Style = .default) {
self.title = title
self.action = action
self.style = style
}
//--------------------------------------------------
// MARK: - Keys
//--------------------------------------------------
private enum CodingKeys: String, CodingKey {
case title
case action
case style
}
//--------------------------------------------------
// MARK: - Codec
//--------------------------------------------------
required public init(from decoder: Decoder) throws {
let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
title = try typeContainer.decode(String.self, forKey: .title)
@ -44,21 +61,38 @@ public class AlertButtonModel: Codable {
}
public class AlertModel: Codable {
//--------------------------------------------------
// MARK: - Properties
//--------------------------------------------------
public var title: String
public var message: String
public var alertActions: [AlertButtonModel]
//--------------------------------------------------
// MARK: - Properties
//--------------------------------------------------
public init(_ title: String,_ message: String,_ alertActions: [AlertButtonModel]) {
self.title = title
self.message = message
self.alertActions = alertActions
}
//--------------------------------------------------
// MARK: - Keys
//--------------------------------------------------
private enum CodingKeys: String, CodingKey {
case title
case message
case alertActions
}
//--------------------------------------------------
// MARK: - Codec
//--------------------------------------------------
required public init(from decoder: Decoder) throws {
let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
title = try typeContainer.decode(String.self, forKey: .title)