bug fix for line if set by template

This commit is contained in:
Pfeil, Scott Robert 2020-07-28 10:34:48 -04:00
parent b609ec85eb
commit e236e9c3a5

View File

@ -20,7 +20,7 @@ import Foundation
public var action: ActionModelProtocol? public var action: ActionModelProtocol?
public var hideArrow: Bool? public var hideArrow: Bool?
public var line: LineModel? public var line: LineModel?
public var style: ListItemStyle? = .standard public var style: ListItemStyle?
//-------------------------------------------------- //--------------------------------------------------
// MARK: - Keys // MARK: - Keys
@ -59,9 +59,12 @@ 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() { open func setByStyle() {
guard let style = style else { return } guard let style = style else {
set(topPadding: Padding.Component.VerticalMarginSpacing, bottomPadding: Padding.Component.VerticalMarginSpacing)
return
}
switch style { switch style {
case .standard: case .standard:
set(topPadding: Padding.Component.VerticalMarginSpacing, bottomPadding: Padding.Component.VerticalMarginSpacing) set(topPadding: Padding.Component.VerticalMarginSpacing, bottomPadding: Padding.Component.VerticalMarginSpacing)
@ -104,9 +107,7 @@ import Foundation
action = try typeContainer.decodeModelIfPresent(codingKey: .action) action = try typeContainer.decodeModelIfPresent(codingKey: .action)
hideArrow = try typeContainer.decodeIfPresent(Bool.self, forKey: .hideArrow) hideArrow = try typeContainer.decodeIfPresent(Bool.self, forKey: .hideArrow)
line = try typeContainer.decodeIfPresent(LineModel.self, forKey: .line) line = try typeContainer.decodeIfPresent(LineModel.self, forKey: .line)
if let style = try typeContainer.decodeIfPresent(ListItemStyle.self, forKey: .style) { style = try typeContainer.decodeIfPresent(ListItemStyle.self, forKey: .style)
self.style = style
}
try super.init(from: decoder) try super.init(from: decoder)
} }