Expands tappable area of Link

This commit is contained in:
Robinson, Blake 2019-12-09 14:15:55 -05:00
parent 1d647ec662
commit 16cc667b02

View File

@ -14,6 +14,9 @@ import UIKit
return MFSizeObject(standardSize: 30, standardiPadPortraitSize: 36, iPadProLandscapeSize: 42) return MFSizeObject(standardSize: 30, standardiPadPortraitSize: 36, iPadProLandscapeSize: 42)
}() }()
private var additionalData: [AnyHashable: Any]?
private var delegateObject: MVMCoreUIDelegateObject?
public override init(frame: CGRect) { public override init(frame: CGRect) {
super.init(frame: frame) super.init(frame: frame)
self.setupView() self.setupView()
@ -50,6 +53,17 @@ import UIKit
contextRef?.closePath() contextRef?.closePath()
contextRef?.drawPath(using: .stroke) contextRef?.drawPath(using: .stroke)
} }
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)
}
open override func touchesEnded(_ touches: Set<UITouch>, with event: UIEvent?) {
MVMCoreActionHandler.shared()?.handleAction(with: actionMap, additionalData: additionalData, delegateObject: delegateObject)
}
} }
extension Link: MVMCoreViewProtocol { extension Link: MVMCoreViewProtocol {
@ -100,14 +114,18 @@ extension Link: MVMCoreUIMoleculeViewProtocol {
public func setWithJSON(_ json: [AnyHashable : Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable : Any]?) { public func setWithJSON(_ json: [AnyHashable : Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable : Any]?) {
if let unwrappedJson = json { if let unwrappedJson = json {
actionMap = unwrappedJson
self.additionalData = additionalData
self.delegateObject = delegateObject
buttonDelegate = delegateObject?.buttonDelegate
let color = unwrappedJson.stringForkey(KeyTextColor) let color = unwrappedJson.stringForkey(KeyTextColor)
setTitleColor(UIColor.mfGet(forHex: color), for: .normal) setTitleColor(UIColor.mfGet(forHex: color), for: .normal)
setWithActionMap(json, delegateObject: delegateObject, additionalData: additionalData) self.titleLabel?.numberOfLines = 0
self.titleLabel?.lineBreakMode = .byWordWrapping;
self.setTitle(actionMap?.stringForkey(KeyTitle), for: .normal)
//enabling must happen after setWithActionMap is called because
//that method enables buttons when the actionMap does not contain
//disableAction = true
if let enabled = unwrappedJson[KeyEnabled] as? Bool { if let enabled = unwrappedJson[KeyEnabled] as? Bool {
isEnabled = enabled isEnabled = enabled
} }