CaretLink
This commit is contained in:
parent
3e8b69a0bc
commit
78461d0557
@ -122,6 +122,7 @@
|
|||||||
D282AAB4223FDDAE00C46919 /* MFLoadImageView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D282AAB3223FDDAE00C46919 /* MFLoadImageView.swift */; };
|
D282AAB4223FDDAE00C46919 /* MFLoadImageView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D282AAB3223FDDAE00C46919 /* MFLoadImageView.swift */; };
|
||||||
D282AABA224131D100C46919 /* MFTransparentGIFView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D282AAB9224131D100C46919 /* MFTransparentGIFView.swift */; };
|
D282AABA224131D100C46919 /* MFTransparentGIFView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D282AAB9224131D100C46919 /* MFTransparentGIFView.swift */; };
|
||||||
D282AACB2243C61700C46919 /* ButtonView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D282AACA2243C61700C46919 /* ButtonView.swift */; };
|
D282AACB2243C61700C46919 /* ButtonView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D282AACA2243C61700C46919 /* ButtonView.swift */; };
|
||||||
|
D28A837723C79FC600DFE4FC /* MFCustomButton+ActionModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = D28A837623C79FC600DFE4FC /* MFCustomButton+ActionModel.swift */; };
|
||||||
D296E13C229598BF0051EBE7 /* MoleculeListCellProtocol.h in Headers */ = {isa = PBXBuildFile; fileRef = D296E13B2295969C0051EBE7 /* MoleculeListCellProtocol.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
D296E13C229598BF0051EBE7 /* MoleculeListCellProtocol.h in Headers */ = {isa = PBXBuildFile; fileRef = D296E13B2295969C0051EBE7 /* MoleculeListCellProtocol.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||||
D296E1412295EBBA0051EBE7 /* MoleculeDelegateProtocol.h in Headers */ = {isa = PBXBuildFile; fileRef = D296E1402295EBBA0051EBE7 /* MoleculeDelegateProtocol.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
D296E1412295EBBA0051EBE7 /* MoleculeDelegateProtocol.h in Headers */ = {isa = PBXBuildFile; fileRef = D296E1402295EBBA0051EBE7 /* MoleculeDelegateProtocol.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||||
D296E14722A5984C0051EBE7 /* MVMCoreUIViewConstrainingProtocol.h in Headers */ = {isa = PBXBuildFile; fileRef = D296E14622A597490051EBE7 /* MVMCoreUIViewConstrainingProtocol.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
D296E14722A5984C0051EBE7 /* MVMCoreUIViewConstrainingProtocol.h in Headers */ = {isa = PBXBuildFile; fileRef = D296E14622A597490051EBE7 /* MVMCoreUIViewConstrainingProtocol.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||||
@ -381,6 +382,7 @@
|
|||||||
D282AAB3223FDDAE00C46919 /* MFLoadImageView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MFLoadImageView.swift; sourceTree = "<group>"; };
|
D282AAB3223FDDAE00C46919 /* MFLoadImageView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MFLoadImageView.swift; sourceTree = "<group>"; };
|
||||||
D282AAB9224131D100C46919 /* MFTransparentGIFView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MFTransparentGIFView.swift; sourceTree = "<group>"; };
|
D282AAB9224131D100C46919 /* MFTransparentGIFView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MFTransparentGIFView.swift; sourceTree = "<group>"; };
|
||||||
D282AACA2243C61700C46919 /* ButtonView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ButtonView.swift; sourceTree = "<group>"; };
|
D282AACA2243C61700C46919 /* ButtonView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ButtonView.swift; sourceTree = "<group>"; };
|
||||||
|
D28A837623C79FC600DFE4FC /* MFCustomButton+ActionModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "MFCustomButton+ActionModel.swift"; sourceTree = "<group>"; };
|
||||||
D296E13B2295969C0051EBE7 /* MoleculeListCellProtocol.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MoleculeListCellProtocol.h; sourceTree = "<group>"; };
|
D296E13B2295969C0051EBE7 /* MoleculeListCellProtocol.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MoleculeListCellProtocol.h; sourceTree = "<group>"; };
|
||||||
D296E1402295EBBA0051EBE7 /* MoleculeDelegateProtocol.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MoleculeDelegateProtocol.h; sourceTree = "<group>"; };
|
D296E1402295EBBA0051EBE7 /* MoleculeDelegateProtocol.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MoleculeDelegateProtocol.h; sourceTree = "<group>"; };
|
||||||
D296E14622A597490051EBE7 /* MVMCoreUIViewConstrainingProtocol.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MVMCoreUIViewConstrainingProtocol.h; sourceTree = "<group>"; };
|
D296E14622A597490051EBE7 /* MVMCoreUIViewConstrainingProtocol.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MVMCoreUIViewConstrainingProtocol.h; sourceTree = "<group>"; };
|
||||||
@ -988,6 +990,7 @@
|
|||||||
D29DF16B21E69E1F003B2FB9 /* ButtonDelegateProtocol.h */,
|
D29DF16B21E69E1F003B2FB9 /* ButtonDelegateProtocol.h */,
|
||||||
D29DF16A21E69E1F003B2FB9 /* MFCustomButton.h */,
|
D29DF16A21E69E1F003B2FB9 /* MFCustomButton.h */,
|
||||||
D29DF17021E69E1F003B2FB9 /* MFCustomButton.m */,
|
D29DF17021E69E1F003B2FB9 /* MFCustomButton.m */,
|
||||||
|
D28A837623C79FC600DFE4FC /* MFCustomButton+ActionModel.swift */,
|
||||||
D29DF16C21E69E1F003B2FB9 /* PrimaryButton.h */,
|
D29DF16C21E69E1F003B2FB9 /* PrimaryButton.h */,
|
||||||
D29DF17121E69E1F003B2FB9 /* PrimaryButton.m */,
|
D29DF17121E69E1F003B2FB9 /* PrimaryButton.m */,
|
||||||
D282AACA2243C61700C46919 /* ButtonView.swift */,
|
D282AACA2243C61700C46919 /* ButtonView.swift */,
|
||||||
@ -1395,6 +1398,7 @@
|
|||||||
D282AABA224131D100C46919 /* MFTransparentGIFView.swift in Sources */,
|
D282AABA224131D100C46919 /* MFTransparentGIFView.swift in Sources */,
|
||||||
944589232385DA9600DE9FD4 /* ImageViewModel.swift in Sources */,
|
944589232385DA9600DE9FD4 /* ImageViewModel.swift in Sources */,
|
||||||
D213347723843825008E41B3 /* Line.swift in Sources */,
|
D213347723843825008E41B3 /* Line.swift in Sources */,
|
||||||
|
D28A837723C79FC600DFE4FC /* MFCustomButton+ActionModel.swift in Sources */,
|
||||||
012A88EC238F084D00FE3DA1 /* FooterModel.swift in Sources */,
|
012A88EC238F084D00FE3DA1 /* FooterModel.swift in Sources */,
|
||||||
D2A514672213885800345BFB /* StandardHeaderView.swift in Sources */,
|
D2A514672213885800345BFB /* StandardHeaderView.swift in Sources */,
|
||||||
01EB369023609801006832FA /* ListItemModel.swift in Sources */,
|
01EB369023609801006832FA /* ListItemModel.swift in Sources */,
|
||||||
|
|||||||
@ -8,7 +8,7 @@
|
|||||||
//
|
//
|
||||||
|
|
||||||
|
|
||||||
open class CaretButton: MFCustomButton, MVMCoreUIMoleculeViewProtocol, MVMCoreUIViewConstrainingProtocol {
|
open class CaretButton: MFCustomButton, MVMCoreUIMoleculeViewProtocol, MVMCoreUIViewConstrainingProtocol, ModelMoleculeViewProtocol {
|
||||||
|
|
||||||
//------------------------------------------------------
|
//------------------------------------------------------
|
||||||
// MARK: - Constants
|
// MARK: - Constants
|
||||||
@ -132,6 +132,20 @@ open class CaretButton: MFCustomButton, MVMCoreUIMoleculeViewProtocol, MVMCoreUI
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [String : AnyHashable]?) {
|
||||||
|
guard let caretLinkModel = model as? CaretLinkModel else { return }
|
||||||
|
if let color = caretLinkModel.backgroundColor {
|
||||||
|
backgroundColor = color.uiColor
|
||||||
|
}
|
||||||
|
enabledColor = caretLinkModel.enabledColor.uiColor
|
||||||
|
if let color = caretLinkModel.disabledColor {
|
||||||
|
disabledColor = color.uiColor
|
||||||
|
}
|
||||||
|
isEnabled = caretLinkModel.enabled
|
||||||
|
set(with: caretLinkModel.action, delegateObject: delegateObject, additionalData: additionalData)
|
||||||
|
setTitle(caretLinkModel.label.text, for: .normal)
|
||||||
|
}
|
||||||
|
|
||||||
public func needsToBeConstrained() -> Bool {
|
public func needsToBeConstrained() -> Bool {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|||||||
@ -14,8 +14,8 @@ public class CaretLinkModel: MoleculeProtocol {
|
|||||||
public var backgroundColor: Color?
|
public var backgroundColor: Color?
|
||||||
public var label: LabelModel
|
public var label: LabelModel
|
||||||
public var action: ActionProtocol
|
public var action: ActionProtocol
|
||||||
public var enabledColor: UIColor = .black
|
public var enabledColor: Color = Color(uiColor: .black)
|
||||||
public var disabledColor: UIColor = .mfSilver()
|
public var disabledColor: Color? = Color(uiColor: .mfSilver())
|
||||||
public var enabled: Bool = true
|
public var enabled: Bool = true
|
||||||
|
|
||||||
public init(label: LabelModel, action: ActionProtocol) {
|
public init(label: LabelModel, action: ActionProtocol) {
|
||||||
@ -36,10 +36,10 @@ public class CaretLinkModel: MoleculeProtocol {
|
|||||||
let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
|
let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
|
||||||
backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor)
|
backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor)
|
||||||
label = try typeContainer.decode(LabelModel.self, forKey: .label)
|
label = try typeContainer.decode(LabelModel.self, forKey: .label)
|
||||||
if let color = try typeContainer.decodeIfPresent(Color.self, forKey: .enabledColor)?.uiColor {
|
if let color = try typeContainer.decodeIfPresent(Color.self, forKey: .enabledColor) {
|
||||||
enabledColor = color
|
enabledColor = color
|
||||||
}
|
}
|
||||||
if let color = try typeContainer.decodeIfPresent(Color.self, forKey: .disabledColor)?.uiColor {
|
if let color = try typeContainer.decodeIfPresent(Color.self, forKey: .disabledColor) {
|
||||||
disabledColor = color
|
disabledColor = color
|
||||||
}
|
}
|
||||||
if let enabled = try typeContainer.decodeIfPresent(Bool.self, forKey: .enabled) {
|
if let enabled = try typeContainer.decodeIfPresent(Bool.self, forKey: .enabled) {
|
||||||
@ -53,8 +53,8 @@ public class CaretLinkModel: MoleculeProtocol {
|
|||||||
try container.encode(label, forKey: .label)
|
try container.encode(label, forKey: .label)
|
||||||
try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor)
|
try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor)
|
||||||
try container.encodeModel(action, forKey: .action)
|
try container.encodeModel(action, forKey: .action)
|
||||||
try container.encode(Color(uiColor: enabledColor), forKey: .enabledColor)
|
try container.encode(enabled, forKey: .enabledColor)
|
||||||
try container.encode(Color(uiColor: disabledColor), forKey: .disabledColor)
|
try container.encodeIfPresent(disabledColor, forKey: .disabledColor)
|
||||||
try container.encode(enabled, forKey: .enabled)
|
try container.encode(enabled, forKey: .enabled)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
23
MVMCoreUI/Atoms/Buttons/MFCustomButton+ActionModel.swift
Normal file
23
MVMCoreUI/Atoms/Buttons/MFCustomButton+ActionModel.swift
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
//
|
||||||
|
// MFCustomButton+ActionModel.swift
|
||||||
|
// MVMCoreUI
|
||||||
|
//
|
||||||
|
// Created by Scott Pfeil on 1/9/20.
|
||||||
|
// Copyright © 2020 Verizon Wireless. All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
import Foundation
|
||||||
|
|
||||||
|
public extension MFCustomButton {
|
||||||
|
func set(with action: ActionProtocol, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) {
|
||||||
|
buttonDelegate = delegateObject?.buttonDelegate
|
||||||
|
add({ [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)
|
||||||
|
}
|
||||||
|
}, for: .touchUpInside)
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -35,7 +35,7 @@
|
|||||||
@"twoButtonView": TwoButtonView.class,
|
@"twoButtonView": TwoButtonView.class,
|
||||||
@"footer": StandardFooterView.class,
|
@"footer": StandardFooterView.class,
|
||||||
@"caretView": CaretView.class,
|
@"caretView": CaretView.class,
|
||||||
@"caretButton": CaretButton.class,
|
@"caretLink": CaretButton.class,
|
||||||
@"textField": MFTextField.class,
|
@"textField": MFTextField.class,
|
||||||
@"dropDown": DropDown.class,
|
@"dropDown": DropDown.class,
|
||||||
@"digitTextField": MFDigitTextField.class,
|
@"digitTextField": MFDigitTextField.class,
|
||||||
|
|||||||
@ -34,5 +34,6 @@ import Foundation
|
|||||||
//ModelRegistry.register(ModuleMoleculeModel.self)
|
//ModelRegistry.register(ModuleMoleculeModel.self)
|
||||||
ModelRegistry.register(LeftRightLabelModel.self)
|
ModelRegistry.register(LeftRightLabelModel.self)
|
||||||
ModelRegistry.register(CaretViewModel.self)
|
ModelRegistry.register(CaretViewModel.self)
|
||||||
|
ModelRegistry.register(CaretLinkModel.self)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user