Merge branch 'bugfix/radiobox_issues' into 'release/7_6_0'
bugfix/radiobox_issues See merge request BPHV_MIPS/mvm_core_ui!374
This commit is contained in:
commit
20b6d4d272
@ -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()
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user