diff --git a/MVMCoreUI/Atomic/Atoms/Buttons/ButtonModel.swift b/MVMCoreUI/Atomic/Atoms/Buttons/ButtonModel.swift index 178c309e..abdc1242 100644 --- a/MVMCoreUI/Atomic/Atoms/Buttons/ButtonModel.swift +++ b/MVMCoreUI/Atomic/Atoms/Buttons/ButtonModel.swift @@ -32,7 +32,7 @@ public class ButtonModel: ButtonModelProtocol, MoleculeModelProtocol, FormGroupW public var disabledFillColor: Color? public var disabledTextColor: Color? public var disabledBorderColor: Color? - public var groupName: String = FormValidator.defaultGroupName + public var groupName: String = "" public func setValidity(_ valid: Bool, group: FormGroupRule) { enabled = valid diff --git a/MVMCoreUI/Atomic/Atoms/Selectors/RadioBox.swift b/MVMCoreUI/Atomic/Atoms/Selectors/RadioBox.swift index da762dbb..ff3452fb 100644 --- a/MVMCoreUI/Atomic/Atoms/Selectors/RadioBox.swift +++ b/MVMCoreUI/Atomic/Atoms/Selectors/RadioBox.swift @@ -39,7 +39,7 @@ open class RadioBox: Control { super.setupView() layer.delegate = self - layer.borderColor = UIColor.black.cgColor + layer.borderColor = UIColor.mvmCoolGray6.cgColor layer.borderWidth = 1 label.numberOfLines = 1 @@ -77,11 +77,12 @@ open class RadioBox: Control { // Draw the strikethrough strikeLayer?.removeFromSuperlayer() if isOutOfStock { - let line = getStrikeThrough(color: .black, thickness: 1) + let line = getStrikeThrough(color: isSelected ? .black : .mvmCoolGray6, thickness: 1) layer.addSublayer(line) strikeLayer = line } + // Draw the border borderLayer?.removeFromSuperlayer() if isSelected { @@ -98,6 +99,7 @@ open class RadioBox: Control { if !isEnabled { let mask = getMaskLayer() layer.mask = mask + maskLayer = mask } } @@ -108,6 +110,7 @@ open class RadioBox: Control { } @objc open func selectBox() { + guard isEnabled else { return } isSelected = true radioBoxModel?.selected = isSelected layer.setNeedsDisplay() diff --git a/MVMCoreUI/Atomic/Atoms/Selectors/RadioBoxes.swift b/MVMCoreUI/Atomic/Atoms/Selectors/RadioBoxes.swift index 6fe66bc2..4b42e9a8 100644 --- a/MVMCoreUI/Atomic/Atoms/Selectors/RadioBoxes.swift +++ b/MVMCoreUI/Atomic/Atoms/Selectors/RadioBoxes.swift @@ -15,6 +15,7 @@ open class RadioBoxes: View { private let boxWidth: CGFloat = 151.0 private let boxHeight: CGFloat = 64.0 private let itemSpacing: CGFloat = 8.0 + private var numberOfColumns: CGFloat = 2.0 private var delegateObject: MVMCoreUIDelegateObject? @@ -94,7 +95,7 @@ open class RadioBoxes: View { } // Calculate the height - let rows = ceil(CGFloat(boxes.count) / 2.0) + let rows = ceil(CGFloat(boxes.count) / numberOfColumns) let height = (rows * boxHeight) + ((rows - 1) * itemSpacing) collectionViewHeight?.constant = height } @@ -102,7 +103,7 @@ open class RadioBoxes: View { extension RadioBoxes: UICollectionViewDelegateFlowLayout { open func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize { - let itemWidth: CGFloat = (collectionView.bounds.width - itemSpacing) / 2 + let itemWidth: CGFloat = (collectionView.bounds.width - itemSpacing) / numberOfColumns return CGSize(width: itemWidth, height: boxHeight) } } @@ -129,6 +130,11 @@ extension RadioBoxes: UICollectionViewDataSource { } extension RadioBoxes: UICollectionViewDelegate { + public func collectionView(_ collectionView: UICollectionView, shouldSelectItemAt indexPath: IndexPath) -> Bool { + guard let molecule = boxes?[indexPath.row] else { return false } + return molecule.enabled + } + public func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) { guard let cell = collectionView.cellForItem(at: indexPath) as? RadioBoxCollectionViewCell else { return } cell.radioBox.selectBox() diff --git a/MVMCoreUI/BaseControllers/ViewController.swift b/MVMCoreUI/BaseControllers/ViewController.swift index eb4be908..a49dfad3 100644 --- a/MVMCoreUI/BaseControllers/ViewController.swift +++ b/MVMCoreUI/BaseControllers/ViewController.swift @@ -266,9 +266,7 @@ import UIKit } // Handle data for first load. Dispatched to allow subclasses to finish their view did load implementations. - DispatchQueue.main.async { - self.handleNewDataAndUpdateUI() - } + self.handleNewDataAndUpdateUI() } open override func viewDidLayoutSubviews() { @@ -292,8 +290,10 @@ import UIKit open override func viewWillAppear(_ animated: Bool) { super.viewWillAppear(animated) - // Update the navigation bar ui when view is appearing - setNavigationController() + // Update the navigation bar ui when view is appearing. Can remove check in the future, see viewControllerReady + if manager == nil { + setNavigationController() + } } open override func viewDidAppear(_ animated: Bool) { @@ -326,6 +326,10 @@ import UIKit // MARK: - MVMCoreViewManagerViewControllerProtocol open func viewControllerReady(inManager manager: UIViewController & MVMCoreViewManagerProtocol) { + // TODO: This check and set aren't technically needed anymore. The one in viewwillappear should be enough. However, there is a timing issue with the manager where the screen lays out before the menu shows, so the screen grows off the screen. Can fix in the future. + if let _ = self.view { + setNavigationController() + } // Janky way to track current page. MVMCoreUISession.sharedGlobal()?.currentPageType = pageType MVMCoreUILoggingHandler.shared()?.defaultLogPageState(forController: self)