New constant. Updated control to work with Apple's design guidelines with control. Updates made to checkbox and checkboxLabel.

This commit is contained in:
Kevin G Christiano 2019-12-12 14:42:32 -05:00
parent ed18970625
commit 8804e21d3c
5 changed files with 26 additions and 14 deletions

View File

@ -140,7 +140,6 @@ import MVMCore
accessibilityTraits = .button
accessibilityHint = MVMCoreUIUtility.hardcodedString(withKey: "checkbox_action_hint")
updateAccessibilityLabel()
setupView()
}
/// There is currently no intention on using xib files.
@ -355,13 +354,6 @@ import MVMCore
sendActions(for: .touchUpInside)
}
override open func point(inside point: CGPoint, with event: UIEvent?) -> Bool {
let faultTolerance: CGFloat = 20.0
let area = bounds.insetBy(dx: -faultTolerance, dy: -faultTolerance)
return area.contains(point)
}
override open func accessibilityActivate() -> Bool {
sendActions(for: .touchUpInside)
return true

View File

@ -30,8 +30,7 @@
//--------------------------------------------------
// MARK: - Constraints
//--------------------------------------------------
public var checkboxHeightConstraint: NSLayoutConstraint?
public var checkboxTopConstraint: NSLayoutConstraint?
public var checkboxBottomConstraint: NSLayoutConstraint?
public var checkboxCenterYConstraint: NSLayoutConstraint?

View File

@ -33,7 +33,7 @@ import UIKit
public required init?(coder: NSCoder) {
super.init(coder: coder)
initialSetup()
fatalError("Control does not support xib.")
}
//--------------------------------------------------
@ -41,18 +41,31 @@ import UIKit
//--------------------------------------------------
public func initialSetup() {
if !initialSetupPerformed {
initialSetupPerformed = true
setupView()
}
}
//--------------------------------------------------
// MARK: - UITouch
//--------------------------------------------------
override open func point(inside point: CGPoint, with event: UIEvent?) -> Bool {
// If the control is smaller than 44pt by width or height, this will compensate.
let faultToleranceX: CGFloat = max((MinimumTappableArea - bounds.size.width) / 2.0, 0)
let faultToleranceY: CGFloat = max((MinimumTappableArea - bounds.size.height) / 2.0, 0)
let area = bounds.insetBy(dx: -faultToleranceX, dy: -faultToleranceY)
return area.contains(point)
}
}
// MARK: - MVMCoreViewProtocol
extension Control: MVMCoreViewProtocol {
public func updateView(_ size: CGFloat) {
}
public func updateView(_ size: CGFloat) {}
/// Will be called only once.
public func setupView() {
@ -63,7 +76,7 @@ extension Control: MVMCoreViewProtocol {
// MARK: - MVMCoreUIMoleculeViewProtocol
extension Control: MVMCoreUIMoleculeViewProtocol {
public func setWithJSON(_ json: [AnyHashable : Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable : Any]?) {
public func setWithJSON(_ json: [AnyHashable: Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) {
self.json = json
if let backgroundColorString = json?.optionalStringForKey(KeyBackgroundColor) {

View File

@ -77,3 +77,7 @@ typedef NS_ENUM(NSInteger, CoreUIErrorCode) {
ErrorCodeModuleMolecule = 100,
ErrorCodeListMolecule = 101
};
#pragma mark - Apple Design Guidelines
extern CGFloat const MinimumTappableArea;

View File

@ -69,3 +69,7 @@ BOOL DisableAnimations = NO;
// Hand Scroll Key
NSString * const KeyHandScrollAnimation = @"handScrollAnimation";
NSString * const KeyHandScroll = @"hand_scroll";
#pragma mark - Apple Design Guidelines
CGFloat const MinimumTappableArea = 44.0f;