From f816081d8e965b9db76095344a5e8bacbfc96e4e Mon Sep 17 00:00:00 2001 From: "Suresh, Kamlesh" Date: Wed, 22 Jan 2020 13:58:56 -0500 Subject: [PATCH] check box --- MVMCoreUI.xcodeproj/project.pbxproj | 8 ++++---- MVMCoreUI/Atoms/Views/Checkbox.swift | 8 ++++---- ...xWithLabelViewModel.swift => CheckboxLabelModel.swift} | 2 +- MVMCoreUI/Atoms/Views/CheckboxModel.swift | 8 ++++---- MVMCoreUI/Atoms/Views/CheckboxWithLabelView.swift | 2 +- MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift | 2 +- 6 files changed, 15 insertions(+), 15 deletions(-) rename MVMCoreUI/Atoms/Views/{CheckboxWithLabelViewModel.swift => CheckboxLabelModel.swift} (94%) diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index 09d66304..314ae317 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -88,7 +88,7 @@ 0ABD136D237CAD1E0081388D /* DateDropdownEntryField.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0ABD136C237CAD1E0081388D /* DateDropdownEntryField.swift */; }; 0ABD1371237DB0450081388D /* ItemDropdownEntryField.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0ABD1370237DB0450081388D /* ItemDropdownEntryField.swift */; }; 0AE14F64238315D2005417F8 /* TextField.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0AE14F63238315D2005417F8 /* TextField.swift */; }; - 31BE15CB23D8924D00452370 /* CheckboxWithLabelViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 31BE15C923D8924C00452370 /* CheckboxWithLabelViewModel.swift */; }; + 31BE15CB23D8924D00452370 /* CheckboxLabelModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 31BE15C923D8924C00452370 /* CheckboxLabelModel.swift */; }; 31BE15CC23D8924D00452370 /* CheckboxModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 31BE15CA23D8924C00452370 /* CheckboxModel.swift */; }; 943784F5236B77BB006A1E82 /* GraphView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 943784F3236B77BB006A1E82 /* GraphView.swift */; }; 943784F6236B77BB006A1E82 /* GraphViewAnimationHandler.swift in Sources */ = {isa = PBXBuildFile; fileRef = 943784F4236B77BB006A1E82 /* GraphViewAnimationHandler.swift */; }; @@ -384,7 +384,7 @@ 0ABD136C237CAD1E0081388D /* DateDropdownEntryField.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DateDropdownEntryField.swift; sourceTree = ""; }; 0ABD1370237DB0450081388D /* ItemDropdownEntryField.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ItemDropdownEntryField.swift; sourceTree = ""; }; 0AE14F63238315D2005417F8 /* TextField.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TextField.swift; sourceTree = ""; }; - 31BE15C923D8924C00452370 /* CheckboxWithLabelViewModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CheckboxWithLabelViewModel.swift; sourceTree = ""; }; + 31BE15C923D8924C00452370 /* CheckboxLabelModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CheckboxLabelModel.swift; sourceTree = ""; }; 31BE15CA23D8924C00452370 /* CheckboxModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CheckboxModel.swift; sourceTree = ""; }; 9402C34F23A2CEA3004B974C /* LeftRightLabelModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LeftRightLabelModel.swift; sourceTree = ""; }; 943784F3236B77BB006A1E82 /* GraphView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = GraphView.swift; sourceTree = ""; }; @@ -1149,7 +1149,7 @@ 0A7BAFA0232BE61800FB8E22 /* Checkbox.swift */, 31BE15CA23D8924C00452370 /* CheckboxModel.swift */, 0A7BAFA2232BE63400FB8E22 /* CheckboxWithLabelView.swift */, - 31BE15C923D8924C00452370 /* CheckboxWithLabelViewModel.swift */, + 31BE15C923D8924C00452370 /* CheckboxLabelModel.swift */, 01004F2F22721C3800991ECC /* RadioButton.swift */, D28A838223CCBD3F00DFE4FC /* CircleProgressModel.swift */, 943784F3236B77BB006A1E82 /* GraphView.swift */, @@ -1562,7 +1562,7 @@ DBEFFA04225A829700230692 /* Label.swift in Sources */, D2D6CD4022E78C1A00D701B8 /* Scroller.swift in Sources */, 01509D952327ED1900EF99AA /* HeadlineBodyTextButtonSwitch.swift in Sources */, - 31BE15CB23D8924D00452370 /* CheckboxWithLabelViewModel.swift in Sources */, + 31BE15CB23D8924D00452370 /* CheckboxLabelModel.swift in Sources */, D260105523CEA7DC00764D80 /* MVMCoreUISwitch+Model.swift in Sources */, D29DF13021E6851E003B2FB9 /* MVMCoreUITopAlertShortView.m in Sources */, 0ABD136D237CAD1E0081388D /* DateDropdownEntryField.swift in Sources */, diff --git a/MVMCoreUI/Atoms/Views/Checkbox.swift b/MVMCoreUI/Atoms/Views/Checkbox.swift index ae9b3354..fe5add9b 100644 --- a/MVMCoreUI/Atoms/Views/Checkbox.swift +++ b/MVMCoreUI/Atoms/Views/Checkbox.swift @@ -485,14 +485,14 @@ import MVMCore layer.borderWidth = borderWidth } - if let isChecked = checkboxModel.isChecked, isChecked { + if checkboxModel.isChecked { updateSelectionOnly = true - isSelected = isChecked + isSelected = checkboxModel.isChecked updateSelectionOnly = false } - if let checkColorHex = checkboxModel.checkColor { - checkColor = UIColor.mfGet(forHex: checkColorHex) + if let uiCheckColor = checkboxModel.checkColor?.uiColor { + checkColor = uiCheckColor } if let unCheckedBackgroundColorHex = checkboxModel.unCheckedBackgroundColor { diff --git a/MVMCoreUI/Atoms/Views/CheckboxWithLabelViewModel.swift b/MVMCoreUI/Atoms/Views/CheckboxLabelModel.swift similarity index 94% rename from MVMCoreUI/Atoms/Views/CheckboxWithLabelViewModel.swift rename to MVMCoreUI/Atoms/Views/CheckboxLabelModel.swift index 81d64361..088f7d9e 100644 --- a/MVMCoreUI/Atoms/Views/CheckboxWithLabelViewModel.swift +++ b/MVMCoreUI/Atoms/Views/CheckboxLabelModel.swift @@ -8,7 +8,7 @@ import Foundation -@objcMembers public class CheckboxWithLabelViewModel: MoleculeModelProtocol { +@objcMembers public class CheckboxLabelModel: MoleculeModelProtocol { public static var identifier: String = "checkboxLabel" public var backgroundColor: Color? diff --git a/MVMCoreUI/Atoms/Views/CheckboxModel.swift b/MVMCoreUI/Atoms/Views/CheckboxModel.swift index 4ad1bade..4b854951 100644 --- a/MVMCoreUI/Atoms/Views/CheckboxModel.swift +++ b/MVMCoreUI/Atoms/Views/CheckboxModel.swift @@ -18,8 +18,8 @@ import Foundation public var required: Bool? public var borderColor: String? public var borderWidth: CGFloat? - public var isChecked: Bool? - public var checkColor: String? + public var isChecked: Bool = false + public var checkColor: Color? public var unCheckedBackgroundColor: String? public var checkedBackgroundColor: String? public var isAnimated: Bool? @@ -53,8 +53,8 @@ import Foundation self.required = try typeContainer.decodeIfPresent(Bool.self, forKey: .required) self.borderColor = try typeContainer.decodeIfPresent(String.self, forKey: .borderColor) self.borderWidth = try typeContainer.decodeIfPresent(CGFloat.self, forKey: .borderWidth) - self.isChecked = try typeContainer.decodeIfPresent(Bool.self, forKey: .isChecked) - self.checkColor = try typeContainer.decodeIfPresent(String.self, forKey: .checkColor) + self.isChecked = try typeContainer.decodeIfPresent(Bool.self, forKey: .isChecked) ?? false + self.checkColor = try typeContainer.decodeIfPresent(Color.self, forKey: .checkColor) self.unCheckedBackgroundColor = try typeContainer.decodeIfPresent(String.self, forKey: .unCheckedBackgroundColor) self.checkedBackgroundColor = try typeContainer.decodeIfPresent(String.self, forKey: .checkedBackgroundColor) self.isAnimated = try typeContainer.decodeIfPresent(Bool.self, forKey: .isAnimated) diff --git a/MVMCoreUI/Atoms/Views/CheckboxWithLabelView.swift b/MVMCoreUI/Atoms/Views/CheckboxWithLabelView.swift index 27256aa3..69141210 100644 --- a/MVMCoreUI/Atoms/Views/CheckboxWithLabelView.swift +++ b/MVMCoreUI/Atoms/Views/CheckboxWithLabelView.swift @@ -122,7 +122,7 @@ } open override func setWithModel(_ model: MoleculeModelProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?) { - guard let checkBoxWithLabelModel = model as? CheckboxWithLabelViewModel else { + guard let checkBoxWithLabelModel = model as? CheckboxLabelModel else { return } diff --git a/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift b/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift index 76d4ba20..6c623572 100644 --- a/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift +++ b/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift @@ -74,6 +74,6 @@ import Foundation //Checkbox ModelRegistry.register(CheckboxModel.self) - ModelRegistry.register(CheckboxWithLabelViewModel.self) + ModelRegistry.register(CheckboxLabelModel.self) } }