From 5d1c87819d23d89a7df4aa88404cf014e56b4c1a Mon Sep 17 00:00:00 2001 From: Kevin G Christiano Date: Thu, 3 Oct 2019 11:14:16 -0400 Subject: [PATCH] making changes to align with comments. --- MVMCoreUI/Atoms/Views/Checkbox.swift | 31 ++++++++++++++++++++++++---- 1 file changed, 27 insertions(+), 4 deletions(-) diff --git a/MVMCoreUI/Atoms/Views/Checkbox.swift b/MVMCoreUI/Atoms/Views/Checkbox.swift index 9fac4910..fd1fa48a 100644 --- a/MVMCoreUI/Atoms/Views/Checkbox.swift +++ b/MVMCoreUI/Atoms/Views/Checkbox.swift @@ -76,8 +76,21 @@ import MVMCore /// Manages the appearance of the checkbox. private var shapeLayer: CAShapeLayer? - public var checkWidth: CGFloat = 2 - public var checkColor: UIColor = .black + public var checkWidth: CGFloat = 2 { + didSet { + CATransaction.withDisabledAnimations { + shapeLayer?.lineWidth = checkWidth + } + } + } + public var checkColor: UIColor = .black { + didSet { + CATransaction.withDisabledAnimations { + shapeLayer?.strokeColor = checkColor.cgColor + } + } + } + public var borderWidth: CGFloat = 1 public var borderColor: UIColor = .black @@ -93,7 +106,9 @@ import MVMCore delegate.formValidatorModel?()?.enableByValidation() } - accessibilityLabel = MVMCoreUIUtility.hardcodedString(withKey: isSelected ? "checkbox_checked_state" : "checkbox_unchecked_state") + if let state = MVMCoreUIUtility.hardcodedString(withKey: isSelected ? "checkbox_checked_state" : "checkbox_unchecked_state") { + accessibilityLabel = String(format: MVMCoreUIUtility.hardcodedString(withKey: "checkbox_desc_state") ?? "%@", state) + } } } } @@ -105,8 +120,11 @@ import MVMCore override public init(frame: CGRect) { super.init(frame: frame) - accessibilityTraits = .none + accessibilityTraits = .button accessibilityHint = MVMCoreUIUtility.hardcodedString(withKey: "checkbox_action_hint") + if let state = MVMCoreUIUtility.hardcodedString(withKey: isSelected ? "checkbox_checked_state" : "checkbox_unchecked_state") { + accessibilityLabel = String(format: MVMCoreUIUtility.hardcodedString(withKey: "checkbox_desc_state") ?? "%@", state) + } setupView() } @@ -276,6 +294,11 @@ import MVMCore return x < -faultTolerance || y < -faultTolerance || x > widthLimit || y > heightLimt } + override open func accessibilityActivate() -> Bool { + sendActions(for: .touchUpInside) + return true + } + //-------------------------------------------------- // MARK: - Molecular //--------------------------------------------------