From cb8f3f9fbcd70ebd08fd0a3bf730fc7597a7d096 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Thu, 8 Apr 2021 09:30:16 -0400 Subject: [PATCH 1/2] tab bar can't press current tab --- .../Atomic/Molecules/HorizontalCombinationViews/TabBar.swift | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/TabBar.swift b/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/TabBar.swift index 4a6e3ca7..6116afc3 100644 --- a/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/TabBar.swift +++ b/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/TabBar.swift @@ -80,6 +80,7 @@ // MARK: - UITabBarDelegate public func tabBar(_ tabBar: UITabBar, didSelect item: UITabBarItem) { + guard item.tag != tabBar.selectedItem?.tag else { return } self.model.selectedTab = item.tag Button.performButtonAction(with: model.tabs[item.tag].action, button: item, delegateObject: delegateObject, additionalData: nil) } @@ -95,7 +96,8 @@ public func selectTab(at index: Int) { MVMCoreDispatchUtility.performBlock(onMainThread: { - guard let newSelectedItem = self.items?[index] else { return } + guard index != self.selectedItem?.tag, + let newSelectedItem = self.items?[index] else { return } self.selectedItem = newSelectedItem self.tabBar(self, didSelect: newSelectedItem) }) From 95e36ffc2d76a941dfa56fdd915c70ebc2d2fac1 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Thu, 8 Apr 2021 11:13:50 -0400 Subject: [PATCH 2/2] helper for always present --- .../ModelProtocols/MoleculeModelProtocol.swift | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/MVMCoreUI/Atomic/Protocols/ModelProtocols/MoleculeModelProtocol.swift b/MVMCoreUI/Atomic/Protocols/ModelProtocols/MoleculeModelProtocol.swift index 2823e5a5..0cd54170 100644 --- a/MVMCoreUI/Atomic/Protocols/ModelProtocols/MoleculeModelProtocol.swift +++ b/MVMCoreUI/Atomic/Protocols/ModelProtocols/MoleculeModelProtocol.swift @@ -21,6 +21,8 @@ public extension MoleculeModelProtocol { static var categoryCodingKey: String { "moleculeName" } } + +// Helpers made due to swift not able to reconcile which category. extension KeyedDecodingContainer where Key: CodingKey { /// Decodes to a registered molecule based on the identifier public func decodeMoleculeIfPresent(codingKey: KeyedDecodingContainer.Key) throws -> T? { @@ -33,6 +35,15 @@ extension KeyedDecodingContainer where Key: CodingKey { } return modelT } + + /// Decodes to a registered molecule based on the identifier. + public func decodeMolecule(codingKey: KeyedDecodingContainer.Key) throws -> T { + guard let model: T = try decodeMoleculeIfPresent(codingKey: codingKey) else { + MVMCoreLoggingHandler.logDebugMessage(withDelegate: "ModelRegistry Error decoderErrorObjectNotPresent: \(codingKey.stringValue)") + throw ModelRegistry.Error.decoderErrorObjectNotPresent(codingKey: codingKey, codingPath: codingPath) + } + return model + } } public extension MoleculeModelProtocol {