clean color code, move function

This commit is contained in:
Pfeil, Scott Robert 2020-04-15 12:59:57 -04:00
parent 7b3e22826c
commit 5ca03674c2
2 changed files with 8 additions and 6 deletions

View File

@ -39,7 +39,7 @@ open class RadioBox: Control {
super.setupView()
layer.delegate = self
layer.borderColor = UIColor.mfGet(forHex: "#747676").cgColor
layer.borderColor = UIColor.mvmCoolGray6.cgColor
layer.borderWidth = 1
label.numberOfLines = 1
@ -77,7 +77,7 @@ open class RadioBox: Control {
// Draw the strikethrough
strikeLayer?.removeFromSuperlayer()
if isOutOfStock {
let line = getStrikeThrough(color: isSelected ?.black:UIColor.mfGet(forHex: "#747676") , thickness: 1)
let line = getStrikeThrough(color: isSelected ? .black : .mvmCoolGray6, thickness: 1)
layer.addSublayer(line)
strikeLayer = line
}
@ -110,6 +110,7 @@ open class RadioBox: Control {
}
@objc open func selectBox() {
guard isEnabled else { return }
isSelected = true
radioBoxModel?.selected = isSelected
layer.setNeedsDisplay()

View File

@ -112,10 +112,6 @@ extension RadioBoxes: UICollectionViewDataSource {
open func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
return boxes?.count ?? 0
}
public func collectionView(_ collectionView: UICollectionView, shouldSelectItemAt indexPath: IndexPath) -> Bool {
guard let molecule = boxes?[indexPath.row] else {return true }
return molecule.enabled
}
open func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
guard let molecule = boxes?[indexPath.row],
@ -134,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()