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 accessibilityTraits = .button
accessibilityHint = MVMCoreUIUtility.hardcodedString(withKey: "checkbox_action_hint") accessibilityHint = MVMCoreUIUtility.hardcodedString(withKey: "checkbox_action_hint")
updateAccessibilityLabel() updateAccessibilityLabel()
setupView()
} }
/// There is currently no intention on using xib files. /// There is currently no intention on using xib files.
@ -355,13 +354,6 @@ import MVMCore
sendActions(for: .touchUpInside) 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 { override open func accessibilityActivate() -> Bool {
sendActions(for: .touchUpInside) sendActions(for: .touchUpInside)
return true return true

View File

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

View File

@ -33,7 +33,7 @@ import UIKit
public required init?(coder: NSCoder) { public required init?(coder: NSCoder) {
super.init(coder: coder) super.init(coder: coder)
initialSetup() fatalError("Control does not support xib.")
} }
//-------------------------------------------------- //--------------------------------------------------
@ -41,18 +41,31 @@ import UIKit
//-------------------------------------------------- //--------------------------------------------------
public func initialSetup() { public func initialSetup() {
if !initialSetupPerformed { if !initialSetupPerformed {
initialSetupPerformed = true initialSetupPerformed = true
setupView() 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 // MARK: - MVMCoreViewProtocol
extension Control: MVMCoreViewProtocol { extension Control: MVMCoreViewProtocol {
public func updateView(_ size: CGFloat) { public func updateView(_ size: CGFloat) {}
}
/// Will be called only once. /// Will be called only once.
public func setupView() { public func setupView() {
@ -63,7 +76,7 @@ extension Control: MVMCoreViewProtocol {
// MARK: - MVMCoreUIMoleculeViewProtocol // MARK: - MVMCoreUIMoleculeViewProtocol
extension Control: 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 self.json = json
if let backgroundColorString = json?.optionalStringForKey(KeyBackgroundColor) { if let backgroundColorString = json?.optionalStringForKey(KeyBackgroundColor) {

View File

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

View File

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