diff --git a/MVMCoreUI/Molecules/Items/ListItemModel.swift b/MVMCoreUI/Molecules/Items/ListItemModel.swift index 7208a2ce..24cb05e0 100644 --- a/MVMCoreUI/Molecules/Items/ListItemModel.swift +++ b/MVMCoreUI/Molecules/Items/ListItemModel.swift @@ -15,7 +15,7 @@ import MVMCore public var action: ActionProtocol? public var hideArrow: Bool? public var line: LineModel? - public var style: String? + public var style: String? = "standard" enum ListItemCodingKeys: String, CodingKey { case backgroundColor @@ -31,10 +31,20 @@ import MVMCore action = try typeContainer.decodeModelIfPresent(codingKey: .action, typeCodingKey: ActionCodingKey.actionType) hideArrow = try typeContainer.decodeIfPresent(Bool.self, forKey: .hideArrow) line = try typeContainer.decodeIfPresent(LineModel.self, forKey: .line) - style = try typeContainer.decodeIfPresent(String.self, forKey: .style) + if let style = try typeContainer.decodeIfPresent(String.self, forKey: .style) { + self.style = style + } + try super.init(from: decoder) + + if useHorizontalMargins == nil { + useHorizontalMargins = true + } + if useVerticalMargins == nil { + useVerticalMargins = true + } } - + public override func encode(to encoder: Encoder) throws { try super.encode(to: encoder) var container = encoder.container(keyedBy: ListItemCodingKeys.self) @@ -43,5 +53,6 @@ import MVMCore try container.encodeIfPresent(hideArrow, forKey: .hideArrow) try container.encodeIfPresent(line, forKey: .line) try container.encodeIfPresent(style, forKey: .style) - } + } } +