diff --git a/VDS/Protocols/SelectorGroupModelHandlerable.swift b/VDS/Protocols/SelectorGroupModelHandlerable.swift index d9aa96d7..447333f4 100644 --- a/VDS/Protocols/SelectorGroupModelHandlerable.swift +++ b/VDS/Protocols/SelectorGroupModelHandlerable.swift @@ -12,6 +12,7 @@ import UIKit public protocol SelectorGroupModelHandlerable: ModelHandlerable, Disabling, Surfaceable where ModelType: SelectorGroupModelable { associatedtype ModelHandlerType: ModelHandlerable where ModelType.SelectorModelType == ModelHandlerType.ModelType, ModelHandlerType: UIControl var selectorViews: [ModelHandlerType] { get set } + func didSelect(_ selectedControl: ModelHandlerType) func createModelHandler(selector: ModelHandlerType.ModelType) -> ModelHandlerType } @@ -23,22 +24,6 @@ extension SelectorGroupModelHandlerable { }) } - public func createModelHandler(selector: ModelHandlerType.ModelType) -> ModelHandlerType { - //create view - let newSelectorView = ModelHandlerType(with: selector) - - //add model update to the subscribers - newSelectorView.handlerPublisher() - .sink { [weak self] model in - if let cached = self?.getCachedSelector(viewModel: model), newSelectorView.shouldUpdateView(viewModel: cached) { - self?.replace(viewModel: model) - } - } - .store(in: &subscribers) - - return newSelectorView - } - public func updateSelectors(){ let selectors = model.selectors.compactMap { existing in return existing.copyWith { @@ -66,18 +51,6 @@ extension SelectorGroupModelHandlerable { model.selectors[index] = viewModel } } -} - -///MARK: Groups that allow single selections -public protocol SelectorGroupSelectedModelHandlerable: SelectorGroupModelHandlerable where ModelType: SelectorGroupSelectedModelable { - func didSelect(_ selectedControl: ModelHandlerType) -} - -extension SelectorGroupSelectedModelHandlerable { - - public var selectedModel: ModelHandlerType.ModelType? { - return model.selectedModel - } public func createModelHandler(selector: ModelHandlerType.ModelType) -> ModelHandlerType { //create view @@ -103,4 +76,15 @@ extension SelectorGroupSelectedModelHandlerable { return newSelectorView } + +} + +///MARK: Groups that allow single selections +public protocol SelectorGroupSelectedModelHandlerable: SelectorGroupModelHandlerable where ModelType: SelectorGroupSelectedModelable { } + +extension SelectorGroupSelectedModelHandlerable { + + public var selectedModel: ModelHandlerType.ModelType? { + return model.selectedModel + } }