diff --git a/MVMCoreUI/Molecules/DesignedComponents/List/RightVariable/ListRightVariableButtonAllTextAndLinks.swift b/MVMCoreUI/Molecules/DesignedComponents/List/RightVariable/ListRightVariableButtonAllTextAndLinks.swift index 8edcdb20..3f95682a 100644 --- a/MVMCoreUI/Molecules/DesignedComponents/List/RightVariable/ListRightVariableButtonAllTextAndLinks.swift +++ b/MVMCoreUI/Molecules/DesignedComponents/List/RightVariable/ListRightVariableButtonAllTextAndLinks.swift @@ -7,3 +7,46 @@ // import Foundation +@objcMembers open class ListRightVariableButtonAllTextAndLinks: TableViewCell { + + //----------------------------------------------------- + // MARK: - Outlets + //----------------------------------------------------- + var stack: Stack + let button = Button(frame: .zero) + let eyebrowHeadlineBodyLink = EyebrowHeadlineBodyLink(frame: .zero) + // MARK: - Initializers + public override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) { + stack = Stack.createStack(with: [(view: eyebrowHeadlineBodyLink, model: StackItemModel(spacing: 5,horizontalAlignment: .leading)), + (view: button, model: StackItemModel( horizontalAlignment:.fill, verticalAlignment: .top))],axis: .horizontal) + super.init(style: style, reuseIdentifier: reuseIdentifier) + } + + public required init?(coder aDecoder: NSCoder) { + fatalError("init(coder:) has not been implemented") + } + + //----------------------------------------------------- + // MARK: - View Lifecycle + //----------------------------------------------------- + override open func setupView() { + super.setupView() + addMolecule(stack) + stack.restack() + } + + open override func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?){ + super.set(with: model, delegateObject, additionalData) + guard let model = model as? ListRightVariableTextButtonAllTextAndLinksModel else { return } + button.set(with: model.button, delegateObject, additionalData) + eyebrowHeadlineBodyLink.set(with: model.eyebrowHeadlineBodyLink, delegateObject, additionalData) + } + + open override class func estimatedHeight(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? { + return 90 + } + + open override func reset() { + super.reset() + } +} diff --git a/MVMCoreUI/Molecules/DesignedComponents/List/RightVariable/ListRightVariableButtonAllTextAndLinksModel.swift b/MVMCoreUI/Molecules/DesignedComponents/List/RightVariable/ListRightVariableButtonAllTextAndLinksModel.swift index ce10407e..91e9ead2 100644 --- a/MVMCoreUI/Molecules/DesignedComponents/List/RightVariable/ListRightVariableButtonAllTextAndLinksModel.swift +++ b/MVMCoreUI/Molecules/DesignedComponents/List/RightVariable/ListRightVariableButtonAllTextAndLinksModel.swift @@ -7,3 +7,40 @@ // import Foundation +public class ListRightVariableTextButtonAllTextAndLinksModel: ListItemModel,MoleculeModelProtocol{ + public static var identifier: String = "listRVBtn" + public var button: ButtonModel + public var eyebrowHeadlineBodyLink: EyebrowHeadlineBodyLinkModel + + public init(button: ButtonModel, eyebrowHeadlineBodyLink: EyebrowHeadlineBodyLinkModel) { + self.button = button + self.eyebrowHeadlineBodyLink = eyebrowHeadlineBodyLink + super.init() + } + /// Defaults to set + override public func setDefaults() { + super.setDefaults() + self.button.size = .tiny + } + + private enum CodingKeys: String, CodingKey { + case moleculeName + case button + case eyebrowHeadlineBodyLink + } + + required public init(from decoder: Decoder) throws { + let typeContainer = try decoder.container(keyedBy: CodingKeys.self) + button = try typeContainer.decode(ButtonModel.self, forKey: .button) + eyebrowHeadlineBodyLink = try typeContainer.decode(EyebrowHeadlineBodyLinkModel.self, forKey: .eyebrowHeadlineBodyLink) + try super.init(from: decoder) + } + + public override func encode(to encoder: Encoder) throws { + try super.encode(to: encoder) + var container = encoder.container(keyedBy: CodingKeys.self) + try container.encode(moleculeName, forKey: .moleculeName) + try container.encode(button, forKey: .button) + try container.encode(eyebrowHeadlineBodyLink, forKey: .eyebrowHeadlineBodyLink) + } +} diff --git a/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift b/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift index cc3950cd..69eb4994 100644 --- a/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift +++ b/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift @@ -103,6 +103,7 @@ import Foundation MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: ListLeftVariableIconWithRightCaret.self, viewModelClass: ListLeftVariableIconWithRightCaretModel.self) MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: ListLeftVariableCheckboxAllTextAndLinks.self, viewModelClass: ListLeftVariableCheckboxAllTextAndLinksModel.self) MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: ListRightVariablePayments.self, viewModelClass: ListRightVariablePaymentsModel.self) + MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: ListRightVariableButtonAllTextAndLinks.self, viewModelClass: ListRightVariableTextButtonAllTextAndLinksModel.self) MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: ListLeftVariableRadioButtonAndPaymentMethod.self, viewModelClass: ListLeftVariableRadioButtonAndPaymentMethodModel.self) MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: ListRVWheel.self, viewModelClass: ListRVWheelModel.self) MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: ListOneColumnFullWidthTextAllTextAndLinks.self, viewModelClass: ListOneColumnFullWidthTextAllTextAndLinksModel.self)