diff --git a/MVMCoreUI/Atoms/Views/Checkbox.swift b/MVMCoreUI/Atoms/Views/Checkbox.swift index 187d9d7c..1f6a429a 100644 --- a/MVMCoreUI/Atoms/Views/Checkbox.swift +++ b/MVMCoreUI/Atoms/Views/Checkbox.swift @@ -62,7 +62,7 @@ import MVMCore private var shapeLayer: CAShapeLayer? /// Width of the check mark. - public var checkWidth: CGFloat = 2 { + public var checkWidth: CGFloat = 2.3 { didSet { if let shapeLayer = shapeLayer { CATransaction.withDisabledAnimations { @@ -75,11 +75,7 @@ import MVMCore /// Color of the check mark. public var checkColor: UIColor = .black { didSet { - if let shapeLayer = shapeLayer { - CATransaction.withDisabledAnimations { - shapeLayer.strokeColor = checkColor.cgColor - } - } + setshapeLayerStrokeColor(checkColor) } } @@ -285,7 +281,7 @@ import MVMCore self.shapeLayer?.strokeEnd = isSelected ? 1 : 0 } - self.backgroundColor = isSelected ? self.checkedBackgroundColor : self.unCheckedBackgroundColor + backgroundColor = isSelected ? checkedBackgroundColor : unCheckedBackgroundColor } } @@ -297,6 +293,32 @@ import MVMCore } } + func isEnabled(_ enabled: Bool) { + + isUserInteractionEnabled = enabled + + if enabled { + layer.borderColor = borderColor.cgColor + backgroundColor = isSelected ? checkedBackgroundColor : unCheckedBackgroundColor + alpha = 1.0 + setshapeLayerStrokeColor(checkColor) + } else { + layer.borderColor = UIColor.mfSilver().cgColor + backgroundColor = .white + alpha = DisableOppacity + setshapeLayerStrokeColor(UIColor.mfSilver()) + } + } + + private func setshapeLayerStrokeColor(_ color: UIColor) { + + if let shapeLayer = shapeLayer { + CATransaction.withDisabledAnimations { + shapeLayer.strokeColor = color.cgColor + } + } + } + //-------------------------------------------------- // MARK: - UITouch //--------------------------------------------------