diff --git a/MVMCoreUI/Atomic/Atoms/Selectors/RadioBox.swift b/MVMCoreUI/Atomic/Atoms/Selectors/RadioBox.swift index ff3452fb..e408b50f 100644 --- a/MVMCoreUI/Atomic/Atoms/Selectors/RadioBox.swift +++ b/MVMCoreUI/Atomic/Atoms/Selectors/RadioBox.swift @@ -69,6 +69,10 @@ open class RadioBox: Control { subTextLabel.text = model.subText isOutOfStock = model.strikethrough subTextLabelHeightConstraint?.isActive = (subTextLabel.text?.count ?? 0) == 0 + if let boxesModel = additionalData?["radioboxesmodel"] as? RadioBoxesModel{ + backgroundColor = model.backgroundColor?.uiColor ?? (boxesModel.backgroundColor?.uiColor ?? UIColor.white) + accentColor = model.selectedAccentColor?.uiColor ?? (boxesModel.selectedAccentColor?.uiColor ?? UIColor.mvmRed) + } } // MARK: - State Handling @@ -134,7 +138,7 @@ open class RadioBox: Control { let topLineLayer = CAShapeLayer() topLineLayer.fillColor = nil - topLineLayer.strokeColor = UIColor.mvmRed.cgColor + topLineLayer.strokeColor = accentColor.cgColor topLineLayer.lineWidth = 4 topLineLayer.path = topLinePath.cgPath layer.addSublayer(topLineLayer) diff --git a/MVMCoreUI/Atomic/Atoms/Selectors/RadioBoxModel.swift b/MVMCoreUI/Atomic/Atoms/Selectors/RadioBoxModel.swift index b2a23c6a..fe47ac29 100644 --- a/MVMCoreUI/Atomic/Atoms/Selectors/RadioBoxModel.swift +++ b/MVMCoreUI/Atomic/Atoms/Selectors/RadioBoxModel.swift @@ -11,8 +11,8 @@ import Foundation public static var identifier: String = "radioBox" public var text: String public var subText: String? - public var backgroundColor: Color? = Color(uiColor: .white) - public var selectedAccentColor = Color(uiColor: .mvmRed) + public var backgroundColor: Color? + public var selectedAccentColor: Color? public var selected: Bool = false public var enabled: Bool = true public var strikethrough: Bool = false diff --git a/MVMCoreUI/Atomic/Atoms/Selectors/RadioBoxes.swift b/MVMCoreUI/Atomic/Atoms/Selectors/RadioBoxes.swift index 4b42e9a8..8d05adac 100644 --- a/MVMCoreUI/Atomic/Atoms/Selectors/RadioBoxes.swift +++ b/MVMCoreUI/Atomic/Atoms/Selectors/RadioBoxes.swift @@ -16,6 +16,8 @@ open class RadioBoxes: View { private let boxHeight: CGFloat = 64.0 private let itemSpacing: CGFloat = 8.0 private var numberOfColumns: CGFloat = 2.0 + private var radioBoxesmodel: RadioBoxesModel! + private var delegateObject: MVMCoreUIDelegateObject? @@ -48,6 +50,7 @@ open class RadioBoxes: View { self.delegateObject = delegateObject guard let radioBoxesModel = model as? RadioBoxesModel else { return } + radioBoxesmodel = radioBoxesModel boxes = radioBoxesModel.boxes FormValidator.setupValidation(for: radioBoxesModel, delegate: delegateObject?.formHolderDelegate) @@ -118,8 +121,9 @@ extension RadioBoxes: UICollectionViewDataSource { let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "RadioBoxCollectionViewCell", for: indexPath) as? RadioBoxCollectionViewCell else { fatalError() } + let additionalData: [AnyHashable : RadioBoxesModel] = ["radioboxesmodel":radioBoxesmodel] cell.radioBox.isUserInteractionEnabled = false - cell.set(with: molecule, delegateObject, nil) + cell.set(with: molecule, delegateObject, additionalData) cell.updateView(size ?? collectionView.bounds.width) if molecule.selected { collectionView.selectItem(at: indexPath, animated: false, scrollPosition: .centeredVertically)