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