Added stroke color changes for selected and not selected.

This commit is contained in:
Lekshmi S 2020-04-14 15:18:29 +05:30
parent 465fb26e8a
commit 98ff848b33
3 changed files with 9 additions and 5 deletions

View File

@ -71,7 +71,7 @@ open class RadioSwatchItem: Control {
//Draw the strikethrough
strikeLayer?.removeFromSuperlayer()
if isOutOfStock {
let line = getStrikeThrough(color: UIColor.mvmCoolGray6, thickness: 1)
let line = getStrikeThrough(color: UIColor.mvmBlack, thickness: 1)
layer.addSublayer(line)
strikeLayer = line
}
@ -79,7 +79,7 @@ open class RadioSwatchItem: Control {
//Draw the selected layer
selectedLayer?.removeFromSuperlayer()
if isSelected {
let outerCircle = getSelectedLayer(color: UIColor.black, thickness: 1)
let outerCircle = getSelectedLayer(color: UIColor.mvmBlack, thickness: 1)
layer.addSublayer(outerCircle)
selectedLayer = outerCircle
bottomText.isHidden = false
@ -121,7 +121,7 @@ open class RadioSwatchItem: Control {
circle.fillColor = fillColor.cgColor
circle.opacity = 1.0
circle.lineWidth = thickness
circle.strokeColor = isEnabled ? color.cgColor : UIColor.mvmCoolGray6.cgColor
circle.strokeColor = isSelected ? color.cgColor : UIColor.mvmCoolGray6.cgColor
let circlePath = UIBezierPath(ovalIn: CGRect(x: 12, y: 1, width: 30, height: 30))
circle.path = circlePath.cgPath
@ -134,7 +134,7 @@ open class RadioSwatchItem: Control {
strikeThrough.fillColor = nil
strikeThrough.opacity = 1.0
strikeThrough.lineWidth = thickness
strikeThrough.strokeColor = color.cgColor
strikeThrough.strokeColor = isSelected ? color.cgColor : UIColor.mvmCoolGray6.cgColor
let linePath = UIBezierPath()
linePath.move(to: CGPoint(x: 12, y: 30))

View File

@ -19,6 +19,5 @@ open class RadioSwatchItemCollectionViewCell: CollectionViewCell {
open override func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) {
guard let model = model as? RadioSwatchItemModel else { return }
radioSwatch.set(with: model, delegateObject, additionalData)
self.isUserInteractionEnabled = model.enabled ?? true
}
}

View File

@ -114,6 +114,11 @@ extension RadioSwatches: UICollectionViewDataSource {
return swatches?.count ?? 0
}
public func collectionView(_ collectionView: UICollectionView, shouldSelectItemAt indexPath: IndexPath) -> Bool {
guard let molecule = swatches?[indexPath.row] else {return true }
return molecule.enabled ?? true
}
open func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
guard let molecule = swatches?[indexPath.row], let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "RadioSwatchItemCollectionViewCell", for: indexPath) as? RadioSwatchItemCollectionViewCell else {
fatalError()