update link method
This commit is contained in:
parent
56b37255c2
commit
e3b0b43272
@ -109,6 +109,18 @@ extension Link {
|
||||
}
|
||||
}
|
||||
|
||||
extension Link: ModelMoleculeViewProtocol {
|
||||
public func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?) {
|
||||
guard let model = model as? LinkModel else { return }
|
||||
setTitle(model.title, for: .normal)
|
||||
setTitleColor(model.textColor.uiColor, for: .normal)
|
||||
isEnabled = model.enabled
|
||||
backgroundColor = model.backgroundColor?.uiColor
|
||||
set(with: model.action, delegateObject: delegateObject, additionalData: additionalData)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// MARK: - MVMCoreUIMoleculeViewProtocol
|
||||
extension Link {
|
||||
|
||||
|
||||
@ -84,6 +84,18 @@ public typealias ButtonAction = (Button) -> ()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public func set(with action: ActionProtocol, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) {
|
||||
buttonDelegate = delegateObject?.buttonDelegate
|
||||
addActionBlock(event: .touchUpInside) { [weak self] (sender) in
|
||||
guard let self = self else { return }
|
||||
if let data = try? action.encode(using: JSONEncoder()),
|
||||
let actionMap = try? JSONSerialization.jsonObject(with: data, options: JSONSerialization.ReadingOptions.init()) as? [AnyHashable: Any],
|
||||
delegateObject?.buttonDelegate?.button?(self, shouldPerformActionWithMap: actionMap, additionalData: additionalData) ?? true {
|
||||
MVMCoreActionHandler.shared()?.handleAction(with: actionMap, additionalData: additionalData, delegateObject: delegateObject)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - MVMCoreUIMoleculeViewProtocol
|
||||
|
||||
@ -30,7 +30,6 @@
|
||||
@"line": Line.class,
|
||||
@"link": Link.class,
|
||||
@"button": PrimaryButton.class,
|
||||
@"link": MFTextButton.class,
|
||||
@"header": StandardHeaderView.class,
|
||||
@"stack": MoleculeStackView.class,
|
||||
@"twoButtonView": TwoButtonView.class,
|
||||
|
||||
Loading…
Reference in New Issue
Block a user