Two button view temporary model fix
primary button model
This commit is contained in:
parent
5c0d57fded
commit
788145332f
@ -124,6 +124,9 @@
|
|||||||
D28A838523CCCA8900DFE4FC /* ScrollerModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = D28A838423CCCA8900DFE4FC /* ScrollerModel.swift */; };
|
D28A838523CCCA8900DFE4FC /* ScrollerModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = D28A838423CCCA8900DFE4FC /* ScrollerModel.swift */; };
|
||||||
D28A838723CCCF6500DFE4FC /* MFTextButton+ModelExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = D28A838623CCCF6500DFE4FC /* MFTextButton+ModelExtension.swift */; };
|
D28A838723CCCF6500DFE4FC /* MFTextButton+ModelExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = D28A838623CCCF6500DFE4FC /* MFTextButton+ModelExtension.swift */; };
|
||||||
D28A838923CCCFCB00DFE4FC /* LinkModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = D28A838823CCCFCB00DFE4FC /* LinkModel.swift */; };
|
D28A838923CCCFCB00DFE4FC /* LinkModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = D28A838823CCCFCB00DFE4FC /* LinkModel.swift */; };
|
||||||
|
D28A838B23CCDA6B00DFE4FC /* ButtonModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = D28A838A23CCDA6B00DFE4FC /* ButtonModel.swift */; };
|
||||||
|
D28A838D23CCDCC200DFE4FC /* PrimaryButton+MoleculeProtocolExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = D28A838C23CCDCC200DFE4FC /* PrimaryButton+MoleculeProtocolExtension.swift */; };
|
||||||
|
D28A838F23CCDEDE00DFE4FC /* TwoButtonViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = D28A838E23CCDEDE00DFE4FC /* TwoButtonViewModel.swift */; };
|
||||||
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, ); }; };
|
||||||
D29770C821F7C4AE00B2F0D0 /* TopLabelsView.m in Sources */ = {isa = PBXBuildFile; fileRef = D29770C621F7C4AE00B2F0D0 /* TopLabelsView.m */; };
|
D29770C821F7C4AE00B2F0D0 /* TopLabelsView.m in Sources */ = {isa = PBXBuildFile; fileRef = D29770C621F7C4AE00B2F0D0 /* TopLabelsView.m */; };
|
||||||
D29770C921F7C4AE00B2F0D0 /* TopLabelsView.h in Headers */ = {isa = PBXBuildFile; fileRef = D29770C721F7C4AE00B2F0D0 /* TopLabelsView.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
D29770C921F7C4AE00B2F0D0 /* TopLabelsView.h in Headers */ = {isa = PBXBuildFile; fileRef = D29770C721F7C4AE00B2F0D0 /* TopLabelsView.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||||
@ -387,6 +390,9 @@
|
|||||||
D28A838423CCCA8900DFE4FC /* ScrollerModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ScrollerModel.swift; sourceTree = "<group>"; };
|
D28A838423CCCA8900DFE4FC /* ScrollerModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ScrollerModel.swift; sourceTree = "<group>"; };
|
||||||
D28A838623CCCF6500DFE4FC /* MFTextButton+ModelExtension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "MFTextButton+ModelExtension.swift"; sourceTree = "<group>"; };
|
D28A838623CCCF6500DFE4FC /* MFTextButton+ModelExtension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "MFTextButton+ModelExtension.swift"; sourceTree = "<group>"; };
|
||||||
D28A838823CCCFCB00DFE4FC /* LinkModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LinkModel.swift; sourceTree = "<group>"; };
|
D28A838823CCCFCB00DFE4FC /* LinkModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LinkModel.swift; sourceTree = "<group>"; };
|
||||||
|
D28A838A23CCDA6B00DFE4FC /* ButtonModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ButtonModel.swift; sourceTree = "<group>"; };
|
||||||
|
D28A838C23CCDCC200DFE4FC /* PrimaryButton+MoleculeProtocolExtension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "PrimaryButton+MoleculeProtocolExtension.swift"; sourceTree = "<group>"; };
|
||||||
|
D28A838E23CCDEDE00DFE4FC /* TwoButtonViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TwoButtonViewModel.swift; 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>"; };
|
||||||
D29770C621F7C4AE00B2F0D0 /* TopLabelsView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TopLabelsView.m; sourceTree = "<group>"; };
|
D29770C621F7C4AE00B2F0D0 /* TopLabelsView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TopLabelsView.m; sourceTree = "<group>"; };
|
||||||
D29770C721F7C4AE00B2F0D0 /* TopLabelsView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TopLabelsView.h; sourceTree = "<group>"; };
|
D29770C721F7C4AE00B2F0D0 /* TopLabelsView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TopLabelsView.h; sourceTree = "<group>"; };
|
||||||
@ -729,6 +735,7 @@
|
|||||||
isa = PBXGroup;
|
isa = PBXGroup;
|
||||||
children = (
|
children = (
|
||||||
D2B1E3E422F37D6A0065F95C /* ImageHeadlineBody.swift */,
|
D2B1E3E422F37D6A0065F95C /* ImageHeadlineBody.swift */,
|
||||||
|
D28A838E23CCDEDE00DFE4FC /* TwoButtonViewModel.swift */,
|
||||||
D20A9A5D2243D3E300ADE781 /* TwoButtonView.swift */,
|
D20A9A5D2243D3E300ADE781 /* TwoButtonView.swift */,
|
||||||
D28A837E23CCA96400DFE4FC /* TabsModel.swift */,
|
D28A837E23CCA96400DFE4FC /* TabsModel.swift */,
|
||||||
);
|
);
|
||||||
@ -995,6 +1002,8 @@
|
|||||||
D29DF16A21E69E1F003B2FB9 /* MFCustomButton.h */,
|
D29DF16A21E69E1F003B2FB9 /* MFCustomButton.h */,
|
||||||
D29DF17021E69E1F003B2FB9 /* MFCustomButton.m */,
|
D29DF17021E69E1F003B2FB9 /* MFCustomButton.m */,
|
||||||
D28A837623C79FC600DFE4FC /* MFCustomButton+ActionModel.swift */,
|
D28A837623C79FC600DFE4FC /* MFCustomButton+ActionModel.swift */,
|
||||||
|
D28A838A23CCDA6B00DFE4FC /* ButtonModel.swift */,
|
||||||
|
D28A838C23CCDCC200DFE4FC /* PrimaryButton+MoleculeProtocolExtension.swift */,
|
||||||
D29DF16C21E69E1F003B2FB9 /* PrimaryButton.h */,
|
D29DF16C21E69E1F003B2FB9 /* PrimaryButton.h */,
|
||||||
D29DF17121E69E1F003B2FB9 /* PrimaryButton.m */,
|
D29DF17121E69E1F003B2FB9 /* PrimaryButton.m */,
|
||||||
D282AACA2243C61700C46919 /* ButtonView.swift */,
|
D282AACA2243C61700C46919 /* ButtonView.swift */,
|
||||||
@ -1383,6 +1392,8 @@
|
|||||||
D28A837B23C928DA00DFE4FC /* MoleculeListCellProtocol.swift in Sources */,
|
D28A837B23C928DA00DFE4FC /* MoleculeListCellProtocol.swift in Sources */,
|
||||||
014AA72F23C5059B006F3E93 /* ThreeLayerPageTemplateModel.swift in Sources */,
|
014AA72F23C5059B006F3E93 /* ThreeLayerPageTemplateModel.swift in Sources */,
|
||||||
D22D1F572204CE5D0077CEC0 /* MVMCoreUIStackableViewController.m in Sources */,
|
D22D1F572204CE5D0077CEC0 /* MVMCoreUIStackableViewController.m in Sources */,
|
||||||
|
D28A838B23CCDA6B00DFE4FC /* ButtonModel.swift in Sources */,
|
||||||
|
D28A838D23CCDCC200DFE4FC /* PrimaryButton+MoleculeProtocolExtension.swift in Sources */,
|
||||||
D2A5145F2211DDC100345BFB /* MoleculeStackView.swift in Sources */,
|
D2A5145F2211DDC100345BFB /* MoleculeStackView.swift in Sources */,
|
||||||
D29DF27621E79E81003B2FB9 /* MVMCoreUILoggingHandler.m in Sources */,
|
D29DF27621E79E81003B2FB9 /* MVMCoreUILoggingHandler.m in Sources */,
|
||||||
D28A838723CCCF6500DFE4FC /* MFTextButton+ModelExtension.swift in Sources */,
|
D28A838723CCCF6500DFE4FC /* MFTextButton+ModelExtension.swift in Sources */,
|
||||||
@ -1448,6 +1459,7 @@
|
|||||||
944589212385D6E900DE9FD4 /* DashLineModel.swift in Sources */,
|
944589212385D6E900DE9FD4 /* DashLineModel.swift in Sources */,
|
||||||
D29DF27A21E7A533003B2FB9 /* MVMCoreUISession.m in Sources */,
|
D29DF27A21E7A533003B2FB9 /* MVMCoreUISession.m in Sources */,
|
||||||
D2A5146B2214905000345BFB /* ThreeLayerViewController.swift in Sources */,
|
D2A5146B2214905000345BFB /* ThreeLayerViewController.swift in Sources */,
|
||||||
|
D28A838F23CCDEDE00DFE4FC /* TwoButtonViewModel.swift in Sources */,
|
||||||
012A88B1238C880100FE3DA1 /* PagingMoleculeProtocol.swift in Sources */,
|
012A88B1238C880100FE3DA1 /* PagingMoleculeProtocol.swift in Sources */,
|
||||||
D29DF2C921E7BFC6003B2FB9 /* MFSizeObject.m in Sources */,
|
D29DF2C921E7BFC6003B2FB9 /* MFSizeObject.m in Sources */,
|
||||||
9445890E2385C3F800DE9FD4 /* MultiProgressModel.swift in Sources */,
|
9445890E2385C3F800DE9FD4 /* MultiProgressModel.swift in Sources */,
|
||||||
|
|||||||
50
MVMCoreUI/Atoms/Buttons/ButtonModel.swift
Normal file
50
MVMCoreUI/Atoms/Buttons/ButtonModel.swift
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
//
|
||||||
|
// ButtonModel.swift
|
||||||
|
// MVMCoreUI
|
||||||
|
//
|
||||||
|
// Created by Scott Pfeil on 1/13/20.
|
||||||
|
// Copyright © 2020 Verizon Wireless. All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
import UIKit
|
||||||
|
|
||||||
|
public enum ButtonStyle: String, Codable {
|
||||||
|
case primary
|
||||||
|
case secondary
|
||||||
|
}
|
||||||
|
|
||||||
|
public class ButtonModel: MoleculeProtocol {
|
||||||
|
public static var identifier: String = "button"
|
||||||
|
public var backgroundColor: Color?
|
||||||
|
public var title: String
|
||||||
|
public var action: ActionProtocol
|
||||||
|
public var style: ButtonStyle?
|
||||||
|
|
||||||
|
init(with title: String, action: ActionProtocol) {
|
||||||
|
self.title = title
|
||||||
|
self.action = action
|
||||||
|
}
|
||||||
|
|
||||||
|
enum CodingKeys: String, CodingKey {
|
||||||
|
case backgroundColor
|
||||||
|
case title
|
||||||
|
case action
|
||||||
|
case style
|
||||||
|
}
|
||||||
|
|
||||||
|
required public init(from decoder: Decoder) throws {
|
||||||
|
let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
|
||||||
|
backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor)
|
||||||
|
title = try typeContainer.decode(String.self, forKey: .title)
|
||||||
|
action = try typeContainer.decodeModel(codingKey: .action, typeCodingKey: ActionCodingKey.type)
|
||||||
|
style = try typeContainer.decode(ButtonStyle.self, forKey: .style)
|
||||||
|
}
|
||||||
|
|
||||||
|
public func encode(to encoder: Encoder) throws {
|
||||||
|
var container = encoder.container(keyedBy: CodingKeys.self)
|
||||||
|
try container.encode(title, forKey: .title)
|
||||||
|
try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor)
|
||||||
|
try container.encodeModel(action, forKey: .action)
|
||||||
|
try container.encodeIfPresent(style, forKey: .style)
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,30 @@
|
|||||||
|
//
|
||||||
|
// PrimaryButton+MoleculeProtocolExtension.swift
|
||||||
|
// MVMCoreUI
|
||||||
|
//
|
||||||
|
// Created by Scott Pfeil on 1/13/20.
|
||||||
|
// Copyright © 2020 Verizon Wireless. All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
import Foundation
|
||||||
|
|
||||||
|
// temporary until link is finished
|
||||||
|
extension PrimaryButton: ModelMoleculeViewProtocol {
|
||||||
|
public func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?) {
|
||||||
|
guard let model = model as? ButtonModel else { return }
|
||||||
|
setTitle(model.title, for: .normal)
|
||||||
|
backgroundColor = model.backgroundColor?.uiColor
|
||||||
|
if let style = model.style {
|
||||||
|
switch style {
|
||||||
|
case .primary:
|
||||||
|
setAsStandardCustom()
|
||||||
|
case .secondary:
|
||||||
|
setAsSecondaryCustom()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//TODO: Use object when handleAction is rewrote to handle action model
|
||||||
|
if let actionMap = model.action.toJSON() {
|
||||||
|
MVMCoreActionHandler.shared()?.handleAction(with: actionMap, additionalData: additionalData, delegateObject: delegateObject)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -137,20 +137,25 @@ import UIKit
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Legacy
|
||||||
func setupUI(withPrimaryButtonMap primaryButtonMap: [AnyHashable: Any]?, secondaryButtonMap: [AnyHashable: Any]?) {
|
func setupUI(withPrimaryButtonMap primaryButtonMap: [AnyHashable: Any]?, secondaryButtonMap: [AnyHashable: Any]?) {
|
||||||
if primaryButtonMap != nil, secondaryButtonMap != nil {
|
setupUI(primaryButtonShowing: primaryButtonMap != nil, secondaryButtonShowing: secondaryButtonMap != nil)
|
||||||
|
}
|
||||||
|
|
||||||
|
func setupUI(primaryButtonShowing: Bool, secondaryButtonShowing: Bool) {
|
||||||
|
if primaryButtonShowing, secondaryButtonShowing {
|
||||||
heightConstraint?.isActive = false
|
heightConstraint?.isActive = false
|
||||||
if primaryButton == nil || secondaryButton == nil {
|
if primaryButton == nil || secondaryButton == nil {
|
||||||
removeButtons()
|
removeButtons()
|
||||||
setupWithTwoButtons()
|
setupWithTwoButtons()
|
||||||
}
|
}
|
||||||
} else if primaryButtonMap != nil {
|
} else if primaryButtonShowing {
|
||||||
heightConstraint?.isActive = false
|
heightConstraint?.isActive = false
|
||||||
if primaryButton == nil || secondaryButton != nil {
|
if primaryButton == nil || secondaryButton != nil {
|
||||||
removeButtons()
|
removeButtons()
|
||||||
setupWithPrimaryButton()
|
setupWithPrimaryButton()
|
||||||
}
|
}
|
||||||
} else if secondaryButtonMap != nil {
|
} else if secondaryButtonShowing {
|
||||||
heightConstraint?.isActive = false
|
heightConstraint?.isActive = false
|
||||||
if secondaryButton == nil || primaryButton != nil {
|
if secondaryButton == nil || primaryButton != nil {
|
||||||
removeButtons()
|
removeButtons()
|
||||||
@ -291,3 +296,14 @@ extension TwoButtonView {
|
|||||||
setup(primaryButtonMap: primaryButtonMap, secondaryButtonMap: secondaryButtonMap, actionDelegate: actionDelegate, additionalData: additionalData, buttonDelegate: buttonDelegate)
|
setup(primaryButtonMap: primaryButtonMap, secondaryButtonMap: secondaryButtonMap, actionDelegate: actionDelegate, additionalData: additionalData, buttonDelegate: buttonDelegate)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
extension TwoButtonView: MoleculeViewProtocol {
|
||||||
|
func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) {
|
||||||
|
guard let model = model as? TwoButtonViewModel else { return }
|
||||||
|
setupUI(primaryButtonShowing: model.primaryButton != nil, secondaryButtonShowing: model.secondaryButton != nil)
|
||||||
|
setDefaultCustom()
|
||||||
|
primaryButton?.setWithModel(model.primaryButton, delegateObject, additionalData)
|
||||||
|
secondaryButton?.setWithModel(model.secondaryButton, delegateObject, additionalData)
|
||||||
|
super.setWithJSON(json, delegateObject: delegateObject, additionalData: additionalData)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@ -0,0 +1,16 @@
|
|||||||
|
//
|
||||||
|
// TwoButtonViewModel.swift
|
||||||
|
// MVMCoreUI
|
||||||
|
//
|
||||||
|
// Created by Scott Pfeil on 1/13/20.
|
||||||
|
// Copyright © 2020 Verizon Wireless. All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
import UIKit
|
||||||
|
|
||||||
|
public class TwoButtonViewModel: MoleculeProtocol {
|
||||||
|
public static var identifier: String = "twoButtonView"
|
||||||
|
public var backgroundColor: Color?
|
||||||
|
public var primaryButton: ButtonModel?
|
||||||
|
public var secondaryButton: ButtonModel?
|
||||||
|
}
|
||||||
@ -16,7 +16,6 @@ import Foundation
|
|||||||
ModelRegistry.register(MoleculeStackModel.self)
|
ModelRegistry.register(MoleculeStackModel.self)
|
||||||
ModelRegistry.register(StackItemModel.self)
|
ModelRegistry.register(StackItemModel.self)
|
||||||
ModelRegistry.register(TextFieldModel.self)
|
ModelRegistry.register(TextFieldModel.self)
|
||||||
ModelRegistry.register(LineModel.self)
|
|
||||||
ModelRegistry.register(ProgressBarModel.self)
|
ModelRegistry.register(ProgressBarModel.self)
|
||||||
ModelRegistry.register(MultiProgressBarModel.self)
|
ModelRegistry.register(MultiProgressBarModel.self)
|
||||||
ModelRegistry.register(CaretViewModel.self)
|
ModelRegistry.register(CaretViewModel.self)
|
||||||
@ -24,6 +23,10 @@ import Foundation
|
|||||||
ModelRegistry.register(ImageViewModel.self)
|
ModelRegistry.register(ImageViewModel.self)
|
||||||
ModelRegistry.register(TabsModel.self)
|
ModelRegistry.register(TabsModel.self)
|
||||||
ModelRegistry.register(ScrollerModel.self)
|
ModelRegistry.register(ScrollerModel.self)
|
||||||
|
// buttons
|
||||||
|
ModelRegistry.register(LineModel.self)
|
||||||
|
ModelRegistry.register(ButtonModel.self)
|
||||||
|
ModelRegistry.register(TwoButtonViewModel.self)
|
||||||
// list items
|
// list items
|
||||||
ModelRegistry.register(ListItemModel.self)
|
ModelRegistry.register(ListItemModel.self)
|
||||||
ModelRegistry.register(DropDownListItemModel.self)
|
ModelRegistry.register(DropDownListItemModel.self)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user