From ae71e723eed0c9784dbde6af6d586ebe4ac0803c Mon Sep 17 00:00:00 2001 From: Scott Pfeil Date: Fri, 23 Feb 2024 09:11:25 -0500 Subject: [PATCH] Allows "gone" property for hiding list molecules in the list template --- MVMCoreUI/Atomic/Molecules/Items/ListItemModel.swift | 5 ++++- MVMCoreUI/Atomic/Templates/MoleculeListTemplate.swift | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/MVMCoreUI/Atomic/Molecules/Items/ListItemModel.swift b/MVMCoreUI/Atomic/Molecules/Items/ListItemModel.swift index 6dbe79ae..aea87731 100644 --- a/MVMCoreUI/Atomic/Molecules/Items/ListItemModel.swift +++ b/MVMCoreUI/Atomic/Molecules/Items/ListItemModel.swift @@ -18,7 +18,7 @@ import MVMCore public var hideArrow: Bool? public var line: LineModel? public var style: ListItemStyle? - @DecodableDefault.False public var gone: Bool + public var gone: Bool = false public var accessibilityTraits: UIAccessibilityTraits? public var accessibilityValue: String? public var accessibilityText: String? @@ -32,6 +32,7 @@ import MVMCore case hideArrow case line case style + case gone case accessibilityTraits case accessibilityValue case accessibilityText @@ -108,6 +109,7 @@ import MVMCore hideArrow = try typeContainer.decodeIfPresent(Bool.self, forKey: .hideArrow) line = try typeContainer.decodeIfPresent(LineModel.self, forKey: .line) style = try typeContainer.decodeIfPresent(ListItemStyle.self, forKey: .style) + gone = try typeContainer.decodeIfPresent(Bool.self, forKey: .gone) ?? false accessibilityTraits = try typeContainer.decodeIfPresent(UIAccessibilityTraits.self, forKey: .accessibilityTraits) accessibilityValue = try typeContainer.decodeIfPresent(String.self, forKey: .accessibilityValue) try super.init(from: decoder) @@ -121,6 +123,7 @@ import MVMCore try container.encodeIfPresent(hideArrow, forKey: .hideArrow) try container.encodeIfPresent(line, forKey: .line) try container.encodeIfPresent(style, forKey: .style) + try container.encode(gone, forKey: .gone) try container.encodeIfPresent(accessibilityTraits, forKey: .accessibilityTraits) try container.encodeIfPresent(accessibilityValue, forKey: .accessibilityValue) try container.encodeIfPresent(accessibilityText, forKey: .accessibilityText) diff --git a/MVMCoreUI/Atomic/Templates/MoleculeListTemplate.swift b/MVMCoreUI/Atomic/Templates/MoleculeListTemplate.swift index 3ee75be1..c00e5181 100644 --- a/MVMCoreUI/Atomic/Templates/MoleculeListTemplate.swift +++ b/MVMCoreUI/Atomic/Templates/MoleculeListTemplate.swift @@ -156,7 +156,7 @@ open class MoleculeListTemplate: ThreeLayerTableViewController, TemplateProtocol guard let moleculeInfo = getMoleculeInfo(for: indexPath), let cell = tableView.dequeueReusableCell(withIdentifier: moleculeInfo.identifier) else { return UITableViewCell() } - + cell.isHidden = (getMoleculeInfo(for: indexPath)?.molecule as? ListItemModelProtocol)?.gone == true (cell as? MoleculeViewProtocol)?.reset() (cell as? MoleculeListCellProtocol)?.setLines(with: templateModel?.line, delegateObject: delegateObjectIVar, additionalData: nil, indexPath: indexPath) if let moleculeView = cell as? MoleculeViewProtocol {