From 5a8e34f327612f2aaba783ac3f06e409e5dac8e3 Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Tue, 11 Oct 2022 10:43:09 -0500 Subject: [PATCH 01/29] removed code Signed-off-by: Matt Bruce --- VDS/Components/RadioSwatch/RadioSwatch.swift | 2 -- 1 file changed, 2 deletions(-) diff --git a/VDS/Components/RadioSwatch/RadioSwatch.swift b/VDS/Components/RadioSwatch/RadioSwatch.swift index c53e7079..db20f6b0 100644 --- a/VDS/Components/RadioSwatch/RadioSwatch.swift +++ b/VDS/Components/RadioSwatch/RadioSwatch.swift @@ -141,8 +141,6 @@ open class RadioSwatchBase: Control { // MARK: - State //-------------------------------------------------- open override func updateView(viewModel: ModelType) { - let enabled = !viewModel.disabled - updateSelector(viewModel) setAccessibilityHint() setAccessibilityValue(viewModel.selected) From fb8159873ab3f7f89435fe45aa19b0d5ed9c570b Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Tue, 11 Oct 2022 10:43:16 -0500 Subject: [PATCH 02/29] removed bitcode Signed-off-by: Matt Bruce --- VDS.xcodeproj/project.pbxproj | 4 ---- 1 file changed, 4 deletions(-) diff --git a/VDS.xcodeproj/project.pbxproj b/VDS.xcodeproj/project.pbxproj index af6f7360..1d203c6d 100644 --- a/VDS.xcodeproj/project.pbxproj +++ b/VDS.xcodeproj/project.pbxproj @@ -848,7 +848,6 @@ EA336181288B19210071C351 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { - BITCODE_GENERATION_MODE = bitcode; CODE_SIGN_STYLE = Automatic; CURRENT_PROJECT_VERSION = 1; DEFINES_MODULE = YES; @@ -856,7 +855,6 @@ DYLIB_COMPATIBILITY_VERSION = 1; DYLIB_CURRENT_VERSION = 1; DYLIB_INSTALL_NAME_BASE = "@rpath"; - ENABLE_BITCODE = YES; GENERATE_INFOPLIST_FILE = YES; INFOPLIST_KEY_NSHumanReadableCopyright = ""; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; @@ -881,7 +879,6 @@ EA336182288B19210071C351 /* Release */ = { isa = XCBuildConfiguration; buildSettings = { - BITCODE_GENERATION_MODE = bitcode; CODE_SIGN_STYLE = Automatic; CURRENT_PROJECT_VERSION = 1; DEFINES_MODULE = YES; @@ -889,7 +886,6 @@ DYLIB_COMPATIBILITY_VERSION = 1; DYLIB_CURRENT_VERSION = 1; DYLIB_INSTALL_NAME_BASE = "@rpath"; - ENABLE_BITCODE = YES; GENERATE_INFOPLIST_FILE = YES; INFOPLIST_KEY_NSHumanReadableCopyright = ""; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; From 49f59a0a6429c5a80b034e4fa324296ab53e56d8 Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Tue, 11 Oct 2022 10:53:00 -0500 Subject: [PATCH 03/29] removed old frameworks Signed-off-by: Matt Bruce --- VDS.xcodeproj/project.pbxproj | 4 ---- 1 file changed, 4 deletions(-) diff --git a/VDS.xcodeproj/project.pbxproj b/VDS.xcodeproj/project.pbxproj index 1d203c6d..929c1515 100644 --- a/VDS.xcodeproj/project.pbxproj +++ b/VDS.xcodeproj/project.pbxproj @@ -194,8 +194,6 @@ EAF7F0BA289D80ED00B287F5 /* Modelable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Modelable.swift; sourceTree = ""; }; EAF7F0E8289DB0DA00B287F5 /* VDSFormControlsTokens.xcframework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcframework; name = VDSFormControlsTokens.xcframework; path = ../SharedFrameworks/VDSFormControlsTokens.xcframework; sourceTree = ""; }; EAF7F0E9289DB0DA00B287F5 /* VDSColorTokens.xcframework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcframework; name = VDSColorTokens.xcframework; path = ../SharedFrameworks/VDSColorTokens.xcframework; sourceTree = ""; }; - EAF7F0EA289DB0DA00B287F5 /* VDSAccessibilityTokens.xcframework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcframework; name = VDSAccessibilityTokens.xcframework; path = ../SharedFrameworks/VDSAccessibilityTokens.xcframework; sourceTree = ""; }; - EAF7F0EB289DB0DA00B287F5 /* VDSLayoutTokens.xcframework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcframework; name = VDSLayoutTokens.xcframework; path = ../SharedFrameworks/VDSLayoutTokens.xcframework; sourceTree = ""; }; EAF7F11528A1475A00B287F5 /* RadioButton.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RadioButton.swift; sourceTree = ""; }; EAF7F11628A1475A00B287F5 /* RadioButtonModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RadioButtonModel.swift; sourceTree = ""; }; EAF7F13228A2A16500B287F5 /* LabelAttributeAttachment.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LabelAttributeAttachment.swift; sourceTree = ""; }; @@ -292,10 +290,8 @@ EA33618D288B1C0C0071C351 /* Frameworks */ = { isa = PBXGroup; children = ( - EAF7F0EA289DB0DA00B287F5 /* VDSAccessibilityTokens.xcframework */, EAF7F0E9289DB0DA00B287F5 /* VDSColorTokens.xcframework */, EAF7F0E8289DB0DA00B287F5 /* VDSFormControlsTokens.xcframework */, - EAF7F0EB289DB0DA00B287F5 /* VDSLayoutTokens.xcframework */, EA3361F32891D5290071C351 /* VDSTypographyTokens.xcframework */, EA33618E288B1C0C0071C351 /* VDSColorTokens.xcframework */, EA33618F288B1C0C0071C351 /* VDSFormControlsTokens.xcframework */, From 539f42f5ba3471b750ee9dc257e8c46f30e2a41a Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Tue, 11 Oct 2022 10:54:56 -0500 Subject: [PATCH 04/29] re-arranged framework requirements Signed-off-by: Matt Bruce --- VDS.xcodeproj/project.pbxproj | 48 +++++++++++++++++++++++------------ 1 file changed, 32 insertions(+), 16 deletions(-) diff --git a/VDS.xcodeproj/project.pbxproj b/VDS.xcodeproj/project.pbxproj index 929c1515..cd3de983 100644 --- a/VDS.xcodeproj/project.pbxproj +++ b/VDS.xcodeproj/project.pbxproj @@ -61,6 +61,12 @@ EA89201728B56CFF006B9984 /* RadioBoxGroupModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA89201628B56CFF006B9984 /* RadioBoxGroupModel.swift */; }; EAA5EEE228F4C62C003B3210 /* Colorable.swift in Sources */ = {isa = PBXBuildFile; fileRef = EAA5EEE128F4C62C003B3210 /* Colorable.swift */; }; EAA5EEE428F5B855003B3210 /* VerizonNHGDS-Light.otf in Resources */ = {isa = PBXBuildFile; fileRef = EAA5EEE328F5B855003B3210 /* VerizonNHGDS-Light.otf */; }; + EAA5EEEF28F5C908003B3210 /* VDSTypographyTokens.xcframework in Frameworks */ = {isa = PBXBuildFile; fileRef = EAA5EEEC28F5C908003B3210 /* VDSTypographyTokens.xcframework */; }; + EAA5EEF028F5C909003B3210 /* VDSTypographyTokens.xcframework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = EAA5EEEC28F5C908003B3210 /* VDSTypographyTokens.xcframework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; + EAA5EEF128F5C909003B3210 /* VDSColorTokens.xcframework in Frameworks */ = {isa = PBXBuildFile; fileRef = EAA5EEED28F5C908003B3210 /* VDSColorTokens.xcframework */; }; + EAA5EEF228F5C909003B3210 /* VDSColorTokens.xcframework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = EAA5EEED28F5C908003B3210 /* VDSColorTokens.xcframework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; + EAA5EEF328F5C909003B3210 /* VDSFormControlsTokens.xcframework in Frameworks */ = {isa = PBXBuildFile; fileRef = EAA5EEEE28F5C908003B3210 /* VDSFormControlsTokens.xcframework */; }; + EAA5EEF428F5C909003B3210 /* VDSFormControlsTokens.xcframework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = EAA5EEEE28F5C908003B3210 /* VDSFormControlsTokens.xcframework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; EAB1D29A28A5611D00DAE764 /* SelectorGroupModelable.swift in Sources */ = {isa = PBXBuildFile; fileRef = EAB1D29928A5611D00DAE764 /* SelectorGroupModelable.swift */; }; EAB1D29C28A5618900DAE764 /* RadioButtonGroup.swift in Sources */ = {isa = PBXBuildFile; fileRef = EAB1D29B28A5618900DAE764 /* RadioButtonGroup.swift */; }; EAB1D29E28A5619500DAE764 /* RadioButtonGroupModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = EAB1D29D28A5619500DAE764 /* RadioButtonGroupModel.swift */; }; @@ -88,9 +94,6 @@ EAF7F0B7289C12A600B287F5 /* UITapGestureRecognizer.swift in Sources */ = {isa = PBXBuildFile; fileRef = EAF7F0B6289C12A600B287F5 /* UITapGestureRecognizer.swift */; }; EAF7F0B9289C139800B287F5 /* ColorConfiguration.swift in Sources */ = {isa = PBXBuildFile; fileRef = EAF7F0B8289C139800B287F5 /* ColorConfiguration.swift */; }; EAF7F0BB289D80ED00B287F5 /* Modelable.swift in Sources */ = {isa = PBXBuildFile; fileRef = EAF7F0BA289D80ED00B287F5 /* Modelable.swift */; }; - EAF7F0F8289DB1AC00B287F5 /* VDSFormControlsTokens.xcframework in Frameworks */ = {isa = PBXBuildFile; fileRef = EAF7F0E8289DB0DA00B287F5 /* VDSFormControlsTokens.xcframework */; }; - EAF7F0F9289DB1AC00B287F5 /* VDSTypographyTokens.xcframework in Frameworks */ = {isa = PBXBuildFile; fileRef = EA3361F32891D5290071C351 /* VDSTypographyTokens.xcframework */; }; - EAF7F0FB289DB1AC00B287F5 /* VDSColorTokens.xcframework in Frameworks */ = {isa = PBXBuildFile; fileRef = EAF7F0E9289DB0DA00B287F5 /* VDSColorTokens.xcframework */; }; EAF7F11728A1475A00B287F5 /* RadioButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = EAF7F11528A1475A00B287F5 /* RadioButton.swift */; }; EAF7F11828A1475A00B287F5 /* RadioButtonModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = EAF7F11628A1475A00B287F5 /* RadioButtonModel.swift */; }; EAF7F13328A2A16500B287F5 /* LabelAttributeAttachment.swift in Sources */ = {isa = PBXBuildFile; fileRef = EAF7F13228A2A16500B287F5 /* LabelAttributeAttachment.swift */; }; @@ -106,6 +109,22 @@ }; /* End PBXContainerItemProxy section */ +/* Begin PBXCopyFilesBuildPhase section */ + EAA5EEF528F5C909003B3210 /* Embed Frameworks */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = ""; + dstSubfolderSpec = 10; + files = ( + EAA5EEF428F5C909003B3210 /* VDSFormControlsTokens.xcframework in Embed Frameworks */, + EAA5EEF028F5C909003B3210 /* VDSTypographyTokens.xcframework in Embed Frameworks */, + EAA5EEF228F5C909003B3210 /* VDSColorTokens.xcframework in Embed Frameworks */, + ); + name = "Embed Frameworks"; + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXCopyFilesBuildPhase section */ + /* Begin PBXFileReference section */ 5F21D7BE28DCEB3D003E7CD6 /* Useable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Useable.swift; sourceTree = ""; }; 5FC35BE228D51405004EBEAC /* Button.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Button.swift; sourceTree = ""; }; @@ -121,8 +140,6 @@ EA336170288B19200071C351 /* VDS.docc */ = {isa = PBXFileReference; lastKnownFileType = folder.documentationcatalog; path = VDS.docc; sourceTree = ""; }; EA336176288B19210071C351 /* VDSTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = VDSTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; EA33617B288B19210071C351 /* VDSTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VDSTests.swift; sourceTree = ""; }; - EA33618E288B1C0C0071C351 /* VDSColorTokens.xcframework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcframework; name = VDSColorTokens.xcframework; path = "/Users/mattbruce/Documents/Projects/iPhone/Frameworks/MVA-JSONCreator/JSONCreator_iOS/../SharedFrameworks/VDSColorTokens.xcframework"; sourceTree = ""; }; - EA33618F288B1C0C0071C351 /* VDSFormControlsTokens.xcframework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcframework; name = VDSFormControlsTokens.xcframework; path = "/Users/mattbruce/Documents/Projects/iPhone/Frameworks/MVA-JSONCreator/JSONCreator_iOS/../SharedFrameworks/VDSFormControlsTokens.xcframework"; sourceTree = ""; }; EA3361A1288B1E840071C351 /* ToggleModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ToggleModel.swift; sourceTree = ""; }; EA3361A7288B23300071C351 /* UIColor.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UIColor.swift; sourceTree = ""; }; EA3361A9288B25E40071C351 /* Disabling.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Disabling.swift; sourceTree = ""; }; @@ -135,7 +152,6 @@ EA3361C228902D960071C351 /* Toggle.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Toggle.swift; sourceTree = ""; }; EA3361C4289030FC0071C351 /* Accessable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Accessable.swift; sourceTree = ""; }; EA3361C8289054C50071C351 /* Surfaceable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Surfaceable.swift; sourceTree = ""; }; - EA3361F32891D5290071C351 /* VDSTypographyTokens.xcframework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcframework; name = VDSTypographyTokens.xcframework; path = ../SharedFrameworks/VDSTypographyTokens.xcframework; sourceTree = ""; }; EA3362002891E14C0071C351 /* VerizonNHGeTX-Bold.otf */ = {isa = PBXFileReference; lastKnownFileType = file; path = "VerizonNHGeTX-Bold.otf"; sourceTree = ""; }; EA3362012891E14D0071C351 /* VerizonNHGeDS-Bold.otf */ = {isa = PBXFileReference; lastKnownFileType = file; path = "VerizonNHGeDS-Bold.otf"; sourceTree = ""; }; EA3362022891E14D0071C351 /* VerizonNHGeTX-Regular.otf */ = {isa = PBXFileReference; lastKnownFileType = file; path = "VerizonNHGeTX-Regular.otf"; sourceTree = ""; }; @@ -165,6 +181,9 @@ EA89201628B56CFF006B9984 /* RadioBoxGroupModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RadioBoxGroupModel.swift; sourceTree = ""; }; EAA5EEE128F4C62C003B3210 /* Colorable.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Colorable.swift; sourceTree = ""; }; EAA5EEE328F5B855003B3210 /* VerizonNHGDS-Light.otf */ = {isa = PBXFileReference; lastKnownFileType = file; path = "VerizonNHGDS-Light.otf"; sourceTree = ""; }; + EAA5EEEC28F5C908003B3210 /* VDSTypographyTokens.xcframework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcframework; name = VDSTypographyTokens.xcframework; path = ../SharedFrameworks/VDSTypographyTokens.xcframework; sourceTree = ""; }; + EAA5EEED28F5C908003B3210 /* VDSColorTokens.xcframework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcframework; name = VDSColorTokens.xcframework; path = ../SharedFrameworks/VDSColorTokens.xcframework; sourceTree = ""; }; + EAA5EEEE28F5C908003B3210 /* VDSFormControlsTokens.xcframework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcframework; name = VDSFormControlsTokens.xcframework; path = ../SharedFrameworks/VDSFormControlsTokens.xcframework; sourceTree = ""; }; EAB1D29928A5611D00DAE764 /* SelectorGroupModelable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SelectorGroupModelable.swift; sourceTree = ""; }; EAB1D29B28A5618900DAE764 /* RadioButtonGroup.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RadioButtonGroup.swift; sourceTree = ""; }; EAB1D29D28A5619500DAE764 /* RadioButtonGroupModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RadioButtonGroupModel.swift; sourceTree = ""; }; @@ -192,8 +211,6 @@ EAF7F0B6289C12A600B287F5 /* UITapGestureRecognizer.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UITapGestureRecognizer.swift; sourceTree = ""; }; EAF7F0B8289C139800B287F5 /* ColorConfiguration.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ColorConfiguration.swift; sourceTree = ""; }; EAF7F0BA289D80ED00B287F5 /* Modelable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Modelable.swift; sourceTree = ""; }; - EAF7F0E8289DB0DA00B287F5 /* VDSFormControlsTokens.xcframework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcframework; name = VDSFormControlsTokens.xcframework; path = ../SharedFrameworks/VDSFormControlsTokens.xcframework; sourceTree = ""; }; - EAF7F0E9289DB0DA00B287F5 /* VDSColorTokens.xcframework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcframework; name = VDSColorTokens.xcframework; path = ../SharedFrameworks/VDSColorTokens.xcframework; sourceTree = ""; }; EAF7F11528A1475A00B287F5 /* RadioButton.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RadioButton.swift; sourceTree = ""; }; EAF7F11628A1475A00B287F5 /* RadioButtonModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RadioButtonModel.swift; sourceTree = ""; }; EAF7F13228A2A16500B287F5 /* LabelAttributeAttachment.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LabelAttributeAttachment.swift; sourceTree = ""; }; @@ -204,9 +221,9 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( - EAF7F0F8289DB1AC00B287F5 /* VDSFormControlsTokens.xcframework in Frameworks */, - EAF7F0F9289DB1AC00B287F5 /* VDSTypographyTokens.xcframework in Frameworks */, - EAF7F0FB289DB1AC00B287F5 /* VDSColorTokens.xcframework in Frameworks */, + EAA5EEF328F5C909003B3210 /* VDSFormControlsTokens.xcframework in Frameworks */, + EAA5EEEF28F5C908003B3210 /* VDSTypographyTokens.xcframework in Frameworks */, + EAA5EEF128F5C909003B3210 /* VDSColorTokens.xcframework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -290,11 +307,9 @@ EA33618D288B1C0C0071C351 /* Frameworks */ = { isa = PBXGroup; children = ( - EAF7F0E9289DB0DA00B287F5 /* VDSColorTokens.xcframework */, - EAF7F0E8289DB0DA00B287F5 /* VDSFormControlsTokens.xcframework */, - EA3361F32891D5290071C351 /* VDSTypographyTokens.xcframework */, - EA33618E288B1C0C0071C351 /* VDSColorTokens.xcframework */, - EA33618F288B1C0C0071C351 /* VDSFormControlsTokens.xcframework */, + EAA5EEED28F5C908003B3210 /* VDSColorTokens.xcframework */, + EAA5EEEE28F5C908003B3210 /* VDSFormControlsTokens.xcframework */, + EAA5EEEC28F5C908003B3210 /* VDSTypographyTokens.xcframework */, ); name = Frameworks; sourceTree = ""; @@ -531,6 +546,7 @@ EA336168288B19200071C351 /* Sources */, EA336169288B19200071C351 /* Frameworks */, EA33616A288B19200071C351 /* Resources */, + EAA5EEF528F5C909003B3210 /* Embed Frameworks */, ); buildRules = ( ); From 0bf344ed313ce18090eef0d8e28f5ebdfc67a476 Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Tue, 11 Oct 2022 14:01:08 -0500 Subject: [PATCH 05/29] allow override of inititalSetup Signed-off-by: Matt Bruce --- VDS/Classes/CollectionView.swift | 2 +- VDS/Classes/CollectionViewCell.swift | 2 +- VDS/Classes/Control.swift | 8 ++------ VDS/Classes/View.swift | 2 +- 4 files changed, 5 insertions(+), 9 deletions(-) diff --git a/VDS/Classes/CollectionView.swift b/VDS/Classes/CollectionView.swift index e0b1ab57..7a163e9d 100644 --- a/VDS/Classes/CollectionView.swift +++ b/VDS/Classes/CollectionView.swift @@ -79,7 +79,7 @@ open class CollectionView: UICollectionView, ModelHandlera // MARK: - Setup //-------------------------------------------------- - public func initialSetup() { + open func initialSetup() { if !initialSetupPerformed { initialSetupPerformed = true setupUpdateView() diff --git a/VDS/Classes/CollectionViewCell.swift b/VDS/Classes/CollectionViewCell.swift index 536053b1..881665f2 100644 --- a/VDS/Classes/CollectionViewCell.swift +++ b/VDS/Classes/CollectionViewCell.swift @@ -52,7 +52,7 @@ open class CollectionViewCell: UICo // MARK: - Setup //-------------------------------------------------- - public func initialSetup() { + open func initialSetup() { if !initialSetupPerformed { initialSetupPerformed = true setup() diff --git a/VDS/Classes/Control.swift b/VDS/Classes/Control.swift index 50283184..227d550e 100644 --- a/VDS/Classes/Control.swift +++ b/VDS/Classes/Control.swift @@ -23,11 +23,7 @@ open class Control: UIControl, ModelHandlerable, ViewProto // MARK: - Properties //-------------------------------------------------- private var initialSetupPerformed = false - - //if set to true this will call the - //defaultAction() in the class - public var executeDefaultAction = true - + @Proxy(\.model.surface) open var surface: Surface @@ -78,7 +74,7 @@ open class Control: UIControl, ModelHandlerable, ViewProto // MARK: - Setup //-------------------------------------------------- - public func initialSetup() { + open func initialSetup() { if !initialSetupPerformed { initialSetupPerformed = true setupUpdateView() diff --git a/VDS/Classes/View.swift b/VDS/Classes/View.swift index 5883930f..57ac207b 100644 --- a/VDS/Classes/View.swift +++ b/VDS/Classes/View.swift @@ -74,7 +74,7 @@ open class View: UIView, ModelHandlerable, ViewProtocol, R // MARK: - Setup //-------------------------------------------------- - public func initialSetup() { + open func initialSetup() { if !initialSetupPerformed { initialSetupPerformed = true setupUpdateView() From 087691bc62d1509ed507b2d0a2d76e29be04ebe8 Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Wed, 12 Oct 2022 08:16:29 -0500 Subject: [PATCH 06/29] update label within toggle Signed-off-by: Matt Bruce --- VDS/Components/Toggle/Toggle.swift | 4 ++-- VDS/Components/Toggle/ToggleModel.swift | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/VDS/Components/Toggle/Toggle.swift b/VDS/Components/Toggle/Toggle.swift index 8babbace..389ec25f 100644 --- a/VDS/Components/Toggle/Toggle.swift +++ b/VDS/Components/Toggle/Toggle.swift @@ -237,7 +237,8 @@ open class ToggleBase: Control { private func updateLabel(_ viewModel: ModelType) { let showText = viewModel.showText stackView.spacing = showText ? 12 : 0 - + label.set(with: viewModel.labelModel) + if stackView.subviews.contains(label) { label.removeFromSuperview() } @@ -326,7 +327,6 @@ open class ToggleBase: Control { // MARK: - State //-------------------------------------------------- open override func updateView(viewModel: ModelType) { - label.set(with: viewModel.label) updateLabel(viewModel) updateToggle(viewModel) setAccessibilityHint() diff --git a/VDS/Components/Toggle/ToggleModel.swift b/VDS/Components/Toggle/ToggleModel.swift index 100b2e56..72b5eef4 100644 --- a/VDS/Components/Toggle/ToggleModel.swift +++ b/VDS/Components/Toggle/ToggleModel.swift @@ -18,7 +18,7 @@ public protocol ToggleModel: Modelable, FormFieldable, DataTrackable, Accessable extension ToggleModel { public var userTrueColor: Bool { return on } - public var label: DefaultLabelModel { + public var labelModel: DefaultLabelModel { var model = DefaultLabelModel() model.textPosition = textPosition model.typograpicalStyle = typograpicalStyle From 1f91459b9ec5cb83def198f07b86fbdbb0bde405 Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Wed, 12 Oct 2022 09:00:41 -0500 Subject: [PATCH 07/29] refactored toggle to match updated property names Signed-off-by: Matt Bruce --- VDS/Components/Toggle/Toggle.swift | 41 +++---------------------- VDS/Components/Toggle/ToggleModel.swift | 40 +++++++++++++++++++++--- 2 files changed, 41 insertions(+), 40 deletions(-) diff --git a/VDS/Components/Toggle/Toggle.swift b/VDS/Components/Toggle/Toggle.swift index 389ec25f..1ff9c450 100644 --- a/VDS/Components/Toggle/Toggle.swift +++ b/VDS/Components/Toggle/Toggle.swift @@ -107,26 +107,14 @@ open class ToggleBase: Control { @Proxy(\.model.offText) public var offText: String - public var fontSize: TypographicalStyle.FontSize = .small{ - didSet { - updateTypography() - } - } + @Proxy(\.model.textSize) + public var textSize: ToggleTextSize - public var isBold: Bool = false { - didSet { - updateTypography() - } - } + @Proxy(\.model.textWeight) + public var textWeight: ToggleTextWeight @Proxy(\.model.textPosition) - public var textPosition: TextPosition { - didSet { - if oldValue != textPosition { - updateLabel(model) - } - } - } + public var textPosition: ToggleTextPosition @Proxy(\.model.inputId) open var inputId: String? @@ -161,25 +149,6 @@ open class ToggleBase: Control { @Proxy(\.model.accessibilityLabelDisabled) open var accessibilityLabelDisabled: String? - //only allows - //fontSize: small, large - //fontWeight: regular, bold - private func updateTypography() { - if fontSize == .small { - if isBold { - model.typograpicalStyle = .BoldBodySmall - } else { - model.typograpicalStyle = .BodySmall - } - } else { - if isBold { - model.typograpicalStyle = .BoldBodyLarge - } else { - model.typograpicalStyle = .BodyLarge - } - } - } - //-------------------------------------------------- // MARK: - Constraints //-------------------------------------------------- diff --git a/VDS/Components/Toggle/ToggleModel.swift b/VDS/Components/Toggle/ToggleModel.swift index 72b5eef4..4c888b49 100644 --- a/VDS/Components/Toggle/ToggleModel.swift +++ b/VDS/Components/Toggle/ToggleModel.swift @@ -8,19 +8,50 @@ import Foundation import UIKit -public protocol ToggleModel: Modelable, FormFieldable, DataTrackable, Accessable, Labelable, BinaryColorable { +public enum ToggleTextSize: String, CaseIterable { + case small, large +} + +public enum ToggleTextWeight: String, CaseIterable { + case regular, bold +} + +public enum ToggleTextPosition: String, CaseIterable { + case left, right +} + +public protocol ToggleModel: Modelable, FormFieldable, DataTrackable, Accessable, BinaryColorable { var showText: Bool { get set } var on: Bool { get set } var offText: String { get set } var onText: String { get set } + var textWeight: ToggleTextWeight { get set } + var textSize: ToggleTextSize { get set } + var textPosition: ToggleTextPosition { get set } } extension ToggleModel { public var userTrueColor: Bool { return on } public var labelModel: DefaultLabelModel { + + var typograpicalStyle: TypographicalStyle + if textSize == .small { + if textWeight == .bold { + typograpicalStyle = .BoldBodySmall + } else { + typograpicalStyle = .BodySmall + } + } else { + if textWeight == .bold { + typograpicalStyle = .BoldBodyLarge + } else { + typograpicalStyle = .BodyLarge + } + } + var model = DefaultLabelModel() - model.textPosition = textPosition + model.textPosition = textPosition == .left ? .left : .right model.typograpicalStyle = typograpicalStyle model.text = on ? onText : offText model.surface = surface @@ -36,8 +67,9 @@ public struct DefaultToggleModel: ToggleModel { public var offText: String = "Off" public var onText: String = "On" - public var typograpicalStyle: TypographicalStyle = .BodySmall - public var textPosition: TextPosition = .left + public var textWeight: ToggleTextWeight = .regular + public var textSize: ToggleTextSize = .small + public var textPosition: ToggleTextPosition = .left public var inputId: String? public var value: AnyHashable? = true From 558d6c16ab9a8688d6bffb8af18557b0f56a9ce8 Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Wed, 12 Oct 2022 09:02:39 -0500 Subject: [PATCH 08/29] updated logic Signed-off-by: Matt Bruce --- VDS/Components/Toggle/Toggle.swift | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/VDS/Components/Toggle/Toggle.swift b/VDS/Components/Toggle/Toggle.swift index 1ff9c450..1bfad430 100644 --- a/VDS/Components/Toggle/Toggle.swift +++ b/VDS/Components/Toggle/Toggle.swift @@ -93,13 +93,7 @@ open class ToggleBase: Control { open var isOn: Bool @Proxy(\.model.showText) - public var showText: Bool { - didSet { - if oldValue != showText { - updateLabel(model) - } - } - } + public var showText: Bool @Proxy(\.model.onText) public var onText: String From f47a910daed742939e50c6b2f071d0a198ee836e Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Thu, 13 Oct 2022 10:51:00 -0500 Subject: [PATCH 09/29] updated constaint Signed-off-by: Matt Bruce --- VDS/Components/Toggle/Toggle.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VDS/Components/Toggle/Toggle.swift b/VDS/Components/Toggle/Toggle.swift index 1bfad430..9157e2e5 100644 --- a/VDS/Components/Toggle/Toggle.swift +++ b/VDS/Components/Toggle/Toggle.swift @@ -265,7 +265,7 @@ open class ToggleBase: Control { stackView.addArrangedSubview(toggleContainerView) stackView.topAnchor.constraint(equalTo: topAnchor).isActive = true stackView.leadingAnchor.constraint(equalTo: leadingAnchor).isActive = true - stackView.trailingAnchor.constraint(equalTo: trailingAnchor).isActive = true + stackView.widthAnchor.constraint(greaterThanOrEqualToConstant: toggleContainerSize.width).isActive = true stackView.bottomAnchor.constraint(equalTo: bottomAnchor).isActive = true toggleView.centerXAnchor.constraint(equalTo: toggleContainerView.centerXAnchor).isActive = true From cc9b769fc09e0a5c10b8dbb6913090cfe75e9a61 Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Wed, 19 Oct 2022 14:30:45 -0500 Subject: [PATCH 10/29] build for distribution Signed-off-by: Matt Bruce --- VDS.xcodeproj/project.pbxproj | 2 ++ 1 file changed, 2 insertions(+) diff --git a/VDS.xcodeproj/project.pbxproj b/VDS.xcodeproj/project.pbxproj index cd3de983..38ea3f2e 100644 --- a/VDS.xcodeproj/project.pbxproj +++ b/VDS.xcodeproj/project.pbxproj @@ -860,6 +860,7 @@ EA336181288B19210071C351 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { + BUILD_LIBRARY_FOR_DISTRIBUTION = YES; CODE_SIGN_STYLE = Automatic; CURRENT_PROJECT_VERSION = 1; DEFINES_MODULE = YES; @@ -891,6 +892,7 @@ EA336182288B19210071C351 /* Release */ = { isa = XCBuildConfiguration; buildSettings = { + BUILD_LIBRARY_FOR_DISTRIBUTION = YES; CODE_SIGN_STYLE = Automatic; CURRENT_PROJECT_VERSION = 1; DEFINES_MODULE = YES; From 4bf9ce83b5b192375b0aa185d8afab42177edb11 Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Thu, 20 Oct 2022 10:55:36 -0500 Subject: [PATCH 11/29] refactored to remove models Signed-off-by: Matt Bruce --- VDS/Classes/CollectionView.swift | 44 ++--- VDS/Classes/CollectionViewCell.swift | 30 +-- VDS/Classes/ColorConfiguration.swift | 4 + VDS/Classes/Control.swift | 39 ++-- VDS/Classes/SelectorGroupHandlerBase.swift | 47 +---- VDS/Classes/View.swift | 39 ++-- VDS/Components/Badge/Badge.swift | 60 +++--- VDS/Components/Button/Button.swift | 82 ++++---- VDS/Components/Button/ButtonModel.swift | 1 - VDS/Components/Checkbox/Checkbox.swift | 184 ++++++++++++------ VDS/Components/Checkbox/CheckboxGroup.swift | 37 ++-- VDS/Components/Label/Label.swift | 100 ++++------ VDS/Components/RadioBox/RadioBox.swift | 139 +++++++------ VDS/Components/RadioBox/RadioBoxGroup.swift | 35 ++-- VDS/Components/RadioButton/RadioButton.swift | 148 ++++++++------ .../RadioButton/RadioButtonGroup.swift | 37 ++-- VDS/Components/RadioSwatch/RadioSwatch.swift | 126 ++++++------ .../RadioSwatch/RadioSwatchGroup.swift | 96 +++------ VDS/Components/Toggle/Toggle.swift | 135 +++++++------ VDS/Protocols/Accessable.swift | 28 ++- VDS/Protocols/ModelHandlerable.swift | 34 +--- 21 files changed, 668 insertions(+), 777 deletions(-) diff --git a/VDS/Classes/CollectionView.swift b/VDS/Classes/CollectionView.swift index 7a163e9d..41caa09e 100644 --- a/VDS/Classes/CollectionView.swift +++ b/VDS/Classes/CollectionView.swift @@ -9,13 +9,12 @@ import Foundation import UIKit import Combine -open class CollectionView: UICollectionView, ModelHandlerable, ViewProtocol, Resettable { +open class CollectionView: UICollectionView, ModelHandlerable, ViewProtocol, Resettable { //-------------------------------------------------- // MARK: - Combine Properties //-------------------------------------------------- - @Published public var model: ModelType = ModelType() - public var modelPublisher: Published.Publisher { $model } + public var subject = PassthroughSubject() public var subscribers = Set() //-------------------------------------------------- @@ -23,24 +22,18 @@ open class CollectionView: UICollectionView, ModelHandlera //-------------------------------------------------- private var initialSetupPerformed = false - @Proxy(\.model.surface) - open var surface: Surface - - @Proxy(\.model.disabled) - open var disabled: Bool { - didSet { - self.isEnabled = !disabled - } - } + open var surface: Surface = .light { didSet { subject.send() }} + open var disabled: Bool = false { didSet { isEnabled = !disabled } } + open var isEnabled: Bool { - get { !model.disabled } + get { !disabled } set { - //create local vars for clear coding - let disabled = !newValue - if model.disabled != disabled { - model.disabled = disabled + if disabled != !newValue { + disabled = !newValue } + isUserInteractionEnabled = isEnabled + subject.send() } } @@ -52,22 +45,14 @@ open class CollectionView: UICollectionView, ModelHandlera initialSetup() } - public required init(with model: ModelType) { - super.init(frame: .zero, collectionViewLayout: UICollectionViewFlowLayout()) - initialSetup() - set(with: model) - } - - public required init(with model: ModelType, collectionViewLayout layout: UICollectionViewLayout) { + public required init(collectionViewLayout layout: UICollectionViewLayout) { super.init(frame: .zero, collectionViewLayout: layout) initialSetup() - set(with: model) } public override init(frame: CGRect, collectionViewLayout layout: UICollectionViewLayout) { super.init(frame: frame, collectionViewLayout: layout) initialSetup() - set(with: model) } public required init?(coder: NSCoder) { @@ -90,15 +75,14 @@ open class CollectionView: UICollectionView, ModelHandlera //-------------------------------------------------- // MARK: - Overrides //-------------------------------------------------- - open func updateView(viewModel: ModelType) { + open func updateView() { fatalError("Implement updateView") } open func reset() { backgroundColor = .clear - if let model = model as? Resettable { - model.reset() - } + surface = .light + disabled = false } // MARK: - ViewProtocol diff --git a/VDS/Classes/CollectionViewCell.swift b/VDS/Classes/CollectionViewCell.swift index 881665f2..2a203dd8 100644 --- a/VDS/Classes/CollectionViewCell.swift +++ b/VDS/Classes/CollectionViewCell.swift @@ -10,7 +10,6 @@ import UIKit import Combine open class CollectionViewCell: UICollectionViewCell, ViewProtocol { - public typealias ModelType = ModelHandlerType.ModelType //-------------------------------------------------- // MARK: - Properties //-------------------------------------------------- @@ -18,10 +17,10 @@ open class CollectionViewCell: UICo public var modelHandler: ModelHandlerType = ModelHandlerType() - @Proxy(\.modelHandler.model.surface) - open var surface: Surface + @Proxy(\.modelHandler.surface) + open var surface: Surface - @Proxy(\.modelHandler.model.disabled) + @Proxy(\.modelHandler.disabled) open var disabled: Bool //-------------------------------------------------- @@ -32,12 +31,6 @@ open class CollectionViewCell: UICo initialSetup() } - public required init(with model: ModelType) { - super.init(frame: .zero) - initialSetup() - set(with: model) - } - public override init(frame: CGRect) { super.init(frame: frame) initialSetup() @@ -58,22 +51,7 @@ open class CollectionViewCell: UICo setup() } } - - //-------------------------------------------------- - // MARK: - Overrides - //-------------------------------------------------- - open func shouldUpdateView(viewModel: ModelType) -> Bool { - return modelHandler.shouldUpdateView(viewModel: viewModel) - } - - open func updateView(viewModel: ModelType) { - modelHandler.updateView(viewModel: viewModel) - } - - public func set(with model: ModelType) { - modelHandler.set(with: model) - } - + // MARK: - ViewProtocol /// Will be called only once. open func setup() { diff --git a/VDS/Classes/ColorConfiguration.swift b/VDS/Classes/ColorConfiguration.swift index da63fc3a..e86756fe 100644 --- a/VDS/Classes/ColorConfiguration.swift +++ b/VDS/Classes/ColorConfiguration.swift @@ -87,6 +87,10 @@ public protocol BinaryColorable{ var userTrueColor: Bool { get } } +extension BinaryColorable where Self: Control { + public var userTrueColor: Bool { return isSelected } +} + extension BinaryColorable where Self: Selectable { public var userTrueColor: Bool { return selected } } diff --git a/VDS/Classes/Control.swift b/VDS/Classes/Control.swift index 227d550e..2e06fd0e 100644 --- a/VDS/Classes/Control.swift +++ b/VDS/Classes/Control.swift @@ -10,13 +10,12 @@ import UIKit import Combine -open class Control: UIControl, ModelHandlerable, ViewProtocol, Resettable { +open class Control: UIControl, ModelHandlerable, ViewProtocol, Resettable { //-------------------------------------------------- // MARK: - Combine Properties //-------------------------------------------------- - @Published public var model: ModelType = ModelType() - public var modelPublisher: Published.Publisher { $model } + public var subject = PassthroughSubject() public var subscribers = Set() //-------------------------------------------------- @@ -24,25 +23,18 @@ open class Control: UIControl, ModelHandlerable, ViewProto //-------------------------------------------------- private var initialSetupPerformed = false - @Proxy(\.model.surface) - open var surface: Surface - - @Proxy(\.model.disabled) - open var disabled: Bool { - didSet { - self.isEnabled = !disabled - } - } + open var surface: Surface = .light { didSet { subject.send() }} + open var disabled: Bool = false { didSet { isEnabled = !disabled } } + open override var isEnabled: Bool { - get { !model.disabled } + get { !disabled } set { - //create local vars for clear coding - let disabled = !newValue - if model.disabled != disabled { - model.disabled = disabled + if disabled != !newValue { + disabled = !newValue } isUserInteractionEnabled = isEnabled + subject.send() } } @@ -54,12 +46,6 @@ open class Control: UIControl, ModelHandlerable, ViewProto initialSetup() } - public required init(with model: ModelType) { - super.init(frame: .zero) - initialSetup() - set(with: model) - } - public override init(frame: CGRect) { super.init(frame: .zero) initialSetup() @@ -92,15 +78,14 @@ open class Control: UIControl, ModelHandlerable, ViewProto //-------------------------------------------------- // MARK: - Overrides //-------------------------------------------------- - open func updateView(viewModel: ModelType) { + open func updateView() { fatalError("Implement updateView") } open func reset() { backgroundColor = .clear - if let model = model as? Resettable { - model.reset() - } + surface = .light + disabled = false } // MARK: - ViewProtocol diff --git a/VDS/Classes/SelectorGroupHandlerBase.swift b/VDS/Classes/SelectorGroupHandlerBase.swift index 5f8b2b8a..d44e229f 100644 --- a/VDS/Classes/SelectorGroupHandlerBase.swift +++ b/VDS/Classes/SelectorGroupHandlerBase.swift @@ -8,7 +8,7 @@ import Foundation import UIKit -public class SelectorGroupHandlerBase>: Control { +public class SelectorGroupHandlerBase: Control { //-------------------------------------------------- // MARK: - Public Properties @@ -33,42 +33,10 @@ public class SelectorGroupHandlerBase ModelHandlerType? { - return selectorViews.first(where: { existingSelectorView in - return existingSelectorView.model.id == id - }) - } - - public func getCachedSelector(viewModel: ModelHandlerType.ModelType) -> ModelHandlerType.ModelType? { - if let index = model.selectors.firstIndex(where: { element in - return element.id == viewModel.id - }) { - return model.selectors[index] - } else { - return nil - } - } - - public func replace(viewModel: ModelHandlerType.ModelType){ - if let index = model.selectors.firstIndex(where: { element in - return element.id == viewModel.id - }) { - model.selectors[index] = viewModel - } - } - - public func createModelHandler(selector: ModelHandlerType.ModelType) -> ModelHandlerType { + + public func createModelHandler() -> ModelHandlerType { //create view - let newSelectorView = ModelHandlerType(with: selector) - - //add model update to the subscribers - newSelectorView - .modelPublisher - .sink { [weak self] model in - self?.replace(viewModel: model) - } - .store(in: &subscribers) + let newSelectorView = ModelHandlerType() //add the selectedPublisher for the change newSelectorView @@ -93,9 +61,8 @@ public class SelectorGroupHandlerBase>: SelectorGroupHandlerBase where GroupModelType.SelectorModelType == ModelHandlerType.ModelType { - - public var selectedModel: ModelHandlerType.ModelType? { - return model.selectedModel +public class SelectorGroupSelectedHandlerBase: SelectorGroupHandlerBase{ + public var selectedHandler: ModelHandlerType? { + return selectorViews.filter { $0.isSelected == true }.first } } diff --git a/VDS/Classes/View.swift b/VDS/Classes/View.swift index 57ac207b..b2bb0205 100644 --- a/VDS/Classes/View.swift +++ b/VDS/Classes/View.swift @@ -10,39 +10,31 @@ import UIKit import Combine -open class View: UIView, ModelHandlerable, ViewProtocol, Resettable { +open class View: UIView, ModelHandlerable, ViewProtocol, Resettable { //-------------------------------------------------- // MARK: - Combine Properties //-------------------------------------------------- - @Published public var model: ModelType = ModelType() - public var modelPublisher: Published.Publisher { $model } + public var subject = PassthroughSubject() public var subscribers = Set() //-------------------------------------------------- // MARK: - Properties //-------------------------------------------------- private var initialSetupPerformed = false - - @Proxy(\.model.surface) - open var surface: Surface - @Proxy(\.model.disabled) - open var disabled: Bool { - didSet { - self.isEnabled = !disabled - } - } + open var surface: Surface = .light { didSet { subject.send() }} + open var disabled: Bool = false { didSet { isEnabled = !disabled } } + open var isEnabled: Bool { - get { !model.disabled } + get { !disabled } set { - //create local vars for clear coding - let disabled = !newValue - if model.disabled != disabled { - model.disabled = disabled + if disabled != !newValue { + disabled = !newValue } isUserInteractionEnabled = isEnabled + subject.send() } } @@ -53,12 +45,6 @@ open class View: UIView, ModelHandlerable, ViewProtocol, R super.init(frame: .zero) initialSetup() } - - public required init(with model: ModelType) { - super.init(frame: .zero) - initialSetup() - set(with: model) - } public override init(frame: CGRect) { super.init(frame: .zero) @@ -85,15 +71,14 @@ open class View: UIView, ModelHandlerable, ViewProtocol, R //-------------------------------------------------- // MARK: - Overrides //-------------------------------------------------- - open func updateView(viewModel: ModelType) { + open func updateView() { fatalError("Implement updateView") } open func reset() { backgroundColor = .clear - if let model = model as? Resettable { - model.reset() - } + surface = .light + disabled = false } // MARK: - ViewProtocol diff --git a/VDS/Components/Badge/Badge.swift b/VDS/Components/Badge/Badge.swift index 746a445b..b6aceede 100644 --- a/VDS/Components/Badge/Badge.swift +++ b/VDS/Components/Badge/Badge.swift @@ -11,44 +11,34 @@ import VDSColorTokens import VDSFormControlsTokens import Combine -public class Badge: BadgeBase{} +public class Badge: BadgeBase{} -open class BadgeBase: View { +open class BadgeBase: View, Accessable { private var label = Label() //-------------------------------------------------- // MARK: - Public Properties //-------------------------------------------------- - @Proxy(\.model.fillColor) - open var fillColor: BadgeFillColor + open var fillColor: BadgeFillColor = .red { didSet { subject.send() }} - @Proxy(\.model.text) - open var text: String + open var text: String = "" { didSet { subject.send() }} - @Proxy(\.model.maxWidth) - open var maxWidth: CGFloat? + open var maxWidth: CGFloat? { didSet { subject.send() }} - @Proxy(\.model.numberOfLines) - open var numberOfLines: Int + open var numberOfLines: Int = 1 { didSet { subject.send() }} - @Proxy(\.model.accessibilityHintEnabled) - open var accessibilityHintEnabled: String? + open var accessibilityHintEnabled: String? { didSet { subject.send() }} - @Proxy(\.model.accessibilityHintDisabled) - open var accessibilityHintDisabled: String? + open var accessibilityHintDisabled: String? { didSet { subject.send() }} - @Proxy(\.model.accessibilityValueEnabled) - open var accessibilityValueEnabled: String? + open var accessibilityValueEnabled: String? { didSet { subject.send() }} - @Proxy(\.model.accessibilityValueDisabled) - open var accessibilityValueDisabled: String? + open var accessibilityValueDisabled: String? { didSet { subject.send() }} - @Proxy(\.model.accessibilityLabelEnabled) - open var accessibilityLabelEnabled: String? + open var accessibilityLabelEnabled: String? { didSet { subject.send() }} - @Proxy(\.model.accessibilityLabelDisabled) - open var accessibilityLabelDisabled: String? + open var accessibilityLabelDisabled: String? { didSet { subject.send() }} //-------------------------------------------------- // MARK: - Constraints @@ -90,9 +80,9 @@ open class BadgeBase: View { //-------------------------------------------------- // MARK: - Configuration //-------------------------------------------------- - public func backgroundColor(for fillColor: BadgeFillColor) -> UIColor { + public func backgroundColor() -> UIColor { var config: SurfaceColorConfiguration - switch model.fillColor { + switch fillColor { case .red: config = SurfaceColorConfiguration().with { $0.lightColor = VDSColor.backgroundBrandhighlight @@ -130,10 +120,10 @@ open class BadgeBase: View { } } - return config.getColor(model) + return config.getColor(self) } - public func textColorConfiguration(for fillColor: BadgeFillColor) -> AnyColorable { + public func textColorConfiguration() -> AnyColorable { switch fillColor { @@ -165,19 +155,23 @@ open class BadgeBase: View { //-------------------------------------------------- // MARK: - State //-------------------------------------------------- - open override func updateView(viewModel: ModelType) { - backgroundColor = backgroundColor(for: viewModel.fillColor) + open override func updateView() { + backgroundColor = backgroundColor() + label.textColorConfiguration = textColorConfiguration() + label.numberOfLines = numberOfLines + label.textPosition = .left + label.typograpicalStyle = .BoldBodySmall + label.text = text + label.surface = surface + label.disabled = disabled - label.textColorConfiguration = textColorConfiguration(for: viewModel.fillColor) - label.numberOfLines = viewModel.numberOfLines - - if let maxWidth = viewModel.maxWidth, let minWidth = minWidthConstraint?.constant, maxWidth > minWidth { + if let maxWidth = maxWidth, let minWidth = minWidthConstraint?.constant, maxWidth > minWidth { maxWidthConstraint?.constant = maxWidth maxWidthConstraint?.isActive = true } else { maxWidthConstraint?.isActive = false } - label.set(with: viewModel.label) + setAccessibilityLabel() } diff --git a/VDS/Components/Button/Button.swift b/VDS/Components/Button/Button.swift index d31d4807..a7ffe8e4 100644 --- a/VDS/Components/Button/Button.swift +++ b/VDS/Components/Button/Button.swift @@ -11,15 +11,12 @@ import VDSColorTokens import VDSFormControlsTokens import Combine -public class Button:ButtonBase{} - -open class ButtonBase: UIButton, ModelHandlerable, ViewProtocol, Resettable { +open class Button: UIButton, ModelHandlerable, ViewProtocol, Resettable, Useable { //-------------------------------------------------- // MARK: - Combine Properties //-------------------------------------------------- - @Published public var model: ModelType = ModelType() - public var modelPublisher: Published.Publisher { $model } + public var subject = PassthroughSubject() public var subscribers = Set() //-------------------------------------------------- @@ -32,39 +29,29 @@ open class ButtonBase: UIButton, ModelHandlerable, ViewP //-------------------------------------------------- // MARK: - Properties //-------------------------------------------------- - @Proxy(\.model.surface) - open var surface: Surface + open var text: String? { didSet { subject.send() }} - @Proxy(\.model.disabled) - open var disabled: Bool { - didSet { - isEnabled = !disabled - } - } + open var use: Use = .primary { didSet { subject.send() }} + + open var size: ButtonSize = .large { didSet { subject.send() }} - @Proxy(\.model.text) - open var text: String? + open var width: CGFloat? { didSet { subject.send() }} - @Proxy(\.model.use) - open var use: Use - - @Proxy(\.model.size) - open var size: ButtonSize - - @Proxy(\.model.width) - open var width: CGFloat? + open var surface: Surface = .light { didSet { subject.send() }} + open var disabled: Bool = false { didSet { isEnabled = !disabled } } + open override var isEnabled: Bool { - get { !model.disabled } + get { !disabled } set { - //create local vars for clear coding - let disabled = !newValue - if model.disabled != disabled { - model.disabled = disabled + if disabled != !newValue { + disabled = !newValue } isUserInteractionEnabled = isEnabled + subject.send() } } + //-------------------------------------------------- // MARK: - Configuration Properties @@ -113,16 +100,9 @@ open class ButtonBase: UIButton, ModelHandlerable, ViewP initialSetup() } - public required init(with model: ModelType) { - super.init(frame: .zero) - initialSetup() - set(with: model) - } - public override init(frame: CGRect) { super.init(frame: .zero) initialSetup() - set(with: model) } public required init?(coder: NSCoder) { @@ -149,15 +129,19 @@ open class ButtonBase: UIButton, ModelHandlerable, ViewP //only 1 of the 2 widths can be on at the same time widthConstraint = widthAnchor.constraint(equalToConstant: 0) - minWidthConstraint = widthAnchor.constraint(greaterThanOrEqualToConstant: model.size.minimumWidth) + minWidthConstraint = widthAnchor.constraint(greaterThanOrEqualToConstant: size.minimumWidth) //height - heightConstraint = heightAnchor.constraint(equalToConstant: model.size.height) + heightConstraint = heightAnchor.constraint(equalToConstant: size.height) heightConstraint?.isActive = true } open func reset() { - model = ModelType() + surface = .light + disabled = false + use = .primary + width = nil + size = .large accessibilityCustomActions = [] accessibilityTraits = .staticText } @@ -165,19 +149,19 @@ open class ButtonBase: UIButton, ModelHandlerable, ViewP //-------------------------------------------------- // MARK: - Overrides //-------------------------------------------------- - open func updateView(viewModel: ModelType) { + open func updateView() { - let bgColor = buttonBackgroundColorConfiguration.getColor(viewModel) - let borderColor = buttonBorderColorConfiguration.getColor(viewModel) - let titleColor = buttonTitleColorConfiguration.getColor(viewModel) - let borderWidth = viewModel.use == .secondary ? 1.0 : 0.0 - let buttonHeight = viewModel.size.height + let bgColor = buttonBackgroundColorConfiguration.getColor(self) + let borderColor = buttonBorderColorConfiguration.getColor(self) + let titleColor = buttonTitleColorConfiguration.getColor(self) + let borderWidth = use == .secondary ? 1.0 : 0.0 + let buttonHeight = size.height let cornerRadius = buttonHeight / 2 - let minWidth = viewModel.size.minimumWidth - let font = viewModel.size == .large ? TypographicalStyle.BoldBodyLarge.font : TypographicalStyle.BoldBodySmall.font - let edgeInsets = viewModel.size.edgeInsets + let minWidth = size.minimumWidth + let font = size == .large ? TypographicalStyle.BoldBodyLarge.font : TypographicalStyle.BoldBodySmall.font + let edgeInsets = size.edgeInsets - if let text = viewModel.text { + if let text = text { setTitle(text, for: .normal) } else { setTitle("No ViewModel Text", for: .normal) @@ -193,7 +177,7 @@ open class ButtonBase: UIButton, ModelHandlerable, ViewP minWidthConstraint?.constant = minWidth heightConstraint?.constant = buttonHeight - if let width = viewModel.width, width > minWidth { + if let width, width > minWidth { widthConstraint?.constant = width widthConstraint?.isActive = true minWidthConstraint?.isActive = false diff --git a/VDS/Components/Button/ButtonModel.swift b/VDS/Components/Button/ButtonModel.swift index d5b7f0d9..140f5561 100644 --- a/VDS/Components/Button/ButtonModel.swift +++ b/VDS/Components/Button/ButtonModel.swift @@ -24,7 +24,6 @@ public struct DefaultButtonModel: ButtonModel { public var id = UUID() public var text: String? - public var typograpicalStyle: TypographicalStyle = .BoldBodyLarge public var surface: Surface = .light public var use: Use = .primary public var disabled: Bool = false diff --git a/VDS/Components/Checkbox/Checkbox.swift b/VDS/Components/Checkbox/Checkbox.swift index e14e5b2b..036af81a 100644 --- a/VDS/Components/Checkbox/Checkbox.swift +++ b/VDS/Components/Checkbox/Checkbox.swift @@ -11,9 +11,9 @@ import VDSColorTokens import VDSFormControlsTokens import Combine -public class Checkbox: CheckboxBase{} +public class Checkbox: CheckboxBase{} -public class SoloCheckbox: CheckboxBase{ +public class SoloCheckbox: CheckboxBase{ public override func initialSetup() { super.initialSetup() publisher(for: .touchUpInside) @@ -23,11 +23,39 @@ public class SoloCheckbox: CheckboxBase{ } } -open class CheckboxBase: Control { +open class CheckboxBase: Control, Accessable, BinaryColorable, Errorable { + //-------------------------------------------------- + // MARK: - Initializers + //-------------------------------------------------- + required public init() { + super.init(frame: .zero) + initialSetup() + } + + public override init(frame: CGRect) { + super.init(frame: .zero) + initialSetup() + } + + public required init?(coder: NSCoder) { + super.init(coder: coder) + initialSetup() + } + //-------------------------------------------------- // MARK: - Private Properties //-------------------------------------------------- + private var shouldShowError: Bool { + guard showError && !disabled && errorText?.isEmpty == false else { return false } + return true + } + + private var shouldShowLabels: Bool { + guard labelText?.isEmpty == false || childText?.isEmpty == false else { return false } + return true + } + private var mainStackView: UIStackView = { return UIStackView().with { $0.translatesAutoresizingMaskIntoConstraints = false @@ -67,60 +95,77 @@ open class CheckboxBase: Control { }() //can't bind to @Proxy - open override var isSelected: Bool { - get { model.selected } - set { - if model.selected != newValue { - model.selected = newValue - } - } - } + open override var isSelected: Bool { didSet { subject.send() }} - @Proxy(\.model.labelText) - open var labelText: String? + open var labelText: String? { didSet { subject.send() }} - @Proxy(\.model.childText) - open var childText: String? + open var labelTextAttributes: [any LabelAttributeModel]? { didSet { subject.send() }} - @Proxy(\.model.showError) - open var showError: Bool - - @Proxy(\.model.errorText) - open var errorText: String? + open var childText: String? { didSet { subject.send() }} - @Proxy(\.model.inputId) - open var inputId: String? + open var childTextAttributes: [any LabelAttributeModel]? { didSet { subject.send() }} - @Proxy(\.model.value) - open var value: AnyHashable? + open var showError: Bool = false { didSet { subject.send() }} - @Proxy(\.model.dataAnalyticsTrack) - open var dataAnalyticsTrack: String? + open var errorText: String? { didSet { subject.send() }} - @Proxy(\.model.dataClickStream) - open var dataClickStream: String? + open var inputId: String? { didSet { subject.send() }} - @Proxy(\.model.dataTrack) - open var dataTrack: String? + open var value: AnyHashable? { didSet { subject.send() }} + + open var dataAnalyticsTrack: String? { didSet { subject.send() }} - @Proxy(\.model.accessibilityHintEnabled) - open var accessibilityHintEnabled: String? + open var dataClickStream: String? { didSet { subject.send() }} + + open var dataTrack: String? { didSet { subject.send() }} + + open var accessibilityHintEnabled: String? { didSet { subject.send() }} - @Proxy(\.model.accessibilityHintDisabled) - open var accessibilityHintDisabled: String? + open var accessibilityHintDisabled: String? { didSet { subject.send() }} - @Proxy(\.model.accessibilityValueEnabled) - open var accessibilityValueEnabled: String? + open var accessibilityValueEnabled: String? { didSet { subject.send() }} - @Proxy(\.model.accessibilityValueDisabled) - open var accessibilityValueDisabled: String? + open var accessibilityValueDisabled: String? { didSet { subject.send() }} - @Proxy(\.model.accessibilityLabelEnabled) - open var accessibilityLabelEnabled: String? + open var accessibilityLabelEnabled: String? { didSet { subject.send() }} - @Proxy(\.model.accessibilityLabelDisabled) - open var accessibilityLabelDisabled: String? + open var accessibilityLabelDisabled: String? { didSet { subject.send() }} + private var labelModel: DefaultLabelModel? { + guard let labelText = labelText else { return nil } + var model = DefaultLabelModel() + model.textPosition = .left + model.typograpicalStyle = .BoldBodyLarge + model.text = labelText + model.surface = surface + model.disabled = disabled + model.attributes = labelTextAttributes + return model + } + + private var childModel: DefaultLabelModel? { + guard let childText = childText else { return nil } + var model = DefaultLabelModel() + model.textPosition = .left + model.typograpicalStyle = .BodyLarge + model.text = childText + model.surface = surface + model.disabled = disabled + model.attributes = childTextAttributes + return model + } + + private var errorModel: DefaultLabelModel? { + guard let errorText = errorText, showError else { return nil } + var model = DefaultLabelModel() + model.textPosition = .left + model.typograpicalStyle = .BodyMedium + model.text = errorText + model.surface = surface + model.disabled = disabled + return model + } + //-------------------------------------------------- // MARK: - Constraints //-------------------------------------------------- @@ -159,7 +204,7 @@ open class CheckboxBase: Control { selectorWidthConstraint = selectorView.widthAnchor.constraint(equalToConstant: selectorSize.width) selectorWidthConstraint?.isActive = true - updateSelector(model) + updateSelector() mainStackView.topAnchor.constraint(equalTo: topAnchor).isActive = true mainStackView.leadingAnchor.constraint(equalTo: leadingAnchor).isActive = true @@ -168,22 +213,32 @@ open class CheckboxBase: Control { } - func updateLabels(_ viewModel: ModelType) { + func updateLabels() { //deal with labels - if viewModel.shouldShowLabels { + if shouldShowLabels { //add the stackview to hold the 2 labels //top label - if let labelModel = viewModel.labelModel { - primaryLabel.set(with: labelModel) + if let labelText { + primaryLabel.textPosition = .left + primaryLabel.typograpicalStyle = .BoldBodyLarge + primaryLabel.text = labelText + primaryLabel.surface = surface + primaryLabel.disabled = disabled + primaryLabel.attributes = labelTextAttributes primaryLabel.isHidden = false } else { primaryLabel.isHidden = true } //bottom label - if let childModel = viewModel.childModel { - secondaryLabel.set(with: childModel) + if let childText { + secondaryLabel.textPosition = .left + secondaryLabel.typograpicalStyle = .BodyLarge + secondaryLabel.text = childText + secondaryLabel.surface = surface + secondaryLabel.disabled = disabled + secondaryLabel.attributes = childTextAttributes secondaryLabel.isHidden = false } else { secondaryLabel.isHidden = true @@ -199,20 +254,23 @@ open class CheckboxBase: Control { } //either add/remove the error from the main stack - if let errorModel = model.errorModel, model.shouldShowError { - errorLabel.set(with: errorModel) + if let errorText, shouldShowError { + errorLabel.textPosition = .left + errorLabel.typograpicalStyle = .BodyMedium + errorLabel.text = errorText + errorLabel.surface = surface + errorLabel.disabled = disabled mainStackView.spacing = 8 errorLabel.isHidden = false } else { mainStackView.spacing = 0 errorLabel.isHidden = true } - } public override func reset() { super.reset() - updateSelector(model) + updateSelector() setAccessibilityLabel() } @@ -229,12 +287,12 @@ open class CheckboxBase: Control { //-------------------------------------------------- // MARK: - State //-------------------------------------------------- - open override func updateView(viewModel: ModelType) { - updateLabels(viewModel) - updateSelector(viewModel) + open override func updateView() { + updateLabels() + updateSelector() setAccessibilityHint() - setAccessibilityValue(viewModel.selected) - setAccessibilityLabel(viewModel.selected) + setAccessibilityValue(isSelected) + setAccessibilityLabel(isSelected) setNeedsLayout() layoutIfNeeded() } @@ -294,11 +352,11 @@ open class CheckboxBase: Control { return checkboxSize } - open func updateSelector(_ viewModel: ModelType) { + open func updateSelector() { //get the colors - let backgroundColor = checkboxBackgroundColorConfiguration.getColor(viewModel) - let borderColor = checkboxBorderColorConfiguration.getColor(viewModel) - let checkColor = checkboxCheckColorConfiguration.getColor(viewModel) + let backgroundColor = checkboxBackgroundColorConfiguration.getColor(self) + let borderColor = checkboxBorderColorConfiguration.getColor(self) + let checkColor = checkboxCheckColorConfiguration.getColor(self) if let shapeLayer = shapeLayer, let sublayers = layer.sublayers, sublayers.contains(shapeLayer) { shapeLayer.removeFromSuperlayer() @@ -340,7 +398,7 @@ open class CheckboxBase: Control { shapeLayer.lineJoin = .miter shapeLayer.lineWidth = 2 CATransaction.withDisabledAnimations { - shapeLayer.strokeEnd = model.selected ? 1 : 0 + shapeLayer.strokeEnd = isSelected ? 1 : 0 } } } diff --git a/VDS/Components/Checkbox/CheckboxGroup.swift b/VDS/Components/Checkbox/CheckboxGroup.swift index 67d87993..8f1110a3 100644 --- a/VDS/Components/Checkbox/CheckboxGroup.swift +++ b/VDS/Components/Checkbox/CheckboxGroup.swift @@ -8,7 +8,7 @@ import Foundation import UIKit -public class CheckboxGroup: CheckboxGroupBase { +public class CheckboxGroup: CheckboxGroupBase { public override func didSelect(_ selectedControl: Checkbox) { selectedControl.toggle() if selectedControl.isSelected, showError{ @@ -18,13 +18,25 @@ public class CheckboxGroup: CheckboxGroupBase>: SelectorGroupHandlerBase { +public class CheckboxGroupBase: SelectorGroupHandlerBase { //-------------------------------------------------- // MARK: - Public Properties //-------------------------------------------------- + + public override var selectorViews: [ModelHandlerType] { + didSet { + for selector in selectorViews { + if !mainStackView.arrangedSubviews.contains(selector) { + mainStackView.addArrangedSubview(selector) + } + } + } + } + + private var _showError: Bool = false public var showError: Bool { - get { model.showError } + get { _showError } set { var newShowError = newValue let anySelected = selectorViews.filter { $0.isSelected == true }.count > 0 @@ -34,8 +46,7 @@ public class CheckboxGroupBase{} +public class Label: LabelBase {} -open class LabelBase: UILabel, ModelHandlerable, ViewProtocol, Resettable { +open class LabelBase: UILabel, ModelHandlerable, ViewProtocol, Resettable { //-------------------------------------------------- // MARK: - Combine Properties //-------------------------------------------------- - @Published public var model: ModelType = ModelType() - public var modelPublisher: Published.Publisher { $model } + public var subject = PassthroughSubject() public var subscribers = Set() //-------------------------------------------------- // MARK: - Properties //-------------------------------------------------- - @Proxy(\.model.surface) - open var surface: Surface + open var surface: Surface = .light { didSet { subject.send() }} - @Proxy(\.model.disabled) - open var disabled: Bool { - didSet { - self.isEnabled = !disabled - } - } + open var disabled: Bool = false { didSet { isEnabled = !disabled } } + + open var attributes: [any LabelAttributeModel]? { didSet { subject.send() }} + open var typograpicalStyle: TypographicalStyle = .defaultStyle { didSet { subject.send() }} + + open var textPosition: TextPosition = .left { didSet { subject.send() }} + open override var isEnabled: Bool { - get { !model.disabled } + get { !disabled } set { - //create local vars for clear coding - let disabled = !newValue - if model.disabled != disabled { - model.disabled = disabled + if disabled != !newValue { + disabled = !newValue } isUserInteractionEnabled = isEnabled + subject.send() } } - @Proxy(\.model.attributes) - open var attributes: [any LabelAttributeModel]? - - @Proxy(\.model.typograpicalStyle) - open var typograpicalStyle: TypographicalStyle - - @Proxy(\.model.textPosition) - open var textPosition: TextPosition - - //can't use @Proxy here override open var text: String? { didSet { - if model.text != oldValue { - model.text = text - } + subject.send() } } @@ -81,17 +67,10 @@ open class LabelBase: UILabel, ModelHandlerable, ViewProt super.init(frame: .zero) initialSetup() } - - public required init(with model: ModelType) { - super.init(frame: .zero) - initialSetup() - set(with: model) - } public override init(frame: CGRect) { super.init(frame: .zero) initialSetup() - set(with: model) } public required init?(coder: NSCoder) { @@ -116,11 +95,13 @@ open class LabelBase: UILabel, ModelHandlerable, ViewProt open func setup() {} open func reset() { + surface = .light + disabled = false + attributes = nil + typograpicalStyle = .defaultStyle + textPosition = .left text = nil attributedText = nil - textColor = .black - font = TypographicalStyle.BodyLarge.font - textAlignment = .left accessibilityCustomActions = [] accessibilityTraits = .staticText numberOfLines = 0 @@ -129,17 +110,12 @@ open class LabelBase: UILabel, ModelHandlerable, ViewProt //-------------------------------------------------- // MARK: - Overrides //-------------------------------------------------- - open func updateView(viewModel: ModelType) { - textAlignment = viewModel.textPosition.textAlignment - textColor = textColorConfiguration.getColor(viewModel) + open func updateView() { + textAlignment = textPosition.textAlignment + textColor = textColorConfiguration.getColor(self) + font = typograpicalStyle.font - if let vdsFont = viewModel.font { - font = vdsFont - } else { - font = TypographicalStyle.defaultStyle.font - } - - if let text = viewModel.text, let font = font, let textColor = textColor { + if let text = text, let font = font, let textColor = textColor { //clear the arrays holding actions accessibilityCustomActions = [] actions = [] @@ -149,9 +125,9 @@ open class LabelBase: UILabel, ModelHandlerable, ViewProt let mutableText = NSMutableAttributedString(string: text, attributes: startingAttributes) //set the local lineHeight/lineSpacing attributes - setStyleAttributes(viewModel: viewModel, attributedString: mutableText) + setStyleAttributes(attributedString: mutableText) - if let attributes = viewModel.attributes { + if let attributes = attributes { //loop through the models attributes for attribute in attributes { @@ -170,42 +146,40 @@ open class LabelBase: UILabel, ModelHandlerable, ViewProt } //only enabled if enabled and has actions - isUserInteractionEnabled = !viewModel.disabled && !actions.isEmpty + isUserInteractionEnabled = !disabled && !actions.isEmpty //set the attributed text attributedText = mutableText - } else { - text = viewModel.text } } // MARK: - Private Attributes - private func setStyleAttributes(viewModel: ModelType, attributedString: NSMutableAttributedString) { + private func setStyleAttributes(attributedString: NSMutableAttributedString) { //get the range let entireRange = NSRange(location: 0, length: attributedString.length) //set letterSpacing - if viewModel.typograpicalStyle.letterSpacing > 0.0 { - attributedString.addAttribute(.kern, value: viewModel.typograpicalStyle.letterSpacing, range: entireRange) + if typograpicalStyle.letterSpacing > 0.0 { + attributedString.addAttribute(.kern, value: typograpicalStyle.letterSpacing, range: entireRange) } //set lineHeight - if viewModel.typograpicalStyle.lineHeight > 0.0 { - let lineHeight = viewModel.typograpicalStyle.lineHeight + if typograpicalStyle.lineHeight > 0.0 { + let lineHeight = typograpicalStyle.lineHeight let adjustment = lineHeight > font.lineHeight ? 2.0 : 1.0 let baselineOffset = (lineHeight - font.lineHeight) / 2.0 / adjustment let paragraph = NSMutableParagraphStyle().with { $0.maximumLineHeight = lineHeight $0.minimumLineHeight = lineHeight - $0.alignment = viewModel.textPosition.textAlignment + $0.alignment = textPosition.textAlignment $0.lineBreakMode = lineBreakMode } attributedString.addAttribute(.baselineOffset, value: baselineOffset, range: entireRange) attributedString.addAttribute( .paragraphStyle, value: paragraph, range: entireRange) - } else if viewModel.textPosition != .left { + } else if textPosition != .left { let paragraph = NSMutableParagraphStyle().with { - $0.alignment = viewModel.textPosition.textAlignment + $0.alignment = textPosition.textAlignment $0.lineBreakMode = lineBreakMode } attributedString.addAttribute( .paragraphStyle, value: paragraph, range: entireRange) diff --git a/VDS/Components/RadioBox/RadioBox.swift b/VDS/Components/RadioBox/RadioBox.swift index a4e47b40..f7e4ec71 100644 --- a/VDS/Components/RadioBox/RadioBox.swift +++ b/VDS/Components/RadioBox/RadioBox.swift @@ -11,9 +11,9 @@ import VDSColorTokens import VDSFormControlsTokens import Combine -public class RadioBox: RadioBoxBase{} +public class RadioBox: RadioBoxBase{} -public class SolorRadioBox: RadioBoxBase{ +public class SolorRadioBox: RadioBoxBase{ public override func initialSetup() { super.initialSetup() @@ -24,8 +24,25 @@ public class SolorRadioBox: RadioBoxBase{ } } -open class RadioBoxBase: Control { +open class RadioBoxBase: Control, BinaryColorable, Accessable { + //-------------------------------------------------- + // MARK: - Initializers + //-------------------------------------------------- + required public init() { + super.init(frame: .zero) + initialSetup() + } + public override init(frame: CGRect) { + super.init(frame: .zero) + initialSetup() + } + + public required init?(coder: NSCoder) { + super.init(coder: coder) + initialSetup() + } + //-------------------------------------------------- // MARK: - Private Properties //-------------------------------------------------- @@ -67,61 +84,42 @@ open class RadioBoxBase: Control { $0.translatesAutoresizingMaskIntoConstraints = false } }() - - //can't bind to @Proxy - open override var isSelected: Bool { - get { model.selected } - set { - if model.selected != newValue { - model.selected = newValue - } - } - } - @Proxy(\.model.text) - open var text: String + open var text: String = "Default Text" { didSet { subject.send() }} - @Proxy(\.model.subText) - open var subText: String? + open var textAttributes: [any LabelAttributeModel]? { didSet { subject.send() }} + + open var subText: String? { didSet { subject.send() }} - @Proxy(\.model.subTextRight) - open var subTextRight: String? + open var subTextAttributes: [any LabelAttributeModel]? { didSet { subject.send() }} - @Proxy(\.model.strikethrough) - open var strikethrough: Bool + open var subTextRight: String? { didSet { subject.send() }} - @Proxy(\.model.inputId) - open var inputId: String? + open var subTextRightAttributes: [any LabelAttributeModel]? { didSet { subject.send() }} - @Proxy(\.model.value) - open var value: AnyHashable? + open var strikethrough: Bool = false { didSet { subject.send() }} + + open var inputId: String? { didSet { subject.send() }} + + open var value: AnyHashable? { didSet { subject.send() }} - @Proxy(\.model.dataAnalyticsTrack) - open var dataAnalyticsTrack: String? + open var dataAnalyticsTrack: String? { didSet { subject.send() }} - @Proxy(\.model.dataClickStream) - open var dataClickStream: String? + open var dataClickStream: String? { didSet { subject.send() }} - @Proxy(\.model.dataTrack) - open var dataTrack: String? + open var dataTrack: String? { didSet { subject.send() }} - @Proxy(\.model.accessibilityHintEnabled) - open var accessibilityHintEnabled: String? + open var accessibilityHintEnabled: String? { didSet { subject.send() }} - @Proxy(\.model.accessibilityHintDisabled) - open var accessibilityHintDisabled: String? + open var accessibilityHintDisabled: String? { didSet { subject.send() }} - @Proxy(\.model.accessibilityValueEnabled) - open var accessibilityValueEnabled: String? + open var accessibilityValueEnabled: String? { didSet { subject.send() }} - @Proxy(\.model.accessibilityValueDisabled) - open var accessibilityValueDisabled: String? + open var accessibilityValueDisabled: String? { didSet { subject.send() }} - @Proxy(\.model.accessibilityLabelEnabled) - open var accessibilityLabelEnabled: String? + open var accessibilityLabelEnabled: String? { didSet { subject.send() }} - @Proxy(\.model.accessibilityLabelDisabled) - open var accessibilityLabelDisabled: String? + open var accessibilityLabelDisabled: String? { didSet { subject.send() }} //functions //-------------------------------------------------- @@ -153,7 +151,7 @@ open class RadioBoxBase: Control { selectorLeftLabelStackView.spacing = 4 selectorLeftLabelStackView.isHidden = false - updateSelector(model) + updateSelector() selectorView.topAnchor.constraint(equalTo: topAnchor).isActive = true selectorView.leadingAnchor.constraint(equalTo: leadingAnchor).isActive = true @@ -167,23 +165,38 @@ open class RadioBoxBase: Control { } - func updateLabels(_ viewModel: ModelType) { + func updateLabels() { //add the stackview to hold the 2 labels //text label - textLabel.set(with: viewModel.textModel) - + textLabel.textPosition = .left + textLabel.typograpicalStyle = .BoldBodyLarge + textLabel.text = text + textLabel.surface = surface + textLabel.disabled = disabled + textLabel.attributes = textAttributes + //subText label - if let subTextModel = viewModel.subTextModel { - subTextLabel.set(with: subTextModel) + if let subText { + subTextLabel.textPosition = .left + subTextLabel.typograpicalStyle = .BodyLarge + subTextLabel.text = subText + subTextLabel.surface = surface + subTextLabel.disabled = disabled + subTextLabel.attributes = subTextAttributes subTextLabel.isHidden = false } else { subTextLabel.isHidden = true } //subTextRight label - if let subTextRightModel = viewModel.subTextRightModel { - subTextRightLabel.set(with: subTextRightModel) + if let subTextRight { + subTextRightLabel.textPosition = .right + subTextRightLabel.typograpicalStyle = .BodyLarge + subTextRightLabel.text = subTextRight + subTextRightLabel.surface = surface + subTextRightLabel.disabled = disabled + subTextRightLabel.attributes = subTextRightAttributes subTextRightLabel.isHidden = false } else { subTextRightLabel.isHidden = true @@ -192,7 +205,7 @@ open class RadioBoxBase: Control { public override func reset() { super.reset() - updateSelector(model) + updateSelector() setAccessibilityLabel() } @@ -206,12 +219,12 @@ open class RadioBoxBase: Control { //-------------------------------------------------- // MARK: - State //-------------------------------------------------- - open override func updateView(viewModel: ModelType) { - updateLabels(viewModel) - updateSelector(viewModel) + open override func updateView() { + updateLabels() + updateSelector() setAccessibilityHint() - setAccessibilityValue(viewModel.selected) - setAccessibilityLabel(viewModel.selected) + setAccessibilityValue(isSelected) + setAccessibilityLabel(isSelected) setNeedsLayout() layoutIfNeeded() } @@ -256,11 +269,11 @@ open class RadioBoxBase: Control { private var shapeLayer: CAShapeLayer? - open func updateSelector(_ viewModel: ModelType) { + open func updateSelector() { //get the colors - let backgroundColor = radioBoxBackgroundColorConfiguration.getColor(viewModel) - let borderColor = radioBoxBorderColorConfiguration.getColor(viewModel) - let borderWidth = viewModel.selected ? selectorBorderWidthSelected : selectorBorderWidth + let backgroundColor = radioBoxBackgroundColorConfiguration.getColor(self) + let borderColor = radioBoxBorderColorConfiguration.getColor(self) + let borderWidth = isSelected ? selectorBorderWidthSelected : selectorBorderWidth selectorView.backgroundColor = backgroundColor selectorView.layer.borderColor = borderColor.cgColor @@ -278,12 +291,12 @@ open class RadioBoxBase: Control { open override func draw(_ layer: CALayer, in ctx: CGContext) { - let borderColor = radioBoxBorderColorConfiguration.getColor(model) + let borderColor = radioBoxBorderColorConfiguration.getColor(self) shapeLayer?.removeFromSuperlayer() shapeLayer = nil - if model.strikethrough { + if strikethrough { let bounds = selectorView.bounds let length = max(bounds.size.height, bounds.size.width) guard length > 0.0, shapeLayer == nil else { return } diff --git a/VDS/Components/RadioBox/RadioBoxGroup.swift b/VDS/Components/RadioBox/RadioBoxGroup.swift index 74059739..5a0e323a 100644 --- a/VDS/Components/RadioBox/RadioBoxGroup.swift +++ b/VDS/Components/RadioBox/RadioBoxGroup.swift @@ -8,7 +8,7 @@ import Foundation import UIKit -public class RadioBoxGroup: RadioBoxGroupBase { +public class RadioBoxGroup: RadioBoxGroupBase { public override func didSelect(_ selectedControl: RadioBox) { let oldSelectedControl = selectorViews.filter { $0.isSelected == true }.first @@ -18,8 +18,21 @@ public class RadioBoxGroup: RadioBoxGroupBase>: SelectorGroupSelectedHandlerBase { - +public class RadioBoxGroupBase: SelectorGroupSelectedHandlerBase { + + //-------------------------------------------------- + // MARK: - Public Properties + //-------------------------------------------------- + public override var selectorViews: [ModelHandlerType] { + didSet { + for selector in selectorViews { + if !mainStackView.arrangedSubviews.contains(selector) { + mainStackView.addArrangedSubview(selector) + } + } + } + } + //-------------------------------------------------- // MARK: - Private Properties //-------------------------------------------------- @@ -68,22 +81,6 @@ public class RadioBoxGroupBase{ +public class RadioButton: RadioButtonBase { //for groups allows "toggle" open override func toggle() { //removed error @@ -21,7 +21,7 @@ public class RadioButton: RadioButtonBase{ } } -public class SoloRadioButton: RadioButtonBase{ +public class SoloRadioButton: RadioButtonBase { public override func initialSetup() { super.initialSetup() publisher(for: .touchUpInside) @@ -31,11 +31,38 @@ public class SoloRadioButton: RadioButtonBase{ } } -open class RadioButtonBase: Control { +open class RadioButtonBase: Control, Accessable, BinaryColorable, Errorable { + //-------------------------------------------------- + // MARK: - Initializers + //-------------------------------------------------- + required public init() { + super.init(frame: .zero) + initialSetup() + } + public override init(frame: CGRect) { + super.init(frame: .zero) + initialSetup() + } + + public required init?(coder: NSCoder) { + super.init(coder: coder) + initialSetup() + } + //-------------------------------------------------- // MARK: - Private Properties //-------------------------------------------------- + private var shouldShowError: Bool { + guard showError && !disabled && errorText?.isEmpty == false else { return false } + return true + } + + private var shouldShowLabels: Bool { + guard labelText?.isEmpty == false || childText?.isEmpty == false else { return false } + return true + } + private var mainStackView: UIStackView = { return UIStackView().with { $0.translatesAutoresizingMaskIntoConstraints = false @@ -73,61 +100,40 @@ open class RadioButtonBase: Control { $0.translatesAutoresizingMaskIntoConstraints = false } }() - - //can't bind to @Proxy - open override var isSelected: Bool { - get { model.selected } - set { - if model.selected != newValue { - model.selected = newValue - } - } - } - @Proxy(\.model.labelText) - open var labelText: String? + open var labelText: String? { didSet { subject.send() }} - @Proxy(\.model.childText) - open var childText: String? + open var labelTextAttributes: [any LabelAttributeModel]? { didSet { subject.send() }} + + open var childText: String? { didSet { subject.send() }} - @Proxy(\.model.showError) - open var showError: Bool - - @Proxy(\.model.errorText) - open var errorText: String? + open var childTextAttributes: [any LabelAttributeModel]? { didSet { subject.send() }} - @Proxy(\.model.inputId) - open var inputId: String? + open var showError: Bool = false { didSet { subject.send() }} + + open var errorText: String? { didSet { subject.send() }} - @Proxy(\.model.value) - open var value: AnyHashable? - - @Proxy(\.model.dataAnalyticsTrack) - open var dataAnalyticsTrack: String? + open var inputId: String? { didSet { subject.send() }} - @Proxy(\.model.dataClickStream) - open var dataClickStream: String? + open var value: AnyHashable? { didSet { subject.send() }} + + open var dataAnalyticsTrack: String? { didSet { subject.send() }} - @Proxy(\.model.dataTrack) - open var dataTrack: String? + open var dataClickStream: String? { didSet { subject.send() }} - @Proxy(\.model.accessibilityHintEnabled) - open var accessibilityHintEnabled: String? + open var dataTrack: String? { didSet { subject.send() }} + + open var accessibilityHintEnabled: String? { didSet { subject.send() }} - @Proxy(\.model.accessibilityHintDisabled) - open var accessibilityHintDisabled: String? + open var accessibilityHintDisabled: String? { didSet { subject.send() }} - @Proxy(\.model.accessibilityValueEnabled) - open var accessibilityValueEnabled: String? + open var accessibilityValueEnabled: String? { didSet { subject.send() }} - @Proxy(\.model.accessibilityValueDisabled) - open var accessibilityValueDisabled: String? + open var accessibilityValueDisabled: String? { didSet { subject.send() }} - @Proxy(\.model.accessibilityLabelEnabled) - open var accessibilityLabelEnabled: String? + open var accessibilityLabelEnabled: String? { didSet { subject.send() }} - @Proxy(\.model.accessibilityLabelDisabled) - open var accessibilityLabelDisabled: String? + open var accessibilityLabelDisabled: String? { didSet { subject.send() }} //-------------------------------------------------- // MARK: - Constraints @@ -167,7 +173,7 @@ open class RadioButtonBase: Control { selectorWidthConstraint = selectorView.widthAnchor.constraint(equalToConstant: selectorSize.width) selectorWidthConstraint?.isActive = true - updateSelector(model) + updateSelector() mainStackView.topAnchor.constraint(equalTo: topAnchor).isActive = true mainStackView.leadingAnchor.constraint(equalTo: leadingAnchor).isActive = true @@ -176,22 +182,32 @@ open class RadioButtonBase: Control { } - func updateLabels(_ viewModel: ModelType) { + func updateLabels() { //deal with labels - if viewModel.shouldShowLabels { + if shouldShowLabels { //add the stackview to hold the 2 labels //top label - if let labelModel = viewModel.labelModel { - primaryLabel.set(with: labelModel) + if let labelText { + primaryLabel.textPosition = .left + primaryLabel.typograpicalStyle = .BoldBodyLarge + primaryLabel.text = labelText + primaryLabel.surface = surface + primaryLabel.disabled = disabled + primaryLabel.attributes = labelTextAttributes primaryLabel.isHidden = false } else { primaryLabel.isHidden = true } //bottom label - if let childModel = viewModel.childModel { - secondaryLabel.set(with: childModel) + if let childText { + secondaryLabel.textPosition = .left + secondaryLabel.typograpicalStyle = .BodyLarge + secondaryLabel.text = childText + secondaryLabel.surface = surface + secondaryLabel.disabled = disabled + secondaryLabel.attributes = childTextAttributes secondaryLabel.isHidden = false } else { secondaryLabel.isHidden = true @@ -207,8 +223,12 @@ open class RadioButtonBase: Control { } //either add/remove the error from the main stack - if let errorModel = model.errorModel, model.shouldShowError { - errorLabel.set(with: errorModel) + if let errorText, shouldShowError { + errorLabel.textPosition = .left + errorLabel.typograpicalStyle = .BodyMedium + errorLabel.text = errorText + errorLabel.surface = surface + errorLabel.disabled = disabled mainStackView.spacing = 8 errorLabel.isHidden = false } else { @@ -220,7 +240,7 @@ open class RadioButtonBase: Control { public override func reset() { super.reset() - updateSelector(model) + updateSelector() setAccessibilityLabel() } @@ -239,12 +259,12 @@ open class RadioButtonBase: Control { //-------------------------------------------------- // MARK: - State //-------------------------------------------------- - open override func updateView(viewModel: ModelType) { - updateLabels(viewModel) - updateSelector(viewModel) + open override func updateView() { + updateLabels() + updateSelector() setAccessibilityHint() - setAccessibilityValue(viewModel.selected) - setAccessibilityLabel(viewModel.selected) + setAccessibilityValue(isSelected) + setAccessibilityLabel(isSelected) setNeedsLayout() layoutIfNeeded() } @@ -295,7 +315,7 @@ open class RadioButtonBase: Control { radioButtonSize } - open func updateSelector(_ viewModel: ModelType) { + open func updateSelector() { if let shapeLayer = shapeLayer, let sublayers = layer.sublayers, sublayers.contains(shapeLayer) { shapeLayer.removeFromSuperlayer() @@ -307,9 +327,9 @@ open class RadioButtonBase: Control { guard length > 0.0, shapeLayer == nil else { return } //get the colors - let backgroundColor = radioButtonBackgroundColorConfiguration.getColor(viewModel) - let borderColor = radioButtonBorderColorConfiguration.getColor(viewModel) - let radioSelectedColor = radioButtonCheckColorConfiguration.getColor(viewModel) + let backgroundColor = radioButtonBackgroundColorConfiguration.getColor(self) + let borderColor = radioButtonBorderColorConfiguration.getColor(self) + let radioSelectedColor = radioButtonCheckColorConfiguration.getColor(self) selectorView.backgroundColor = backgroundColor selectorView.layer.borderColor = borderColor.cgColor diff --git a/VDS/Components/RadioButton/RadioButtonGroup.swift b/VDS/Components/RadioButton/RadioButtonGroup.swift index 7d48e404..57f3c0e3 100644 --- a/VDS/Components/RadioButton/RadioButtonGroup.swift +++ b/VDS/Components/RadioButton/RadioButtonGroup.swift @@ -8,7 +8,7 @@ import Foundation import UIKit -public class RadioButtonGroup: RadioButtonGroupBase { +public class RadioButtonGroup: RadioButtonGroupBase { public override func didSelect(_ selectedControl: RadioButton) { let oldSelectedControl = selectorViews.filter { $0.isSelected == true }.first @@ -21,22 +21,33 @@ public class RadioButtonGroup: RadioButtonGroupBase>: SelectorGroupSelectedHandlerBase { +public class RadioButtonGroupBase: SelectorGroupSelectedHandlerBase { //-------------------------------------------------- // MARK: - Public Properties //-------------------------------------------------- + public override var selectorViews: [ModelHandlerType] { + didSet { + for selector in selectorViews { + if !mainStackView.arrangedSubviews.contains(selector) { + mainStackView.addArrangedSubview(selector) + } + } + } + } + + private var _showError: Bool = false public var showError: Bool { - get { model.showError } + get { _showError } set { var newShowError = newValue - if selectedModel != nil, newShowError { + if selectedModelHandler != nil, newShowError { newShowError = false } selectorViews.forEach { handler in handler.showError = newShowError } - model.showError = newShowError + _showError = newShowError } } @@ -68,22 +79,6 @@ public class RadioButtonGroupBase{ +public class RadioSwatch: RadioSwatchBase{ public override func initialSetup() { super.initialSetup() publisher(for: .touchUpInside) @@ -21,8 +21,26 @@ public class RadioSwatch: RadioSwatchBase{ } } -open class RadioSwatchBase: Control { - +open class RadioSwatchBase: Control, Accessable, DataTrackable, BinaryColorable { + + //-------------------------------------------------- + // MARK: - Initializers + //-------------------------------------------------- + required public init() { + super.init(frame: .zero) + initialSetup() + } + + public override init(frame: CGRect) { + super.init(frame: .zero) + initialSetup() + } + + public required init?(coder: NSCoder) { + super.init(coder: coder) + initialSetup() + } + //-------------------------------------------------- // MARK: - Public Properties //-------------------------------------------------- @@ -38,55 +56,38 @@ open class RadioSwatchBase: Control { $0.contentMode = .scaleAspectFit } }() + + open var fillImage: UIImage? { didSet { subject.send() }} + + open var text: String = "" { didSet { subject.send() }} + + open var primaryColor: UIColor? { didSet { subject.send() }} + + open var secondaryColor: UIColor? { didSet { subject.send() }} + + open var strikethrough: Bool = false { didSet { subject.send() }} - //can't bind to @Proxy - open override var isSelected: Bool { - get { model.selected } - set { - if model.selected != newValue { - model.selected = newValue - } - } - } - - @Proxy(\.model.text) - open var text: String - - @Proxy(\.model.strikethrough) - open var strikethrough: Bool + open var inputId: String? { didSet { subject.send() }} - @Proxy(\.model.inputId) - open var inputId: String? + open var value: AnyHashable? { didSet { subject.send() }} + + open var dataAnalyticsTrack: String? { didSet { subject.send() }} - @Proxy(\.model.value) - open var value: AnyHashable? - - @Proxy(\.model.dataAnalyticsTrack) - open var dataAnalyticsTrack: String? + open var dataClickStream: String? { didSet { subject.send() }} - @Proxy(\.model.dataClickStream) - open var dataClickStream: String? + open var dataTrack: String? { didSet { subject.send() }} - @Proxy(\.model.dataTrack) - open var dataTrack: String? - - @Proxy(\.model.accessibilityHintEnabled) - open var accessibilityHintEnabled: String? + open var accessibilityHintEnabled: String? { didSet { subject.send() }} - @Proxy(\.model.accessibilityHintDisabled) - open var accessibilityHintDisabled: String? + open var accessibilityHintDisabled: String? { didSet { subject.send() }} - @Proxy(\.model.accessibilityValueEnabled) - open var accessibilityValueEnabled: String? + open var accessibilityValueEnabled: String? { didSet { subject.send() }} - @Proxy(\.model.accessibilityValueDisabled) - open var accessibilityValueDisabled: String? + open var accessibilityValueDisabled: String? { didSet { subject.send() }} - @Proxy(\.model.accessibilityLabelEnabled) - open var accessibilityLabelEnabled: String? + open var accessibilityLabelEnabled: String? { didSet { subject.send() }} - @Proxy(\.model.accessibilityLabelDisabled) - open var accessibilityLabelDisabled: String? + open var accessibilityLabelDisabled: String? { didSet { subject.send() }} //functions //-------------------------------------------------- @@ -107,7 +108,7 @@ open class RadioSwatchBase: Control { selectorView.addSubview(fillView) - updateSelector(model) + updateSelector() selectorView.topAnchor.constraint(equalTo: topAnchor).isActive = true selectorView.leadingAnchor.constraint(equalTo: leadingAnchor).isActive = true @@ -128,7 +129,7 @@ open class RadioSwatchBase: Control { public override func reset() { super.reset() - updateSelector(model) + updateSelector() setAccessibilityLabel() } @@ -140,11 +141,11 @@ open class RadioSwatchBase: Control { //-------------------------------------------------- // MARK: - State //-------------------------------------------------- - open override func updateView(viewModel: ModelType) { - updateSelector(viewModel) + open override func updateView() { + updateSelector() setAccessibilityHint() - setAccessibilityValue(viewModel.selected) - setAccessibilityLabel(viewModel.selected) + setAccessibilityValue(isSelected) + setAccessibilityLabel(isSelected) setNeedsLayout() layoutIfNeeded() } @@ -199,15 +200,15 @@ open class RadioSwatchBase: Control { return swatchSize } - open func updateSelector(_ viewModel: ModelType) { + open func updateSelector() { //get the colors - let backgroundColor = radioSwatchBackgroundColorConfiguration.getColor(viewModel) - let borderColor = viewModel.selected ? radioSwatchBorderColorConfiguration.getColor(viewModel) : .clear - let fillBorderColor = radioSwatchFillBorderColorConfiguration.getColor(viewModel) + let backgroundColor = radioSwatchBackgroundColorConfiguration.getColor(self) + let borderColor = isSelected ? radioSwatchBorderColorConfiguration.getColor(self) : .clear + let fillBorderColor = radioSwatchFillBorderColorConfiguration.getColor(self) selectorView.backgroundColor = backgroundColor selectorView.layer.borderColor = borderColor.cgColor selectorView.layer.cornerRadius = selectorView.bounds.width * 0.5 - selectorView.layer.borderWidth = viewModel.selected ? selectorBorderWidth : 0 + selectorView.layer.borderWidth = isSelected ? selectorBorderWidth : 0 selectorView.layer.masksToBounds = true gradientLayer?.removeFromSuperlayer() @@ -215,14 +216,14 @@ open class RadioSwatchBase: Control { var fillColorBackground: UIColor = .clear - if let fillImage = viewModel.fillImage { - fillView.image = viewModel.disabled ? fillImage.image(alpha: disabledAlpha) : fillImage + if let fillImage { + fillView.image = disabled ? fillImage.image(alpha: disabledAlpha) : fillImage } else { fillView.image = nil - if let primary = viewModel.primaryColor, let secondary = viewModel.secondaryColor { - let firstColor = viewModel.disabled ? primary.withAlphaComponent(disabledAlpha) : primary - let secondColor = viewModel.disabled ? secondary.withAlphaComponent(disabledAlpha) : secondary + if let primary = primaryColor, let secondary = secondaryColor { + let firstColor = disabled ? primary.withAlphaComponent(disabledAlpha) : primary + let secondColor = disabled ? secondary.withAlphaComponent(disabledAlpha) : secondary let gradient = CAGradientLayer() gradientLayer = gradient gradient.frame = fillView.bounds @@ -231,10 +232,11 @@ open class RadioSwatchBase: Control { gradient.transform = CATransform3DMakeRotation(135.0 / 180.0 * .pi, 0.0, 0.0, 1.0) fillView.layer.addSublayer(gradient) } else { - fillColorBackground = viewModel.primaryColor ?? .white + fillColorBackground = primaryColor ?? .white } } - fillView.backgroundColor = viewModel.disabled ? fillColorBackground.withAlphaComponent(disabledAlpha) : fillColorBackground + + fillView.backgroundColor = disabled ? fillColorBackground.withAlphaComponent(disabledAlpha) : fillColorBackground fillView.layer.borderColor = fillBorderColor.cgColor fillView.layer.cornerRadius = fillView.bounds.width * 0.5 fillView.layer.borderWidth = selectorBorderWidth @@ -250,12 +252,12 @@ open class RadioSwatchBase: Control { open override func draw(_ layer: CALayer, in ctx: CGContext) { - let borderColor = radioSwatchBorderColorConfiguration.getColor(model) + let borderColor = radioSwatchBorderColorConfiguration.getColor(self) shapeLayer?.removeFromSuperlayer() shapeLayer = nil - if model.strikethrough { + if strikethrough { let bounds = selectorView.bounds let length = max(bounds.size.height, bounds.size.width) guard length > 0.0, shapeLayer == nil else { return } diff --git a/VDS/Components/RadioSwatch/RadioSwatchGroup.swift b/VDS/Components/RadioSwatch/RadioSwatchGroup.swift index 1769a89a..e6f1a242 100644 --- a/VDS/Components/RadioSwatch/RadioSwatchGroup.swift +++ b/VDS/Components/RadioSwatch/RadioSwatchGroup.swift @@ -9,29 +9,31 @@ import Foundation import UIKit import Combine -public class RadioSwatchGroup: RadioSwatchGroupBase { +public class RadioSwatchGroup: RadioSwatchGroupBase { public override func didSelect(selector: RadioSwatch) { - if let index = model.selectors.firstIndex(where: {$0.selected == true }), + if let index = selectorViews.firstIndex(where: {$0.isSelected == true }), let cell = collectionView.cellForItem(at: IndexPath(item: index, section: 0)) as? CollectionViewCell { cell.modelHandler.toggle() } selector.toggle() - label.text = selector.model.text + label.text = selector.text valueChanged() } } -public class RadioSwatchGroupBase>: Control, UICollectionViewDataSource, UICollectionViewDelegateFlowLayout, UICollectionViewDelegate { +public class RadioSwatchGroupBase: SelectorGroupSelectedHandlerBase, UICollectionViewDataSource, UICollectionViewDelegateFlowLayout, UICollectionViewDelegate { //-------------------------------------------------- // MARK: - Public Properties //-------------------------------------------------- - public var selectedModel: ModelHandlerType.ModelType? { - return model.selectedModel + public override var selectorViews: [ModelHandlerType] { + didSet { + collectionView.reloadData() + } } - + //-------------------------------------------------- // MARK: - Private Properties //-------------------------------------------------- @@ -109,16 +111,14 @@ public class RadioSwatchGroupBase 0 else { + guard selectorViews.count > 0 else { collectionViewHeight?.constant = 0 return } // Calculate the height let swatchesInRow = floor(CGFloat(collectionView.bounds.width/(cellSize + itemSpacing))) - let numberOfRows = ceil(CGFloat(swatches.count)/swatchesInRow) + let numberOfRows = ceil(CGFloat(selectorViews.count)/swatchesInRow) let height = (numberOfRows * cellSize) + (itemSpacing * (numberOfRows-1)) collectionViewHeight?.constant = CGFloat(height) @@ -130,31 +130,23 @@ public class RadioSwatchGroupBase Bool { - return !model.selectors[indexPath.row].disabled + return !selectorViews[indexPath.row].disabled } open func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) { @@ -182,34 +174,16 @@ public class RadioSwatchGroupBase Int { - return model.selectors.count + return selectorViews.count } - var cellsubs: [Int: AnyCancellable] = [:] public func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell { guard let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "collectionViewCell", for: indexPath) as? CollectionViewCell else { return UICollectionViewCell() } - let model = model.selectors[indexPath.row] + let model = selectorViews[indexPath.row] + cell.modelHandler = selectorViews[indexPath.row] cell.modelHandler.isUserInteractionEnabled = false - - //cancel if sub exists - if let sub = cellsubs[indexPath.row] { - sub.cancel() - cellsubs[indexPath.row] = nil - } - - let sub = cell.modelHandler - .handlerPublisher() - .sink { [weak self] changed in - if cell.modelHandler.shouldUpdateView(viewModel: model) { - print("Model Change: \(changed)") - self?.replace(viewModel: changed) - } - } - cellsubs[indexPath.row] = sub - - cell.set(with: model) return cell } @@ -217,18 +191,4 @@ public class RadioSwatchGroupBase else { - return nil - } - return cell.modelHandler - } } diff --git a/VDS/Components/Toggle/Toggle.swift b/VDS/Components/Toggle/Toggle.swift index 9157e2e5..aed60e41 100644 --- a/VDS/Components/Toggle/Toggle.swift +++ b/VDS/Components/Toggle/Toggle.swift @@ -18,7 +18,7 @@ import Combine Knob: The circular indicator that slides on the container. */ -public class Toggle: ToggleBase{ +public class Toggle: ToggleBase{ public override func initialSetup() { super.initialSetup() publisher(for: .touchUpInside) @@ -28,7 +28,25 @@ public class Toggle: ToggleBase{ } } -open class ToggleBase: Control { +open class ToggleBase: Control, Accessable, DataTrackable, BinaryColorable { + + //-------------------------------------------------- + // MARK: - Initializers + //-------------------------------------------------- + required public init() { + super.init(frame: .zero) + initialSetup() + } + + public override init(frame: CGRect) { + super.init(frame: .zero) + initialSetup() + } + + public required init?(coder: NSCoder) { + super.init(coder: coder) + initialSetup() + } //-------------------------------------------------- // MARK: - Private Properties @@ -86,62 +104,60 @@ open class ToggleBase: Control { $0.forFalse.disabled.darkColor = VDSColor.paletteGray44 } + private var typograpicalStyle: TypographicalStyle { + if textSize == .small { + if textWeight == .bold { + return .BoldBodySmall + } else { + return .BodySmall + } + } else { + if textWeight == .bold { + return .BoldBodyLarge + } else { + return .BodyLarge + } + } + } + //-------------------------------------------------- // MARK: - Public Properties //-------------------------------------------------- - @Proxy(\.model.on) - open var isOn: Bool + open var isOn: Bool = false { didSet { subject.send() }} - @Proxy(\.model.showText) - public var showText: Bool + public var showText: Bool = false { didSet { subject.send() }} - @Proxy(\.model.onText) - public var onText: String + public var onText: String = "On" { didSet { subject.send() }} - @Proxy(\.model.offText) - public var offText: String + public var offText: String = "Off" { didSet { subject.send() }} - @Proxy(\.model.textSize) - public var textSize: ToggleTextSize + public var textSize: ToggleTextSize = .small { didSet { subject.send() }} - @Proxy(\.model.textWeight) - public var textWeight: ToggleTextWeight + public var textWeight: ToggleTextWeight = .regular { didSet { subject.send() }} - @Proxy(\.model.textPosition) - public var textPosition: ToggleTextPosition + public var textPosition: ToggleTextPosition = .left { didSet { subject.send() }} - @Proxy(\.model.inputId) - open var inputId: String? + open var inputId: String? { didSet { subject.send() }} - @Proxy(\.model.value) - open var value: AnyHashable? + open var value: AnyHashable? { didSet { subject.send() }} - @Proxy(\.model.dataAnalyticsTrack) - open var dataAnalyticsTrack: String? + open var dataAnalyticsTrack: String? { didSet { subject.send() }} - @Proxy(\.model.dataClickStream) - open var dataClickStream: String? + open var dataClickStream: String? { didSet { subject.send() }} - @Proxy(\.model.dataTrack) - open var dataTrack: String? + open var dataTrack: String? { didSet { subject.send() }} - @Proxy(\.model.accessibilityHintEnabled) - open var accessibilityHintEnabled: String? + open var accessibilityHintEnabled: String? { didSet { subject.send() }} - @Proxy(\.model.accessibilityHintDisabled) - open var accessibilityHintDisabled: String? + open var accessibilityHintDisabled: String? { didSet { subject.send() }} - @Proxy(\.model.accessibilityValueEnabled) - open var accessibilityValueEnabled: String? + open var accessibilityValueEnabled: String? { didSet { subject.send() }} - @Proxy(\.model.accessibilityValueDisabled) - open var accessibilityValueDisabled: String? + open var accessibilityValueDisabled: String? { didSet { subject.send() }} - @Proxy(\.model.accessibilityLabelEnabled) - open var accessibilityLabelEnabled: String? + open var accessibilityLabelEnabled: String? { didSet { subject.send() }} - @Proxy(\.model.accessibilityLabelDisabled) - open var accessibilityLabelDisabled: String? + open var accessibilityLabelDisabled: String? { didSet { subject.send() }} //-------------------------------------------------- // MARK: - Constraints @@ -157,12 +173,12 @@ open class ToggleBase: Control { //-------------------------------------------------- // MARK: - Toggle //-------------------------------------------------- - private func updateToggle(_ viewModel: ModelType) { + private func updateToggle() { //private func func constrainKnob(){ self.knobLeadingConstraint?.isActive = false self.knobTrailingConstraint?.isActive = false - if viewModel.on { + if isOn { self.knobTrailingConstraint = self.toggleView.trailingAnchor.constraint(equalTo: self.knobView.trailingAnchor, constant: 2) self.knobLeadingConstraint = self.knobView.leadingAnchor.constraint(greaterThanOrEqualTo: self.toggleView.leadingAnchor) } else { @@ -175,10 +191,10 @@ open class ToggleBase: Control { self.layoutIfNeeded() } - let toggleColor = toggleColorConfiguration.getColor(viewModel) - let knobColor = knobColorConfiguration.getColor(viewModel) + let toggleColor = toggleColorConfiguration.getColor(self) + let knobColor = knobColorConfiguration.getColor(self) - if viewModel.disabled { + if disabled { toggleView.backgroundColor = toggleColor knobView.backgroundColor = knobColor constrainKnob() @@ -197,16 +213,21 @@ open class ToggleBase: Control { //-------------------------------------------------- // MARK: - Labels //-------------------------------------------------- - private func updateLabel(_ viewModel: ModelType) { - let showText = viewModel.showText - stackView.spacing = showText ? 12 : 0 - label.set(with: viewModel.labelModel) + private func updateLabel() { + stackView.spacing = showText ? 12 : 0 + if stackView.subviews.contains(label) { label.removeFromSuperview() } if showText { + label.textPosition = textPosition == .left ? .left : .right + label.typograpicalStyle = typograpicalStyle + label.text = isOn ? onText : offText + label.surface = surface + label.disabled = disabled + if textPosition == .left { stackView.insertArrangedSubview(label, at: 0) } else { @@ -246,7 +267,7 @@ open class ToggleBase: Control { toggleView.layer.cornerRadius = toggleSize.height / 2.0 knobView.layer.cornerRadius = knobSize.height / 2.0 - toggleView.backgroundColor = toggleColorConfiguration.getColor(model) + toggleView.backgroundColor = toggleColorConfiguration.getColor(self) toggleContainerView.addSubview(toggleView) toggleView.addSubview(knobView) @@ -261,7 +282,7 @@ open class ToggleBase: Control { toggleView.bottomAnchor.constraint(greaterThanOrEqualTo: knobView.bottomAnchor).isActive = true - updateLabel(model) + updateLabel() stackView.addArrangedSubview(toggleContainerView) stackView.topAnchor.constraint(equalTo: topAnchor).isActive = true stackView.leadingAnchor.constraint(equalTo: leadingAnchor).isActive = true @@ -275,8 +296,8 @@ open class ToggleBase: Control { public override func reset() { super.reset() - toggleView.backgroundColor = toggleColorConfiguration.getColor(model) - knobView.backgroundColor = knobColorConfiguration.getColor(model) + toggleView.backgroundColor = toggleColorConfiguration.getColor(self) + knobView.backgroundColor = knobColorConfiguration.getColor(self) setAccessibilityLabel() } @@ -289,13 +310,13 @@ open class ToggleBase: Control { //-------------------------------------------------- // MARK: - State //-------------------------------------------------- - open override func updateView(viewModel: ModelType) { - updateLabel(viewModel) - updateToggle(viewModel) + open override func updateView() { + updateLabel() + updateToggle() setAccessibilityHint() - setAccessibilityValue(viewModel.on) - setAccessibilityLabel(viewModel.on) - backgroundColor = viewModel.surface.color + setAccessibilityValue(isOn) + setAccessibilityLabel(isOn) + backgroundColor = surface.color setNeedsLayout() layoutIfNeeded() } diff --git a/VDS/Protocols/Accessable.swift b/VDS/Protocols/Accessable.swift index fd9ad370..0b2981fe 100644 --- a/VDS/Protocols/Accessable.swift +++ b/VDS/Protocols/Accessable.swift @@ -18,37 +18,31 @@ public protocol Accessable { } //Configurations to set within the UIControl -extension ModelHandlerable where Self: UIView { - private var accessableModel: Accessable? { - guard let model = self.model as? Accessable else { - return nil - } - return model - } - +extension ModelHandlerable where Self: UIView, Self: Accessable { + public func setAccessibilityHint(_ override: Bool? = nil) { - let check = override ?? !model.disabled - if let value = accessableModel?.accessibilityHintEnabled, check { + let check = override ?? !disabled + if let value = accessibilityHintEnabled, check { accessibilityHint = value - } else if let value = accessableModel?.accessibilityHintDisabled, !check { + } else if let value = accessibilityHintDisabled, !check { accessibilityHint = value } } public func setAccessibilityValue(_ override: Bool? = nil) { - let check = override ?? !model.disabled - if let value = accessableModel?.accessibilityValueEnabled, check { + let check = override ?? !disabled + if let value = accessibilityValueEnabled, check { accessibilityValue = value - } else if let value = accessableModel?.accessibilityValueDisabled, !check { + } else if let value = accessibilityValueDisabled, !check { accessibilityValue = value } } public func setAccessibilityLabel(_ override: Bool? = nil) { - let check = override ?? !model.disabled - if let value = accessableModel?.accessibilityLabelEnabled, check { + let check = override ?? !disabled + if let value = accessibilityLabelEnabled, check { accessibilityLabel = value - } else if let value = accessableModel?.accessibilityLabelDisabled, !check { + } else if let value = accessibilityLabelDisabled, !check { accessibilityLabel = value } } diff --git a/VDS/Protocols/ModelHandlerable.swift b/VDS/Protocols/ModelHandlerable.swift index 0b3c684e..feab652e 100644 --- a/VDS/Protocols/ModelHandlerable.swift +++ b/VDS/Protocols/ModelHandlerable.swift @@ -9,44 +9,26 @@ import Foundation import Combine import UIKit -public protocol ModelHandlerable: AnyObject, Initable { - associatedtype ModelType: Modelable - var model: ModelType { get set } - var modelPublisher: Published.Publisher { get } +public protocol ModelHandlerable: AnyObject, Initable, Disabling, Surfaceable { + var subject: PassthroughSubject { get set } var subscribers: Set { get set } - init(with model: ModelType) - func set(with model: ModelType) - func shouldUpdateView(viewModel: ModelType) -> Bool - func updateView(viewModel: ModelType) + func updateView() } extension ModelHandlerable { - public init() { - self.init(with: ModelType()) - } - - public func set(with model: ModelType) { - if shouldUpdateView(viewModel: model){ - updateView(viewModel: model) - self.model = model - } - } - - public func shouldUpdateView(viewModel: ModelType) -> Bool { - model != viewModel - } public func setupUpdateView() { handlerPublisher() .subscribe(on: RunLoop.main) - .sink { [weak self] viewModel in - self?.updateView(viewModel: viewModel) + .sink { [weak self] _ in + self?.updateView() } .store(in: &subscribers) } - public func handlerPublisher() -> AnyPublisher { - modelPublisher + public func handlerPublisher() -> AnyPublisher { + subject + .eraseToAnyPublisher() .debounce(for: .seconds(Constants.ModelStateDebounce), scheduler: RunLoop.main) .eraseToAnyPublisher() } From 63543b5cf56817b7ea86257434f07dacdcde026a Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Thu, 20 Oct 2022 13:13:28 -0500 Subject: [PATCH 12/29] fixed issues with init Signed-off-by: Matt Bruce --- VDS/Classes/CollectionView.swift | 1 + VDS/Classes/Control.swift | 1 + VDS/Classes/View.swift | 1 + VDS/Components/Checkbox/Checkbox.swift | 4 ---- VDS/Components/RadioBox/RadioBox.swift | 3 --- VDS/Components/RadioButton/RadioButton.swift | 3 --- VDS/Components/RadioSwatch/RadioSwatch.swift | 3 --- 7 files changed, 3 insertions(+), 13 deletions(-) diff --git a/VDS/Classes/CollectionView.swift b/VDS/Classes/CollectionView.swift index 41caa09e..f9500765 100644 --- a/VDS/Classes/CollectionView.swift +++ b/VDS/Classes/CollectionView.swift @@ -69,6 +69,7 @@ open class CollectionView: UICollectionView, ModelHandlerable, ViewProtocol, Res initialSetupPerformed = true setupUpdateView() setup() + updateView() } } diff --git a/VDS/Classes/Control.swift b/VDS/Classes/Control.swift index 2e06fd0e..2cd702de 100644 --- a/VDS/Classes/Control.swift +++ b/VDS/Classes/Control.swift @@ -65,6 +65,7 @@ open class Control: UIControl, ModelHandlerable, ViewProtocol, Resettable { initialSetupPerformed = true setupUpdateView() setup() + updateView() } } diff --git a/VDS/Classes/View.swift b/VDS/Classes/View.swift index b2bb0205..2a585e16 100644 --- a/VDS/Classes/View.swift +++ b/VDS/Classes/View.swift @@ -65,6 +65,7 @@ open class View: UIView, ModelHandlerable, ViewProtocol, Resettable { initialSetupPerformed = true setupUpdateView() setup() + updateView() } } diff --git a/VDS/Components/Checkbox/Checkbox.swift b/VDS/Components/Checkbox/Checkbox.swift index 036af81a..b556ba1b 100644 --- a/VDS/Components/Checkbox/Checkbox.swift +++ b/VDS/Components/Checkbox/Checkbox.swift @@ -24,23 +24,19 @@ public class SoloCheckbox: CheckboxBase{ } open class CheckboxBase: Control, Accessable, BinaryColorable, Errorable { - //-------------------------------------------------- // MARK: - Initializers //-------------------------------------------------- required public init() { super.init(frame: .zero) - initialSetup() } public override init(frame: CGRect) { super.init(frame: .zero) - initialSetup() } public required init?(coder: NSCoder) { super.init(coder: coder) - initialSetup() } //-------------------------------------------------- diff --git a/VDS/Components/RadioBox/RadioBox.swift b/VDS/Components/RadioBox/RadioBox.swift index f7e4ec71..cec0f44d 100644 --- a/VDS/Components/RadioBox/RadioBox.swift +++ b/VDS/Components/RadioBox/RadioBox.swift @@ -30,17 +30,14 @@ open class RadioBoxBase: Control, BinaryColorable, Accessable { //-------------------------------------------------- required public init() { super.init(frame: .zero) - initialSetup() } public override init(frame: CGRect) { super.init(frame: .zero) - initialSetup() } public required init?(coder: NSCoder) { super.init(coder: coder) - initialSetup() } //-------------------------------------------------- diff --git a/VDS/Components/RadioButton/RadioButton.swift b/VDS/Components/RadioButton/RadioButton.swift index 6e39b9b6..24588687 100644 --- a/VDS/Components/RadioButton/RadioButton.swift +++ b/VDS/Components/RadioButton/RadioButton.swift @@ -37,17 +37,14 @@ open class RadioButtonBase: Control, Accessable, BinaryColorable, Errorable { //-------------------------------------------------- required public init() { super.init(frame: .zero) - initialSetup() } public override init(frame: CGRect) { super.init(frame: .zero) - initialSetup() } public required init?(coder: NSCoder) { super.init(coder: coder) - initialSetup() } //-------------------------------------------------- diff --git a/VDS/Components/RadioSwatch/RadioSwatch.swift b/VDS/Components/RadioSwatch/RadioSwatch.swift index 8fef268d..0e280a35 100644 --- a/VDS/Components/RadioSwatch/RadioSwatch.swift +++ b/VDS/Components/RadioSwatch/RadioSwatch.swift @@ -28,17 +28,14 @@ open class RadioSwatchBase: Control, Accessable, DataTrackable, BinaryColorable //-------------------------------------------------- required public init() { super.init(frame: .zero) - initialSetup() } public override init(frame: CGRect) { super.init(frame: .zero) - initialSetup() } public required init?(coder: NSCoder) { super.init(coder: coder) - initialSetup() } //-------------------------------------------------- From fa39ce82d1f8ca747810e485406d6b212bf93601 Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Thu, 20 Oct 2022 13:13:38 -0500 Subject: [PATCH 13/29] fix toggle bugs Signed-off-by: Matt Bruce --- VDS/Components/Toggle/Toggle.swift | 53 ++++++++++++++---------------- 1 file changed, 25 insertions(+), 28 deletions(-) diff --git a/VDS/Components/Toggle/Toggle.swift b/VDS/Components/Toggle/Toggle.swift index aed60e41..0e01621e 100644 --- a/VDS/Components/Toggle/Toggle.swift +++ b/VDS/Components/Toggle/Toggle.swift @@ -35,17 +35,14 @@ open class ToggleBase: Control, Accessable, DataTrackable, BinaryColorable { //-------------------------------------------------- required public init() { super.init(frame: .zero) - initialSetup() } public override init(frame: CGRect) { super.init(frame: .zero) - initialSetup() } public required init?(coder: NSCoder) { super.init(coder: coder) - initialSetup() } //-------------------------------------------------- @@ -125,17 +122,17 @@ open class ToggleBase: Control, Accessable, DataTrackable, BinaryColorable { //-------------------------------------------------- open var isOn: Bool = false { didSet { subject.send() }} - public var showText: Bool = false { didSet { subject.send() }} + open var showText: Bool = false { didSet { subject.send() }} - public var onText: String = "On" { didSet { subject.send() }} + open var onText: String = "On" { didSet { subject.send() }} - public var offText: String = "Off" { didSet { subject.send() }} + open var offText: String = "Off" { didSet { subject.send() }} - public var textSize: ToggleTextSize = .small { didSet { subject.send() }} + open var textSize: ToggleTextSize = .small { didSet { subject.send() }} - public var textWeight: ToggleTextWeight = .regular { didSet { subject.send() }} + open var textWeight: ToggleTextWeight = .regular { didSet { subject.send() }} - public var textPosition: ToggleTextPosition = .left { didSet { subject.send() }} + open var textPosition: ToggleTextPosition = .left { didSet { subject.send() }} open var inputId: String? { didSet { subject.send() }} @@ -173,24 +170,23 @@ open class ToggleBase: Control, Accessable, DataTrackable, BinaryColorable { //-------------------------------------------------- // MARK: - Toggle //-------------------------------------------------- - private func updateToggle() { - //private func - func constrainKnob(){ - self.knobLeadingConstraint?.isActive = false - self.knobTrailingConstraint?.isActive = false - if isOn { - self.knobTrailingConstraint = self.toggleView.trailingAnchor.constraint(equalTo: self.knobView.trailingAnchor, constant: 2) - self.knobLeadingConstraint = self.knobView.leadingAnchor.constraint(greaterThanOrEqualTo: self.toggleView.leadingAnchor) - } else { - self.knobTrailingConstraint = self.toggleView.trailingAnchor.constraint(greaterThanOrEqualTo: self.knobView.trailingAnchor) - self.knobLeadingConstraint = self.knobView.leadingAnchor.constraint(equalTo: self.toggleView.leadingAnchor, constant: 2) - } - self.knobTrailingConstraint?.isActive = true - self.knobLeadingConstraint?.isActive = true - self.knobWidthConstraint?.constant = self.knobSize.width - self.layoutIfNeeded() + private func constrainKnob(){ + self.knobLeadingConstraint?.isActive = false + self.knobTrailingConstraint?.isActive = false + if isOn { + self.knobTrailingConstraint = self.toggleView.trailingAnchor.constraint(equalTo: self.knobView.trailingAnchor, constant: 2) + self.knobLeadingConstraint = self.knobView.leadingAnchor.constraint(greaterThanOrEqualTo: self.toggleView.leadingAnchor) + } else { + self.knobTrailingConstraint = self.toggleView.trailingAnchor.constraint(greaterThanOrEqualTo: self.knobView.trailingAnchor) + self.knobLeadingConstraint = self.knobView.leadingAnchor.constraint(equalTo: self.toggleView.leadingAnchor, constant: 2) } - + self.knobTrailingConstraint?.isActive = true + self.knobLeadingConstraint?.isActive = true + self.knobWidthConstraint?.constant = self.knobSize.width + self.layoutIfNeeded() + } + + private func updateToggle() { let toggleColor = toggleColorConfiguration.getColor(self) let knobColor = knobColorConfiguration.getColor(self) @@ -204,8 +200,8 @@ open class ToggleBase: Control, Accessable, DataTrackable, BinaryColorable { self.knobView.backgroundColor = knobColor }, completion: nil) - UIView.animate(withDuration: 0.33, delay: 0, usingSpringWithDamping: 0.7, initialSpringVelocity: 0.5, options: [], animations: { - constrainKnob() + UIView.animate(withDuration: 0.33, delay: 0, usingSpringWithDamping: 0.7, initialSpringVelocity: 0.5, options: [], animations: { [weak self] in + self?.constrainKnob() }, completion: nil) } } @@ -304,6 +300,7 @@ open class ToggleBase: Control, Accessable, DataTrackable, BinaryColorable { /// This will toggle the state of the Toggle and execute the actionBlock if provided. open func toggle() { isOn.toggle() + isSelected = isOn sendActions(for: .valueChanged) } From e53e66b96a25e01e3fbb69f9965cdb26e3c49789 Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Thu, 20 Oct 2022 13:17:16 -0500 Subject: [PATCH 14/29] updated Signed-off-by: Matt Bruce --- VDS/Classes/CollectionViewCell.swift | 1 + VDS/Components/Button/Button.swift | 1 + VDS/Components/Label/Label.swift | 1 + 3 files changed, 3 insertions(+) diff --git a/VDS/Classes/CollectionViewCell.swift b/VDS/Classes/CollectionViewCell.swift index 2a203dd8..773ec6e6 100644 --- a/VDS/Classes/CollectionViewCell.swift +++ b/VDS/Classes/CollectionViewCell.swift @@ -49,6 +49,7 @@ open class CollectionViewCell: UICo if !initialSetupPerformed { initialSetupPerformed = true setup() + modelHandler.updateView() } } diff --git a/VDS/Components/Button/Button.swift b/VDS/Components/Button/Button.swift index a7ffe8e4..e223c764 100644 --- a/VDS/Components/Button/Button.swift +++ b/VDS/Components/Button/Button.swift @@ -120,6 +120,7 @@ open class Button: UIButton, ModelHandlerable, ViewProtocol, Resettable, Useable accessibilityTraits = .staticText setupUpdateView() setup() + updateView() } open func setup() { diff --git a/VDS/Components/Label/Label.swift b/VDS/Components/Label/Label.swift index c3873cae..b277a8a9 100644 --- a/VDS/Components/Label/Label.swift +++ b/VDS/Components/Label/Label.swift @@ -90,6 +90,7 @@ open class LabelBase: UILabel, ModelHandlerable, ViewProtocol, Resettable { accessibilityTraits = .staticText setupUpdateView() setup() + updateView() } open func setup() {} From 60dbfa9d2b546d7bc6c014ded5d340c669434d80 Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Thu, 20 Oct 2022 14:06:03 -0500 Subject: [PATCH 15/29] refactored to use layoutSubviews Signed-off-by: Matt Bruce --- VDS/Classes/CollectionView.swift | 14 ++++--- VDS/Classes/Constants.swift | 2 +- VDS/Classes/Control.swift | 16 +++++--- VDS/Classes/View.swift | 17 +++++---- VDS/Components/Badge/Badge.swift | 20 +++++----- VDS/Components/Button/Button.swift | 27 +++++++------ VDS/Components/Checkbox/Checkbox.swift | 38 +++++++++---------- VDS/Components/Checkbox/CheckboxGroup.swift | 5 +++ VDS/Components/Label/Label.swift | 24 +++++++----- VDS/Components/RadioBox/RadioBox.swift | 38 +++++++++---------- VDS/Components/RadioBox/RadioBoxGroup.swift | 5 +++ VDS/Components/RadioButton/RadioButton.swift | 36 +++++++++--------- .../RadioButton/RadioButtonGroup.swift | 20 ++++------ VDS/Components/RadioSwatch/RadioSwatch.swift | 34 ++++++++--------- .../RadioSwatch/RadioSwatchGroup.swift | 1 - VDS/Components/Toggle/Toggle.swift | 38 +++++++++---------- VDS/Protocols/ModelHandlerable.swift | 18 ++++----- 17 files changed, 177 insertions(+), 176 deletions(-) diff --git a/VDS/Classes/CollectionView.swift b/VDS/Classes/CollectionView.swift index f9500765..e279c41c 100644 --- a/VDS/Classes/CollectionView.swift +++ b/VDS/Classes/CollectionView.swift @@ -22,7 +22,7 @@ open class CollectionView: UICollectionView, ModelHandlerable, ViewProtocol, Res //-------------------------------------------------- private var initialSetupPerformed = false - open var surface: Surface = .light { didSet { subject.send() }} + open var surface: Surface = .light { didSet { didChange() }} open var disabled: Bool = false { didSet { isEnabled = !disabled } } @@ -33,7 +33,7 @@ open class CollectionView: UICollectionView, ModelHandlerable, ViewProtocol, Res disabled = !newValue } isUserInteractionEnabled = isEnabled - subject.send() + didChange() } } @@ -67,18 +67,20 @@ open class CollectionView: UICollectionView, ModelHandlerable, ViewProtocol, Res open func initialSetup() { if !initialSetupPerformed { initialSetupPerformed = true - setupUpdateView() setup() updateView() } } + open override func layoutSubviews() { + super.layoutSubviews() + updateView() + } + //-------------------------------------------------- // MARK: - Overrides //-------------------------------------------------- - open func updateView() { - fatalError("Implement updateView") - } + open func updateView() {} open func reset() { backgroundColor = .clear diff --git a/VDS/Classes/Constants.swift b/VDS/Classes/Constants.swift index fe3bd6f0..2ad7285b 100644 --- a/VDS/Classes/Constants.swift +++ b/VDS/Classes/Constants.swift @@ -8,6 +8,6 @@ import Foundation public struct Constants { - public static let ModelStateDebounce = 0.02 + public static let ModelStateDebounce = 0.0 //.001 public static let PaddingOne = 10.0 } diff --git a/VDS/Classes/Control.swift b/VDS/Classes/Control.swift index 2cd702de..246b78a6 100644 --- a/VDS/Classes/Control.swift +++ b/VDS/Classes/Control.swift @@ -17,16 +17,18 @@ open class Control: UIControl, ModelHandlerable, ViewProtocol, Resettable { //-------------------------------------------------- public var subject = PassthroughSubject() public var subscribers = Set() - + //-------------------------------------------------- // MARK: - Properties //-------------------------------------------------- private var initialSetupPerformed = false - open var surface: Surface = .light { didSet { subject.send() }} + open var surface: Surface = .light { didSet { didChange() } } open var disabled: Bool = false { didSet { isEnabled = !disabled } } + open override var isSelected: Bool { didSet { didChange() } } + open override var isEnabled: Bool { get { !disabled } set { @@ -34,7 +36,7 @@ open class Control: UIControl, ModelHandlerable, ViewProtocol, Resettable { disabled = !newValue } isUserInteractionEnabled = isEnabled - subject.send() + didChange() } } @@ -63,7 +65,6 @@ open class Control: UIControl, ModelHandlerable, ViewProtocol, Resettable { open func initialSetup() { if !initialSetupPerformed { initialSetupPerformed = true - setupUpdateView() setup() updateView() } @@ -79,10 +80,13 @@ open class Control: UIControl, ModelHandlerable, ViewProtocol, Resettable { //-------------------------------------------------- // MARK: - Overrides //-------------------------------------------------- - open func updateView() { - fatalError("Implement updateView") + open override func layoutSubviews() { + super.layoutSubviews() + updateView() } + open func updateView() {} + open func reset() { backgroundColor = .clear surface = .light diff --git a/VDS/Classes/View.swift b/VDS/Classes/View.swift index 2a585e16..3d0d3841 100644 --- a/VDS/Classes/View.swift +++ b/VDS/Classes/View.swift @@ -17,13 +17,13 @@ open class View: UIView, ModelHandlerable, ViewProtocol, Resettable { //-------------------------------------------------- public var subject = PassthroughSubject() public var subscribers = Set() - + //-------------------------------------------------- // MARK: - Properties //-------------------------------------------------- private var initialSetupPerformed = false - open var surface: Surface = .light { didSet { subject.send() }} + open var surface: Surface = .light { didSet { didChange() }} open var disabled: Bool = false { didSet { isEnabled = !disabled } } @@ -34,7 +34,7 @@ open class View: UIView, ModelHandlerable, ViewProtocol, Resettable { disabled = !newValue } isUserInteractionEnabled = isEnabled - subject.send() + didChange() } } @@ -63,18 +63,19 @@ open class View: UIView, ModelHandlerable, ViewProtocol, Resettable { open func initialSetup() { if !initialSetupPerformed { initialSetupPerformed = true - setupUpdateView() setup() - updateView() } } + open override func layoutSubviews() { + super.layoutSubviews() + updateView() + } + //-------------------------------------------------- // MARK: - Overrides //-------------------------------------------------- - open func updateView() { - fatalError("Implement updateView") - } + open func updateView() {} open func reset() { backgroundColor = .clear diff --git a/VDS/Components/Badge/Badge.swift b/VDS/Components/Badge/Badge.swift index b6aceede..f90ed3e7 100644 --- a/VDS/Components/Badge/Badge.swift +++ b/VDS/Components/Badge/Badge.swift @@ -20,25 +20,25 @@ open class BadgeBase: View, Accessable { //-------------------------------------------------- // MARK: - Public Properties //-------------------------------------------------- - open var fillColor: BadgeFillColor = .red { didSet { subject.send() }} + open var fillColor: BadgeFillColor = .red { didSet { didChange() }} - open var text: String = "" { didSet { subject.send() }} + open var text: String = "" { didSet { didChange() }} - open var maxWidth: CGFloat? { didSet { subject.send() }} + open var maxWidth: CGFloat? { didSet { didChange() }} - open var numberOfLines: Int = 1 { didSet { subject.send() }} + open var numberOfLines: Int = 1 { didSet { didChange() }} - open var accessibilityHintEnabled: String? { didSet { subject.send() }} + open var accessibilityHintEnabled: String? { didSet { didChange() }} - open var accessibilityHintDisabled: String? { didSet { subject.send() }} + open var accessibilityHintDisabled: String? { didSet { didChange() }} - open var accessibilityValueEnabled: String? { didSet { subject.send() }} + open var accessibilityValueEnabled: String? { didSet { didChange() }} - open var accessibilityValueDisabled: String? { didSet { subject.send() }} + open var accessibilityValueDisabled: String? { didSet { didChange() }} - open var accessibilityLabelEnabled: String? { didSet { subject.send() }} + open var accessibilityLabelEnabled: String? { didSet { didChange() }} - open var accessibilityLabelDisabled: String? { didSet { subject.send() }} + open var accessibilityLabelDisabled: String? { didSet { didChange() }} //-------------------------------------------------- // MARK: - Constraints diff --git a/VDS/Components/Button/Button.swift b/VDS/Components/Button/Button.swift index e223c764..881bcefc 100644 --- a/VDS/Components/Button/Button.swift +++ b/VDS/Components/Button/Button.swift @@ -29,15 +29,15 @@ open class Button: UIButton, ModelHandlerable, ViewProtocol, Resettable, Useable //-------------------------------------------------- // MARK: - Properties //-------------------------------------------------- - open var text: String? { didSet { subject.send() }} + open var text: String? { didSet { didChange() } } - open var use: Use = .primary { didSet { subject.send() }} + open var use: Use = .primary { didSet { didChange() }} - open var size: ButtonSize = .large { didSet { subject.send() }} + open var size: ButtonSize = .large { didSet { didChange() }} - open var width: CGFloat? { didSet { subject.send() }} + open var width: CGFloat? { didSet { didChange() }} - open var surface: Surface = .light { didSet { subject.send() }} + open var surface: Surface = .light { didSet { didChange() }} open var disabled: Bool = false { didSet { isEnabled = !disabled } } @@ -48,7 +48,7 @@ open class Button: UIButton, ModelHandlerable, ViewProtocol, Resettable, Useable disabled = !newValue } isUserInteractionEnabled = isEnabled - subject.send() + didChange() } } @@ -118,9 +118,7 @@ open class Button: UIButton, ModelHandlerable, ViewProtocol, Resettable, Useable translatesAutoresizingMaskIntoConstraints = false accessibilityCustomActions = [] accessibilityTraits = .staticText - setupUpdateView() setup() - updateView() } open func setup() { @@ -146,6 +144,11 @@ open class Button: UIButton, ModelHandlerable, ViewProtocol, Resettable, Useable accessibilityCustomActions = [] accessibilityTraits = .staticText } + + open override func layoutSubviews() { + super.layoutSubviews() + updateView() + } //-------------------------------------------------- // MARK: - Overrides @@ -162,11 +165,7 @@ open class Button: UIButton, ModelHandlerable, ViewProtocol, Resettable, Useable let font = size == .large ? TypographicalStyle.BoldBodyLarge.font : TypographicalStyle.BoldBodySmall.font let edgeInsets = size.edgeInsets - if let text = text { - setTitle(text, for: .normal) - } else { - setTitle("No ViewModel Text", for: .normal) - } + setTitle(text ?? "No Text", for: .normal) titleLabel?.font = font backgroundColor = bgColor setTitleColor(titleColor, for: .normal) @@ -187,7 +186,7 @@ open class Button: UIButton, ModelHandlerable, ViewProtocol, Resettable, Useable minWidthConstraint?.isActive = true } } - + //-------------------------------------------------- // MARK: - PRIVATE //-------------------------------------------------- diff --git a/VDS/Components/Checkbox/Checkbox.swift b/VDS/Components/Checkbox/Checkbox.swift index b556ba1b..e0a5fbc5 100644 --- a/VDS/Components/Checkbox/Checkbox.swift +++ b/VDS/Components/Checkbox/Checkbox.swift @@ -91,41 +91,41 @@ open class CheckboxBase: Control, Accessable, BinaryColorable, Errorable { }() //can't bind to @Proxy - open override var isSelected: Bool { didSet { subject.send() }} + open override var isSelected: Bool { didSet { didChange() }} - open var labelText: String? { didSet { subject.send() }} + open var labelText: String? { didSet { didChange() }} - open var labelTextAttributes: [any LabelAttributeModel]? { didSet { subject.send() }} + open var labelTextAttributes: [any LabelAttributeModel]? { didSet { didChange() }} - open var childText: String? { didSet { subject.send() }} + open var childText: String? { didSet { didChange() }} - open var childTextAttributes: [any LabelAttributeModel]? { didSet { subject.send() }} + open var childTextAttributes: [any LabelAttributeModel]? { didSet { didChange() }} - open var showError: Bool = false { didSet { subject.send() }} + open var showError: Bool = false { didSet { didChange() }} - open var errorText: String? { didSet { subject.send() }} + open var errorText: String? { didSet { didChange() }} - open var inputId: String? { didSet { subject.send() }} + open var inputId: String? { didSet { didChange() }} - open var value: AnyHashable? { didSet { subject.send() }} + open var value: AnyHashable? { didSet { didChange() }} - open var dataAnalyticsTrack: String? { didSet { subject.send() }} + open var dataAnalyticsTrack: String? { didSet { didChange() }} - open var dataClickStream: String? { didSet { subject.send() }} + open var dataClickStream: String? { didSet { didChange() }} - open var dataTrack: String? { didSet { subject.send() }} + open var dataTrack: String? { didSet { didChange() }} - open var accessibilityHintEnabled: String? { didSet { subject.send() }} + open var accessibilityHintEnabled: String? { didSet { didChange() }} - open var accessibilityHintDisabled: String? { didSet { subject.send() }} + open var accessibilityHintDisabled: String? { didSet { didChange() }} - open var accessibilityValueEnabled: String? { didSet { subject.send() }} + open var accessibilityValueEnabled: String? { didSet { didChange() }} - open var accessibilityValueDisabled: String? { didSet { subject.send() }} + open var accessibilityValueDisabled: String? { didSet { didChange() }} - open var accessibilityLabelEnabled: String? { didSet { subject.send() }} + open var accessibilityLabelEnabled: String? { didSet { didChange() }} - open var accessibilityLabelDisabled: String? { didSet { subject.send() }} + open var accessibilityLabelDisabled: String? { didSet { didChange() }} private var labelModel: DefaultLabelModel? { guard let labelText = labelText else { return nil } @@ -289,8 +289,6 @@ open class CheckboxBase: Control, Accessable, BinaryColorable, Errorable { setAccessibilityHint() setAccessibilityValue(isSelected) setAccessibilityLabel(isSelected) - setNeedsLayout() - layoutIfNeeded() } diff --git a/VDS/Components/Checkbox/CheckboxGroup.swift b/VDS/Components/Checkbox/CheckboxGroup.swift index 8f1110a3..29dfa4c9 100644 --- a/VDS/Components/Checkbox/CheckboxGroup.swift +++ b/VDS/Components/Checkbox/CheckboxGroup.swift @@ -28,6 +28,11 @@ public class CheckboxGroupBase: SelectorGroupHan didSet { for selector in selectorViews { if !mainStackView.arrangedSubviews.contains(selector) { + selector + .publisher(for: .touchUpInside) + .sink { [weak self] handler in + self?.didSelect(handler) + }.store(in: &subscribers) mainStackView.addArrangedSubview(selector) } } diff --git a/VDS/Components/Label/Label.swift b/VDS/Components/Label/Label.swift index b277a8a9..d56e7c70 100644 --- a/VDS/Components/Label/Label.swift +++ b/VDS/Components/Label/Label.swift @@ -19,19 +19,20 @@ open class LabelBase: UILabel, ModelHandlerable, ViewProtocol, Resettable { //-------------------------------------------------- public var subject = PassthroughSubject() public var subscribers = Set() - + public var hasChanged: Bool = false + //-------------------------------------------------- // MARK: - Properties //-------------------------------------------------- - open var surface: Surface = .light { didSet { subject.send() }} + open var surface: Surface = .light { didSet { didChange() }} open var disabled: Bool = false { didSet { isEnabled = !disabled } } - open var attributes: [any LabelAttributeModel]? { didSet { subject.send() }} + open var attributes: [any LabelAttributeModel]? { didSet { didChange() }} - open var typograpicalStyle: TypographicalStyle = .defaultStyle { didSet { subject.send() }} + open var typograpicalStyle: TypographicalStyle = .defaultStyle { didSet { didChange() }} - open var textPosition: TextPosition = .left { didSet { subject.send() }} + open var textPosition: TextPosition = .left { didSet { didChange() }} open override var isEnabled: Bool { get { !disabled } @@ -40,13 +41,13 @@ open class LabelBase: UILabel, ModelHandlerable, ViewProtocol, Resettable { disabled = !newValue } isUserInteractionEnabled = isEnabled - subject.send() + didChange() } } override open var text: String? { didSet { - subject.send() + didChange() } } @@ -88,9 +89,7 @@ open class LabelBase: UILabel, ModelHandlerable, ViewProtocol, Resettable { translatesAutoresizingMaskIntoConstraints = false accessibilityCustomActions = [] accessibilityTraits = .staticText - setupUpdateView() setup() - updateView() } open func setup() {} @@ -107,10 +106,15 @@ open class LabelBase: UILabel, ModelHandlerable, ViewProtocol, Resettable { accessibilityTraits = .staticText numberOfLines = 0 } - + //-------------------------------------------------- // MARK: - Overrides //-------------------------------------------------- + open override func layoutSubviews() { + super.layoutSubviews() + updateView() + } + open func updateView() { textAlignment = textPosition.textAlignment textColor = textColorConfiguration.getColor(self) diff --git a/VDS/Components/RadioBox/RadioBox.swift b/VDS/Components/RadioBox/RadioBox.swift index cec0f44d..4d3bc664 100644 --- a/VDS/Components/RadioBox/RadioBox.swift +++ b/VDS/Components/RadioBox/RadioBox.swift @@ -82,41 +82,41 @@ open class RadioBoxBase: Control, BinaryColorable, Accessable { } }() - open var text: String = "Default Text" { didSet { subject.send() }} + open var text: String = "Default Text" { didSet { didChange() }} - open var textAttributes: [any LabelAttributeModel]? { didSet { subject.send() }} + open var textAttributes: [any LabelAttributeModel]? { didSet { didChange() }} - open var subText: String? { didSet { subject.send() }} + open var subText: String? { didSet { didChange() }} - open var subTextAttributes: [any LabelAttributeModel]? { didSet { subject.send() }} + open var subTextAttributes: [any LabelAttributeModel]? { didSet { didChange() }} - open var subTextRight: String? { didSet { subject.send() }} + open var subTextRight: String? { didSet { didChange() }} - open var subTextRightAttributes: [any LabelAttributeModel]? { didSet { subject.send() }} + open var subTextRightAttributes: [any LabelAttributeModel]? { didSet { didChange() }} - open var strikethrough: Bool = false { didSet { subject.send() }} + open var strikethrough: Bool = false { didSet { didChange() }} - open var inputId: String? { didSet { subject.send() }} + open var inputId: String? { didSet { didChange() }} - open var value: AnyHashable? { didSet { subject.send() }} + open var value: AnyHashable? { didSet { didChange() }} - open var dataAnalyticsTrack: String? { didSet { subject.send() }} + open var dataAnalyticsTrack: String? { didSet { didChange() }} - open var dataClickStream: String? { didSet { subject.send() }} + open var dataClickStream: String? { didSet { didChange() }} - open var dataTrack: String? { didSet { subject.send() }} + open var dataTrack: String? { didSet { didChange() }} - open var accessibilityHintEnabled: String? { didSet { subject.send() }} + open var accessibilityHintEnabled: String? { didSet { didChange() }} - open var accessibilityHintDisabled: String? { didSet { subject.send() }} + open var accessibilityHintDisabled: String? { didSet { didChange() }} - open var accessibilityValueEnabled: String? { didSet { subject.send() }} + open var accessibilityValueEnabled: String? { didSet { didChange() }} - open var accessibilityValueDisabled: String? { didSet { subject.send() }} + open var accessibilityValueDisabled: String? { didSet { didChange() }} - open var accessibilityLabelEnabled: String? { didSet { subject.send() }} + open var accessibilityLabelEnabled: String? { didSet { didChange() }} - open var accessibilityLabelDisabled: String? { didSet { subject.send() }} + open var accessibilityLabelDisabled: String? { didSet { didChange() }} //functions //-------------------------------------------------- @@ -222,8 +222,6 @@ open class RadioBoxBase: Control, BinaryColorable, Accessable { setAccessibilityHint() setAccessibilityValue(isSelected) setAccessibilityLabel(isSelected) - setNeedsLayout() - layoutIfNeeded() } diff --git a/VDS/Components/RadioBox/RadioBoxGroup.swift b/VDS/Components/RadioBox/RadioBoxGroup.swift index 5a0e323a..618eaf73 100644 --- a/VDS/Components/RadioBox/RadioBoxGroup.swift +++ b/VDS/Components/RadioBox/RadioBoxGroup.swift @@ -27,6 +27,11 @@ public class RadioBoxGroupBase: SelectorGroupSel didSet { for selector in selectorViews { if !mainStackView.arrangedSubviews.contains(selector) { + selector + .publisher(for: .touchUpInside) + .sink { [weak self] handler in + self?.didSelect(handler) + }.store(in: &subscribers) mainStackView.addArrangedSubview(selector) } } diff --git a/VDS/Components/RadioButton/RadioButton.swift b/VDS/Components/RadioButton/RadioButton.swift index 24588687..c5c42777 100644 --- a/VDS/Components/RadioButton/RadioButton.swift +++ b/VDS/Components/RadioButton/RadioButton.swift @@ -98,39 +98,39 @@ open class RadioButtonBase: Control, Accessable, BinaryColorable, Errorable { } }() - open var labelText: String? { didSet { subject.send() }} + open var labelText: String? { didSet { didChange() }} - open var labelTextAttributes: [any LabelAttributeModel]? { didSet { subject.send() }} + open var labelTextAttributes: [any LabelAttributeModel]? { didSet { didChange() }} - open var childText: String? { didSet { subject.send() }} + open var childText: String? { didSet { didChange() }} - open var childTextAttributes: [any LabelAttributeModel]? { didSet { subject.send() }} + open var childTextAttributes: [any LabelAttributeModel]? { didSet { didChange() }} - open var showError: Bool = false { didSet { subject.send() }} + open var showError: Bool = false { didSet { didChange() }} - open var errorText: String? { didSet { subject.send() }} + open var errorText: String? { didSet { didChange() }} - open var inputId: String? { didSet { subject.send() }} + open var inputId: String? { didSet { didChange() }} - open var value: AnyHashable? { didSet { subject.send() }} + open var value: AnyHashable? { didSet { didChange() }} - open var dataAnalyticsTrack: String? { didSet { subject.send() }} + open var dataAnalyticsTrack: String? { didSet { didChange() }} - open var dataClickStream: String? { didSet { subject.send() }} + open var dataClickStream: String? { didSet { didChange() }} - open var dataTrack: String? { didSet { subject.send() }} + open var dataTrack: String? { didSet { didChange() }} - open var accessibilityHintEnabled: String? { didSet { subject.send() }} + open var accessibilityHintEnabled: String? { didSet { didChange() }} - open var accessibilityHintDisabled: String? { didSet { subject.send() }} + open var accessibilityHintDisabled: String? { didSet { didChange() }} - open var accessibilityValueEnabled: String? { didSet { subject.send() }} + open var accessibilityValueEnabled: String? { didSet { didChange() }} - open var accessibilityValueDisabled: String? { didSet { subject.send() }} + open var accessibilityValueDisabled: String? { didSet { didChange() }} - open var accessibilityLabelEnabled: String? { didSet { subject.send() }} + open var accessibilityLabelEnabled: String? { didSet { didChange() }} - open var accessibilityLabelDisabled: String? { didSet { subject.send() }} + open var accessibilityLabelDisabled: String? { didSet { didChange() }} //-------------------------------------------------- // MARK: - Constraints @@ -262,8 +262,6 @@ open class RadioButtonBase: Control, Accessable, BinaryColorable, Errorable { setAccessibilityHint() setAccessibilityValue(isSelected) setAccessibilityLabel(isSelected) - setNeedsLayout() - layoutIfNeeded() } //-------------------------------------------------- diff --git a/VDS/Components/RadioButton/RadioButtonGroup.swift b/VDS/Components/RadioButton/RadioButtonGroup.swift index 57f3c0e3..9436d522 100644 --- a/VDS/Components/RadioButton/RadioButtonGroup.swift +++ b/VDS/Components/RadioButton/RadioButtonGroup.swift @@ -11,8 +11,7 @@ import UIKit public class RadioButtonGroup: RadioButtonGroupBase { public override func didSelect(_ selectedControl: RadioButton) { - let oldSelectedControl = selectorViews.filter { $0.isSelected == true }.first - oldSelectedControl?.toggle() + selectedHandler?.toggle() selectedControl.toggle() if showError { showError = false @@ -30,6 +29,11 @@ public class RadioButtonGroupBase: SelectorGr didSet { for selector in selectorViews { if !mainStackView.arrangedSubviews.contains(selector) { + selector + .publisher(for: .touchUpInside) + .sink { [weak self] handler in + self?.didSelect(handler) + }.store(in: &subscribers) mainStackView.addArrangedSubview(selector) } } @@ -41,7 +45,7 @@ public class RadioButtonGroupBase: SelectorGr get { _showError } set { var newShowError = newValue - if selectedModelHandler != nil, newShowError { + if selectedHandler != nil, newShowError { newShowError = false } selectorViews.forEach { handler in @@ -79,14 +83,4 @@ public class RadioButtonGroupBase: SelectorGr mainStackView.trailingAnchor.constraint(equalTo: trailingAnchor).isActive = true mainStackView.bottomAnchor.constraint(equalTo: bottomAnchor).isActive = true } - - public var selectedModelHandler: ModelHandlerType? { - if let index = selectorViews.firstIndex(where: { element in - return element.isSelected == true - }) { - return selectorViews[index] - } else { - return nil - } - } } diff --git a/VDS/Components/RadioSwatch/RadioSwatch.swift b/VDS/Components/RadioSwatch/RadioSwatch.swift index 0e280a35..5514cdaa 100644 --- a/VDS/Components/RadioSwatch/RadioSwatch.swift +++ b/VDS/Components/RadioSwatch/RadioSwatch.swift @@ -54,37 +54,37 @@ open class RadioSwatchBase: Control, Accessable, DataTrackable, BinaryColorable } }() - open var fillImage: UIImage? { didSet { subject.send() }} + open var fillImage: UIImage? { didSet { didChange() }} - open var text: String = "" { didSet { subject.send() }} + open var text: String = "" { didSet { didChange() }} - open var primaryColor: UIColor? { didSet { subject.send() }} + open var primaryColor: UIColor? { didSet { didChange() }} - open var secondaryColor: UIColor? { didSet { subject.send() }} + open var secondaryColor: UIColor? { didSet { didChange() }} - open var strikethrough: Bool = false { didSet { subject.send() }} + open var strikethrough: Bool = false { didSet { didChange() }} - open var inputId: String? { didSet { subject.send() }} + open var inputId: String? { didSet { didChange() }} - open var value: AnyHashable? { didSet { subject.send() }} + open var value: AnyHashable? { didSet { didChange() }} - open var dataAnalyticsTrack: String? { didSet { subject.send() }} + open var dataAnalyticsTrack: String? { didSet { didChange() }} - open var dataClickStream: String? { didSet { subject.send() }} + open var dataClickStream: String? { didSet { didChange() }} - open var dataTrack: String? { didSet { subject.send() }} + open var dataTrack: String? { didSet { didChange() }} - open var accessibilityHintEnabled: String? { didSet { subject.send() }} + open var accessibilityHintEnabled: String? { didSet { didChange() }} - open var accessibilityHintDisabled: String? { didSet { subject.send() }} + open var accessibilityHintDisabled: String? { didSet { didChange() }} - open var accessibilityValueEnabled: String? { didSet { subject.send() }} + open var accessibilityValueEnabled: String? { didSet { didChange() }} - open var accessibilityValueDisabled: String? { didSet { subject.send() }} + open var accessibilityValueDisabled: String? { didSet { didChange() }} - open var accessibilityLabelEnabled: String? { didSet { subject.send() }} + open var accessibilityLabelEnabled: String? { didSet { didChange() }} - open var accessibilityLabelDisabled: String? { didSet { subject.send() }} + open var accessibilityLabelDisabled: String? { didSet { didChange() }} //functions //-------------------------------------------------- @@ -143,8 +143,6 @@ open class RadioSwatchBase: Control, Accessable, DataTrackable, BinaryColorable setAccessibilityHint() setAccessibilityValue(isSelected) setAccessibilityLabel(isSelected) - setNeedsLayout() - layoutIfNeeded() } //-------------------------------------------------- diff --git a/VDS/Components/RadioSwatch/RadioSwatchGroup.swift b/VDS/Components/RadioSwatch/RadioSwatchGroup.swift index e6f1a242..93c7dae0 100644 --- a/VDS/Components/RadioSwatch/RadioSwatchGroup.swift +++ b/VDS/Components/RadioSwatch/RadioSwatchGroup.swift @@ -137,7 +137,6 @@ public class RadioSwatchGroupBase: SelectorGr label.surface = surface label.disabled = disabled collectionView.reloadData() - setNeedsLayout() } private func updateSelectors() { diff --git a/VDS/Components/Toggle/Toggle.swift b/VDS/Components/Toggle/Toggle.swift index 0e01621e..83c46c0c 100644 --- a/VDS/Components/Toggle/Toggle.swift +++ b/VDS/Components/Toggle/Toggle.swift @@ -120,41 +120,41 @@ open class ToggleBase: Control, Accessable, DataTrackable, BinaryColorable { //-------------------------------------------------- // MARK: - Public Properties //-------------------------------------------------- - open var isOn: Bool = false { didSet { subject.send() }} + open var isOn: Bool = false { didSet { didChange() }} - open var showText: Bool = false { didSet { subject.send() }} + open var showText: Bool = false { didSet { didChange() }} - open var onText: String = "On" { didSet { subject.send() }} + open var onText: String = "On" { didSet { didChange() }} - open var offText: String = "Off" { didSet { subject.send() }} + open var offText: String = "Off" { didSet { didChange() }} - open var textSize: ToggleTextSize = .small { didSet { subject.send() }} + open var textSize: ToggleTextSize = .small { didSet { didChange() }} - open var textWeight: ToggleTextWeight = .regular { didSet { subject.send() }} + open var textWeight: ToggleTextWeight = .regular { didSet { didChange() }} - open var textPosition: ToggleTextPosition = .left { didSet { subject.send() }} + open var textPosition: ToggleTextPosition = .left { didSet { didChange() }} - open var inputId: String? { didSet { subject.send() }} + open var inputId: String? { didSet { didChange() }} - open var value: AnyHashable? { didSet { subject.send() }} + open var value: AnyHashable? { didSet { didChange() }} - open var dataAnalyticsTrack: String? { didSet { subject.send() }} + open var dataAnalyticsTrack: String? { didSet { didChange() }} - open var dataClickStream: String? { didSet { subject.send() }} + open var dataClickStream: String? { didSet { didChange() }} - open var dataTrack: String? { didSet { subject.send() }} + open var dataTrack: String? { didSet { didChange() }} - open var accessibilityHintEnabled: String? { didSet { subject.send() }} + open var accessibilityHintEnabled: String? { didSet { didChange() }} - open var accessibilityHintDisabled: String? { didSet { subject.send() }} + open var accessibilityHintDisabled: String? { didSet { didChange() }} - open var accessibilityValueEnabled: String? { didSet { subject.send() }} + open var accessibilityValueEnabled: String? { didSet { didChange() }} - open var accessibilityValueDisabled: String? { didSet { subject.send() }} + open var accessibilityValueDisabled: String? { didSet { didChange() }} - open var accessibilityLabelEnabled: String? { didSet { subject.send() }} + open var accessibilityLabelEnabled: String? { didSet { didChange() }} - open var accessibilityLabelDisabled: String? { didSet { subject.send() }} + open var accessibilityLabelDisabled: String? { didSet { didChange() }} //-------------------------------------------------- // MARK: - Constraints @@ -314,7 +314,5 @@ open class ToggleBase: Control, Accessable, DataTrackable, BinaryColorable { setAccessibilityValue(isOn) setAccessibilityLabel(isOn) backgroundColor = surface.color - setNeedsLayout() - layoutIfNeeded() } } diff --git a/VDS/Protocols/ModelHandlerable.swift b/VDS/Protocols/ModelHandlerable.swift index feab652e..ab6bbcb4 100644 --- a/VDS/Protocols/ModelHandlerable.swift +++ b/VDS/Protocols/ModelHandlerable.swift @@ -16,16 +16,7 @@ public protocol ModelHandlerable: AnyObject, Initable, Disabling, Surfaceable { } extension ModelHandlerable { - - public func setupUpdateView() { - handlerPublisher() - .subscribe(on: RunLoop.main) - .sink { [weak self] _ in - self?.updateView() - } - .store(in: &subscribers) - } - + public func handlerPublisher() -> AnyPublisher { subject .eraseToAnyPublisher() @@ -33,3 +24,10 @@ extension ModelHandlerable { .eraseToAnyPublisher() } } + +extension ModelHandlerable where Self: UIView { + public func didChange() { + subject.send() + setNeedsLayout() + } +} From 0b237b48474028094ff52658a1dc3fb897a9f45e Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Thu, 20 Oct 2022 15:07:58 -0500 Subject: [PATCH 16/29] updated swatch Signed-off-by: Matt Bruce --- VDS/Classes/CollectionView.swift | 1 - VDS/Classes/CollectionViewCell.swift | 33 ++++++++------ VDS/Classes/Control.swift | 1 - VDS/Components/RadioSwatch/RadioSwatch.swift | 35 ++++++--------- .../RadioSwatch/RadioSwatchGroup.swift | 44 +++++++++---------- 5 files changed, 54 insertions(+), 60 deletions(-) diff --git a/VDS/Classes/CollectionView.swift b/VDS/Classes/CollectionView.swift index e279c41c..d74d88d6 100644 --- a/VDS/Classes/CollectionView.swift +++ b/VDS/Classes/CollectionView.swift @@ -68,7 +68,6 @@ open class CollectionView: UICollectionView, ModelHandlerable, ViewProtocol, Res if !initialSetupPerformed { initialSetupPerformed = true setup() - updateView() } } diff --git a/VDS/Classes/CollectionViewCell.swift b/VDS/Classes/CollectionViewCell.swift index 773ec6e6..753389fd 100644 --- a/VDS/Classes/CollectionViewCell.swift +++ b/VDS/Classes/CollectionViewCell.swift @@ -14,14 +14,26 @@ open class CollectionViewCell: UICo // MARK: - Properties //-------------------------------------------------- private var initialSetupPerformed = false - - public var modelHandler: ModelHandlerType = ModelHandlerType() - - @Proxy(\.modelHandler.surface) - open var surface: Surface - @Proxy(\.modelHandler.disabled) - open var disabled: Bool + public var modelHandler: ModelHandlerType? { + didSet { + if let oldValue { + oldValue.removeFromSuperview() + } + if let modelHandler { + addSubview(modelHandler) + modelHandler.didChange() + modelHandler.topAnchor.constraint(equalTo: topAnchor).isActive = true + modelHandler.leadingAnchor.constraint(equalTo: leadingAnchor).isActive = true + modelHandler.trailingAnchor.constraint(equalTo: trailingAnchor).isActive = true + modelHandler.bottomAnchor.constraint(equalTo: bottomAnchor).isActive = true + } + } + } + + open var surface: Surface = .light { didSet { modelHandler?.surface = surface } } + + open var disabled: Bool = false { didSet{ modelHandler?.disabled = disabled } } //-------------------------------------------------- // MARK: - Initializers @@ -49,7 +61,6 @@ open class CollectionViewCell: UICo if !initialSetupPerformed { initialSetupPerformed = true setup() - modelHandler.updateView() } } @@ -59,12 +70,6 @@ open class CollectionViewCell: UICo translatesAutoresizingMaskIntoConstraints = false insetsLayoutMarginsFromSafeArea = false - addSubview(modelHandler) - - modelHandler.topAnchor.constraint(equalTo: topAnchor).isActive = true - modelHandler.leadingAnchor.constraint(equalTo: leadingAnchor).isActive = true - modelHandler.trailingAnchor.constraint(equalTo: trailingAnchor).isActive = true - modelHandler.bottomAnchor.constraint(equalTo: bottomAnchor).isActive = true } open override func prepareForReuse() { diff --git a/VDS/Classes/Control.swift b/VDS/Classes/Control.swift index 246b78a6..ee069bf1 100644 --- a/VDS/Classes/Control.swift +++ b/VDS/Classes/Control.swift @@ -66,7 +66,6 @@ open class Control: UIControl, ModelHandlerable, ViewProtocol, Resettable { if !initialSetupPerformed { initialSetupPerformed = true setup() - updateView() } } diff --git a/VDS/Components/RadioSwatch/RadioSwatch.swift b/VDS/Components/RadioSwatch/RadioSwatch.swift index 5514cdaa..003feceb 100644 --- a/VDS/Components/RadioSwatch/RadioSwatch.swift +++ b/VDS/Components/RadioSwatch/RadioSwatch.swift @@ -104,9 +104,7 @@ open class RadioSwatchBase: Control, Accessable, DataTrackable, BinaryColorable addSubview(selectorView) selectorView.addSubview(fillView) - - updateSelector() - + selectorView.topAnchor.constraint(equalTo: topAnchor).isActive = true selectorView.leadingAnchor.constraint(equalTo: leadingAnchor).isActive = true selectorView.trailingAnchor.constraint(equalTo: trailingAnchor).isActive = true @@ -126,7 +124,7 @@ open class RadioSwatchBase: Control, Accessable, DataTrackable, BinaryColorable public override func reset() { super.reset() - updateSelector() + setNeedsDisplay() setAccessibilityLabel() } @@ -139,10 +137,10 @@ open class RadioSwatchBase: Control, Accessable, DataTrackable, BinaryColorable // MARK: - State //-------------------------------------------------- open override func updateView() { - updateSelector() setAccessibilityHint() setAccessibilityValue(isSelected) setAccessibilityLabel(isSelected) + setNeedsDisplay() } //-------------------------------------------------- @@ -195,8 +193,14 @@ open class RadioSwatchBase: Control, Accessable, DataTrackable, BinaryColorable return swatchSize } - open func updateSelector() { - //get the colors + open override func layoutSubviews() { + super.layoutSubviews() + // Accounts for any size changes + layer.setNeedsDisplay() + } + + open override func draw(_ layer: CALayer, in ctx: CGContext) { + let backgroundColor = radioSwatchBackgroundColorConfiguration.getColor(self) let borderColor = isSelected ? radioSwatchBorderColorConfiguration.getColor(self) : .clear let fillBorderColor = radioSwatchFillBorderColorConfiguration.getColor(self) @@ -236,23 +240,12 @@ open class RadioSwatchBase: Control, Accessable, DataTrackable, BinaryColorable fillView.layer.cornerRadius = fillView.bounds.width * 0.5 fillView.layer.borderWidth = selectorBorderWidth fillView.layer.masksToBounds = true - setNeedsDisplay() - } - - open override func layoutSubviews() { - super.layoutSubviews() - // Accounts for any size changes - layer.setNeedsDisplay() - } - - open override func draw(_ layer: CALayer, in ctx: CGContext) { - - let borderColor = radioSwatchBorderColorConfiguration.getColor(self) - + shapeLayer?.removeFromSuperlayer() shapeLayer = nil if strikethrough { + let strikeThroughBorderColor = radioSwatchBorderColorConfiguration.getColor(self) let bounds = selectorView.bounds let length = max(bounds.size.height, bounds.size.width) guard length > 0.0, shapeLayer == nil else { return } @@ -262,7 +255,7 @@ open class RadioSwatchBase: Control, Accessable, DataTrackable, BinaryColorable strikeThrough.fillColor = nil strikeThrough.opacity = 1.0 strikeThrough.lineWidth = strikeThroughLineThickness - strikeThrough.strokeColor = borderColor.cgColor + strikeThrough.strokeColor = strikeThroughBorderColor.cgColor let linePath = UIBezierPath() linePath.move(to: CGPoint(x: 0, y: bounds.height)) diff --git a/VDS/Components/RadioSwatch/RadioSwatchGroup.swift b/VDS/Components/RadioSwatch/RadioSwatchGroup.swift index 93c7dae0..bba253e9 100644 --- a/VDS/Components/RadioSwatch/RadioSwatchGroup.swift +++ b/VDS/Components/RadioSwatch/RadioSwatchGroup.swift @@ -12,10 +12,7 @@ import Combine public class RadioSwatchGroup: RadioSwatchGroupBase { public override func didSelect(selector: RadioSwatch) { - if let index = selectorViews.firstIndex(where: {$0.isSelected == true }), - let cell = collectionView.cellForItem(at: IndexPath(item: index, section: 0)) as? CollectionViewCell { - cell.modelHandler.toggle() - } + selectedHandler?.toggle() selector.toggle() label.text = selector.text valueChanged() @@ -57,7 +54,7 @@ public class RadioSwatchGroupBase: SelectorGr $0.showsVerticalScrollIndicator = false $0.isScrollEnabled = false $0.translatesAutoresizingMaskIntoConstraints = false - $0.register(CollectionViewCell.self, forCellWithReuseIdentifier: "collectionViewCell") + $0.register(UICollectionViewCell.self, forCellWithReuseIdentifier: "collectionViewCell") } }() @@ -66,13 +63,19 @@ public class RadioSwatchGroupBase: SelectorGr //-------------------------------------------------- override public var disabled: Bool { didSet { - updateSelectors() + for selector in selectorViews { + selector.disabled = disabled + } + collectionView.reloadData() } } override public var surface: Surface { didSet { - updateSelectors() + for selector in selectorViews { + selector.surface = surface + } + collectionView.reloadData() } } @@ -139,13 +142,6 @@ public class RadioSwatchGroupBase: SelectorGr collectionView.reloadData() } - private func updateSelectors() { - for selector in selectorViews { - selector.surface = surface - selector.disabled = disabled - } - } - //-------------------------------------------------- // MARK: - UICollectionViewDelegateFlowLayout //-------------------------------------------------- @@ -161,8 +157,7 @@ public class RadioSwatchGroupBase: SelectorGr } open func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) { - guard let cell = collectionView.cellForItem(at: indexPath) as? CollectionViewCell else { return } - didSelect(selector: cell.modelHandler) + didSelect(selector: selectorViews[indexPath.row]) } //-------------------------------------------------- @@ -176,15 +171,18 @@ public class RadioSwatchGroupBase: SelectorGr return selectorViews.count } - + var cellsubs: [Int: AnyCancellable] = [:] + public func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell { - guard let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "collectionViewCell", for: indexPath) as? CollectionViewCell else { return UICollectionViewCell() } - - let model = selectorViews[indexPath.row] - cell.modelHandler = selectorViews[indexPath.row] - cell.modelHandler.isUserInteractionEnabled = false + let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "collectionViewCell", for: indexPath) + let handler = selectorViews[indexPath.row] + handler.isUserInteractionEnabled = false + cell.addSubview(handler) + handler.topAnchor.constraint(equalTo: cell.topAnchor).isActive = true + handler.leadingAnchor.constraint(equalTo: cell.leadingAnchor).isActive = true + handler.trailingAnchor.constraint(equalTo: cell.trailingAnchor).isActive = true + handler.bottomAnchor.constraint(equalTo: cell.bottomAnchor).isActive = true return cell - } open func didSelect(selector: ModelHandlerType) { From b5314ad8794627c884f9e696ed80145cb7a056e1 Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Thu, 20 Oct 2022 15:12:25 -0500 Subject: [PATCH 17/29] deleted all models Signed-off-by: Matt Bruce --- VDS.xcodeproj/project.pbxproj | 48 ------- VDS/Components/Badge/Badge.swift | 6 +- VDS/Components/Badge/BadgeModel.swift | 53 -------- VDS/Components/Button/Button.swift | 5 + VDS/Components/Button/ButtonModel.swift | 33 ----- VDS/Components/Checkbox/Checkbox.swift | 35 ----- .../Checkbox/CheckboxGroupModel.swift | 29 ---- VDS/Components/Checkbox/CheckboxModel.swift | 123 ----------------- VDS/Components/Label/LabelModel.swift | 40 ------ .../RadioBox/RadioBoxGroupModel.swift | 26 ---- VDS/Components/RadioBox/RadioBoxModel.swift | 122 ----------------- .../RadioButton/RadioButtonGroupModel.swift | 30 ---- .../RadioButton/RadioButtonModel.swift | 128 ------------------ .../RadioSwatch/RadioSwatchGroupModel.swift | 36 ----- .../RadioSwatch/RadioSwatchModel.swift | 47 ------- VDS/Components/Toggle/Toggle.swift | 14 +- VDS/Components/Toggle/ToggleModel.swift | 91 ------------- 17 files changed, 22 insertions(+), 844 deletions(-) delete mode 100644 VDS/Components/Badge/BadgeModel.swift delete mode 100644 VDS/Components/Button/ButtonModel.swift delete mode 100644 VDS/Components/Checkbox/CheckboxGroupModel.swift delete mode 100644 VDS/Components/Checkbox/CheckboxModel.swift delete mode 100644 VDS/Components/Label/LabelModel.swift delete mode 100644 VDS/Components/RadioBox/RadioBoxGroupModel.swift delete mode 100644 VDS/Components/RadioBox/RadioBoxModel.swift delete mode 100644 VDS/Components/RadioButton/RadioButtonGroupModel.swift delete mode 100644 VDS/Components/RadioButton/RadioButtonModel.swift delete mode 100644 VDS/Components/RadioSwatch/RadioSwatchGroupModel.swift delete mode 100644 VDS/Components/RadioSwatch/RadioSwatchModel.swift delete mode 100644 VDS/Components/Toggle/ToggleModel.swift diff --git a/VDS.xcodeproj/project.pbxproj b/VDS.xcodeproj/project.pbxproj index 38ea3f2e..56ad00b9 100644 --- a/VDS.xcodeproj/project.pbxproj +++ b/VDS.xcodeproj/project.pbxproj @@ -9,18 +9,14 @@ /* Begin PBXBuildFile section */ 5F21D7BF28DCEB3D003E7CD6 /* Useable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5F21D7BE28DCEB3D003E7CD6 /* Useable.swift */; }; 5FC35BE328D51405004EBEAC /* Button.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5FC35BE228D51405004EBEAC /* Button.swift */; }; - 5FC35BE528D51414004EBEAC /* ButtonModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5FC35BE428D51413004EBEAC /* ButtonModel.swift */; }; EA1F265D28B944F00033E859 /* CollectionView.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA1F265B28B944F00033E859 /* CollectionView.swift */; }; EA1F265E28B944F00033E859 /* CollectionViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA1F265C28B944F00033E859 /* CollectionViewCell.swift */; }; - EA1F266428B945070033E859 /* RadioSwatchGroupModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA1F266028B945070033E859 /* RadioSwatchGroupModel.swift */; }; EA1F266528B945070033E859 /* RadioSwatch.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA1F266128B945070033E859 /* RadioSwatch.swift */; }; EA1F266628B945070033E859 /* RadioSwatchGroup.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA1F266228B945070033E859 /* RadioSwatchGroup.swift */; }; - EA1F266728B945070033E859 /* RadioSwatchModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA1F266328B945070033E859 /* RadioSwatchModel.swift */; }; EA336171288B19200071C351 /* VDS.docc in Sources */ = {isa = PBXBuildFile; fileRef = EA336170288B19200071C351 /* VDS.docc */; }; EA336177288B19210071C351 /* VDS.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = EA33616C288B19200071C351 /* VDS.framework */; }; EA33617C288B19210071C351 /* VDSTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA33617B288B19210071C351 /* VDSTests.swift */; }; EA33617D288B19210071C351 /* VDS.h in Headers */ = {isa = PBXBuildFile; fileRef = EA33616F288B19200071C351 /* VDS.h */; settings = {ATTRIBUTES = (Public, ); }; }; - EA3361A2288B1E840071C351 /* ToggleModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA3361A1288B1E840071C351 /* ToggleModel.swift */; }; EA3361A8288B23300071C351 /* UIColor.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA3361A7288B23300071C351 /* UIColor.swift */; }; EA3361AA288B25E40071C351 /* Disabling.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA3361A9288B25E40071C351 /* Disabling.swift */; }; EA3361AD288B26190071C351 /* DataTrackable.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA3361AC288B26190071C351 /* DataTrackable.swift */; }; @@ -41,24 +37,19 @@ EA3362302891EB4A0071C351 /* Fonts.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA33622F2891EB4A0071C351 /* Fonts.swift */; }; EA33623E2892EE950071C351 /* UIDevice.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA33623D2892EE950071C351 /* UIDevice.swift */; }; EA3362402892EF6C0071C351 /* Label.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA33623F2892EF6B0071C351 /* Label.swift */; }; - EA3362432892EFF20071C351 /* LabelModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA3362422892EFF20071C351 /* LabelModel.swift */; }; EA3362452892F9130071C351 /* Labelable.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA3362442892F9130071C351 /* Labelable.swift */; }; EA33624728931B050071C351 /* Initable.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA33624628931B050071C351 /* Initable.swift */; }; EA3C3B4C2894823E000CA526 /* AnyProxy.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA3C3B4B2894823E000CA526 /* AnyProxy.swift */; }; EA4DB18528CA967F00103EE3 /* SelectorGroupHandlerBase.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA4DB18428CA967F00103EE3 /* SelectorGroupHandlerBase.swift */; }; EA4DB2FD28D3D0CA00103EE3 /* AnyEquatable.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA4DB2FC28D3D0CA00103EE3 /* AnyEquatable.swift */; }; - EA4DB30028DCBC9900103EE3 /* BadgeModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA4DB2FF28DCBC9900103EE3 /* BadgeModel.swift */; }; EA4DB30228DCBCA500103EE3 /* Badge.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA4DB30128DCBCA500103EE3 /* Badge.swift */; }; EA84F6B128B94A2500D67ABC /* CodableColor.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA84F6B028B94A2500D67ABC /* CodableColor.swift */; }; EA89200228AECF2A006B9984 /* UIButton+Publisher.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA89200128AECF2A006B9984 /* UIButton+Publisher.swift */; }; EA89200428AECF4B006B9984 /* UITextField+Publisher.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA89200328AECF4B006B9984 /* UITextField+Publisher.swift */; }; EA89200628B526D6006B9984 /* CheckboxGroup.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA89200528B526D6006B9984 /* CheckboxGroup.swift */; }; - EA89200828B526E0006B9984 /* CheckboxGroupModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA89200728B526E0006B9984 /* CheckboxGroupModel.swift */; }; - EA89200D28B530FD006B9984 /* RadioBoxModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA89200C28B530FD006B9984 /* RadioBoxModel.swift */; }; EA89200F28B53921006B9984 /* Selectable.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA89200E28B53921006B9984 /* Selectable.swift */; }; EA89201328B568D8006B9984 /* RadioBox.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA89201228B568D8006B9984 /* RadioBox.swift */; }; EA89201528B56CF4006B9984 /* RadioBoxGroup.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA89201428B56CF4006B9984 /* RadioBoxGroup.swift */; }; - EA89201728B56CFF006B9984 /* RadioBoxGroupModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA89201628B56CFF006B9984 /* RadioBoxGroupModel.swift */; }; EAA5EEE228F4C62C003B3210 /* Colorable.swift in Sources */ = {isa = PBXBuildFile; fileRef = EAA5EEE128F4C62C003B3210 /* Colorable.swift */; }; EAA5EEE428F5B855003B3210 /* VerizonNHGDS-Light.otf in Resources */ = {isa = PBXBuildFile; fileRef = EAA5EEE328F5B855003B3210 /* VerizonNHGDS-Light.otf */; }; EAA5EEEF28F5C908003B3210 /* VDSTypographyTokens.xcframework in Frameworks */ = {isa = PBXBuildFile; fileRef = EAA5EEEC28F5C908003B3210 /* VDSTypographyTokens.xcframework */; }; @@ -69,7 +60,6 @@ EAA5EEF428F5C909003B3210 /* VDSFormControlsTokens.xcframework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = EAA5EEEE28F5C908003B3210 /* VDSFormControlsTokens.xcframework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; EAB1D29A28A5611D00DAE764 /* SelectorGroupModelable.swift in Sources */ = {isa = PBXBuildFile; fileRef = EAB1D29928A5611D00DAE764 /* SelectorGroupModelable.swift */; }; EAB1D29C28A5618900DAE764 /* RadioButtonGroup.swift in Sources */ = {isa = PBXBuildFile; fileRef = EAB1D29B28A5618900DAE764 /* RadioButtonGroup.swift */; }; - EAB1D29E28A5619500DAE764 /* RadioButtonGroupModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = EAB1D29D28A5619500DAE764 /* RadioButtonGroupModel.swift */; }; EAB1D2A128A598FE00DAE764 /* UsesAutoLayout.swift in Sources */ = {isa = PBXBuildFile; fileRef = EAB1D2A028A598FE00DAE764 /* UsesAutoLayout.swift */; }; EAB1D2A328A5994800DAE764 /* Debuggable.swift in Sources */ = {isa = PBXBuildFile; fileRef = EAB1D2A228A5994800DAE764 /* Debuggable.swift */; }; EAB1D2CD28ABE76100DAE764 /* Withable.swift in Sources */ = {isa = PBXBuildFile; fileRef = EAB1D2CC28ABE76000DAE764 /* Withable.swift */; }; @@ -78,7 +68,6 @@ EAB1D2EA28AE84AA00DAE764 /* UIControlPublisher.swift in Sources */ = {isa = PBXBuildFile; fileRef = EAB1D2E928AE84AA00DAE764 /* UIControlPublisher.swift */; }; EAD8D2C128BFDE8B006EB6A6 /* UIGestureRecognizer+Publisher.swift in Sources */ = {isa = PBXBuildFile; fileRef = EAD8D2C028BFDE8B006EB6A6 /* UIGestureRecognizer+Publisher.swift */; }; EAF7F0952899861000B287F5 /* Checkbox.swift in Sources */ = {isa = PBXBuildFile; fileRef = EAF7F0932899861000B287F5 /* Checkbox.swift */; }; - EAF7F0962899861000B287F5 /* CheckboxModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = EAF7F0942899861000B287F5 /* CheckboxModel.swift */; }; EAF7F09A2899B17200B287F5 /* CATransaction.swift in Sources */ = {isa = PBXBuildFile; fileRef = EAF7F0992899B17200B287F5 /* CATransaction.swift */; }; EAF7F09E289AAEC000B287F5 /* Constants.swift in Sources */ = {isa = PBXBuildFile; fileRef = EAF7F09D289AAEC000B287F5 /* Constants.swift */; }; EAF7F0A0289AB7EC00B287F5 /* View.swift in Sources */ = {isa = PBXBuildFile; fileRef = EAF7F09F289AB7EC00B287F5 /* View.swift */; }; @@ -95,7 +84,6 @@ EAF7F0B9289C139800B287F5 /* ColorConfiguration.swift in Sources */ = {isa = PBXBuildFile; fileRef = EAF7F0B8289C139800B287F5 /* ColorConfiguration.swift */; }; EAF7F0BB289D80ED00B287F5 /* Modelable.swift in Sources */ = {isa = PBXBuildFile; fileRef = EAF7F0BA289D80ED00B287F5 /* Modelable.swift */; }; EAF7F11728A1475A00B287F5 /* RadioButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = EAF7F11528A1475A00B287F5 /* RadioButton.swift */; }; - EAF7F11828A1475A00B287F5 /* RadioButtonModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = EAF7F11628A1475A00B287F5 /* RadioButtonModel.swift */; }; EAF7F13328A2A16500B287F5 /* LabelAttributeAttachment.swift in Sources */ = {isa = PBXBuildFile; fileRef = EAF7F13228A2A16500B287F5 /* LabelAttributeAttachment.swift */; }; /* End PBXBuildFile section */ @@ -128,19 +116,15 @@ /* Begin PBXFileReference section */ 5F21D7BE28DCEB3D003E7CD6 /* Useable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Useable.swift; sourceTree = ""; }; 5FC35BE228D51405004EBEAC /* Button.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Button.swift; sourceTree = ""; }; - 5FC35BE428D51413004EBEAC /* ButtonModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ButtonModel.swift; sourceTree = ""; }; EA1F265B28B944F00033E859 /* CollectionView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CollectionView.swift; sourceTree = ""; }; EA1F265C28B944F00033E859 /* CollectionViewCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CollectionViewCell.swift; sourceTree = ""; }; - EA1F266028B945070033E859 /* RadioSwatchGroupModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RadioSwatchGroupModel.swift; sourceTree = ""; }; EA1F266128B945070033E859 /* RadioSwatch.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RadioSwatch.swift; sourceTree = ""; }; EA1F266228B945070033E859 /* RadioSwatchGroup.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RadioSwatchGroup.swift; sourceTree = ""; }; - EA1F266328B945070033E859 /* RadioSwatchModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RadioSwatchModel.swift; sourceTree = ""; }; EA33616C288B19200071C351 /* VDS.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = VDS.framework; sourceTree = BUILT_PRODUCTS_DIR; }; EA33616F288B19200071C351 /* VDS.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = VDS.h; sourceTree = ""; }; EA336170288B19200071C351 /* VDS.docc */ = {isa = PBXFileReference; lastKnownFileType = folder.documentationcatalog; path = VDS.docc; sourceTree = ""; }; EA336176288B19210071C351 /* VDSTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = VDSTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; EA33617B288B19210071C351 /* VDSTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VDSTests.swift; sourceTree = ""; }; - EA3361A1288B1E840071C351 /* ToggleModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ToggleModel.swift; sourceTree = ""; }; EA3361A7288B23300071C351 /* UIColor.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UIColor.swift; sourceTree = ""; }; EA3361A9288B25E40071C351 /* Disabling.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Disabling.swift; sourceTree = ""; }; EA3361AC288B26190071C351 /* DataTrackable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DataTrackable.swift; sourceTree = ""; }; @@ -161,24 +145,19 @@ EA33622F2891EB4A0071C351 /* Fonts.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Fonts.swift; sourceTree = ""; }; EA33623D2892EE950071C351 /* UIDevice.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UIDevice.swift; sourceTree = ""; }; EA33623F2892EF6B0071C351 /* Label.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Label.swift; sourceTree = ""; }; - EA3362422892EFF20071C351 /* LabelModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LabelModel.swift; sourceTree = ""; }; EA3362442892F9130071C351 /* Labelable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Labelable.swift; sourceTree = ""; }; EA33624628931B050071C351 /* Initable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Initable.swift; sourceTree = ""; }; EA3C3B4B2894823E000CA526 /* AnyProxy.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AnyProxy.swift; sourceTree = ""; }; EA4DB18428CA967F00103EE3 /* SelectorGroupHandlerBase.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SelectorGroupHandlerBase.swift; sourceTree = ""; }; EA4DB2FC28D3D0CA00103EE3 /* AnyEquatable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AnyEquatable.swift; sourceTree = ""; }; - EA4DB2FF28DCBC9900103EE3 /* BadgeModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BadgeModel.swift; sourceTree = ""; }; EA4DB30128DCBCA500103EE3 /* Badge.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Badge.swift; sourceTree = ""; }; EA84F6B028B94A2500D67ABC /* CodableColor.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CodableColor.swift; sourceTree = ""; }; EA89200128AECF2A006B9984 /* UIButton+Publisher.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIButton+Publisher.swift"; sourceTree = ""; }; EA89200328AECF4B006B9984 /* UITextField+Publisher.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UITextField+Publisher.swift"; sourceTree = ""; }; EA89200528B526D6006B9984 /* CheckboxGroup.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CheckboxGroup.swift; sourceTree = ""; }; - EA89200728B526E0006B9984 /* CheckboxGroupModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CheckboxGroupModel.swift; sourceTree = ""; }; - EA89200C28B530FD006B9984 /* RadioBoxModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RadioBoxModel.swift; sourceTree = ""; }; EA89200E28B53921006B9984 /* Selectable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Selectable.swift; sourceTree = ""; }; EA89201228B568D8006B9984 /* RadioBox.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RadioBox.swift; sourceTree = ""; }; EA89201428B56CF4006B9984 /* RadioBoxGroup.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RadioBoxGroup.swift; sourceTree = ""; }; - EA89201628B56CFF006B9984 /* RadioBoxGroupModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RadioBoxGroupModel.swift; sourceTree = ""; }; EAA5EEE128F4C62C003B3210 /* Colorable.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Colorable.swift; sourceTree = ""; }; EAA5EEE328F5B855003B3210 /* VerizonNHGDS-Light.otf */ = {isa = PBXFileReference; lastKnownFileType = file; path = "VerizonNHGDS-Light.otf"; sourceTree = ""; }; EAA5EEEC28F5C908003B3210 /* VDSTypographyTokens.xcframework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcframework; name = VDSTypographyTokens.xcframework; path = ../SharedFrameworks/VDSTypographyTokens.xcframework; sourceTree = ""; }; @@ -186,7 +165,6 @@ EAA5EEEE28F5C908003B3210 /* VDSFormControlsTokens.xcframework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcframework; name = VDSFormControlsTokens.xcframework; path = ../SharedFrameworks/VDSFormControlsTokens.xcframework; sourceTree = ""; }; EAB1D29928A5611D00DAE764 /* SelectorGroupModelable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SelectorGroupModelable.swift; sourceTree = ""; }; EAB1D29B28A5618900DAE764 /* RadioButtonGroup.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RadioButtonGroup.swift; sourceTree = ""; }; - EAB1D29D28A5619500DAE764 /* RadioButtonGroupModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RadioButtonGroupModel.swift; sourceTree = ""; }; EAB1D2A028A598FE00DAE764 /* UsesAutoLayout.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UsesAutoLayout.swift; sourceTree = ""; }; EAB1D2A228A5994800DAE764 /* Debuggable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Debuggable.swift; sourceTree = ""; }; EAB1D2CC28ABE76000DAE764 /* Withable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Withable.swift; sourceTree = ""; }; @@ -195,7 +173,6 @@ EAB1D2E928AE84AA00DAE764 /* UIControlPublisher.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UIControlPublisher.swift; sourceTree = ""; }; EAD8D2C028BFDE8B006EB6A6 /* UIGestureRecognizer+Publisher.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIGestureRecognizer+Publisher.swift"; sourceTree = ""; }; EAF7F0932899861000B287F5 /* Checkbox.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Checkbox.swift; sourceTree = ""; }; - EAF7F0942899861000B287F5 /* CheckboxModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CheckboxModel.swift; sourceTree = ""; }; EAF7F0992899B17200B287F5 /* CATransaction.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CATransaction.swift; sourceTree = ""; }; EAF7F09D289AAEC000B287F5 /* Constants.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Constants.swift; sourceTree = ""; }; EAF7F09F289AB7EC00B287F5 /* View.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = View.swift; sourceTree = ""; }; @@ -212,7 +189,6 @@ EAF7F0B8289C139800B287F5 /* ColorConfiguration.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ColorConfiguration.swift; sourceTree = ""; }; EAF7F0BA289D80ED00B287F5 /* Modelable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Modelable.swift; sourceTree = ""; }; EAF7F11528A1475A00B287F5 /* RadioButton.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RadioButton.swift; sourceTree = ""; }; - EAF7F11628A1475A00B287F5 /* RadioButtonModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RadioButtonModel.swift; sourceTree = ""; }; EAF7F13228A2A16500B287F5 /* LabelAttributeAttachment.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LabelAttributeAttachment.swift; sourceTree = ""; }; /* End PBXFileReference section */ @@ -242,7 +218,6 @@ isa = PBXGroup; children = ( 5FC35BE228D51405004EBEAC /* Button.swift */, - 5FC35BE428D51413004EBEAC /* ButtonModel.swift */, ); path = Button; sourceTree = ""; @@ -251,9 +226,7 @@ isa = PBXGroup; children = ( EA1F266128B945070033E859 /* RadioSwatch.swift */, - EA1F266328B945070033E859 /* RadioSwatchModel.swift */, EA1F266228B945070033E859 /* RadioSwatchGroup.swift */, - EA1F266028B945070033E859 /* RadioSwatchGroupModel.swift */, ); path = RadioSwatch; sourceTree = ""; @@ -333,7 +306,6 @@ isa = PBXGroup; children = ( EA3361C228902D960071C351 /* Toggle.swift */, - EA3361A1288B1E840071C351 /* ToggleModel.swift */, ); path = Toggle; sourceTree = ""; @@ -431,7 +403,6 @@ isa = PBXGroup; children = ( EA33623F2892EF6B0071C351 /* Label.swift */, - EA3362422892EFF20071C351 /* LabelModel.swift */, EAF7F0A9289B13EF00B287F5 /* Attributes */, ); path = Label; @@ -440,7 +411,6 @@ EA4DB2FE28DCBC1900103EE3 /* Badge */ = { isa = PBXGroup; children = ( - EA4DB2FF28DCBC9900103EE3 /* BadgeModel.swift */, EA4DB30128DCBCA500103EE3 /* Badge.swift */, ); path = Badge; @@ -450,9 +420,7 @@ isa = PBXGroup; children = ( EA89201228B568D8006B9984 /* RadioBox.swift */, - EA89200C28B530FD006B9984 /* RadioBoxModel.swift */, EA89201428B56CF4006B9984 /* RadioBoxGroup.swift */, - EA89201628B56CFF006B9984 /* RadioBoxGroupModel.swift */, ); path = RadioBox; sourceTree = ""; @@ -492,9 +460,7 @@ isa = PBXGroup; children = ( EAF7F0932899861000B287F5 /* Checkbox.swift */, - EAF7F0942899861000B287F5 /* CheckboxModel.swift */, EA89200528B526D6006B9984 /* CheckboxGroup.swift */, - EA89200728B526E0006B9984 /* CheckboxGroupModel.swift */, ); path = Checkbox; sourceTree = ""; @@ -517,9 +483,7 @@ isa = PBXGroup; children = ( EAF7F11528A1475A00B287F5 /* RadioButton.swift */, - EAF7F11628A1475A00B287F5 /* RadioButtonModel.swift */, EAB1D29B28A5618900DAE764 /* RadioButtonGroup.swift */, - EAB1D29D28A5619500DAE764 /* RadioButtonGroupModel.swift */, ); path = RadioButton; sourceTree = ""; @@ -644,9 +608,6 @@ EA89200428AECF4B006B9984 /* UITextField+Publisher.swift in Sources */, EA3361C328902D960071C351 /* Toggle.swift in Sources */, EAF7F0A0289AB7EC00B287F5 /* View.swift in Sources */, - EAF7F11828A1475A00B287F5 /* RadioButtonModel.swift in Sources */, - EA89200D28B530FD006B9984 /* RadioBoxModel.swift in Sources */, - EA1F266728B945070033E859 /* RadioSwatchModel.swift in Sources */, EA89201328B568D8006B9984 /* RadioBox.swift in Sources */, EA84F6B128B94A2500D67ABC /* CodableColor.swift in Sources */, EA3362402892EF6C0071C351 /* Label.swift in Sources */, @@ -660,12 +621,9 @@ EAB1D2A128A598FE00DAE764 /* UsesAutoLayout.swift in Sources */, EAB1D2CD28ABE76100DAE764 /* Withable.swift in Sources */, EAF7F0952899861000B287F5 /* Checkbox.swift in Sources */, - EA89201728B56CFF006B9984 /* RadioBoxGroupModel.swift in Sources */, EA3361C9289054C50071C351 /* Surfaceable.swift in Sources */, - EA3361A2288B1E840071C351 /* ToggleModel.swift in Sources */, EA1F265D28B944F00033E859 /* CollectionView.swift in Sources */, EA4DB30228DCBCA500103EE3 /* Badge.swift in Sources */, - EA3362432892EFF20071C351 /* LabelModel.swift in Sources */, EA33624728931B050071C351 /* Initable.swift in Sources */, EAF7F0A4289B017C00B287F5 /* LabelAttributeModel.swift in Sources */, EAF7F0B1289B177F00B287F5 /* LabelAttributeColor.swift in Sources */, @@ -678,15 +636,12 @@ EAB1D2CF28ABEF2B00DAE764 /* Typography.swift in Sources */, EAF7F09A2899B17200B287F5 /* CATransaction.swift in Sources */, EA89200F28B53921006B9984 /* Selectable.swift in Sources */, - EAB1D29E28A5619500DAE764 /* RadioButtonGroupModel.swift in Sources */, EAF7F0A2289AFB3900B287F5 /* Errorable.swift in Sources */, EA3C3B4C2894823E000CA526 /* AnyProxy.swift in Sources */, - 5FC35BE528D51414004EBEAC /* ButtonModel.swift in Sources */, EA3361AF288B26310071C351 /* FormFieldable.swift in Sources */, EAB1D29A28A5611D00DAE764 /* SelectorGroupModelable.swift in Sources */, EAF7F0BB289D80ED00B287F5 /* Modelable.swift in Sources */, EA89201528B56CF4006B9984 /* RadioBoxGroup.swift in Sources */, - EA4DB30028DCBC9900103EE3 /* BadgeModel.swift in Sources */, EAF7F09E289AAEC000B287F5 /* Constants.swift in Sources */, EA1F266528B945070033E859 /* RadioSwatch.swift in Sources */, EA4DB18528CA967F00103EE3 /* SelectorGroupHandlerBase.swift in Sources */, @@ -694,10 +649,8 @@ EAF7F0AB289B13FD00B287F5 /* LabelAttributeFont.swift in Sources */, EAB1D29C28A5618900DAE764 /* RadioButtonGroup.swift in Sources */, EA336171288B19200071C351 /* VDS.docc in Sources */, - EAF7F0962899861000B287F5 /* CheckboxModel.swift in Sources */, EAB1D2E628AE842000DAE764 /* Publisher+Bind.swift in Sources */, EA3361AA288B25E40071C351 /* Disabling.swift in Sources */, - EA89200828B526E0006B9984 /* CheckboxGroupModel.swift in Sources */, EA3361B6288B2A410071C351 /* Control.swift in Sources */, EAB1D2A328A5994800DAE764 /* Debuggable.swift in Sources */, 5F21D7BF28DCEB3D003E7CD6 /* Useable.swift in Sources */, @@ -712,7 +665,6 @@ EA3361B8288B2AAA0071C351 /* ViewProtocol.swift in Sources */, EA3361BF288B2EA60071C351 /* ModelHandlerable.swift in Sources */, EA3361A8288B23300071C351 /* UIColor.swift in Sources */, - EA1F266428B945070033E859 /* RadioSwatchGroupModel.swift in Sources */, EA1F266628B945070033E859 /* RadioSwatchGroup.swift in Sources */, 5FC35BE328D51405004EBEAC /* Button.swift in Sources */, ); diff --git a/VDS/Components/Badge/Badge.swift b/VDS/Components/Badge/Badge.swift index f90ed3e7..2f1feed6 100644 --- a/VDS/Components/Badge/Badge.swift +++ b/VDS/Components/Badge/Badge.swift @@ -11,9 +11,11 @@ import VDSColorTokens import VDSFormControlsTokens import Combine -public class Badge: BadgeBase{} +public enum BadgeFillColor: String, Codable, CaseIterable { + case red, yellow, green, orange, blue, black, white +} -open class BadgeBase: View, Accessable { +public class Badge: View, Accessable { private var label = Label() diff --git a/VDS/Components/Badge/BadgeModel.swift b/VDS/Components/Badge/BadgeModel.swift deleted file mode 100644 index 93876157..00000000 --- a/VDS/Components/Badge/BadgeModel.swift +++ /dev/null @@ -1,53 +0,0 @@ -// -// BadgeModel.swift -// VDS -// -// Created by Matt Bruce on 9/22/22. -// - -import Foundation -import UIKit -import VDSColorTokens - -public enum BadgeFillColor: String, Codable, CaseIterable { - case red, yellow, green, orange, blue, black, white -} - -public protocol BadgeModel: Modelable, Accessable { - var fillColor: BadgeFillColor { get set } - var text: String { get set } - var maxWidth: CGFloat? { get set } - var numberOfLines: Int { get set } -} - -extension BadgeModel { - public var label: DefaultLabelModel { - var model = DefaultLabelModel() - model.textPosition = .left - model.typograpicalStyle = .BoldBodySmall - model.text = text - model.surface = surface - model.disabled = disabled - return model - } -} - -public struct DefaultBadgeModel: BadgeModel { - public var id = UUID() - public var fillColor: BadgeFillColor = .red - public var text: String = "" - public var maxWidth: CGFloat? - public var numberOfLines: Int = 1 - - public var surface: Surface = .light - public var disabled: Bool = false - - public var accessibilityHintEnabled: String? - public var accessibilityHintDisabled: String? - public var accessibilityValueEnabled: String? - public var accessibilityValueDisabled: String? - public var accessibilityLabelEnabled: String? - public var accessibilityLabelDisabled: String? - - public init() { } -} diff --git a/VDS/Components/Button/Button.swift b/VDS/Components/Button/Button.swift index 881bcefc..11f72e42 100644 --- a/VDS/Components/Button/Button.swift +++ b/VDS/Components/Button/Button.swift @@ -11,6 +11,11 @@ import VDSColorTokens import VDSFormControlsTokens import Combine +public enum ButtonSize: String, Codable, CaseIterable { + case large + case small +} + open class Button: UIButton, ModelHandlerable, ViewProtocol, Resettable, Useable { //-------------------------------------------------- diff --git a/VDS/Components/Button/ButtonModel.swift b/VDS/Components/Button/ButtonModel.swift deleted file mode 100644 index 140f5561..00000000 --- a/VDS/Components/Button/ButtonModel.swift +++ /dev/null @@ -1,33 +0,0 @@ -// -// ButtonModel.swift -// VDS -// -// Created by Jarrod Courtney on 9/16/22. -// - -import Foundation -import UIKit - -public enum ButtonSize: String, Codable, CaseIterable { - case large - case small -} - -public protocol ButtonModel: Modelable, Useable { - var text: String? { get set } - var width: CGFloat? { get set } - var size: ButtonSize { get set } - var use: Use { get set } -} - -public struct DefaultButtonModel: ButtonModel { - - public var id = UUID() - public var text: String? - public var surface: Surface = .light - public var use: Use = .primary - public var disabled: Bool = false - public var width: CGFloat? - public var size: ButtonSize = .large - public init(){} -} diff --git a/VDS/Components/Checkbox/Checkbox.swift b/VDS/Components/Checkbox/Checkbox.swift index e0a5fbc5..0d020dbb 100644 --- a/VDS/Components/Checkbox/Checkbox.swift +++ b/VDS/Components/Checkbox/Checkbox.swift @@ -126,41 +126,6 @@ open class CheckboxBase: Control, Accessable, BinaryColorable, Errorable { open var accessibilityLabelEnabled: String? { didSet { didChange() }} open var accessibilityLabelDisabled: String? { didSet { didChange() }} - - private var labelModel: DefaultLabelModel? { - guard let labelText = labelText else { return nil } - var model = DefaultLabelModel() - model.textPosition = .left - model.typograpicalStyle = .BoldBodyLarge - model.text = labelText - model.surface = surface - model.disabled = disabled - model.attributes = labelTextAttributes - return model - } - - private var childModel: DefaultLabelModel? { - guard let childText = childText else { return nil } - var model = DefaultLabelModel() - model.textPosition = .left - model.typograpicalStyle = .BodyLarge - model.text = childText - model.surface = surface - model.disabled = disabled - model.attributes = childTextAttributes - return model - } - - private var errorModel: DefaultLabelModel? { - guard let errorText = errorText, showError else { return nil } - var model = DefaultLabelModel() - model.textPosition = .left - model.typograpicalStyle = .BodyMedium - model.text = errorText - model.surface = surface - model.disabled = disabled - return model - } //-------------------------------------------------- // MARK: - Constraints diff --git a/VDS/Components/Checkbox/CheckboxGroupModel.swift b/VDS/Components/Checkbox/CheckboxGroupModel.swift deleted file mode 100644 index 93e253ab..00000000 --- a/VDS/Components/Checkbox/CheckboxGroupModel.swift +++ /dev/null @@ -1,29 +0,0 @@ -// -// CheckboxGroupModel.swift -// VDS -// -// Created by Matt Bruce on 8/23/22. -// - -import Foundation - -public protocol CheckboxGroupModel: SelectorGroupModelable, Errorable where SelectorModelType: CheckboxModel { - -} - -public struct DefaultCheckboxGroupModel: CheckboxGroupModel { - public typealias SelectorModelType = DefaultCheckboxModel - public var id = UUID() - public var inputId: String? - public var value: AnyHashable? - public var surface: Surface = .light - public var disabled: Bool = false - public var selectors: [SelectorModelType] - public var showError: Bool = false - public var errorText: String? - public init() { selectors = [] } - public init(selectors: [SelectorModelType]){ - self.selectors = selectors - } - -} diff --git a/VDS/Components/Checkbox/CheckboxModel.swift b/VDS/Components/Checkbox/CheckboxModel.swift deleted file mode 100644 index fad6c1e3..00000000 --- a/VDS/Components/Checkbox/CheckboxModel.swift +++ /dev/null @@ -1,123 +0,0 @@ -// -// ToggleModel.swift -// VDS -// -// Created by Matt Bruce on 7/22/22. -// - -import Foundation -import UIKit - -public protocol CheckboxModel: Modelable, FormFieldable, Errorable, DataTrackable, Accessable, Selectable, BinaryColorable { - var labelText: String? { get set } - var labelTextAttributes: [any LabelAttributeModel]? { get set } - var childText: String? { get set } - var childTextAttributes: [any LabelAttributeModel]? { get set } -} - -extension CheckboxModel { - - public var shouldShowError: Bool { - guard showError && !disabled && errorText?.isEmpty == false else { return false } - return true - } - - public var shouldShowLabels: Bool { - guard labelText?.isEmpty == false || childText?.isEmpty == false else { return false } - return true - } - - public var labelModel: DefaultLabelModel? { - guard let labelText = labelText else { return nil } - var model = DefaultLabelModel() - model.textPosition = .left - model.typograpicalStyle = .BoldBodyLarge - model.text = labelText - model.surface = surface - model.disabled = disabled - model.attributes = labelTextAttributes - return model - } - - public var childModel: DefaultLabelModel? { - guard let childText = childText else { return nil } - var model = DefaultLabelModel() - model.textPosition = .left - model.typograpicalStyle = .BodyLarge - model.text = childText - model.surface = surface - model.disabled = disabled - model.attributes = childTextAttributes - return model - } - - public var errorModel: DefaultLabelModel? { - guard let errorText = errorText, showError else { return nil } - var model = DefaultLabelModel() - model.textPosition = .left - model.typograpicalStyle = .BodyMedium - model.text = errorText - model.surface = surface - model.disabled = disabled - return model - } -} - -public struct DefaultCheckboxModel: CheckboxModel { - public var id = UUID() - public var selected: Bool = false - public var labelText: String? - public var labelTextAttributes: [any LabelAttributeModel]? - public var childText: String? - public var childTextAttributes: [any LabelAttributeModel]? - - public var showError: Bool = false - public var errorText: String? - - public var inputId: String? - public var value: AnyHashable? - - public var surface: Surface = .light - public var disabled: Bool = false - - public var dataAnalyticsTrack: String? - public var dataClickStream: String? - public var dataTrack: String? - public var accessibilityHintEnabled: String? - public var accessibilityHintDisabled: String? - public var accessibilityValueEnabled: String? - public var accessibilityValueDisabled: String? - public var accessibilityLabelEnabled: String? - public var accessibilityLabelDisabled: String? - - public init() {} - - public static func == (lhs: DefaultCheckboxModel, rhs: DefaultCheckboxModel) -> Bool { - lhs.isEqual(rhs) - } - - public func isEqual(_ equatable: DefaultCheckboxModel) -> Bool { - return id == equatable.id - && selected == equatable.selected - && labelText == equatable.labelText - && labelTextAttributes == equatable.labelTextAttributes - && childText == equatable.childText - && childTextAttributes == equatable.childTextAttributes - && showError == equatable.showError - && errorText == equatable.errorText - && inputId == equatable.inputId - && value == equatable.value - && surface == equatable.surface - && disabled == equatable.disabled - && dataAnalyticsTrack == equatable.dataAnalyticsTrack - && dataClickStream == equatable.dataClickStream - && dataTrack == equatable.dataTrack - && accessibilityHintEnabled == equatable.accessibilityHintEnabled - && accessibilityHintDisabled == equatable.accessibilityHintDisabled - && accessibilityValueEnabled == equatable.accessibilityValueEnabled - && accessibilityValueDisabled == equatable.accessibilityValueDisabled - && accessibilityLabelEnabled == equatable.accessibilityLabelEnabled - && accessibilityLabelDisabled == equatable.accessibilityLabelDisabled - } - -} diff --git a/VDS/Components/Label/LabelModel.swift b/VDS/Components/Label/LabelModel.swift deleted file mode 100644 index a8e8b659..00000000 --- a/VDS/Components/Label/LabelModel.swift +++ /dev/null @@ -1,40 +0,0 @@ -// -// VDSLabelModel.swift -// VDS -// -// Created by Matt Bruce on 7/28/22. -// - -import Foundation -import UIKit - -public protocol LabelModel: Modelable, Labelable, Equatable, AnyEquatable { - var text: String? { get set } - var attributes: [any LabelAttributeModel]? { get set } -} - -public struct DefaultLabelModel: LabelModel { - public static func == (lhs: DefaultLabelModel, rhs: DefaultLabelModel) -> Bool { - lhs.isEqual(rhs) - } - - public func isEqual(_ equatable: DefaultLabelModel) -> Bool { - return id == equatable.id - && attributes == equatable.attributes - && text == equatable.text - && surface == equatable.surface - && typograpicalStyle == equatable.typograpicalStyle - && textPosition == equatable.textPosition - && surface == equatable.surface - && disabled == equatable.disabled - } - - public var id = UUID() - public var text: String? - public var attributes: [any LabelAttributeModel]? - public var typograpicalStyle: TypographicalStyle = .BodySmall - public var textPosition: TextPosition = .left - public var surface: Surface = .light - public var disabled: Bool = false - public init(){} -} diff --git a/VDS/Components/RadioBox/RadioBoxGroupModel.swift b/VDS/Components/RadioBox/RadioBoxGroupModel.swift deleted file mode 100644 index 2a7e9413..00000000 --- a/VDS/Components/RadioBox/RadioBoxGroupModel.swift +++ /dev/null @@ -1,26 +0,0 @@ -// -// RadioBoxGroupModel.swift -// VDS -// -// Created by Matt Bruce on 8/23/22. -// - -import Foundation - -public protocol RadioBoxGroupModel: SelectorGroupSelectedModelable where SelectorModelType: RadioBoxModel { } - -public struct DefaultRadioBoxGroupModel: RadioBoxGroupModel { - public typealias SelectorModelType = DefaultRadioBoxModel - public var id = UUID() - public var inputId: String? - public var value: AnyHashable? - public var surface: Surface = .light - public var disabled: Bool = false - public var selectors: [SelectorModelType] - public var showError: Bool = false - public var errorText: String? - public init() { selectors = [] } - public init(selectors: [SelectorModelType]){ - self.selectors = selectors - } -} diff --git a/VDS/Components/RadioBox/RadioBoxModel.swift b/VDS/Components/RadioBox/RadioBoxModel.swift deleted file mode 100644 index 7c6884fa..00000000 --- a/VDS/Components/RadioBox/RadioBoxModel.swift +++ /dev/null @@ -1,122 +0,0 @@ -// -// RadioBoxModel.swift -// VDS -// -// Created by Matt Bruce on 8/23/22. -// - -import Foundation -import UIKit - -public protocol RadioBoxModel: Modelable, FormFieldable, DataTrackable, Accessable, Selectable, BinaryColorable { - var text: String { get set } - var textAttributes: [any LabelAttributeModel]? { get set } - var subText: String? { get set } - var subTextAttributes: [any LabelAttributeModel]? { get set } - var subTextRight: String? { get set } - var subTextRightAttributes: [any LabelAttributeModel]? { get set } - var strikethrough: Bool { get set } -} - -extension RadioBoxModel { - - public var textModel: DefaultLabelModel { - var model = DefaultLabelModel() - model.textPosition = .left - model.typograpicalStyle = .BoldBodyLarge - model.text = text - model.surface = surface - model.disabled = disabled - model.attributes = textAttributes - return model - } - - public var subTextModel: DefaultLabelModel? { - guard let subText else { return nil } - var model = DefaultLabelModel() - model.textPosition = .left - model.typograpicalStyle = .BodyLarge - model.text = subText - model.surface = surface - model.disabled = disabled - model.attributes = subTextAttributes - return model - } - - public var subTextRightModel: DefaultLabelModel? { - guard let subTextRight else { return nil } - var model = DefaultLabelModel() - model.textPosition = .right - model.typograpicalStyle = .BodyLarge - model.text = subTextRight - model.surface = surface - model.disabled = disabled - model.attributes = subTextRightAttributes - return model - } - -} - -public struct DefaultRadioBoxModel: RadioBoxModel { - public var id = UUID() - public var selected: Bool = false - public var text: String = "Default Text" - public var textAttributes: [any LabelAttributeModel]? - public var subText: String? - public var subTextAttributes: [any LabelAttributeModel]? - public var subTextRight: String? - public var subTextRightAttributes: [any LabelAttributeModel]? - public var selectedAccentColor: UIColor? - public var strikethrough: Bool = false - - public var inputId: String? - public var value: AnyHashable? - - public var surface: Surface = .light - public var disabled: Bool = false - - public var dataAnalyticsTrack: String? - public var dataClickStream: String? - public var dataTrack: String? - public var accessibilityHintEnabled: String? - public var accessibilityHintDisabled: String? - public var accessibilityValueEnabled: String? - public var accessibilityValueDisabled: String? - public var accessibilityLabelEnabled: String? - public var accessibilityLabelDisabled: String? - - public init() {} - - public static func == (lhs: DefaultRadioBoxModel, rhs: DefaultRadioBoxModel) -> Bool { - lhs.isEqual(rhs) - } - - public func isEqual(_ equatable: DefaultRadioBoxModel) -> Bool { - return id == equatable.id - && selected == equatable.selected - && text == equatable.text - && textAttributes == equatable.textAttributes - && subText == equatable.subText - && subTextAttributes == equatable.subTextAttributes - && subTextRight == equatable.subTextRight - && subTextRightAttributes == equatable.subTextRightAttributes - && selectedAccentColor == equatable.selectedAccentColor - && strikethrough == equatable.strikethrough - - && inputId == equatable.inputId - && value == equatable.value - - && surface == equatable.surface - && disabled == equatable.disabled - - && dataAnalyticsTrack == equatable.dataAnalyticsTrack - && dataClickStream == equatable.dataClickStream - && dataTrack == equatable.dataTrack - && accessibilityHintEnabled == equatable.accessibilityHintEnabled - && accessibilityHintDisabled == equatable.accessibilityHintDisabled - && accessibilityValueEnabled == equatable.accessibilityValueEnabled - && accessibilityValueDisabled == equatable.accessibilityValueDisabled - && accessibilityLabelEnabled == equatable.accessibilityLabelEnabled - && accessibilityLabelDisabled == equatable.accessibilityLabelDisabled - } -} diff --git a/VDS/Components/RadioButton/RadioButtonGroupModel.swift b/VDS/Components/RadioButton/RadioButtonGroupModel.swift deleted file mode 100644 index f9e8539f..00000000 --- a/VDS/Components/RadioButton/RadioButtonGroupModel.swift +++ /dev/null @@ -1,30 +0,0 @@ -// -// RadioButtonGroupModel.swift -// VDS -// -// Created by Matt Bruce on 8/11/22. -// - -import Foundation - -public protocol RadioButtonGroupModel: SelectorGroupSelectedModelable, Errorable where SelectorModelType: RadioButtonModel { } - -extension RadioButtonGroupModel { - public var errorText: String? { return nil } -} - -public struct DefaultRadioButtonGroupModel: RadioButtonGroupModel { - public typealias SelectorModelType = DefaultRadioButtonModel - public var id = UUID() - public var inputId: String? - public var value: AnyHashable? - public var surface: Surface = .light - public var disabled: Bool = false - public var selectors: [SelectorModelType] - public var showError: Bool = false - public var errorText: String? - public init() { selectors = [] } - public init(selectors: [SelectorModelType]){ - self.selectors = selectors - } -} diff --git a/VDS/Components/RadioButton/RadioButtonModel.swift b/VDS/Components/RadioButton/RadioButtonModel.swift deleted file mode 100644 index bf9d5e6e..00000000 --- a/VDS/Components/RadioButton/RadioButtonModel.swift +++ /dev/null @@ -1,128 +0,0 @@ -// -// ToggleModel.swift -// VDS -// -// Created by Matt Bruce on 7/22/22. -// - -import Foundation -import UIKit - -public protocol RadioButtonModel: Modelable, FormFieldable, Errorable, DataTrackable, Accessable, Selectable, BinaryColorable { - var labelText: String? { get set } - var labelTextAttributes: [any LabelAttributeModel]? { get set } - var childText: String? { get set } - var childTextAttributes: [any LabelAttributeModel]? { get set } -} - -extension RadioButtonModel { - - public var shouldShowError: Bool { - guard showError && !disabled && errorText?.isEmpty == false else { return false } - return true - } - - public var shouldShowLabels: Bool { - guard labelText?.isEmpty == false || childText?.isEmpty == false else { return false } - return true - } - - public var labelModel: DefaultLabelModel? { - guard let labelText = labelText else { return nil } - var model = DefaultLabelModel() - model.textPosition = .left - model.typograpicalStyle = .BoldBodyLarge - model.text = labelText - model.surface = surface - model.disabled = disabled - model.attributes = labelTextAttributes - return model - } - - public var childModel: DefaultLabelModel? { - guard let childText = childText else { return nil } - var model = DefaultLabelModel() - model.textPosition = .left - model.typograpicalStyle = .BodyLarge - model.text = childText - model.surface = surface - model.disabled = disabled - model.attributes = childTextAttributes - return model - } - - public var errorModel: DefaultLabelModel? { - guard let errorText = errorText, showError else { return nil } - var model = DefaultLabelModel() - model.textPosition = .left - model.typograpicalStyle = .BodyMedium - model.text = errorText - model.surface = surface - model.disabled = disabled - return model - } -} - -public struct DefaultRadioButtonModel: RadioButtonModel { - public var id = UUID() - public var selected: Bool = false - - public var labelText: String? - public var labelTextAttributes: [any LabelAttributeModel]? - public var childText: String? - public var childTextAttributes: [any LabelAttributeModel]? - - public var showError: Bool = false - public var errorText: String? - - public var inputId: String? - public var value: AnyHashable? - - public var surface: Surface = .light - public var disabled: Bool = false - - public var dataAnalyticsTrack: String? - public var dataClickStream: String? - public var dataTrack: String? - public var accessibilityHintEnabled: String? - public var accessibilityHintDisabled: String? - public var accessibilityValueEnabled: String? - public var accessibilityValueDisabled: String? - public var accessibilityLabelEnabled: String? - public var accessibilityLabelDisabled: String? - - public init() {} - - public static func == (lhs: DefaultRadioButtonModel, rhs: DefaultRadioButtonModel) -> Bool { - lhs.isEqual(rhs) - } - - public func isEqual(_ equatable: DefaultRadioButtonModel) -> Bool { - return id == equatable.id - && selected == equatable.selected - - && labelText == equatable.labelText - && labelTextAttributes == equatable.labelTextAttributes - && childText == equatable.childText - && childTextAttributes == equatable.childTextAttributes - - && showError == equatable.showError - && errorText == equatable.errorText - - && inputId == equatable.inputId - && value == equatable.value - - && surface == equatable.surface - && disabled == equatable.disabled - - && dataAnalyticsTrack == equatable.dataAnalyticsTrack - && dataClickStream == equatable.dataClickStream - && dataTrack == equatable.dataTrack - && accessibilityHintEnabled == equatable.accessibilityHintEnabled - && accessibilityHintDisabled == equatable.accessibilityHintDisabled - && accessibilityValueEnabled == equatable.accessibilityValueEnabled - && accessibilityValueDisabled == equatable.accessibilityValueDisabled - && accessibilityLabelEnabled == equatable.accessibilityLabelEnabled - && accessibilityLabelDisabled == equatable.accessibilityLabelDisabled - } -} diff --git a/VDS/Components/RadioSwatch/RadioSwatchGroupModel.swift b/VDS/Components/RadioSwatch/RadioSwatchGroupModel.swift deleted file mode 100644 index 4aeb9628..00000000 --- a/VDS/Components/RadioSwatch/RadioSwatchGroupModel.swift +++ /dev/null @@ -1,36 +0,0 @@ -// -// RadioSwatchGroupModel.swift -// VDS -// -// Created by Matt Bruce on 8/25/22. -// - -import Foundation - -public protocol RadioSwatchGroupModel: SelectorGroupSelectedModelable, Equatable where SelectorModelType: RadioSwatchModel { } - -extension RadioSwatchGroupModel { - public var labelModel: DefaultLabelModel { - var model = DefaultLabelModel() - model.textPosition = .left - model.typograpicalStyle = .BodySmall - model.text = selectedModel?.text ?? " " - model.surface = surface - model.disabled = disabled - return model - } -} - -public struct DefaultRadioSwatchGroupModel: RadioSwatchGroupModel { - public typealias SelectorModelType = DefaultRadioSwatchModel - public var id = UUID() - public var inputId: String? - public var value: AnyHashable? - public var surface: Surface = .light - public var disabled: Bool = false - public var selectors: [SelectorModelType] - public init() { selectors = [] } - public init(selectors: [SelectorModelType]){ - self.selectors = selectors - } -} diff --git a/VDS/Components/RadioSwatch/RadioSwatchModel.swift b/VDS/Components/RadioSwatch/RadioSwatchModel.swift deleted file mode 100644 index c70e6e43..00000000 --- a/VDS/Components/RadioSwatch/RadioSwatchModel.swift +++ /dev/null @@ -1,47 +0,0 @@ -// -// RadioSwatchModel.swift -// VDS -// -// Created by Matt Bruce on 8/25/22. -// - -import Foundation -import UIKit - -public protocol RadioSwatchModel: Modelable, FormFieldable, DataTrackable, Accessable, Selectable, BinaryColorable, Equatable { - var fillImage: UIImage? { get set } - var primaryColor: UIColor? { get set } - var secondaryColor: UIColor? { get set } - var text: String { get set } - var strikethrough: Bool { get set } -} - -public struct DefaultRadioSwatchModel: RadioSwatchModel { - public var id = UUID() - public var selected: Bool = false - - public var fillImage: UIImage? - public var primaryColor: UIColor? - public var secondaryColor: UIColor? - public var text: String = "" - public var strikethrough: Bool = false - - public var inputId: String? - public var value: AnyHashable? - - public var surface: Surface = .light - public var disabled: Bool = false - - public var dataAnalyticsTrack: String? - public var dataClickStream: String? - public var dataTrack: String? - public var accessibilityHintEnabled: String? - public var accessibilityHintDisabled: String? - public var accessibilityValueEnabled: String? - public var accessibilityValueDisabled: String? - public var accessibilityLabelEnabled: String? - public var accessibilityLabelDisabled: String? - - public init() {} - -} diff --git a/VDS/Components/Toggle/Toggle.swift b/VDS/Components/Toggle/Toggle.swift index 83c46c0c..59f27f70 100644 --- a/VDS/Components/Toggle/Toggle.swift +++ b/VDS/Components/Toggle/Toggle.swift @@ -9,6 +9,19 @@ import Foundation import UIKit import VDSColorTokens import Combine + +public enum ToggleTextSize: String, CaseIterable { + case small, large +} + +public enum ToggleTextWeight: String, CaseIterable { + case regular, bold +} + +public enum ToggleTextPosition: String, CaseIterable { + case left, right +} + /** A custom implementation of Apple's UISwitch. @@ -17,7 +30,6 @@ import Combine Container: The background of the toggle control. Knob: The circular indicator that slides on the container. */ - public class Toggle: ToggleBase{ public override func initialSetup() { super.initialSetup() diff --git a/VDS/Components/Toggle/ToggleModel.swift b/VDS/Components/Toggle/ToggleModel.swift deleted file mode 100644 index 4c888b49..00000000 --- a/VDS/Components/Toggle/ToggleModel.swift +++ /dev/null @@ -1,91 +0,0 @@ -// -// ToggleModel.swift -// VDS -// -// Created by Matt Bruce on 7/22/22. -// - -import Foundation -import UIKit - -public enum ToggleTextSize: String, CaseIterable { - case small, large -} - -public enum ToggleTextWeight: String, CaseIterable { - case regular, bold -} - -public enum ToggleTextPosition: String, CaseIterable { - case left, right -} - -public protocol ToggleModel: Modelable, FormFieldable, DataTrackable, Accessable, BinaryColorable { - var showText: Bool { get set } - var on: Bool { get set } - var offText: String { get set } - var onText: String { get set } - var textWeight: ToggleTextWeight { get set } - var textSize: ToggleTextSize { get set } - var textPosition: ToggleTextPosition { get set } -} - -extension ToggleModel { - public var userTrueColor: Bool { return on } - - public var labelModel: DefaultLabelModel { - - var typograpicalStyle: TypographicalStyle - if textSize == .small { - if textWeight == .bold { - typograpicalStyle = .BoldBodySmall - } else { - typograpicalStyle = .BodySmall - } - } else { - if textWeight == .bold { - typograpicalStyle = .BoldBodyLarge - } else { - typograpicalStyle = .BodyLarge - } - } - - var model = DefaultLabelModel() - model.textPosition = textPosition == .left ? .left : .right - model.typograpicalStyle = typograpicalStyle - model.text = on ? onText : offText - model.surface = surface - model.disabled = disabled - return model - } -} - -public struct DefaultToggleModel: ToggleModel { - public var id = UUID() - public var on: Bool = false - public var showText: Bool = false - public var offText: String = "Off" - public var onText: String = "On" - - public var textWeight: ToggleTextWeight = .regular - public var textSize: ToggleTextSize = .small - public var textPosition: ToggleTextPosition = .left - - public var inputId: String? - public var value: AnyHashable? = true - - public var surface: Surface = .light - public var disabled: Bool = false - - public var dataAnalyticsTrack: String? - public var dataClickStream: String? - public var dataTrack: String? - public var accessibilityHintEnabled: String? - public var accessibilityHintDisabled: String? - public var accessibilityValueEnabled: String? - public var accessibilityValueDisabled: String? - public var accessibilityLabelEnabled: String? - public var accessibilityLabelDisabled: String? - - public init() { } -} From 1e046fa336ad3cb4d1b3c8471a783aca3effc337 Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Thu, 20 Oct 2022 15:41:41 -0500 Subject: [PATCH 18/29] removed / replaced anything to do with model Signed-off-by: Matt Bruce --- VDS.xcodeproj/project.pbxproj | 56 +---------- VDS/Classes/CollectionView.swift | 96 ------------------- VDS/Classes/CollectionViewCell.swift | 81 ---------------- VDS/Classes/ColorConfiguration.swift | 44 ++++----- VDS/Classes/Constants.swift | 2 +- VDS/Classes/Control.swift | 2 +- VDS/Classes/SelectorGroupHandlerBase.swift | 28 ++---- VDS/Classes/View.swift | 2 +- VDS/Components/Button/Button.swift | 8 +- VDS/Components/Checkbox/Checkbox.swift | 12 +-- VDS/Components/Checkbox/CheckboxGroup.swift | 6 +- VDS/Components/Label/Label.swift | 2 +- VDS/Components/RadioBox/RadioBox.swift | 2 +- VDS/Components/RadioBox/RadioBoxGroup.swift | 15 +-- VDS/Components/RadioButton/RadioButton.swift | 2 +- .../RadioButton/RadioButtonGroup.swift | 4 +- .../RadioSwatch/RadioSwatchGroup.swift | 6 +- VDS/PropertyWrappers/AnyProxy.swift | 45 --------- VDS/PropertyWrappers/CodableColor.swift | 57 ----------- VDS/PropertyWrappers/Debuggable.swift | 31 ------ VDS/PropertyWrappers/UsesAutoLayout.swift | 23 ----- VDS/Protocols/Accessable.swift | 2 +- VDS/Protocols/Colorable.swift | 26 ++--- ...delHandlerable.swift => Handlerable.swift} | 10 +- VDS/Protocols/Labelable.swift | 20 ---- VDS/Protocols/Modelable.swift | 18 ---- VDS/Protocols/Selectable.swift | 12 --- VDS/Protocols/SelectorGroupModelable.swift | 37 ------- 28 files changed, 75 insertions(+), 574 deletions(-) delete mode 100644 VDS/Classes/CollectionView.swift delete mode 100644 VDS/Classes/CollectionViewCell.swift delete mode 100644 VDS/PropertyWrappers/AnyProxy.swift delete mode 100644 VDS/PropertyWrappers/CodableColor.swift delete mode 100644 VDS/PropertyWrappers/Debuggable.swift delete mode 100644 VDS/PropertyWrappers/UsesAutoLayout.swift rename VDS/Protocols/{ModelHandlerable.swift => Handlerable.swift} (64%) delete mode 100644 VDS/Protocols/Labelable.swift delete mode 100644 VDS/Protocols/Modelable.swift delete mode 100644 VDS/Protocols/Selectable.swift delete mode 100644 VDS/Protocols/SelectorGroupModelable.swift diff --git a/VDS.xcodeproj/project.pbxproj b/VDS.xcodeproj/project.pbxproj index 56ad00b9..72db300b 100644 --- a/VDS.xcodeproj/project.pbxproj +++ b/VDS.xcodeproj/project.pbxproj @@ -9,8 +9,6 @@ /* Begin PBXBuildFile section */ 5F21D7BF28DCEB3D003E7CD6 /* Useable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5F21D7BE28DCEB3D003E7CD6 /* Useable.swift */; }; 5FC35BE328D51405004EBEAC /* Button.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5FC35BE228D51405004EBEAC /* Button.swift */; }; - EA1F265D28B944F00033E859 /* CollectionView.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA1F265B28B944F00033E859 /* CollectionView.swift */; }; - EA1F265E28B944F00033E859 /* CollectionViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA1F265C28B944F00033E859 /* CollectionViewCell.swift */; }; EA1F266528B945070033E859 /* RadioSwatch.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA1F266128B945070033E859 /* RadioSwatch.swift */; }; EA1F266628B945070033E859 /* RadioSwatchGroup.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA1F266228B945070033E859 /* RadioSwatchGroup.swift */; }; EA336171288B19200071C351 /* VDS.docc in Sources */ = {isa = PBXBuildFile; fileRef = EA336170288B19200071C351 /* VDS.docc */; }; @@ -24,7 +22,7 @@ EA3361B6288B2A410071C351 /* Control.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA3361B5288B2A410071C351 /* Control.swift */; }; EA3361B8288B2AAA0071C351 /* ViewProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA3361B7288B2AAA0071C351 /* ViewProtocol.swift */; }; EA3361BD288B2C760071C351 /* TypeAlias.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA3361BC288B2C760071C351 /* TypeAlias.swift */; }; - EA3361BF288B2EA60071C351 /* ModelHandlerable.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA3361BE288B2EA60071C351 /* ModelHandlerable.swift */; }; + EA3361BF288B2EA60071C351 /* Handlerable.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA3361BE288B2EA60071C351 /* Handlerable.swift */; }; EA3361C328902D960071C351 /* Toggle.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA3361C228902D960071C351 /* Toggle.swift */; }; EA3361C5289030FC0071C351 /* Accessable.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA3361C4289030FC0071C351 /* Accessable.swift */; }; EA3361C9289054C50071C351 /* Surfaceable.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA3361C8289054C50071C351 /* Surfaceable.swift */; }; @@ -37,17 +35,13 @@ EA3362302891EB4A0071C351 /* Fonts.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA33622F2891EB4A0071C351 /* Fonts.swift */; }; EA33623E2892EE950071C351 /* UIDevice.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA33623D2892EE950071C351 /* UIDevice.swift */; }; EA3362402892EF6C0071C351 /* Label.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA33623F2892EF6B0071C351 /* Label.swift */; }; - EA3362452892F9130071C351 /* Labelable.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA3362442892F9130071C351 /* Labelable.swift */; }; EA33624728931B050071C351 /* Initable.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA33624628931B050071C351 /* Initable.swift */; }; - EA3C3B4C2894823E000CA526 /* AnyProxy.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA3C3B4B2894823E000CA526 /* AnyProxy.swift */; }; EA4DB18528CA967F00103EE3 /* SelectorGroupHandlerBase.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA4DB18428CA967F00103EE3 /* SelectorGroupHandlerBase.swift */; }; EA4DB2FD28D3D0CA00103EE3 /* AnyEquatable.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA4DB2FC28D3D0CA00103EE3 /* AnyEquatable.swift */; }; EA4DB30228DCBCA500103EE3 /* Badge.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA4DB30128DCBCA500103EE3 /* Badge.swift */; }; - EA84F6B128B94A2500D67ABC /* CodableColor.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA84F6B028B94A2500D67ABC /* CodableColor.swift */; }; EA89200228AECF2A006B9984 /* UIButton+Publisher.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA89200128AECF2A006B9984 /* UIButton+Publisher.swift */; }; EA89200428AECF4B006B9984 /* UITextField+Publisher.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA89200328AECF4B006B9984 /* UITextField+Publisher.swift */; }; EA89200628B526D6006B9984 /* CheckboxGroup.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA89200528B526D6006B9984 /* CheckboxGroup.swift */; }; - EA89200F28B53921006B9984 /* Selectable.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA89200E28B53921006B9984 /* Selectable.swift */; }; EA89201328B568D8006B9984 /* RadioBox.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA89201228B568D8006B9984 /* RadioBox.swift */; }; EA89201528B56CF4006B9984 /* RadioBoxGroup.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA89201428B56CF4006B9984 /* RadioBoxGroup.swift */; }; EAA5EEE228F4C62C003B3210 /* Colorable.swift in Sources */ = {isa = PBXBuildFile; fileRef = EAA5EEE128F4C62C003B3210 /* Colorable.swift */; }; @@ -58,10 +52,7 @@ EAA5EEF228F5C909003B3210 /* VDSColorTokens.xcframework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = EAA5EEED28F5C908003B3210 /* VDSColorTokens.xcframework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; EAA5EEF328F5C909003B3210 /* VDSFormControlsTokens.xcframework in Frameworks */ = {isa = PBXBuildFile; fileRef = EAA5EEEE28F5C908003B3210 /* VDSFormControlsTokens.xcframework */; }; EAA5EEF428F5C909003B3210 /* VDSFormControlsTokens.xcframework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = EAA5EEEE28F5C908003B3210 /* VDSFormControlsTokens.xcframework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; - EAB1D29A28A5611D00DAE764 /* SelectorGroupModelable.swift in Sources */ = {isa = PBXBuildFile; fileRef = EAB1D29928A5611D00DAE764 /* SelectorGroupModelable.swift */; }; EAB1D29C28A5618900DAE764 /* RadioButtonGroup.swift in Sources */ = {isa = PBXBuildFile; fileRef = EAB1D29B28A5618900DAE764 /* RadioButtonGroup.swift */; }; - EAB1D2A128A598FE00DAE764 /* UsesAutoLayout.swift in Sources */ = {isa = PBXBuildFile; fileRef = EAB1D2A028A598FE00DAE764 /* UsesAutoLayout.swift */; }; - EAB1D2A328A5994800DAE764 /* Debuggable.swift in Sources */ = {isa = PBXBuildFile; fileRef = EAB1D2A228A5994800DAE764 /* Debuggable.swift */; }; EAB1D2CD28ABE76100DAE764 /* Withable.swift in Sources */ = {isa = PBXBuildFile; fileRef = EAB1D2CC28ABE76000DAE764 /* Withable.swift */; }; EAB1D2CF28ABEF2B00DAE764 /* Typography.swift in Sources */ = {isa = PBXBuildFile; fileRef = EAB1D2CE28ABEF2B00DAE764 /* Typography.swift */; }; EAB1D2E628AE842000DAE764 /* Publisher+Bind.swift in Sources */ = {isa = PBXBuildFile; fileRef = EAB1D2E328AE842000DAE764 /* Publisher+Bind.swift */; }; @@ -82,7 +73,6 @@ EAF7F0B5289C126F00B287F5 /* UILabel.swift in Sources */ = {isa = PBXBuildFile; fileRef = EAF7F0B4289C126F00B287F5 /* UILabel.swift */; }; EAF7F0B7289C12A600B287F5 /* UITapGestureRecognizer.swift in Sources */ = {isa = PBXBuildFile; fileRef = EAF7F0B6289C12A600B287F5 /* UITapGestureRecognizer.swift */; }; EAF7F0B9289C139800B287F5 /* ColorConfiguration.swift in Sources */ = {isa = PBXBuildFile; fileRef = EAF7F0B8289C139800B287F5 /* ColorConfiguration.swift */; }; - EAF7F0BB289D80ED00B287F5 /* Modelable.swift in Sources */ = {isa = PBXBuildFile; fileRef = EAF7F0BA289D80ED00B287F5 /* Modelable.swift */; }; EAF7F11728A1475A00B287F5 /* RadioButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = EAF7F11528A1475A00B287F5 /* RadioButton.swift */; }; EAF7F13328A2A16500B287F5 /* LabelAttributeAttachment.swift in Sources */ = {isa = PBXBuildFile; fileRef = EAF7F13228A2A16500B287F5 /* LabelAttributeAttachment.swift */; }; /* End PBXBuildFile section */ @@ -116,8 +106,6 @@ /* Begin PBXFileReference section */ 5F21D7BE28DCEB3D003E7CD6 /* Useable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Useable.swift; sourceTree = ""; }; 5FC35BE228D51405004EBEAC /* Button.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Button.swift; sourceTree = ""; }; - EA1F265B28B944F00033E859 /* CollectionView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CollectionView.swift; sourceTree = ""; }; - EA1F265C28B944F00033E859 /* CollectionViewCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CollectionViewCell.swift; sourceTree = ""; }; EA1F266128B945070033E859 /* RadioSwatch.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RadioSwatch.swift; sourceTree = ""; }; EA1F266228B945070033E859 /* RadioSwatchGroup.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RadioSwatchGroup.swift; sourceTree = ""; }; EA33616C288B19200071C351 /* VDS.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = VDS.framework; sourceTree = BUILT_PRODUCTS_DIR; }; @@ -132,7 +120,7 @@ EA3361B5288B2A410071C351 /* Control.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Control.swift; sourceTree = ""; }; EA3361B7288B2AAA0071C351 /* ViewProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewProtocol.swift; sourceTree = ""; }; EA3361BC288B2C760071C351 /* TypeAlias.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TypeAlias.swift; sourceTree = ""; }; - EA3361BE288B2EA60071C351 /* ModelHandlerable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ModelHandlerable.swift; sourceTree = ""; }; + EA3361BE288B2EA60071C351 /* Handlerable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Handlerable.swift; sourceTree = ""; }; EA3361C228902D960071C351 /* Toggle.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Toggle.swift; sourceTree = ""; }; EA3361C4289030FC0071C351 /* Accessable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Accessable.swift; sourceTree = ""; }; EA3361C8289054C50071C351 /* Surfaceable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Surfaceable.swift; sourceTree = ""; }; @@ -145,17 +133,13 @@ EA33622F2891EB4A0071C351 /* Fonts.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Fonts.swift; sourceTree = ""; }; EA33623D2892EE950071C351 /* UIDevice.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UIDevice.swift; sourceTree = ""; }; EA33623F2892EF6B0071C351 /* Label.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Label.swift; sourceTree = ""; }; - EA3362442892F9130071C351 /* Labelable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Labelable.swift; sourceTree = ""; }; EA33624628931B050071C351 /* Initable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Initable.swift; sourceTree = ""; }; - EA3C3B4B2894823E000CA526 /* AnyProxy.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AnyProxy.swift; sourceTree = ""; }; EA4DB18428CA967F00103EE3 /* SelectorGroupHandlerBase.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SelectorGroupHandlerBase.swift; sourceTree = ""; }; EA4DB2FC28D3D0CA00103EE3 /* AnyEquatable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AnyEquatable.swift; sourceTree = ""; }; EA4DB30128DCBCA500103EE3 /* Badge.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Badge.swift; sourceTree = ""; }; - EA84F6B028B94A2500D67ABC /* CodableColor.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CodableColor.swift; sourceTree = ""; }; EA89200128AECF2A006B9984 /* UIButton+Publisher.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIButton+Publisher.swift"; sourceTree = ""; }; EA89200328AECF4B006B9984 /* UITextField+Publisher.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UITextField+Publisher.swift"; sourceTree = ""; }; EA89200528B526D6006B9984 /* CheckboxGroup.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CheckboxGroup.swift; sourceTree = ""; }; - EA89200E28B53921006B9984 /* Selectable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Selectable.swift; sourceTree = ""; }; EA89201228B568D8006B9984 /* RadioBox.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RadioBox.swift; sourceTree = ""; }; EA89201428B56CF4006B9984 /* RadioBoxGroup.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RadioBoxGroup.swift; sourceTree = ""; }; EAA5EEE128F4C62C003B3210 /* Colorable.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Colorable.swift; sourceTree = ""; }; @@ -163,10 +147,7 @@ EAA5EEEC28F5C908003B3210 /* VDSTypographyTokens.xcframework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcframework; name = VDSTypographyTokens.xcframework; path = ../SharedFrameworks/VDSTypographyTokens.xcframework; sourceTree = ""; }; EAA5EEED28F5C908003B3210 /* VDSColorTokens.xcframework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcframework; name = VDSColorTokens.xcframework; path = ../SharedFrameworks/VDSColorTokens.xcframework; sourceTree = ""; }; EAA5EEEE28F5C908003B3210 /* VDSFormControlsTokens.xcframework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcframework; name = VDSFormControlsTokens.xcframework; path = ../SharedFrameworks/VDSFormControlsTokens.xcframework; sourceTree = ""; }; - EAB1D29928A5611D00DAE764 /* SelectorGroupModelable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SelectorGroupModelable.swift; sourceTree = ""; }; EAB1D29B28A5618900DAE764 /* RadioButtonGroup.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RadioButtonGroup.swift; sourceTree = ""; }; - EAB1D2A028A598FE00DAE764 /* UsesAutoLayout.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UsesAutoLayout.swift; sourceTree = ""; }; - EAB1D2A228A5994800DAE764 /* Debuggable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Debuggable.swift; sourceTree = ""; }; EAB1D2CC28ABE76000DAE764 /* Withable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Withable.swift; sourceTree = ""; }; EAB1D2CE28ABEF2B00DAE764 /* Typography.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Typography.swift; sourceTree = ""; }; EAB1D2E328AE842000DAE764 /* Publisher+Bind.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "Publisher+Bind.swift"; sourceTree = ""; }; @@ -187,7 +168,6 @@ EAF7F0B4289C126F00B287F5 /* UILabel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UILabel.swift; sourceTree = ""; }; EAF7F0B6289C12A600B287F5 /* UITapGestureRecognizer.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UITapGestureRecognizer.swift; sourceTree = ""; }; EAF7F0B8289C139800B287F5 /* ColorConfiguration.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ColorConfiguration.swift; sourceTree = ""; }; - EAF7F0BA289D80ED00B287F5 /* Modelable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Modelable.swift; sourceTree = ""; }; EAF7F11528A1475A00B287F5 /* RadioButton.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RadioButton.swift; sourceTree = ""; }; EAF7F13228A2A16500B287F5 /* LabelAttributeAttachment.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LabelAttributeAttachment.swift; sourceTree = ""; }; /* End PBXFileReference section */ @@ -258,7 +238,6 @@ EA3361A6288B23240071C351 /* Extensions */, EA3361DF2891D0F10071C351 /* Fonts */, EA3361AB288B25EC0071C351 /* Protocols */, - EAB1D29F28A598D000DAE764 /* PropertyWrappers */, EAB1D2E228AE842000DAE764 /* Publishers */, EAB1D2D028ABEF3100DAE764 /* Typography */, EA3361B9288B2BE30071C351 /* Utilities */, @@ -333,13 +312,9 @@ EA3361A9288B25E40071C351 /* Disabling.swift */, EAF7F0A1289AFB3900B287F5 /* Errorable.swift */, EA3361AE288B26310071C351 /* FormFieldable.swift */, + EA3361BE288B2EA60071C351 /* Handlerable.swift */, EA33624628931B050071C351 /* Initable.swift */, - EA3362442892F9130071C351 /* Labelable.swift */, - EAF7F0BA289D80ED00B287F5 /* Modelable.swift */, - EA3361BE288B2EA60071C351 /* ModelHandlerable.swift */, EAF7F0A5289B0CE000B287F5 /* Resetable.swift */, - EA89200E28B53921006B9984 /* Selectable.swift */, - EAB1D29928A5611D00DAE764 /* SelectorGroupModelable.swift */, EA3361C8289054C50071C351 /* Surfaceable.swift */, EA3361B7288B2AAA0071C351 /* ViewProtocol.swift */, EAB1D2CC28ABE76000DAE764 /* Withable.swift */, @@ -351,8 +326,6 @@ EA3361B4288B2A360071C351 /* Classes */ = { isa = PBXGroup; children = ( - EA1F265B28B944F00033E859 /* CollectionView.swift */, - EA1F265C28B944F00033E859 /* CollectionViewCell.swift */, EAF7F0B8289C139800B287F5 /* ColorConfiguration.swift */, EAF7F09D289AAEC000B287F5 /* Constants.swift */, EA3361B5288B2A410071C351 /* Control.swift */, @@ -425,17 +398,6 @@ path = RadioBox; sourceTree = ""; }; - EAB1D29F28A598D000DAE764 /* PropertyWrappers */ = { - isa = PBXGroup; - children = ( - EA3C3B4B2894823E000CA526 /* AnyProxy.swift */, - EA84F6B028B94A2500D67ABC /* CodableColor.swift */, - EAB1D2A228A5994800DAE764 /* Debuggable.swift */, - EAB1D2A028A598FE00DAE764 /* UsesAutoLayout.swift */, - ); - path = PropertyWrappers; - sourceTree = ""; - }; EAB1D2D028ABEF3100DAE764 /* Typography */ = { isa = PBXGroup; children = ( @@ -609,7 +571,6 @@ EA3361C328902D960071C351 /* Toggle.swift in Sources */, EAF7F0A0289AB7EC00B287F5 /* View.swift in Sources */, EA89201328B568D8006B9984 /* RadioBox.swift in Sources */, - EA84F6B128B94A2500D67ABC /* CodableColor.swift in Sources */, EA3362402892EF6C0071C351 /* Label.swift in Sources */, EAF7F0B3289B1ADC00B287F5 /* LabelAttributeAction.swift in Sources */, EA33622E2891EA3C0071C351 /* DispatchQueue+Once.swift in Sources */, @@ -618,11 +579,9 @@ EA3361C5289030FC0071C351 /* Accessable.swift in Sources */, EA33622C2891E73B0071C351 /* FontProtocol.swift in Sources */, EAF7F11728A1475A00B287F5 /* RadioButton.swift in Sources */, - EAB1D2A128A598FE00DAE764 /* UsesAutoLayout.swift in Sources */, EAB1D2CD28ABE76100DAE764 /* Withable.swift in Sources */, EAF7F0952899861000B287F5 /* Checkbox.swift in Sources */, EA3361C9289054C50071C351 /* Surfaceable.swift in Sources */, - EA1F265D28B944F00033E859 /* CollectionView.swift in Sources */, EA4DB30228DCBCA500103EE3 /* Badge.swift in Sources */, EA33624728931B050071C351 /* Initable.swift in Sources */, EAF7F0A4289B017C00B287F5 /* LabelAttributeModel.swift in Sources */, @@ -635,12 +594,8 @@ EA3361BD288B2C760071C351 /* TypeAlias.swift in Sources */, EAB1D2CF28ABEF2B00DAE764 /* Typography.swift in Sources */, EAF7F09A2899B17200B287F5 /* CATransaction.swift in Sources */, - EA89200F28B53921006B9984 /* Selectable.swift in Sources */, EAF7F0A2289AFB3900B287F5 /* Errorable.swift in Sources */, - EA3C3B4C2894823E000CA526 /* AnyProxy.swift in Sources */, EA3361AF288B26310071C351 /* FormFieldable.swift in Sources */, - EAB1D29A28A5611D00DAE764 /* SelectorGroupModelable.swift in Sources */, - EAF7F0BB289D80ED00B287F5 /* Modelable.swift in Sources */, EA89201528B56CF4006B9984 /* RadioBoxGroup.swift in Sources */, EAF7F09E289AAEC000B287F5 /* Constants.swift in Sources */, EA1F266528B945070033E859 /* RadioSwatch.swift in Sources */, @@ -652,18 +607,15 @@ EAB1D2E628AE842000DAE764 /* Publisher+Bind.swift in Sources */, EA3361AA288B25E40071C351 /* Disabling.swift in Sources */, EA3361B6288B2A410071C351 /* Control.swift in Sources */, - EAB1D2A328A5994800DAE764 /* Debuggable.swift in Sources */, 5F21D7BF28DCEB3D003E7CD6 /* Useable.swift in Sources */, EAF7F0B7289C12A600B287F5 /* UITapGestureRecognizer.swift in Sources */, - EA3362452892F9130071C351 /* Labelable.swift in Sources */, EA3361AD288B26190071C351 /* DataTrackable.swift in Sources */, EAA5EEE228F4C62C003B3210 /* Colorable.swift in Sources */, EA33623E2892EE950071C351 /* UIDevice.swift in Sources */, EA3362302891EB4A0071C351 /* Fonts.swift in Sources */, - EA1F265E28B944F00033E859 /* CollectionViewCell.swift in Sources */, EAF7F0AD289B142900B287F5 /* LabelAttributeStrikeThrough.swift in Sources */, EA3361B8288B2AAA0071C351 /* ViewProtocol.swift in Sources */, - EA3361BF288B2EA60071C351 /* ModelHandlerable.swift in Sources */, + EA3361BF288B2EA60071C351 /* Handlerable.swift in Sources */, EA3361A8288B23300071C351 /* UIColor.swift in Sources */, EA1F266628B945070033E859 /* RadioSwatchGroup.swift in Sources */, 5FC35BE328D51405004EBEAC /* Button.swift in Sources */, diff --git a/VDS/Classes/CollectionView.swift b/VDS/Classes/CollectionView.swift deleted file mode 100644 index d74d88d6..00000000 --- a/VDS/Classes/CollectionView.swift +++ /dev/null @@ -1,96 +0,0 @@ -// -// CollectionView.swift -// VDS -// -// Created by Matt Bruce on 8/25/22. -// - -import Foundation -import UIKit -import Combine - -open class CollectionView: UICollectionView, ModelHandlerable, ViewProtocol, Resettable { - - //-------------------------------------------------- - // MARK: - Combine Properties - //-------------------------------------------------- - public var subject = PassthroughSubject() - public var subscribers = Set() - - //-------------------------------------------------- - // MARK: - Properties - //-------------------------------------------------- - private var initialSetupPerformed = false - - open var surface: Surface = .light { didSet { didChange() }} - - open var disabled: Bool = false { didSet { isEnabled = !disabled } } - - open var isEnabled: Bool { - get { !disabled } - set { - if disabled != !newValue { - disabled = !newValue - } - isUserInteractionEnabled = isEnabled - didChange() - } - } - - //-------------------------------------------------- - // MARK: - Initializers - //-------------------------------------------------- - required public init() { - super.init(frame: .zero, collectionViewLayout: UICollectionViewFlowLayout()) - initialSetup() - } - - public required init(collectionViewLayout layout: UICollectionViewLayout) { - super.init(frame: .zero, collectionViewLayout: layout) - initialSetup() - } - - public override init(frame: CGRect, collectionViewLayout layout: UICollectionViewLayout) { - super.init(frame: frame, collectionViewLayout: layout) - initialSetup() - } - - public required init?(coder: NSCoder) { - super.init(coder: coder) - initialSetup() - } - - //-------------------------------------------------- - // MARK: - Setup - //-------------------------------------------------- - - open func initialSetup() { - if !initialSetupPerformed { - initialSetupPerformed = true - setup() - } - } - - open override func layoutSubviews() { - super.layoutSubviews() - updateView() - } - - //-------------------------------------------------- - // MARK: - Overrides - //-------------------------------------------------- - open func updateView() {} - - open func reset() { - backgroundColor = .clear - surface = .light - disabled = false - } - - // MARK: - ViewProtocol - /// Will be called only once. - open func setup() { - translatesAutoresizingMaskIntoConstraints = false - insetsLayoutMarginsFromSafeArea = false - } -} diff --git a/VDS/Classes/CollectionViewCell.swift b/VDS/Classes/CollectionViewCell.swift deleted file mode 100644 index 753389fd..00000000 --- a/VDS/Classes/CollectionViewCell.swift +++ /dev/null @@ -1,81 +0,0 @@ -// -// CollectionViewCell.swift -// VDS -// -// Created by Matt Bruce on 8/25/22. -// - -import Foundation -import UIKit -import Combine - -open class CollectionViewCell: UICollectionViewCell, ViewProtocol { - //-------------------------------------------------- - // MARK: - Properties - //-------------------------------------------------- - private var initialSetupPerformed = false - - public var modelHandler: ModelHandlerType? { - didSet { - if let oldValue { - oldValue.removeFromSuperview() - } - if let modelHandler { - addSubview(modelHandler) - modelHandler.didChange() - modelHandler.topAnchor.constraint(equalTo: topAnchor).isActive = true - modelHandler.leadingAnchor.constraint(equalTo: leadingAnchor).isActive = true - modelHandler.trailingAnchor.constraint(equalTo: trailingAnchor).isActive = true - modelHandler.bottomAnchor.constraint(equalTo: bottomAnchor).isActive = true - } - } - } - - open var surface: Surface = .light { didSet { modelHandler?.surface = surface } } - - open var disabled: Bool = false { didSet{ modelHandler?.disabled = disabled } } - - //-------------------------------------------------- - // MARK: - Initializers - //-------------------------------------------------- - required public init() { - super.init(frame: .zero) - initialSetup() - } - - public override init(frame: CGRect) { - super.init(frame: frame) - initialSetup() - } - - public required init?(coder: NSCoder) { - super.init(coder: coder) - initialSetup() - } - - //-------------------------------------------------- - // MARK: - Setup - //-------------------------------------------------- - - open func initialSetup() { - if !initialSetupPerformed { - initialSetupPerformed = true - setup() - } - } - - // MARK: - ViewProtocol - /// Will be called only once. - open func setup() { - translatesAutoresizingMaskIntoConstraints = false - insetsLayoutMarginsFromSafeArea = false - - } - - open override func prepareForReuse() { - super.prepareForReuse() - if let handler = modelHandler as? Resettable { - handler.reset() - } - } -} diff --git a/VDS/Classes/ColorConfiguration.swift b/VDS/Classes/ColorConfiguration.swift index e86756fe..89cfe2c4 100644 --- a/VDS/Classes/ColorConfiguration.swift +++ b/VDS/Classes/ColorConfiguration.swift @@ -23,13 +23,13 @@ public typealias ObjectColorable = Colorable & Initable & ObjectWithable /// /// let textColor = config.getColor(model) //returns .black final public class SurfaceColorConfiguration: ObjectColorable { - public typealias ModelType = Surfaceable + public typealias ObjectType = Surfaceable public var lightColor: UIColor = .clear public var darkColor: UIColor = .clear required public init(){} - public func getColor(_ viewModel: any ModelType) -> UIColor { - return viewModel.surface == .light ? lightColor : darkColor + public func getColor(_ object: any ObjectType) -> UIColor { + return object.surface == .light ? lightColor : darkColor } } @@ -42,8 +42,8 @@ public protocol DisabledSurfaceColorable: ObjectColorable { } extension DisabledSurfaceColorable { - public func getDisabledColor (_ viewModel: M) -> UIColor { - viewModel.disabled ? disabled.getColor(viewModel) : enabled.getColor(viewModel) + public func getDisabledColor (_ object: M) -> UIColor { + object.disabled ? disabled.getColor(object) : enabled.getColor(object) } } @@ -69,14 +69,14 @@ extension DisabledSurfaceColorable { /// /// final public class DisabledSurfaceColorConfiguration: DisabledSurfaceColorable { - public typealias ModelType = Surfaceable & Disabling + public typealias ObjectType = Surfaceable & Disabling public var disabled = SurfaceColorConfiguration() public var enabled = SurfaceColorConfiguration() required public init(){} - public func getColor(_ viewModel: any ModelType) -> UIColor { - getDisabledColor(viewModel) + public func getColor(_ object: any ObjectType) -> UIColor { + getDisabledColor(object) } } @@ -84,15 +84,11 @@ final public class DisabledSurfaceColorConfiguration: DisabledSurfaceColorable { ///MARK -- BinaryColorable ///------------------------------------------------------------------- public protocol BinaryColorable{ - var userTrueColor: Bool { get } + var useTrueColor: Bool { get } } extension BinaryColorable where Self: Control { - public var userTrueColor: Bool { return isSelected } -} - -extension BinaryColorable where Self: Selectable { - public var userTrueColor: Bool { return selected } + public var useTrueColor: Bool { return isSelected } } ///------------------------------------------------------------------- @@ -104,8 +100,8 @@ public protocol BinarySurfaceColorable: ObjectColorable { } extension BinarySurfaceColorable { - public func getBinaryColor(_ viewModel: M) -> UIColor { - viewModel.userTrueColor ? forTrue.getColor(viewModel) : forFalse.getColor(viewModel) + public func getBinaryColor(_ object: M) -> UIColor { + object.useTrueColor ? forTrue.getColor(object) : forFalse.getColor(object) } } @@ -130,14 +126,14 @@ extension BinarySurfaceColorable { /// /// final public class BinarySurfaceColorConfiguration: BinarySurfaceColorable { - public typealias ModelType = Surfaceable & BinaryColorable + public typealias ObjectType = Surfaceable & BinaryColorable public var forTrue = SurfaceColorConfiguration() public var forFalse = SurfaceColorConfiguration() required public init(){} - public func getColor(_ viewModel: any ModelType) -> UIColor { - getBinaryColor(viewModel) + public func getColor(_ object: any ObjectType) -> UIColor { + getBinaryColor(object) } } @@ -151,8 +147,8 @@ public protocol BinaryDisabledSurfaceColorable: ObjectColorable { } extension BinaryDisabledSurfaceColorable { - public func getBinaryColor(_ viewModel: M) -> UIColor { - viewModel.userTrueColor ? forTrue.getColor(viewModel) : forFalse.getColor(viewModel) + public func getBinaryColor(_ object: M) -> UIColor { + object.useTrueColor ? forTrue.getColor(object) : forFalse.getColor(object) } } @@ -183,13 +179,13 @@ extension BinaryDisabledSurfaceColorable { /// /// final public class BinaryDisabledSurfaceColorConfiguration: BinaryDisabledSurfaceColorable { - public typealias ModelType = Disabling & Surfaceable & BinaryColorable + public typealias ObjectType = Disabling & Surfaceable & BinaryColorable public var forTrue = DisabledSurfaceColorConfiguration() public var forFalse = DisabledSurfaceColorConfiguration() required public init(){} - public func getColor(_ viewModel: any ModelType) -> UIColor { - getBinaryColor(viewModel) + public func getColor(_ object: any ObjectType) -> UIColor { + getBinaryColor(object) } } diff --git a/VDS/Classes/Constants.swift b/VDS/Classes/Constants.swift index 2ad7285b..4928c3f1 100644 --- a/VDS/Classes/Constants.swift +++ b/VDS/Classes/Constants.swift @@ -8,6 +8,6 @@ import Foundation public struct Constants { - public static let ModelStateDebounce = 0.0 //.001 + public static let StateDebounce = 0.0 //.001 public static let PaddingOne = 10.0 } diff --git a/VDS/Classes/Control.swift b/VDS/Classes/Control.swift index ee069bf1..1eca6467 100644 --- a/VDS/Classes/Control.swift +++ b/VDS/Classes/Control.swift @@ -10,7 +10,7 @@ import UIKit import Combine -open class Control: UIControl, ModelHandlerable, ViewProtocol, Resettable { +open class Control: UIControl, Handlerable, ViewProtocol, Resettable { //-------------------------------------------------- // MARK: - Combine Properties diff --git a/VDS/Classes/SelectorGroupHandlerBase.swift b/VDS/Classes/SelectorGroupHandlerBase.swift index d44e229f..27c56353 100644 --- a/VDS/Classes/SelectorGroupHandlerBase.swift +++ b/VDS/Classes/SelectorGroupHandlerBase.swift @@ -8,12 +8,12 @@ import Foundation import UIKit -public class SelectorGroupHandlerBase: Control { +public class SelectorGroupHandlerBase: Control { //-------------------------------------------------- // MARK: - Public Properties //-------------------------------------------------- - public var selectorViews: [ModelHandlerType] = [] + public var selectorViews: [HandlerType] = [] //-------------------------------------------------- // MARK: - Overrides @@ -33,36 +33,20 @@ public class SelectorGroupHandlerBase: Control { } } } - - public func createModelHandler() -> ModelHandlerType { - //create view - let newSelectorView = ModelHandlerType() - - //add the selectedPublisher for the change - newSelectorView - .publisher(for: .touchUpInside) - .sink { [weak self] control in - self?.didSelect(control) - } - .store(in: &subscribers) - - return newSelectorView - - } - open func didSelect(_ selectedControl: ModelHandlerType) { + open func didSelect(_ selectedControl: HandlerType) { fatalError("Must override didSelect") } public func valueChanged() { - DispatchQueue.main.asyncAfter(deadline: .now() + Constants.ModelStateDebounce) { [weak self] in + DispatchQueue.main.asyncAfter(deadline: .now() + Constants.StateDebounce) { [weak self] in self?.sendActions(for: .valueChanged) } } } -public class SelectorGroupSelectedHandlerBase: SelectorGroupHandlerBase{ - public var selectedHandler: ModelHandlerType? { +public class SelectorGroupSelectedHandlerBase: SelectorGroupHandlerBase{ + public var selectedHandler: HandlerType? { return selectorViews.filter { $0.isSelected == true }.first } } diff --git a/VDS/Classes/View.swift b/VDS/Classes/View.swift index 3d0d3841..c8304ccb 100644 --- a/VDS/Classes/View.swift +++ b/VDS/Classes/View.swift @@ -10,7 +10,7 @@ import UIKit import Combine -open class View: UIView, ModelHandlerable, ViewProtocol, Resettable { +open class View: UIView, Handlerable, ViewProtocol, Resettable { //-------------------------------------------------- // MARK: - Combine Properties diff --git a/VDS/Components/Button/Button.swift b/VDS/Components/Button/Button.swift index 11f72e42..8fb5ec7e 100644 --- a/VDS/Components/Button/Button.swift +++ b/VDS/Components/Button/Button.swift @@ -16,7 +16,7 @@ public enum ButtonSize: String, Codable, CaseIterable { case small } -open class Button: UIButton, ModelHandlerable, ViewProtocol, Resettable, Useable { +open class Button: UIButton, Handlerable, ViewProtocol, Resettable, Useable { //-------------------------------------------------- // MARK: - Combine Properties @@ -197,14 +197,14 @@ open class Button: UIButton, ModelHandlerable, ViewProtocol, Resettable, Useable //-------------------------------------------------- private class UseableColorConfiguration: ObjectColorable { - typealias ModelType = Disabling & Surfaceable & Useable + typealias ObjectType = Disabling & Surfaceable & Useable public var primary = DisabledSurfaceColorConfiguration() public var secondary = DisabledSurfaceColorConfiguration() required public init(){} - public func getColor(_ viewModel: ModelType) -> UIColor { - return viewModel.use == .primary ? primary.getColor(viewModel) : secondary.getColor(viewModel) + public func getColor(_ object: ObjectType) -> UIColor { + return object.use == .primary ? primary.getColor(object) : secondary.getColor(object) } } diff --git a/VDS/Components/Checkbox/Checkbox.swift b/VDS/Components/Checkbox/Checkbox.swift index 0d020dbb..e2355e10 100644 --- a/VDS/Components/Checkbox/Checkbox.swift +++ b/VDS/Components/Checkbox/Checkbox.swift @@ -23,7 +23,7 @@ public class SoloCheckbox: CheckboxBase{ } } -open class CheckboxBase: Control, Accessable, BinaryColorable, Errorable { +open class CheckboxBase: Control, Accessable, DataTrackable, BinaryColorable, Errorable { //-------------------------------------------------- // MARK: - Initializers //-------------------------------------------------- @@ -367,21 +367,21 @@ open class CheckboxBase: Control, Accessable, BinaryColorable, Errorable { // MARK: - Color Class Configurations //-------------------------------------------------- internal class ErrorBinaryDisabledSurfaceColorConfiguration: BinaryDisabledSurfaceColorable { - typealias ModelType = Errorable & Disabling & Surfaceable & BinaryColorable + typealias ObjectType = Errorable & Disabling & Surfaceable & BinaryColorable var error = BinarySurfaceColorConfiguration() var forTrue = DisabledSurfaceColorConfiguration() var forFalse = DisabledSurfaceColorConfiguration() required init() {} - func getColor(_ viewModel: ModelType) -> UIColor { + func getColor(_ object: ObjectType) -> UIColor { //only show error is enabled and showError == true - let showErrorColor = !viewModel.disabled && viewModel.showError + let showErrorColor = !object.disabled && object.showError if showErrorColor { - return error.getColor(viewModel) + return error.getColor(object) } else { - return getBinaryColor(viewModel) + return getBinaryColor(object) } } } diff --git a/VDS/Components/Checkbox/CheckboxGroup.swift b/VDS/Components/Checkbox/CheckboxGroup.swift index 29dfa4c9..105e916f 100644 --- a/VDS/Components/Checkbox/CheckboxGroup.swift +++ b/VDS/Components/Checkbox/CheckboxGroup.swift @@ -18,13 +18,13 @@ public class CheckboxGroup: CheckboxGroupBase { } } -public class CheckboxGroupBase: SelectorGroupHandlerBase { +public class CheckboxGroupBase: SelectorGroupHandlerBase { //-------------------------------------------------- // MARK: - Public Properties //-------------------------------------------------- - public override var selectorViews: [ModelHandlerType] { + public override var selectorViews: [HandlerType] { didSet { for selector in selectorViews { if !mainStackView.arrangedSubviews.contains(selector) { @@ -84,7 +84,7 @@ public class CheckboxGroupBase: SelectorGroupHan mainStackView.bottomAnchor.constraint(equalTo: bottomAnchor).isActive = true } - public var selectedModelHandlers: [ModelHandlerType]? { + public var selectedHandlers: [HandlerType]? { let selected = selectorViews.filter{ $0.isSelected == true } guard selected.count > 0 else { return nil } return selected diff --git a/VDS/Components/Label/Label.swift b/VDS/Components/Label/Label.swift index d56e7c70..be475664 100644 --- a/VDS/Components/Label/Label.swift +++ b/VDS/Components/Label/Label.swift @@ -12,7 +12,7 @@ import Combine public class Label: LabelBase {} -open class LabelBase: UILabel, ModelHandlerable, ViewProtocol, Resettable { +open class LabelBase: UILabel, Handlerable, ViewProtocol, Resettable { //-------------------------------------------------- // MARK: - Combine Properties diff --git a/VDS/Components/RadioBox/RadioBox.swift b/VDS/Components/RadioBox/RadioBox.swift index 4d3bc664..b0c77f43 100644 --- a/VDS/Components/RadioBox/RadioBox.swift +++ b/VDS/Components/RadioBox/RadioBox.swift @@ -24,7 +24,7 @@ public class SolorRadioBox: RadioBoxBase{ } } -open class RadioBoxBase: Control, BinaryColorable, Accessable { +open class RadioBoxBase: Control, BinaryColorable, Accessable, DataTrackable{ //-------------------------------------------------- // MARK: - Initializers //-------------------------------------------------- diff --git a/VDS/Components/RadioBox/RadioBoxGroup.swift b/VDS/Components/RadioBox/RadioBoxGroup.swift index 618eaf73..057cd18a 100644 --- a/VDS/Components/RadioBox/RadioBoxGroup.swift +++ b/VDS/Components/RadioBox/RadioBoxGroup.swift @@ -18,12 +18,12 @@ public class RadioBoxGroup: RadioBoxGroupBase { } } -public class RadioBoxGroupBase: SelectorGroupSelectedHandlerBase { +public class RadioBoxGroupBase: SelectorGroupSelectedHandlerBase { //-------------------------------------------------- // MARK: - Public Properties //-------------------------------------------------- - public override var selectorViews: [ModelHandlerType] { + public override var selectorViews: [HandlerType] { didSet { for selector in selectorViews { if !mainStackView.arrangedSubviews.contains(selector) { @@ -86,15 +86,4 @@ public class RadioBoxGroupBase: SelectorGroupSel } }.store(in: &subscribers) } - - public var selectedModelHandler: ModelHandlerType? { - if let index = selectorViews.firstIndex(where: { element in - return element.isSelected == true - }) { - return selectorViews[index] - } else { - return nil - } - } - } diff --git a/VDS/Components/RadioButton/RadioButton.swift b/VDS/Components/RadioButton/RadioButton.swift index c5c42777..9b406fb6 100644 --- a/VDS/Components/RadioButton/RadioButton.swift +++ b/VDS/Components/RadioButton/RadioButton.swift @@ -31,7 +31,7 @@ public class SoloRadioButton: RadioButtonBase { } } -open class RadioButtonBase: Control, Accessable, BinaryColorable, Errorable { +open class RadioButtonBase: Control, Accessable, DataTrackable, BinaryColorable, Errorable { //-------------------------------------------------- // MARK: - Initializers //-------------------------------------------------- diff --git a/VDS/Components/RadioButton/RadioButtonGroup.swift b/VDS/Components/RadioButton/RadioButtonGroup.swift index 9436d522..d3b103fa 100644 --- a/VDS/Components/RadioButton/RadioButtonGroup.swift +++ b/VDS/Components/RadioButton/RadioButtonGroup.swift @@ -20,12 +20,12 @@ public class RadioButtonGroup: RadioButtonGroupBase { } } -public class RadioButtonGroupBase: SelectorGroupSelectedHandlerBase { +public class RadioButtonGroupBase: SelectorGroupSelectedHandlerBase { //-------------------------------------------------- // MARK: - Public Properties //-------------------------------------------------- - public override var selectorViews: [ModelHandlerType] { + public override var selectorViews: [HandlerType] { didSet { for selector in selectorViews { if !mainStackView.arrangedSubviews.contains(selector) { diff --git a/VDS/Components/RadioSwatch/RadioSwatchGroup.swift b/VDS/Components/RadioSwatch/RadioSwatchGroup.swift index bba253e9..c3eca4a6 100644 --- a/VDS/Components/RadioSwatch/RadioSwatchGroup.swift +++ b/VDS/Components/RadioSwatch/RadioSwatchGroup.swift @@ -20,12 +20,12 @@ public class RadioSwatchGroup: RadioSwatchGroupBase { } -public class RadioSwatchGroupBase: SelectorGroupSelectedHandlerBase, UICollectionViewDataSource, UICollectionViewDelegateFlowLayout, UICollectionViewDelegate { +public class RadioSwatchGroupBase: SelectorGroupSelectedHandlerBase, UICollectionViewDataSource, UICollectionViewDelegateFlowLayout, UICollectionViewDelegate { //-------------------------------------------------- // MARK: - Public Properties //-------------------------------------------------- - public override var selectorViews: [ModelHandlerType] { + public override var selectorViews: [HandlerType] { didSet { collectionView.reloadData() } @@ -185,7 +185,7 @@ public class RadioSwatchGroupBase: SelectorGr return cell } - open func didSelect(selector: ModelHandlerType) { + open func didSelect(selector: HandlerType) { fatalError("Must override didSelect") } } diff --git a/VDS/PropertyWrappers/AnyProxy.swift b/VDS/PropertyWrappers/AnyProxy.swift deleted file mode 100644 index b504c36d..00000000 --- a/VDS/PropertyWrappers/AnyProxy.swift +++ /dev/null @@ -1,45 +0,0 @@ -// -// ProxPropertyWrapper.swift -// VDS -// -// Created by Matt Bruce on 7/29/22. -// - -import Foundation - -//https://www.swiftbysundell.com/articles/accessing-a-swift-property-wrappers-enclosing-instance/ -@propertyWrapper -public struct AnyProxy { - private let keyPath: ReferenceWritableKeyPath - - public init(_ keyPath: ReferenceWritableKeyPath) { - self.keyPath = keyPath - } - - @available(*, unavailable, message: "The wrapped value must be accessed from the enclosing instance property.") - public var wrappedValue: Value { - get { fatalError() } - set { fatalError() } - } - - public static subscript( - _enclosingInstance observed: EnclosingSelf, - wrapped wrappedKeyPath: ReferenceWritableKeyPath, - storage storageKeyPath: ReferenceWritableKeyPath - ) -> Value { - get { - let storageValue = observed[keyPath: storageKeyPath] - let value = observed[keyPath: storageValue.keyPath] - return value - } - set { - let storageValue = observed[keyPath: storageKeyPath] - observed[keyPath: storageValue.keyPath] = newValue - } - } -} - -extension NSObject: ProxyContainer {} -public protocol ProxyContainer { - typealias Proxy = AnyProxy -} diff --git a/VDS/PropertyWrappers/CodableColor.swift b/VDS/PropertyWrappers/CodableColor.swift deleted file mode 100644 index 3b046acc..00000000 --- a/VDS/PropertyWrappers/CodableColor.swift +++ /dev/null @@ -1,57 +0,0 @@ -// -// CodableColor.swift -// VDS -// -// Created by Matt Bruce on 8/26/22. -// - -import Foundation -import UIKit - -@propertyWrapper -public struct CodableColor { - public var wrappedValue: UIColor - - public init(wrappedValue: UIColor) { - self.wrappedValue = wrappedValue - } -} - -extension CodableColor: Codable { - public init(from decoder: Decoder) throws { - let container = try decoder.singleValueContainer() - let colorString = try container.decode(String.self) - wrappedValue = UIColor(hexString: colorString) - } - - public func encode(to encoder: Encoder) throws { - var container = encoder.singleValueContainer() - try container.encode(wrappedValue.hexString) - } -} - -@propertyWrapper -public struct OptionalCodableColor { - public var wrappedValue: UIColor? - - public init(wrappedValue: UIColor?) { - self.wrappedValue = wrappedValue - } -} - -extension OptionalCodableColor: Codable { - public init(from decoder: Decoder) throws { - let container = try decoder.singleValueContainer() - if container.decodeNil() { - wrappedValue = nil - } else { - let colorString = try container.decode(String.self) - wrappedValue = UIColor(hexString: colorString) - } - } - - public func encode(to encoder: Encoder) throws { - var container = encoder.singleValueContainer() - try container.encode(wrappedValue?.hexString) - } -} diff --git a/VDS/PropertyWrappers/Debuggable.swift b/VDS/PropertyWrappers/Debuggable.swift deleted file mode 100644 index 822f6182..00000000 --- a/VDS/PropertyWrappers/Debuggable.swift +++ /dev/null @@ -1,31 +0,0 @@ -// -// File.swift -// VDS -// -// Created by Matt Bruce on 8/11/22. -// - -import Foundation - -@propertyWrapper -public struct Debuggable { - private var value: Value - private let description: String - - public init(wrappedValue: Value, description: String = "") { - print("Initialized '\(description)' with value \(wrappedValue)") - self.value = wrappedValue - self.description = description - } - - public var wrappedValue: Value { - get { - print("Accessing '\(description)', returning: \(value)") - return value - } - set { - print("Updating '\(description)', newValue: \(newValue)") - value = newValue - } - } -} diff --git a/VDS/PropertyWrappers/UsesAutoLayout.swift b/VDS/PropertyWrappers/UsesAutoLayout.swift deleted file mode 100644 index 4556a291..00000000 --- a/VDS/PropertyWrappers/UsesAutoLayout.swift +++ /dev/null @@ -1,23 +0,0 @@ -// -// UseAutoLayout.swift -// VDS -// -// Created by Matt Bruce on 8/11/22. -// - -import Foundation -import UIKit - -@propertyWrapper -public struct UsesAutoLayout { - public var wrappedValue: T { - didSet { - wrappedValue.translatesAutoresizingMaskIntoConstraints = false - } - } - - public init(wrappedValue: T) { - self.wrappedValue = wrappedValue - wrappedValue.translatesAutoresizingMaskIntoConstraints = false - } -} diff --git a/VDS/Protocols/Accessable.swift b/VDS/Protocols/Accessable.swift index 0b2981fe..75d44fca 100644 --- a/VDS/Protocols/Accessable.swift +++ b/VDS/Protocols/Accessable.swift @@ -18,7 +18,7 @@ public protocol Accessable { } //Configurations to set within the UIControl -extension ModelHandlerable where Self: UIView, Self: Accessable { +extension Handlerable where Self: UIView, Self: Accessable { public func setAccessibilityHint(_ override: Bool? = nil) { let check = override ?? !disabled diff --git a/VDS/Protocols/Colorable.swift b/VDS/Protocols/Colorable.swift index 92a7f461..3c43bf1a 100644 --- a/VDS/Protocols/Colorable.swift +++ b/VDS/Protocols/Colorable.swift @@ -8,15 +8,15 @@ import Foundation import UIKit -public protocol Colorable { - associatedtype ModelType - func getColor(_ viewModel: ModelType) -> UIColor +public protocol Colorable { + associatedtype ObjectType + func getColor(_ object: ObjectType) -> UIColor } extension Colorable { - fileprivate func getColor(_ viewModel: Any) -> UIColor { - guard let model = viewModel as? ModelType else { - assertionFailure("Invalid ModelType, Expecting type \(ModelType.self), received \(viewModel) ") + fileprivate func getColor(_ object: Any) -> UIColor { + guard let model = object as? ObjectType else { + assertionFailure("Invalid ObjectType, Expecting type \(ObjectType.self), received \(object) ") return .black } return getColor(model) @@ -25,15 +25,15 @@ extension Colorable { public func eraseToAnyColorable() -> AnyColorable { AnyColorable(self) } } -public struct GenericColorable: Colorable, Withable { - private var wrapped: any Colorable +public struct GenericColorable: Colorable, Withable { + private var wrapped: any Colorable - public init(colorable: C) where C.ModelType == ModelType { + public init(colorable: C) where C.ObjectType == ObjectType { wrapped = colorable } - public func getColor(_ viewModel: ModelType) -> UIColor { - wrapped.getColor(viewModel) + public func getColor(_ object: ObjectType) -> UIColor { + wrapped.getColor(object) } } @@ -44,7 +44,7 @@ public struct AnyColorable: Colorable, Withable { wrapped = colorable } - public func getColor(_ viewModel: Any) -> UIColor { - wrapped.getColor(viewModel) + public func getColor(_ object: Any) -> UIColor { + wrapped.getColor(object) } } diff --git a/VDS/Protocols/ModelHandlerable.swift b/VDS/Protocols/Handlerable.swift similarity index 64% rename from VDS/Protocols/ModelHandlerable.swift rename to VDS/Protocols/Handlerable.swift index ab6bbcb4..70c2508f 100644 --- a/VDS/Protocols/ModelHandlerable.swift +++ b/VDS/Protocols/Handlerable.swift @@ -1,5 +1,5 @@ // -// Modelable.swift +// Handlerable.swift // VDS // // Created by Matt Bruce on 7/22/22. @@ -9,23 +9,23 @@ import Foundation import Combine import UIKit -public protocol ModelHandlerable: AnyObject, Initable, Disabling, Surfaceable { +public protocol Handlerable: AnyObject, Initable, Disabling, Surfaceable { var subject: PassthroughSubject { get set } var subscribers: Set { get set } func updateView() } -extension ModelHandlerable { +extension Handlerable { public func handlerPublisher() -> AnyPublisher { subject .eraseToAnyPublisher() - .debounce(for: .seconds(Constants.ModelStateDebounce), scheduler: RunLoop.main) + .debounce(for: .seconds(Constants.StateDebounce), scheduler: RunLoop.main) .eraseToAnyPublisher() } } -extension ModelHandlerable where Self: UIView { +extension Handlerable where Self: UIView { public func didChange() { subject.send() setNeedsLayout() diff --git a/VDS/Protocols/Labelable.swift b/VDS/Protocols/Labelable.swift deleted file mode 100644 index f5ff76cc..00000000 --- a/VDS/Protocols/Labelable.swift +++ /dev/null @@ -1,20 +0,0 @@ -// -// LabelModelable.swift -// VDS -// -// Created by Matt Bruce on 7/28/22. -// - -import Foundation -import UIKit - -public protocol Labelable { - var typograpicalStyle: TypographicalStyle { get set } - var textPosition: TextPosition { get set } -} - -extension Labelable { - public var font: UIFont? { - return typograpicalStyle.font - } -} diff --git a/VDS/Protocols/Modelable.swift b/VDS/Protocols/Modelable.swift deleted file mode 100644 index 78c5ab6c..00000000 --- a/VDS/Protocols/Modelable.swift +++ /dev/null @@ -1,18 +0,0 @@ -// -// Modelable.swift -// VDS -// -// Created by Matt Bruce on 8/5/22. -// - -import Foundation - -public protocol Modelable: Surfaceable, Disabling, Initable, Withable, Identifiable, Equatable, CustomDebugStringConvertible where ID == UUID { - -} - -extension Modelable { - public var debugDescription: String { - return "\(id.uuidString)" - } -} diff --git a/VDS/Protocols/Selectable.swift b/VDS/Protocols/Selectable.swift deleted file mode 100644 index fa7777cd..00000000 --- a/VDS/Protocols/Selectable.swift +++ /dev/null @@ -1,12 +0,0 @@ -// -// Selectable.swift -// VDS -// -// Created by Matt Bruce on 8/23/22. -// - -import Foundation - -public protocol Selectable { - var selected: Bool { get set } -} diff --git a/VDS/Protocols/SelectorGroupModelable.swift b/VDS/Protocols/SelectorGroupModelable.swift deleted file mode 100644 index 4657b7c6..00000000 --- a/VDS/Protocols/SelectorGroupModelable.swift +++ /dev/null @@ -1,37 +0,0 @@ -// -// SelectorGroupModel.swift -// VDS -// -// Created by Matt Bruce on 8/11/22. -// - -import Foundation - -///MARK: Groups that allow anything selected -public protocol SelectorGroupModelable: Modelable, FormFieldable { - associatedtype SelectorModelType: Modelable where SelectorModelType: FormFieldable & Selectable - var selectors: [SelectorModelType] { get set } -} - -extension SelectorGroupModelable { - public var debugDescription: String { - "group id: \(id.uuidString)\r\(selectors.compactMap{"id: \($0.debugDescription) \($0.selected ? "*" : "")"}.joined(separator: "\r"))" - } -} - -///MARK: Groups that allow single selections -public protocol SelectorGroupSelectedModelable: SelectorGroupModelable { - var selectedModel: SelectorModelType? { get } -} - -extension SelectorGroupSelectedModelable { - public var selectedModel: SelectorModelType? { - if let index = selectors.firstIndex(where: { element in - return element.selected == true - }) { - return selectors[index] - } else { - return nil - } - } -} From 46d0bb3047f7fb4532f16252dec68dda9d220e83 Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Fri, 21 Oct 2022 10:42:24 -0500 Subject: [PATCH 19/29] added @objc() class name to keep collisions from occurring Signed-off-by: Matt Bruce --- VDS/Classes/Control.swift | 2 +- VDS/Classes/View.swift | 1 + VDS/Components/Badge/Badge.swift | 1 + VDS/Components/Button/Button.swift | 1 + VDS/Components/Checkbox/Checkbox.swift | 3 +++ VDS/Components/Checkbox/CheckboxGroup.swift | 1 + VDS/Components/Label/Label.swift | 2 ++ VDS/Components/RadioBox/RadioBox.swift | 5 ++++- VDS/Components/RadioBox/RadioBoxGroup.swift | 1 + VDS/Components/RadioButton/RadioButton.swift | 3 +++ VDS/Components/RadioButton/RadioButtonGroup.swift | 1 + VDS/Components/RadioSwatch/RadioSwatch.swift | 2 ++ VDS/Components/RadioSwatch/RadioSwatchGroup.swift | 2 ++ VDS/Components/Toggle/Toggle.swift | 2 ++ 14 files changed, 25 insertions(+), 2 deletions(-) diff --git a/VDS/Classes/Control.swift b/VDS/Classes/Control.swift index 1eca6467..79a26591 100644 --- a/VDS/Classes/Control.swift +++ b/VDS/Classes/Control.swift @@ -9,7 +9,7 @@ import Foundation import UIKit import Combine - +@objc(VDSControl) open class Control: UIControl, Handlerable, ViewProtocol, Resettable { //-------------------------------------------------- diff --git a/VDS/Classes/View.swift b/VDS/Classes/View.swift index c8304ccb..1a08301a 100644 --- a/VDS/Classes/View.swift +++ b/VDS/Classes/View.swift @@ -10,6 +10,7 @@ import UIKit import Combine +@objc(VDSView) open class View: UIView, Handlerable, ViewProtocol, Resettable { //-------------------------------------------------- diff --git a/VDS/Components/Badge/Badge.swift b/VDS/Components/Badge/Badge.swift index 2f1feed6..d0550acf 100644 --- a/VDS/Components/Badge/Badge.swift +++ b/VDS/Components/Badge/Badge.swift @@ -15,6 +15,7 @@ public enum BadgeFillColor: String, Codable, CaseIterable { case red, yellow, green, orange, blue, black, white } +@objc(VDSBadge) public class Badge: View, Accessable { private var label = Label() diff --git a/VDS/Components/Button/Button.swift b/VDS/Components/Button/Button.swift index 8fb5ec7e..0d5ed7d5 100644 --- a/VDS/Components/Button/Button.swift +++ b/VDS/Components/Button/Button.swift @@ -16,6 +16,7 @@ public enum ButtonSize: String, Codable, CaseIterable { case small } +@objc(VDSButton) open class Button: UIButton, Handlerable, ViewProtocol, Resettable, Useable { //-------------------------------------------------- diff --git a/VDS/Components/Checkbox/Checkbox.swift b/VDS/Components/Checkbox/Checkbox.swift index e2355e10..303d7f81 100644 --- a/VDS/Components/Checkbox/Checkbox.swift +++ b/VDS/Components/Checkbox/Checkbox.swift @@ -11,8 +11,10 @@ import VDSColorTokens import VDSFormControlsTokens import Combine +@objc(VDSCheckbox) public class Checkbox: CheckboxBase{} +@objc(VDSSoloCheckbox) public class SoloCheckbox: CheckboxBase{ public override func initialSetup() { super.initialSetup() @@ -23,6 +25,7 @@ public class SoloCheckbox: CheckboxBase{ } } +@objc(VDSCheckboxBase) open class CheckboxBase: Control, Accessable, DataTrackable, BinaryColorable, Errorable { //-------------------------------------------------- // MARK: - Initializers diff --git a/VDS/Components/Checkbox/CheckboxGroup.swift b/VDS/Components/Checkbox/CheckboxGroup.swift index 105e916f..7501d11f 100644 --- a/VDS/Components/Checkbox/CheckboxGroup.swift +++ b/VDS/Components/Checkbox/CheckboxGroup.swift @@ -8,6 +8,7 @@ import Foundation import UIKit +@objc(VDSCheckboxGroup) public class CheckboxGroup: CheckboxGroupBase { public override func didSelect(_ selectedControl: Checkbox) { selectedControl.toggle() diff --git a/VDS/Components/Label/Label.swift b/VDS/Components/Label/Label.swift index be475664..67d4b837 100644 --- a/VDS/Components/Label/Label.swift +++ b/VDS/Components/Label/Label.swift @@ -10,8 +10,10 @@ import UIKit import VDSColorTokens import Combine +@objc(VDSLabel) public class Label: LabelBase {} +@objc(VDSLabelBase) open class LabelBase: UILabel, Handlerable, ViewProtocol, Resettable { //-------------------------------------------------- diff --git a/VDS/Components/RadioBox/RadioBox.swift b/VDS/Components/RadioBox/RadioBox.swift index b0c77f43..b5a3c252 100644 --- a/VDS/Components/RadioBox/RadioBox.swift +++ b/VDS/Components/RadioBox/RadioBox.swift @@ -11,9 +11,11 @@ import VDSColorTokens import VDSFormControlsTokens import Combine +@objc(VDSRadioBox) public class RadioBox: RadioBoxBase{} -public class SolorRadioBox: RadioBoxBase{ +@objc(VDSSoloRadioBox) +public class SoloRadioBox: RadioBoxBase{ public override func initialSetup() { super.initialSetup() @@ -24,6 +26,7 @@ public class SolorRadioBox: RadioBoxBase{ } } +@objc(VDSRadioBoxBase) open class RadioBoxBase: Control, BinaryColorable, Accessable, DataTrackable{ //-------------------------------------------------- // MARK: - Initializers diff --git a/VDS/Components/RadioBox/RadioBoxGroup.swift b/VDS/Components/RadioBox/RadioBoxGroup.swift index 057cd18a..f2c4022f 100644 --- a/VDS/Components/RadioBox/RadioBoxGroup.swift +++ b/VDS/Components/RadioBox/RadioBoxGroup.swift @@ -8,6 +8,7 @@ import Foundation import UIKit +@objc(VDSRadioBoxGroup) public class RadioBoxGroup: RadioBoxGroupBase { public override func didSelect(_ selectedControl: RadioBox) { diff --git a/VDS/Components/RadioButton/RadioButton.swift b/VDS/Components/RadioButton/RadioButton.swift index 9b406fb6..e46a4e8c 100644 --- a/VDS/Components/RadioButton/RadioButton.swift +++ b/VDS/Components/RadioButton/RadioButton.swift @@ -10,6 +10,7 @@ import UIKit import VDSColorTokens import VDSFormControlsTokens +@objc(VDSRadioButton) public class RadioButton: RadioButtonBase { //for groups allows "toggle" open override func toggle() { @@ -21,6 +22,7 @@ public class RadioButton: RadioButtonBase { } } +@objc(VDSSoloRadioButton) public class SoloRadioButton: RadioButtonBase { public override func initialSetup() { super.initialSetup() @@ -31,6 +33,7 @@ public class SoloRadioButton: RadioButtonBase { } } +@objc(VDSRadioButtonBase) open class RadioButtonBase: Control, Accessable, DataTrackable, BinaryColorable, Errorable { //-------------------------------------------------- // MARK: - Initializers diff --git a/VDS/Components/RadioButton/RadioButtonGroup.swift b/VDS/Components/RadioButton/RadioButtonGroup.swift index d3b103fa..1b357102 100644 --- a/VDS/Components/RadioButton/RadioButtonGroup.swift +++ b/VDS/Components/RadioButton/RadioButtonGroup.swift @@ -8,6 +8,7 @@ import Foundation import UIKit +@objc(VDSRadioButtonGroup) public class RadioButtonGroup: RadioButtonGroupBase { public override func didSelect(_ selectedControl: RadioButton) { diff --git a/VDS/Components/RadioSwatch/RadioSwatch.swift b/VDS/Components/RadioSwatch/RadioSwatch.swift index 003feceb..f548f18d 100644 --- a/VDS/Components/RadioSwatch/RadioSwatch.swift +++ b/VDS/Components/RadioSwatch/RadioSwatch.swift @@ -11,6 +11,7 @@ import VDSColorTokens import VDSFormControlsTokens import Combine +@objc(VDSRadioSwatch) public class RadioSwatch: RadioSwatchBase{ public override func initialSetup() { super.initialSetup() @@ -21,6 +22,7 @@ public class RadioSwatch: RadioSwatchBase{ } } +@objc(VDSRadioSwatchBase) open class RadioSwatchBase: Control, Accessable, DataTrackable, BinaryColorable { //-------------------------------------------------- diff --git a/VDS/Components/RadioSwatch/RadioSwatchGroup.swift b/VDS/Components/RadioSwatch/RadioSwatchGroup.swift index c3eca4a6..5132ba7a 100644 --- a/VDS/Components/RadioSwatch/RadioSwatchGroup.swift +++ b/VDS/Components/RadioSwatch/RadioSwatchGroup.swift @@ -9,6 +9,7 @@ import Foundation import UIKit import Combine +@objc(VDSRadioSwatchGroup) public class RadioSwatchGroup: RadioSwatchGroupBase { public override func didSelect(selector: RadioSwatch) { @@ -177,6 +178,7 @@ public class RadioSwatchGroupBase: SelectorGroupSe let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "collectionViewCell", for: indexPath) let handler = selectorViews[indexPath.row] handler.isUserInteractionEnabled = false + cell.subviews.forEach { $0.removeFromSuperview() } cell.addSubview(handler) handler.topAnchor.constraint(equalTo: cell.topAnchor).isActive = true handler.leadingAnchor.constraint(equalTo: cell.leadingAnchor).isActive = true diff --git a/VDS/Components/Toggle/Toggle.swift b/VDS/Components/Toggle/Toggle.swift index 59f27f70..636f7545 100644 --- a/VDS/Components/Toggle/Toggle.swift +++ b/VDS/Components/Toggle/Toggle.swift @@ -30,6 +30,7 @@ public enum ToggleTextPosition: String, CaseIterable { Container: The background of the toggle control. Knob: The circular indicator that slides on the container. */ +@objc(VDSToggle) public class Toggle: ToggleBase{ public override func initialSetup() { super.initialSetup() @@ -40,6 +41,7 @@ public class Toggle: ToggleBase{ } } +@objc(VDSToggleBase) open class ToggleBase: Control, Accessable, DataTrackable, BinaryColorable { //-------------------------------------------------- From a46507c90a483ee37b9a0364e5552798fc088044 Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Fri, 21 Oct 2022 10:43:10 -0500 Subject: [PATCH 20/29] added objc header for compilation Signed-off-by: Matt Bruce --- VDS.xcodeproj/project.pbxproj | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/VDS.xcodeproj/project.pbxproj b/VDS.xcodeproj/project.pbxproj index 72db300b..fbb8f852 100644 --- a/VDS.xcodeproj/project.pbxproj +++ b/VDS.xcodeproj/project.pbxproj @@ -787,7 +787,7 @@ SKIP_INSTALL = YES; SUPPORTS_MACCATALYST = YES; SWIFT_EMIT_LOC_STRINGS = YES; - SWIFT_INSTALL_OBJC_HEADER = NO; + SWIFT_INSTALL_OBJC_HEADER = YES; SWIFT_VERSION = 5.0; TARGETED_DEVICE_FAMILY = "1,2"; }; @@ -819,7 +819,7 @@ SKIP_INSTALL = YES; SUPPORTS_MACCATALYST = YES; SWIFT_EMIT_LOC_STRINGS = YES; - SWIFT_INSTALL_OBJC_HEADER = NO; + SWIFT_INSTALL_OBJC_HEADER = YES; SWIFT_VERSION = 5.0; TARGETED_DEVICE_FAMILY = "1,2"; }; From 5e8a1d349bcc2674e79d93d4f85ade316b636c9f Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Fri, 21 Oct 2022 15:28:06 -0500 Subject: [PATCH 21/29] removed code Signed-off-by: Matt Bruce --- VDS/Components/Toggle/Toggle.swift | 75 +++++++++++++----------------- 1 file changed, 33 insertions(+), 42 deletions(-) diff --git a/VDS/Components/Toggle/Toggle.swift b/VDS/Components/Toggle/Toggle.swift index 636f7545..5e43393d 100644 --- a/VDS/Components/Toggle/Toggle.swift +++ b/VDS/Components/Toggle/Toggle.swift @@ -67,6 +67,7 @@ open class ToggleBase: Control, Accessable, DataTrackable, BinaryColorable { $0.translatesAutoresizingMaskIntoConstraints = false $0.axis = .horizontal $0.distribution = .fill + $0.alignment = .leading } }() @@ -175,10 +176,6 @@ open class ToggleBase: Control, Accessable, DataTrackable, BinaryColorable { //-------------------------------------------------- private var knobLeadingConstraint: NSLayoutConstraint? private var knobTrailingConstraint: NSLayoutConstraint? - private var knobHeightConstraint: NSLayoutConstraint? - private var knobWidthConstraint: NSLayoutConstraint? - private var toggleHeightConstraint: NSLayoutConstraint? - private var toggleWidthConstraint: NSLayoutConstraint? //functions //-------------------------------------------------- @@ -188,15 +185,14 @@ open class ToggleBase: Control, Accessable, DataTrackable, BinaryColorable { self.knobLeadingConstraint?.isActive = false self.knobTrailingConstraint?.isActive = false if isOn { - self.knobTrailingConstraint = self.toggleView.trailingAnchor.constraint(equalTo: self.knobView.trailingAnchor, constant: 2) - self.knobLeadingConstraint = self.knobView.leadingAnchor.constraint(greaterThanOrEqualTo: self.toggleView.leadingAnchor) + knobTrailingConstraint = toggleView.trailingAnchor.constraint(equalTo: knobView.trailingAnchor, constant: 2) + knobLeadingConstraint = knobView.leadingAnchor.constraint(greaterThanOrEqualTo: toggleView.leadingAnchor) } else { - self.knobTrailingConstraint = self.toggleView.trailingAnchor.constraint(greaterThanOrEqualTo: self.knobView.trailingAnchor) - self.knobLeadingConstraint = self.knobView.leadingAnchor.constraint(equalTo: self.toggleView.leadingAnchor, constant: 2) + knobTrailingConstraint = toggleView.trailingAnchor.constraint(greaterThanOrEqualTo: knobView.trailingAnchor) + knobLeadingConstraint = knobView.leadingAnchor.constraint(equalTo: toggleView.leadingAnchor, constant: 2) } - self.knobTrailingConstraint?.isActive = true - self.knobLeadingConstraint?.isActive = true - self.knobWidthConstraint?.constant = self.knobSize.width + knobTrailingConstraint?.isActive = true + knobLeadingConstraint?.isActive = true self.layoutIfNeeded() } @@ -260,48 +256,43 @@ open class ToggleBase: Control, Accessable, DataTrackable, BinaryColorable { isAccessibilityElement = true accessibilityTraits = .button addSubview(stackView) - - //create the wrapping view + + //set the h/w to container size, since the width "can" grow if text is there + //allow this to be greaterThanEqualTo + heightAnchor.constraint(equalToConstant: toggleContainerSize.height).isActive = true + widthAnchor.constraint(greaterThanOrEqualToConstant: toggleContainerSize.width).isActive = true + + //create the container for the toggle/knob let toggleContainerView = UIView() toggleContainerView.translatesAutoresizingMaskIntoConstraints = false toggleContainerView.backgroundColor = .clear toggleContainerView.widthAnchor.constraint(equalToConstant: toggleContainerSize.width).isActive = true toggleContainerView.heightAnchor.constraint(equalToConstant: toggleContainerSize.height).isActive = true - toggleHeightConstraint = toggleView.heightAnchor.constraint(equalToConstant: toggleSize.height) - toggleHeightConstraint?.isActive = true - - toggleWidthConstraint = toggleView.widthAnchor.constraint(equalToConstant: toggleSize.width) - toggleWidthConstraint?.isActive = true - - toggleView.layer.cornerRadius = toggleSize.height / 2.0 - knobView.layer.cornerRadius = knobSize.height / 2.0 - - toggleView.backgroundColor = toggleColorConfiguration.getColor(self) - + //adding views toggleContainerView.addSubview(toggleView) toggleView.addSubview(knobView) - - - knobHeightConstraint = knobView.heightAnchor.constraint(equalToConstant: knobSize.height) - knobHeightConstraint?.isActive = true - knobWidthConstraint = knobView.widthAnchor.constraint(equalToConstant: knobSize.width) - knobWidthConstraint?.isActive = true - knobView.centerYAnchor.constraint(equalTo: toggleView.centerYAnchor).isActive = true - knobView.topAnchor.constraint(greaterThanOrEqualTo: toggleView.topAnchor).isActive = true - - toggleView.bottomAnchor.constraint(greaterThanOrEqualTo: knobView.bottomAnchor).isActive = true - - updateLabel() stackView.addArrangedSubview(toggleContainerView) - stackView.topAnchor.constraint(equalTo: topAnchor).isActive = true - stackView.leadingAnchor.constraint(equalTo: leadingAnchor).isActive = true - stackView.widthAnchor.constraint(greaterThanOrEqualToConstant: toggleContainerSize.width).isActive = true - stackView.bottomAnchor.constraint(equalTo: bottomAnchor).isActive = true - + + //adding constraints + toggleView.heightAnchor.constraint(equalToConstant: toggleSize.height).isActive = true + toggleView.widthAnchor.constraint(equalToConstant: toggleSize.width).isActive = true + toggleView.layer.cornerRadius = toggleSize.height / 2.0 + toggleView.bottomAnchor.constraint(greaterThanOrEqualTo: knobView.bottomAnchor).isActive = true toggleView.centerXAnchor.constraint(equalTo: toggleContainerView.centerXAnchor).isActive = true toggleView.centerYAnchor.constraint(equalTo: toggleContainerView.centerYAnchor).isActive = true - + + knobView.layer.cornerRadius = knobSize.height / 2.0 + knobView.heightAnchor.constraint(equalToConstant: knobSize.height).isActive = true + knobView.widthAnchor.constraint(equalToConstant: knobSize.width).isActive = true + knobView.centerYAnchor.constraint(equalTo: toggleView.centerYAnchor).isActive = true + knobView.topAnchor.constraint(greaterThanOrEqualTo: toggleView.topAnchor).isActive = true + + //pin stackview to edges + stackView.topAnchor.constraint(equalTo: topAnchor).isActive = true + stackView.leadingAnchor.constraint(equalTo: leadingAnchor).isActive = true + stackView.trailingAnchor.constraint(equalTo: trailingAnchor).isActive = true + stackView.bottomAnchor.constraint(equalTo: bottomAnchor).isActive = true } public override func reset() { From 790fa208db995cdaf380a937070ee78159e1bb63 Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Fri, 21 Oct 2022 17:07:45 -0500 Subject: [PATCH 22/29] added isAnimated logic Signed-off-by: Matt Bruce --- VDS/Components/Toggle/Toggle.swift | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/VDS/Components/Toggle/Toggle.swift b/VDS/Components/Toggle/Toggle.swift index 5e43393d..17c74373 100644 --- a/VDS/Components/Toggle/Toggle.swift +++ b/VDS/Components/Toggle/Toggle.swift @@ -136,6 +136,8 @@ open class ToggleBase: Control, Accessable, DataTrackable, BinaryColorable { // MARK: - Public Properties //-------------------------------------------------- open var isOn: Bool = false { didSet { didChange() }} + + open var isAnimated: Bool = true { didSet { didChange() }} open var showText: Bool = false { didSet { didChange() }} @@ -200,7 +202,7 @@ open class ToggleBase: Control, Accessable, DataTrackable, BinaryColorable { let toggleColor = toggleColorConfiguration.getColor(self) let knobColor = knobColorConfiguration.getColor(self) - if disabled { + if disabled || !isAnimated { toggleView.backgroundColor = toggleColor knobView.backgroundColor = knobColor constrainKnob() From 4fc2fbd63b1c2d618fc09c37d02bd13e275ca1bd Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Fri, 21 Oct 2022 17:08:01 -0500 Subject: [PATCH 23/29] removed embedded setting Signed-off-by: Matt Bruce --- VDS.xcodeproj/project.pbxproj | 20 -------------------- 1 file changed, 20 deletions(-) diff --git a/VDS.xcodeproj/project.pbxproj b/VDS.xcodeproj/project.pbxproj index fbb8f852..d063f035 100644 --- a/VDS.xcodeproj/project.pbxproj +++ b/VDS.xcodeproj/project.pbxproj @@ -47,11 +47,8 @@ EAA5EEE228F4C62C003B3210 /* Colorable.swift in Sources */ = {isa = PBXBuildFile; fileRef = EAA5EEE128F4C62C003B3210 /* Colorable.swift */; }; EAA5EEE428F5B855003B3210 /* VerizonNHGDS-Light.otf in Resources */ = {isa = PBXBuildFile; fileRef = EAA5EEE328F5B855003B3210 /* VerizonNHGDS-Light.otf */; }; EAA5EEEF28F5C908003B3210 /* VDSTypographyTokens.xcframework in Frameworks */ = {isa = PBXBuildFile; fileRef = EAA5EEEC28F5C908003B3210 /* VDSTypographyTokens.xcframework */; }; - EAA5EEF028F5C909003B3210 /* VDSTypographyTokens.xcframework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = EAA5EEEC28F5C908003B3210 /* VDSTypographyTokens.xcframework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; EAA5EEF128F5C909003B3210 /* VDSColorTokens.xcframework in Frameworks */ = {isa = PBXBuildFile; fileRef = EAA5EEED28F5C908003B3210 /* VDSColorTokens.xcframework */; }; - EAA5EEF228F5C909003B3210 /* VDSColorTokens.xcframework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = EAA5EEED28F5C908003B3210 /* VDSColorTokens.xcframework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; EAA5EEF328F5C909003B3210 /* VDSFormControlsTokens.xcframework in Frameworks */ = {isa = PBXBuildFile; fileRef = EAA5EEEE28F5C908003B3210 /* VDSFormControlsTokens.xcframework */; }; - EAA5EEF428F5C909003B3210 /* VDSFormControlsTokens.xcframework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = EAA5EEEE28F5C908003B3210 /* VDSFormControlsTokens.xcframework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; EAB1D29C28A5618900DAE764 /* RadioButtonGroup.swift in Sources */ = {isa = PBXBuildFile; fileRef = EAB1D29B28A5618900DAE764 /* RadioButtonGroup.swift */; }; EAB1D2CD28ABE76100DAE764 /* Withable.swift in Sources */ = {isa = PBXBuildFile; fileRef = EAB1D2CC28ABE76000DAE764 /* Withable.swift */; }; EAB1D2CF28ABEF2B00DAE764 /* Typography.swift in Sources */ = {isa = PBXBuildFile; fileRef = EAB1D2CE28ABEF2B00DAE764 /* Typography.swift */; }; @@ -87,22 +84,6 @@ }; /* End PBXContainerItemProxy section */ -/* Begin PBXCopyFilesBuildPhase section */ - EAA5EEF528F5C909003B3210 /* Embed Frameworks */ = { - isa = PBXCopyFilesBuildPhase; - buildActionMask = 2147483647; - dstPath = ""; - dstSubfolderSpec = 10; - files = ( - EAA5EEF428F5C909003B3210 /* VDSFormControlsTokens.xcframework in Embed Frameworks */, - EAA5EEF028F5C909003B3210 /* VDSTypographyTokens.xcframework in Embed Frameworks */, - EAA5EEF228F5C909003B3210 /* VDSColorTokens.xcframework in Embed Frameworks */, - ); - name = "Embed Frameworks"; - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXCopyFilesBuildPhase section */ - /* Begin PBXFileReference section */ 5F21D7BE28DCEB3D003E7CD6 /* Useable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Useable.swift; sourceTree = ""; }; 5FC35BE228D51405004EBEAC /* Button.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Button.swift; sourceTree = ""; }; @@ -472,7 +453,6 @@ EA336168288B19200071C351 /* Sources */, EA336169288B19200071C351 /* Frameworks */, EA33616A288B19200071C351 /* Resources */, - EAA5EEF528F5C909003B3210 /* Embed Frameworks */, ); buildRules = ( ); From 87703edf8de9cd4a6568a78587537f750fd66bb5 Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Tue, 25 Oct 2022 14:18:08 -0500 Subject: [PATCH 24/29] added framework search paths Signed-off-by: Matt Bruce --- VDS.xcodeproj/project.pbxproj | 2 ++ 1 file changed, 2 insertions(+) diff --git a/VDS.xcodeproj/project.pbxproj b/VDS.xcodeproj/project.pbxproj index d063f035..22a08b39 100644 --- a/VDS.xcodeproj/project.pbxproj +++ b/VDS.xcodeproj/project.pbxproj @@ -752,6 +752,7 @@ DYLIB_COMPATIBILITY_VERSION = 1; DYLIB_CURRENT_VERSION = 1; DYLIB_INSTALL_NAME_BASE = "@rpath"; + FRAMEWORK_SEARCH_PATHS = "$(PROJECT_DIR)/../../SharedFrameworks"; GENERATE_INFOPLIST_FILE = YES; INFOPLIST_KEY_NSHumanReadableCopyright = ""; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; @@ -784,6 +785,7 @@ DYLIB_COMPATIBILITY_VERSION = 1; DYLIB_CURRENT_VERSION = 1; DYLIB_INSTALL_NAME_BASE = "@rpath"; + FRAMEWORK_SEARCH_PATHS = "$(PROJECT_DIR)/../../SharedFrameworks"; GENERATE_INFOPLIST_FILE = YES; INFOPLIST_KEY_NSHumanReadableCopyright = ""; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; From 9ad55d523ef12d9a7b2cf8b51681fe6a494d7f36 Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Wed, 26 Oct 2022 09:27:26 -0500 Subject: [PATCH 25/29] added scripts for creating frameworks Signed-off-by: Matt Bruce --- .gitlab-ci.yml | 90 ++++++++++++++++++++++++++++++++ Scripts/build_aggregate.sh | 53 +++++++++++++++++++ Scripts/download_dependencies.sh | 25 +++++++++ Scripts/download_framework.sh | 86 ++++++++++++++++++++++++++++++ Scripts/upload_framework.sh | 86 ++++++++++++++++++++++++++++++ Scripts/upload_vds_frameworks.sh | 25 +++++++++ 6 files changed, 365 insertions(+) create mode 100644 .gitlab-ci.yml create mode 100755 Scripts/build_aggregate.sh create mode 100755 Scripts/download_dependencies.sh create mode 100755 Scripts/download_framework.sh create mode 100755 Scripts/upload_framework.sh create mode 100755 Scripts/upload_vds_frameworks.sh diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 00000000..aed16c3a --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,90 @@ +stages: +# - test + - download + - build + - deploy + +#test: +# stage: test +# script: +# - echo "This job tests something" +# tags: +# - xcode_12_2 + +download_artifacts: + stage: download + script: + - ./Scripts/download_dependencies.sh + only: + - branches + - develop + tags: + - bash_shell + environment: + name: oneartifactory + url: https://oneartifactoryprod.verizon.com/artifactory + variables: + ARTIFACTORY_URL: https://oneartifactoryprod.verizon.com/artifactory + +build_project: + stage: build + script: + - ./Scripts/build_aggregate.sh + only: + - branches + - develop + tags: + - xcode_12_2 + +deploy_snapshot: + stage: deploy + script: + - cd Scripts && ./upload_vds_frameworks.sh + only: + - branches + - develop + tags: + - bash_shell + environment: + name: oneartifactory + url: https://oneartifactoryprod.verizon.com/artifactory + variables: + ARTIFACTORY_URL: https://oneartifactoryprod.verizon.com/artifactory + +#promote_snapshot: +# stage: go live +# # Prevent artifacts from needing to re-download. Everything we need is in Artifactory. +# dependencies: [] +# script: +# # Grab the framework version from the xcode project. +# - framework_ver=$(cd RemoteView && agvtool vers -terse) +# - cd Scripts && ./promote_remote_view_frameworks.sh $framework_ver +# only: +# - tags +# tags: +# - bash_shell +# environment: +# name: oneartifactory +# url: https://oneartifactoryprod.verizon.com/artifactory +# variables: +# ARTIFACTORY_URL: https://oneartifactoryprod.verizon.com/artifactory +# +#create_version_tag: +# stage: tag +# when: manual +# # Prevent artifacts from needing to re-download. +# dependencies: [] +# script: +# # Grab the framework version from the xcode project and create a tag of the version. +# - framework_ver=$(cd RemoteView && agvtool vers -terse) +# - git tag -a "v${framework_ver}" -m "Version ${framework_ver} created by gitlab-ci Build" +# # Extract the git repo url to ssh version (git@gitlab.verizon.com) +# - ci_push_repo="git@${CI_SERVER_HOST}:${CI_PROJECT_PATH}.git" +# - echo $ci_push_repo +# # Set the remote url for pushing assuming the gitlab runner has SSH access to the repo. +# - git remote set-url --push origin $ci_push_repo +# - git push origin "v${framework_ver}" +# only: +# - develop +# tags: +# - bash_shell diff --git a/Scripts/build_aggregate.sh b/Scripts/build_aggregate.sh new file mode 100755 index 00000000..27d26e39 --- /dev/null +++ b/Scripts/build_aggregate.sh @@ -0,0 +1,53 @@ +#!/bin/bash -3 + +unset TOOLCHAINS #Xcode 7.3 BUG FIX http://stackoverflow.com/questions/36184930/xcodebuild-7-3-cant-enable-bitcode + +# define variables +C_PROJECT_NAME="VDS" +PHONE_CONFIGURATION="Release" +BUILD_DIR=$(xcodebuild -showBuildSettings -project ./${C_PROJECT_NAME}.xcodeproj | grep -w -o 'BUILD_DIR = .*' | cut -d\ -f3-) +PHONE_ARCHIVE_PATH="${BUILD_DIR}/${PHONE_CONFIGURATION}-iphoneos/${C_PROJECT_NAME}.xcarchive" +SIMULATOR_CONFIGURATION="Debug" +SIMULATOR_ARCHIVE_PATH="${BUILD_DIR}/${SIMULATOR_CONFIGURATION}-iphonesimulator/${C_PROJECT_NAME}.xcarchive" +FRAMEWORKS_DIR=$BUILD_DIR/../../../Frameworks/VDS +UNIVERSAL_OUTPUTFOLDER="${BUILD_DIR}/universal" + +# Build device archive +xcodebuild archive \ + -scheme "${C_PROJECT_NAME}" \ + -configuration ${PHONE_CONFIGURATION} \ + -archivePath "${PHONE_ARCHIVE_PATH}" \ + -sdk iphoneos \ + -destination 'generic/platform=iOS' \ + -quiet \ + SKIP_INSTALL=NO \ + ONLY_ACTIVE_ARCH=NO \ + FRAMEWORK_SEARCH_PATHS="$FRAMEWORKS_DIR" \ + ALWAYS_SEARCH_USER_PATHS=true + +# Build simulator archive +xcodebuild archive \ + -scheme "${C_PROJECT_NAME}" \ + -configuration ${SIMULATOR_CONFIGURATION} \ + -archivePath "${SIMULATOR_ARCHIVE_PATH}" \ + -sdk iphonesimulator \ + -destination 'generic/platform=iOS Simulator' \ + -quiet \ + SKIP_INSTALL=NO \ + ONLY_ACTIVE_ARCH=NO \ + FRAMEWORK_SEARCH_PATHS=$FRAMEWORKS_DIR \ + ALWAYS_SEARCH_USER_PATHS=true + +mkdir -p "${UNIVERSAL_OUTPUTFOLDER}" + +# Remove any existing xc framework. +rm -rf ${UNIVERSAL_OUTPUTFOLDER}/${C_PROJECT_NAME}.xcframework + +# Create the xcframework in the universal output folder. +xcodebuild -create-xcframework \ + -framework "${PHONE_ARCHIVE_PATH}/Products/Library/Frameworks/${C_PROJECT_NAME}.framework" \ + -framework "${SIMULATOR_ARCHIVE_PATH}/Products/Library/Frameworks/${C_PROJECT_NAME}.framework" \ + -output ${UNIVERSAL_OUTPUTFOLDER}/${C_PROJECT_NAME}.xcframework + +# Copy the dSYM file as well. +ditto "${PHONE_ARCHIVE_PATH}/dSYMs/${C_PROJECT_NAME}.framework.dSYM" "${UNIVERSAL_OUTPUTFOLDER}/${C_PROJECT_NAME}.xcframework.dSYM" diff --git a/Scripts/download_dependencies.sh b/Scripts/download_dependencies.sh new file mode 100755 index 00000000..ccc388a1 --- /dev/null +++ b/Scripts/download_dependencies.sh @@ -0,0 +1,25 @@ +#!/bin/sh -e + +# download_dependencies.sh +# +# Downloads all compiled framework flavors in from Artifactory. +# + +# Create new aggregate builds + +if [ -z $ARTIFACTORY_URL ]; then + ARTIFACTORY_URL="https://oneartifactoryprod.verizon.com/artifactory" +fi + +BUILD_DIR=$(xcodebuild -showBuildSettings -project ./VDS.xcodeproj | grep -w -o 'BUILD_DIR = .*' | cut -d\ -f3-) +FRAMEWORKS_DIR=$BUILD_DIR/../../../Frameworks/VDS + +if [ ! -d $FRAMEWORKS_DIR ]; then + mkdir -p $FRAMEWORKS_DIR +fi + +./Scripts/download_framework.sh $ARTIFACTORY_URL "$FRAMEWORKS_DIR/VDSColorTokens.xcframework" GVJV_VDS_Maven/@vds-tokens/ios/VDSColorTokens.1.0.6.xcframework.zip + +./Scripts/download_framework.sh $ARTIFACTORY_URL "$FRAMEWORKS_DIR/VDSFormControlsTokens.xcframework" GVJV_VDS_Maven/@vds-tokens/ios/VDSFormControlsTokens.1.0.7.xcframework.zip + +./Scripts/download_framework.sh $ARTIFACTORY_URL "$FRAMEWORKS_DIR/VDSTypographyTokens.xcframework" GVJV_VDS_Maven/@vds-tokens/ios/VDSTypographyTokens.2.0.0.xcframework.zip diff --git a/Scripts/download_framework.sh b/Scripts/download_framework.sh new file mode 100755 index 00000000..791e9ead --- /dev/null +++ b/Scripts/download_framework.sh @@ -0,0 +1,86 @@ +#!/bin/bash -e + +# upload_framework.sh +# +# Downloads an iOS framework from Artificatory. +# +# An API key from Artifcatory is required in the api_key.private file before uploading. +# + +URL=$1 +LOCALPATH="${2}" +REMOTEPATH="${3}" +LOGFILE=$3 +LOCALDIR=$(dirname "${LOCALPATH}") +LOCALBASE=$(basename "${LOCALPATH}") +NEWFILEPATH="${LOCALDIR}"/$(basename "${REMOTEPATH}") +VERSIONFILE=$LOCALDIR/Checksums/"${LOCALBASE}".txt + +if [ -z $URL ]; then + echo "The artifactory instance url must be specified as the first argument!" + exit 1 +fi + +#first argument is error message. +exit_with_error () { +echo "Error: $1" +if [ -f "${NEWFILEPATH}" ]; then + rm -rf "${NEWFILEPATH}" 2 +fi +exit 1 +} + +echo "----------------------------------------------------------" +echo "Logs for ${LOCALBASE}" + +echo -e "Local Target: ${LOCALPATH}" +echo -e "Remote Source: ${REMOTEPATH}" + +if [ -z "$LOCALPATH" ]; then + exit_with_error "Missing local path argument" +fi + +if [ -z "$REMOTEPATH" ]; then + exit_with_error "Missing filename path argument" +fi + +#get local and remote checksums for comparison +echo -e "Getting checksums..." +echo -e "URL: ${URL}/api/storage/${REMOTEPATH}" +JSON=$(curl --header "X-JFrog-Art-Api: ${ARTIFACTORY_APIKEY}" -X GET "${URL}/api/storage/${REMOTEPATH}") +CHECKSUM=$(echo "$JSON" | python3 -c 'import sys, json; print (json.load(sys.stdin)["checksums"]["sha1"])') +if [[ -z "$CHECKSUM" ]]; then + exit_with_error "No Checksum found in json: ${JSON}" +fi +echo "Remote checksum ${CHECKSUM}" +if [[ -f "${VERSIONFILE}" ]]; then + OLDCHECKSUM=$(cat "${VERSIONFILE}") +else + OLDCHECKSUM="none" + mkdir -p $(dirname ${VERSIONFILE}) && touch "$VERSIONFILE" +fi +echo "Local checksum ${OLDCHECKSUM}" + +#get new framework if no original framework, no local checksum, or remote checksum is different from local. +if [ ! -e "${LOCALPATH}" ] || [ -z "$OLDCHECKSUM" ] || [ "$CHECKSUM" != "$OLDCHECKSUM" ]; then + echo "Downloading..." + echo -e "URL: ${URL}/${REMOTEPATH}" + curl --header "X-JFrog-Art-Api: ${ARTIFACTORY_APIKEY}" -f -X GET "$URL/$REMOTEPATH" --output "${NEWFILEPATH}" + if [ $? -eq 0 ] && [ -e "${NEWFILEPATH}" ]; then + echo "Finished Downloading, begin unzip" + unzip -q -o "${NEWFILEPATH}" -d "${LOCALDIR}" + if [ $? -eq 0 ]; then + echo "Finished unzipping, remove zip" + rm -rf "${NEWFILEPATH}" + echo "Writing new checksum to file" + echo "${CHECKSUM}" > "${VERSIONFILE}" + echo "Successfully downloaded and unzipped archive." + else + exit_with_error "Error unzipping" + fi + else + exit_with_error "Failed to download" + fi +else + echo "Successful, No New Version" +fi diff --git a/Scripts/upload_framework.sh b/Scripts/upload_framework.sh new file mode 100755 index 00000000..8793960e --- /dev/null +++ b/Scripts/upload_framework.sh @@ -0,0 +1,86 @@ +#!/bin/bash -e + +# upload_framework.sh +# +# Uploads an iOS framework to Artificatory given the local path as the first argument and the remote project name in Verizon OneArtifactory for the second argument. +# +# An API key from Artifcatory is required in the api_key.private file before uploading. +# +# The script will replace [VER] in the provided remote path with the version found in the framework bundle. +# +# Copied from Hedden, Kyle Matthew on 3/2/18. +# Copyright © 2018 Verizon. All rights reserved. + +URL=$1 +LOCALPATH=$2 +REMOTEPATH=$3 +FRAMEWORKVER=$4 + +if [ -z $URL ]; then + echo "The artifactory instance url must be specified as the first argument!" + exit 1 +fi + +echo ">>> UPLOAD START <<<" +echo "Local path: ${LOCALPATH}" +echo "Remote path: ${REMOTEPATH}" + +cat "${LOCALPATH}/Info.plist" + +LOCALBASE=$(basename "${LOCALPATH}") +LOCALDIR=$(dirname "${LOCALPATH}") + +# Replace the [VER] placeholders with the found version. +REMOTEPATH="${REMOTEPATH//\[VER\]/$FRAMEWORKVER}" +echo -e "Resolved path: \t\t${REMOTEPATH}" + +if [ -z $ARTIFACTORY_APIKEY ]; then + # Read the API key from a private file. + read -r APIKEY < "api_key.private" +else + APIKEY=$ARTIFACTORY_APIKEY +fi + +if [ -z $APIKEY ]; then + read -p "Artifactory API Key:" APIKEY + echo $APIKEY >> api_key.private +fi + +echo -e "API Key: \t\t${APIKEY}" + +# Zip the framework & DSYM for uploading. +pushd $LOCALDIR +echo -e "---------\nZipping: \t\t${LOCALBASE}.zip" +zip -r -X "${LOCALBASE}.zip" $LOCALBASE +# Generate framework's SHA-1 checksum. +CHECKSUM=$(shasum -a 1 "${LOCALBASE}.zip" | cut -d " " -f 1) +echo -e "SHA-1 Checksum: \t${CHECKSUM}" +if [ -e ${LOCALBASE}.dSYM ]; then + echo -e "---------\nZipping: \t\t${LOCALBASE}.dSYM.zip" + zip -r -X "${LOCALBASE}.dSYM.zip" $LOCALBASE.dSYM + # Generate its SHA-1 checksum for dsym. + DSYM_CHECKSUM=$(shasum -a 1 "${LOCALBASE}.dSYM.zip" | cut -d " " -f 1) + echo -e "SHA-1 Checksum: \t${DSYM_CHECKSUM}" +fi +popd +mv ${LOCALPATH}.zip . +if [ -e ${LOCALPATH}.dSYM.zip ]; then + mv ${LOCALPATH}.dSYM.zip . +fi + +# Upload framework to Artifactory. +echo -e "---------\nUploading to: \t\t${URL}/${REMOTEPATH}.zip" +curl --header "X-JFrog-Art-Api: ${APIKEY}" --header "X-Checksum-Sha1: ${CHECKSUM}" -X PUT "${URL}/${REMOTEPATH}.zip" -T "${LOCALBASE}.zip" + +# Cleanup. +rm "${LOCALBASE}.zip" + +if [ -e ${LOCALBASE}.dSYM.zip ]; then + # Upload dsym Artifactory. + echo -e "---------\nUploading to: \t\t${URL}/${REMOTEPATH}.dSYM.zip" + curl --header "X-JFrog-Art-Api: ${APIKEY}" --header "X-Checksum-Sha1: ${DSYM_CHECKSUM}" -X PUT "${URL}/${REMOTEPATH}.dSYM.zip" -T "${LOCALBASE}.dSYM.zip" + # Cleanup dsym. + rm ${LOCALBASE}.dSYM.zip +fi + +echo -e "\n\n<<< UPLOAD COMPLETE >>>\n\n" diff --git a/Scripts/upload_vds_frameworks.sh b/Scripts/upload_vds_frameworks.sh new file mode 100755 index 00000000..bc89f5c6 --- /dev/null +++ b/Scripts/upload_vds_frameworks.sh @@ -0,0 +1,25 @@ +#!/bin/sh -e + +# upload_core_ui_frameworks.sh +# +# Uploads all compiled framework flavors in MVMCoreUI to Artifactory with the SNAPSHOT classifier. This is to avoid accidently clobbering a release build of a particular version. Remove the classifier in Artificatory to make a release. +# +# Copied from Hedden, Kyle Matthew on 3/2/18. +# + +BUILD_SETTINGS=$(xcodebuild -showBuildSettings -project ../VDS.xcodeproj) +FRAMEWORK_VERSION=$(echo "$BUILD_SETTINGS" | grep -w -o 'MARKETING_VERSION = .*' | cut -d\ -f3-) +if [ $(git tag --list | grep "v${FRAMEWORK_VERSION}") ]; then + echo This version tag has already been committed! Aborting! + exit 1 +fi + +# Create new aggregate builds + +if [ -z $ARTIFACTORY_URL ]; then + ARTIFACTORY_URL="https://oneartifactoryprod.verizon.com/artifactory" +fi + +# Upload +BUILD_DIR=$(echo "$BUILD_SETTINGS" | grep -w -o 'BUILD_DIR = .*' | cut -d\ -f3-) +./upload_framework.sh $ARTIFACTORY_URL "${BUILD_DIR}/universal/VDS.xcframework" BPHV_MobileFirst_IOS/com/vzw/hss/myverizon/VDS/[VER]/VDS-[VER]-Debug-SNAPSHOT $FRAMEWORK_VERSION From faf6c84044a02a9a0126da08a73ee858709f8aa9 Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Wed, 26 Oct 2022 13:44:25 -0500 Subject: [PATCH 26/29] fixed bug Signed-off-by: Matt Bruce --- VDS/Components/Toggle/Toggle.swift | 1 - 1 file changed, 1 deletion(-) diff --git a/VDS/Components/Toggle/Toggle.swift b/VDS/Components/Toggle/Toggle.swift index 17c74373..5a525a05 100644 --- a/VDS/Components/Toggle/Toggle.swift +++ b/VDS/Components/Toggle/Toggle.swift @@ -67,7 +67,6 @@ open class ToggleBase: Control, Accessable, DataTrackable, BinaryColorable { $0.translatesAutoresizingMaskIntoConstraints = false $0.axis = .horizontal $0.distribution = .fill - $0.alignment = .leading } }() From 03ae8c54ecaf349024266dd5fb9618f28a7e7a58 Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Wed, 26 Oct 2022 13:51:30 -0500 Subject: [PATCH 27/29] fixed script Signed-off-by: Matt Bruce --- Scripts/build_aggregate.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Scripts/build_aggregate.sh b/Scripts/build_aggregate.sh index 27d26e39..5239cfb0 100755 --- a/Scripts/build_aggregate.sh +++ b/Scripts/build_aggregate.sh @@ -1,4 +1,4 @@ -#!/bin/bash -3 +#!/bin/bash -e unset TOOLCHAINS #Xcode 7.3 BUG FIX http://stackoverflow.com/questions/36184930/xcodebuild-7-3-cant-enable-bitcode From 1d244d914232edadc64473c86e6bd03c9ec84471 Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Wed, 26 Oct 2022 15:56:03 -0500 Subject: [PATCH 28/29] updated script Signed-off-by: Matt Bruce --- Scripts/build_aggregate.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Scripts/build_aggregate.sh b/Scripts/build_aggregate.sh index 5239cfb0..01cbd235 100755 --- a/Scripts/build_aggregate.sh +++ b/Scripts/build_aggregate.sh @@ -12,6 +12,8 @@ SIMULATOR_ARCHIVE_PATH="${BUILD_DIR}/${SIMULATOR_CONFIGURATION}-iphonesimulator/ FRAMEWORKS_DIR=$BUILD_DIR/../../../Frameworks/VDS UNIVERSAL_OUTPUTFOLDER="${BUILD_DIR}/universal" +sed -i '' "s|path = \.\.\/SharedFrameworks|path = ${FRAMEWORKS_DIR}|g" ./MVMCoreUI.xcodeproj/project.pbxproj + # Build device archive xcodebuild archive \ -scheme "${C_PROJECT_NAME}" \ From f06a6aac78d1fb9dee31b526fdd481f44c255d31 Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Wed, 26 Oct 2022 15:57:06 -0500 Subject: [PATCH 29/29] ha, updated project Signed-off-by: Matt Bruce --- Scripts/build_aggregate.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Scripts/build_aggregate.sh b/Scripts/build_aggregate.sh index 01cbd235..b4183ead 100755 --- a/Scripts/build_aggregate.sh +++ b/Scripts/build_aggregate.sh @@ -12,7 +12,7 @@ SIMULATOR_ARCHIVE_PATH="${BUILD_DIR}/${SIMULATOR_CONFIGURATION}-iphonesimulator/ FRAMEWORKS_DIR=$BUILD_DIR/../../../Frameworks/VDS UNIVERSAL_OUTPUTFOLDER="${BUILD_DIR}/universal" -sed -i '' "s|path = \.\.\/SharedFrameworks|path = ${FRAMEWORKS_DIR}|g" ./MVMCoreUI.xcodeproj/project.pbxproj +sed -i '' "s|path = \.\.\/SharedFrameworks|path = ${FRAMEWORKS_DIR}|g" ./VDS.xcodeproj/project.pbxproj # Build device archive xcodebuild archive \