From 9c5f30b886ea7182f4541971215b7d562d33d2f3 Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Thu, 20 Oct 2022 15:58:40 -0500 Subject: [PATCH] Signed-off-by: Matt Bruce --- .../JSON/Samples/FormContactInfo.json | 7 ++++--- JSONCreator_iOS/JSONCreator/TestToggle.swift | 21 ------------------- .../JSONCreator/TestToggleVM.swift | 1 - JSONCreator_iOS/JSONCreator/VDSToggleVM.swift | 6 ++++-- 4 files changed, 8 insertions(+), 27 deletions(-) diff --git a/JSONCreator_iOS/JSONCreator/JSON/Samples/FormContactInfo.json b/JSONCreator_iOS/JSONCreator/JSON/Samples/FormContactInfo.json index 0a71e14..10e7cfb 100644 --- a/JSONCreator_iOS/JSONCreator/JSON/Samples/FormContactInfo.json +++ b/JSONCreator_iOS/JSONCreator/JSON/Samples/FormContactInfo.json @@ -22,18 +22,19 @@ { "moleculeName": "stackItem", "molecule": { - "moleculeName": "testToggle3" + "moleculeName": "toggle" } }, { "moleculeName": "stackItem", "molecule": { - "moleculeName": "testLabelToggle", + "moleculeName": "labelToggle", "label": { + "moleculeName": "label", "text": "isActive" }, "toggle": { - "moleculeName": "testToggle1", + "moleculeName": "toggle", "fieldKey": "isActive" } } diff --git a/JSONCreator_iOS/JSONCreator/TestToggle.swift b/JSONCreator_iOS/JSONCreator/TestToggle.swift index dcf5968..7619530 100644 --- a/JSONCreator_iOS/JSONCreator/TestToggle.swift +++ b/JSONCreator_iOS/JSONCreator/TestToggle.swift @@ -11,26 +11,6 @@ import MVMCoreUI import UIKit import VDS -///----------------------------------------------------------------------------- -///MARK: -- VDSMoleculeViewProtocol (Contract between VDS -> Atomic) -///----------------------------------------------------------------------------- -public protocol VDSMoleculeViewProtocol: MoleculeViewProtocol, MVMCoreViewProtocol { - associatedtype ViewModel: MoleculeModelProtocol - var viewModel: ViewModel! { get set } - var delegateObject: MVMCoreUIDelegateObject? { get set } - var additionalData: [AnyHashable: Any]? { get set } - func viewModelDidUpdate() -} - -extension VDSMoleculeViewProtocol { - public func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { - guard let castedModel = model as? ViewModel else { return } - self.delegateObject = delegateObject - viewModel = castedModel - viewModelDidUpdate() - } -} - ///----------------------------------------------------------------------------- ///MARK: -- TestToggleModel Extension ///----------------------------------------------------------------------------- @@ -96,7 +76,6 @@ open class TestToggle: ToggleBase, VDSMoleculeViewProtocol { open func viewModelDidUpdate() { guard let viewModel else { return } - FormValidator.setupValidation(for: viewModel, delegate: delegateObject?.formHolderDelegate) additionalData = additionalData.dictionaryAdding(key: KeySourceModel, value: viewModel) set(with: viewModel.getVDSModel()) } diff --git a/JSONCreator_iOS/JSONCreator/TestToggleVM.swift b/JSONCreator_iOS/JSONCreator/TestToggleVM.swift index aec3e91..de00f5c 100644 --- a/JSONCreator_iOS/JSONCreator/TestToggleVM.swift +++ b/JSONCreator_iOS/JSONCreator/TestToggleVM.swift @@ -198,7 +198,6 @@ open class TestToggle3: ToggleViewModelHandlerBase: AnyObject, Surfaceable, Disabling { associatedtype ModelType: Modelable - var model: ModelType { get set } + var model: ModelType { get } var modelSubject: CurrentValueSubject { get set } var publisher: AnyPublisher { get } init(with model: ModelType) @@ -92,7 +92,7 @@ public protocol ViewModel: AnyObject, Surfaceable, Disabling { ///----------------------------------------------------------------------------- ///MARK: -- ViewModel Generic Base Class ///----------------------------------------------------------------------------- -public class ViewModelBase: NSObject, ViewModel, ObservableObject { +public class ViewModelBase: NSObject, ViewModel { public var model: ModelType public var modelSubject = CurrentValueSubject(ModelType()) public var publisher: AnyPublisher { modelSubject.eraseToAnyPublisher() } @@ -519,5 +519,7 @@ open class ToggleViewModelHandlerBase: ControlVi backgroundColor = viewModel.surface.color setNeedsLayout() layoutIfNeeded() + //viewModel.model = DefaultToggleModel() + //viewModel.model.disabled = true } }