Merge branch 'develop' into feature/radio_swatches
This commit is contained in:
commit
21a214ca89
@ -32,7 +32,7 @@ public class ButtonModel: ButtonModelProtocol, MoleculeModelProtocol, FormGroupW
|
|||||||
public var disabledFillColor: Color?
|
public var disabledFillColor: Color?
|
||||||
public var disabledTextColor: Color?
|
public var disabledTextColor: Color?
|
||||||
public var disabledBorderColor: Color?
|
public var disabledBorderColor: Color?
|
||||||
public var groupName: String = FormValidator.defaultGroupName
|
public var groupName: String = ""
|
||||||
|
|
||||||
public func setValidity(_ valid: Bool, group: FormGroupRule) {
|
public func setValidity(_ valid: Bool, group: FormGroupRule) {
|
||||||
enabled = valid
|
enabled = valid
|
||||||
|
|||||||
@ -39,7 +39,7 @@ open class RadioBox: Control {
|
|||||||
super.setupView()
|
super.setupView()
|
||||||
|
|
||||||
layer.delegate = self
|
layer.delegate = self
|
||||||
layer.borderColor = UIColor.black.cgColor
|
layer.borderColor = UIColor.mvmCoolGray6.cgColor
|
||||||
layer.borderWidth = 1
|
layer.borderWidth = 1
|
||||||
|
|
||||||
label.numberOfLines = 1
|
label.numberOfLines = 1
|
||||||
@ -77,11 +77,12 @@ open class RadioBox: Control {
|
|||||||
// Draw the strikethrough
|
// Draw the strikethrough
|
||||||
strikeLayer?.removeFromSuperlayer()
|
strikeLayer?.removeFromSuperlayer()
|
||||||
if isOutOfStock {
|
if isOutOfStock {
|
||||||
let line = getStrikeThrough(color: .black, thickness: 1)
|
let line = getStrikeThrough(color: isSelected ? .black : .mvmCoolGray6, thickness: 1)
|
||||||
layer.addSublayer(line)
|
layer.addSublayer(line)
|
||||||
strikeLayer = line
|
strikeLayer = line
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Draw the border
|
// Draw the border
|
||||||
borderLayer?.removeFromSuperlayer()
|
borderLayer?.removeFromSuperlayer()
|
||||||
if isSelected {
|
if isSelected {
|
||||||
@ -98,6 +99,7 @@ open class RadioBox: Control {
|
|||||||
if !isEnabled {
|
if !isEnabled {
|
||||||
let mask = getMaskLayer()
|
let mask = getMaskLayer()
|
||||||
layer.mask = mask
|
layer.mask = mask
|
||||||
|
maskLayer = mask
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -108,6 +110,7 @@ open class RadioBox: Control {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@objc open func selectBox() {
|
@objc open func selectBox() {
|
||||||
|
guard isEnabled else { return }
|
||||||
isSelected = true
|
isSelected = true
|
||||||
radioBoxModel?.selected = isSelected
|
radioBoxModel?.selected = isSelected
|
||||||
layer.setNeedsDisplay()
|
layer.setNeedsDisplay()
|
||||||
|
|||||||
@ -15,6 +15,7 @@ open class RadioBoxes: View {
|
|||||||
private let boxWidth: CGFloat = 151.0
|
private let boxWidth: CGFloat = 151.0
|
||||||
private let boxHeight: CGFloat = 64.0
|
private let boxHeight: CGFloat = 64.0
|
||||||
private let itemSpacing: CGFloat = 8.0
|
private let itemSpacing: CGFloat = 8.0
|
||||||
|
private var numberOfColumns: CGFloat = 2.0
|
||||||
|
|
||||||
private var delegateObject: MVMCoreUIDelegateObject?
|
private var delegateObject: MVMCoreUIDelegateObject?
|
||||||
|
|
||||||
@ -94,7 +95,7 @@ open class RadioBoxes: View {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Calculate the height
|
// 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)
|
let height = (rows * boxHeight) + ((rows - 1) * itemSpacing)
|
||||||
collectionViewHeight?.constant = height
|
collectionViewHeight?.constant = height
|
||||||
}
|
}
|
||||||
@ -102,7 +103,7 @@ open class RadioBoxes: View {
|
|||||||
|
|
||||||
extension RadioBoxes: UICollectionViewDelegateFlowLayout {
|
extension RadioBoxes: UICollectionViewDelegateFlowLayout {
|
||||||
open func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize {
|
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)
|
return CGSize(width: itemWidth, height: boxHeight)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -129,6 +130,11 @@ extension RadioBoxes: UICollectionViewDataSource {
|
|||||||
}
|
}
|
||||||
|
|
||||||
extension RadioBoxes: UICollectionViewDelegate {
|
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) {
|
public func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
|
||||||
guard let cell = collectionView.cellForItem(at: indexPath) as? RadioBoxCollectionViewCell else { return }
|
guard let cell = collectionView.cellForItem(at: indexPath) as? RadioBoxCollectionViewCell else { return }
|
||||||
cell.radioBox.selectBox()
|
cell.radioBox.selectBox()
|
||||||
|
|||||||
@ -266,9 +266,7 @@ import UIKit
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Handle data for first load. Dispatched to allow subclasses to finish their view did load implementations.
|
// 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() {
|
open override func viewDidLayoutSubviews() {
|
||||||
@ -292,8 +290,10 @@ import UIKit
|
|||||||
open override func viewWillAppear(_ animated: Bool) {
|
open override func viewWillAppear(_ animated: Bool) {
|
||||||
super.viewWillAppear(animated)
|
super.viewWillAppear(animated)
|
||||||
|
|
||||||
// Update the navigation bar ui when view is appearing
|
// Update the navigation bar ui when view is appearing. Can remove check in the future, see viewControllerReady
|
||||||
setNavigationController()
|
if manager == nil {
|
||||||
|
setNavigationController()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
open override func viewDidAppear(_ animated: Bool) {
|
open override func viewDidAppear(_ animated: Bool) {
|
||||||
@ -326,6 +326,10 @@ import UIKit
|
|||||||
|
|
||||||
// MARK: - MVMCoreViewManagerViewControllerProtocol
|
// MARK: - MVMCoreViewManagerViewControllerProtocol
|
||||||
open func viewControllerReady(inManager manager: UIViewController & MVMCoreViewManagerProtocol) {
|
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.
|
// Janky way to track current page.
|
||||||
MVMCoreUISession.sharedGlobal()?.currentPageType = pageType
|
MVMCoreUISession.sharedGlobal()?.currentPageType = pageType
|
||||||
MVMCoreUILoggingHandler.shared()?.defaultLogPageState(forController: self)
|
MVMCoreUILoggingHandler.shared()?.defaultLogPageState(forController: self)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user