diff --git a/MVMCoreUI/Atomic/Molecules/Items/ListItemModel.swift b/MVMCoreUI/Atomic/Molecules/Items/ListItemModel.swift index fcee1166..4c34cc39 100644 --- a/MVMCoreUI/Atomic/Molecules/Items/ListItemModel.swift +++ b/MVMCoreUI/Atomic/Molecules/Items/ListItemModel.swift @@ -20,7 +20,7 @@ import Foundation public var action: ActionModelProtocol? public var hideArrow: Bool? public var line: LineModel? - public var style: ListItemStyle? = .standard + public var style: ListItemStyle? //-------------------------------------------------- // MARK: - Keys @@ -59,9 +59,9 @@ import Foundation } } - /// Convenience function to set common values based on style. + /// Convenience function to set common values based on style. We default to standard if not set. open func setByStyle() { - guard let style = style else { return } + let style = self.style ?? .standard switch style { case .standard: set(topPadding: Padding.Component.VerticalMarginSpacing, bottomPadding: Padding.Component.VerticalMarginSpacing) @@ -104,9 +104,7 @@ import Foundation action = try typeContainer.decodeModelIfPresent(codingKey: .action) hideArrow = try typeContainer.decodeIfPresent(Bool.self, forKey: .hideArrow) line = try typeContainer.decodeIfPresent(LineModel.self, forKey: .line) - if let style = try typeContainer.decodeIfPresent(ListItemStyle.self, forKey: .style) { - self.style = style - } + style = try typeContainer.decodeIfPresent(ListItemStyle.self, forKey: .style) try super.init(from: decoder) }