required identifiers

This commit is contained in:
Pfeil, Scott Robert 2020-03-19 16:28:35 -04:00
parent db542b170d
commit 18dcf3072f
27 changed files with 38 additions and 49 deletions

View File

@ -10,7 +10,7 @@ import UIKit
@objcMembers public class ActionCollapseNotificationModel: ActionModelProtocol { @objcMembers public class ActionCollapseNotificationModel: ActionModelProtocol {
public static var identifier: String = "collapseNotification" public static var identifier: String = "collapseNotification"
public var actionType: String? public var actionType: String
public var extraParameters: JSONValueDictionary? public var extraParameters: JSONValueDictionary?
public var analyticsData: JSONValueDictionary? public var analyticsData: JSONValueDictionary?
public var title: String? public var title: String?

View File

@ -18,7 +18,7 @@ public class ActionOpenPanelModel: ActionModelProtocol {
} }
public static var identifier: String = "openPanel" public static var identifier: String = "openPanel"
public var actionType: String? public var actionType: String = ActionOpenPanelModel.identifier
public var panel: Panel public var panel: Panel
public var extraParameters: JSONValueDictionary? public var extraParameters: JSONValueDictionary?
public var analyticsData: JSONValueDictionary? public var analyticsData: JSONValueDictionary?

View File

@ -10,7 +10,7 @@ import Foundation
@objcMembers public class ActionTopAlertModel: ActionModelProtocol { @objcMembers public class ActionTopAlertModel: ActionModelProtocol {
public static var identifier: String = "topAlert" public static var identifier: String = "topAlert"
public var actionType: String? public var actionType: String = ActionTopAlertModel.identifier
public var pageType: String public var pageType: String
public var extraParameters: JSONValueDictionary? public var extraParameters: JSONValueDictionary?
public var analyticsData: JSONValueDictionary? public var analyticsData: JSONValueDictionary?

View File

@ -12,7 +12,7 @@ import UIKit
public static var identifier: String = "textField" public static var identifier: String = "textField"
public var backgroundColor: Color? public var backgroundColor: Color?
public var moleculeName: String? = TextFieldModel.identifier public var moleculeName: String = TextFieldModel.identifier
public var editable: Bool? public var editable: Bool?
public var disabled: Bool? public var disabled: Bool?
public var errorMsg: String? public var errorMsg: String?

View File

@ -11,7 +11,7 @@ import Foundation
@objcMembers public class ImageViewModel: MoleculeModelProtocol { @objcMembers public class ImageViewModel: MoleculeModelProtocol {
public static var identifier: String = "image" public static var identifier: String = "image"
public var backgroundColor: Color? public var backgroundColor: Color?
public var moleculeName: String? = ImageViewModel.identifier public var moleculeName: String = ImageViewModel.identifier
public var image: String public var image: String
public var accessibilityText: String? public var accessibilityText: String?
public var fallbackImage: String? public var fallbackImage: String?

View File

@ -14,7 +14,7 @@ import UIKit
//-------------------------------------------------- //--------------------------------------------------
public static var identifier: String = "leftRightLabelView" public static var identifier: String = "leftRightLabelView"
public var moleculeName: String? = LeftRightLabelModel.identifier public var moleculeName: String = LeftRightLabelModel.identifier
public var backgroundColor: Color? public var backgroundColor: Color?
public var leftText: LabelModel public var leftText: LabelModel
public var rightText: LabelModel? public var rightText: LabelModel?

View File

@ -186,7 +186,7 @@ import UIKit
navigationItem.accessibilityLabel = navigationItemModel.title navigationItem.accessibilityLabel = navigationItemModel.title
navigationController.setNavigationBarHidden(navigationItemModel.hidden, animated: true) navigationController.setNavigationBarHidden(navigationItemModel.hidden, animated: true)
UIColor.setBackgroundColor(forNavigationBar: navigationItemModel.backgroundColor?.uiColor ?? .white, navigationBar: navigationController.navigationBar, transparent: navigationItemModel.transparent) UIColor.setBackgroundColor(navigationItemModel.backgroundColor?.uiColor ?? .white, for: navigationController.navigationBar, isTransparent: navigationItemModel.transparent)
let tint = navigationItemModel.tintColor.uiColor let tint = navigationItemModel.tintColor.uiColor
navigationController.navigationBar.tintColor = tint navigationController.navigationBar.tintColor = tint

View File

@ -2,13 +2,13 @@ import Foundation
public protocol MoleculeModelProtocol: ModelProtocol { public protocol MoleculeModelProtocol: ModelProtocol {
var moleculeName: String? { get } var moleculeName: String { get }
var backgroundColor: Color? { get set } var backgroundColor: Color? { get set }
} }
public extension MoleculeModelProtocol { public extension MoleculeModelProtocol {
var moleculeName: String? { var moleculeName: String {
get { return Self.identifier } get { return Self.identifier }
} }

View File

@ -11,7 +11,7 @@ import Foundation
@objcMembers public class DoughnutChartModel: MoleculeModelProtocol { @objcMembers public class DoughnutChartModel: MoleculeModelProtocol {
public var backgroundColor: Color? public var backgroundColor: Color?
public static var identifier: String = "doughnutChart" public static var identifier: String = "doughnutChart"
public var moleculeName: String? = DoughnutChartModel.identifier public var moleculeName: String = DoughnutChartModel.identifier
public var title: LabelModel? public var title: LabelModel?
public var subtitle: LabelModel? public var subtitle: LabelModel?
public var sections: [DoughnutChartItemModel] public var sections: [DoughnutChartItemModel]
@ -25,7 +25,7 @@ import Foundation
@objcMembers public class DoughnutChartItemModel: MoleculeModelProtocol { @objcMembers public class DoughnutChartItemModel: MoleculeModelProtocol {
public var backgroundColor: Color? public var backgroundColor: Color?
public static var identifier: String = "doughnutChartItem" public static var identifier: String = "doughnutChartItem"
public var moleculeName: String? = DoughnutChartItemModel.identifier public var moleculeName: String = DoughnutChartItemModel.identifier
public var label: LabelModel public var label: LabelModel
@Percent public var percent: CGFloat @Percent public var percent: CGFloat
public var color: Color public var color: Color

View File

@ -10,7 +10,7 @@ import Foundation
public struct ImageHeadlineBodyModel: MoleculeModelProtocol { public struct ImageHeadlineBodyModel: MoleculeModelProtocol {
public static var identifier: String = "imageHeadlineBody" public static var identifier: String = "imageHeadlineBody"
public var moleculeName: String? = ImageHeadlineBodyModel.identifier public var moleculeName: String = ImageHeadlineBodyModel.identifier
public var backgroundColor: Color? public var backgroundColor: Color?
public var image: ImageViewModel public var image: ImageViewModel
public var headlineBody: HeadlineBodyModel public var headlineBody: HeadlineBodyModel

View File

@ -116,11 +116,10 @@ open class MoleculeCollectionViewCell: UICollectionViewCell, MVMCoreUIMoleculeVi
public class func nameForReuse(_ model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> String? { public class func nameForReuse(_ model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> String? {
guard let molecule = (model as? CarouselItemModel)?.molecule, guard let molecule = (model as? CarouselItemModel)?.molecule,
let moleculeClass = MVMCoreUIMoleculeMappingObject.shared()?.getMoleculeClass(molecule) as? ModelMoleculeViewProtocol.Type, let moleculeClass = MVMCoreUIMoleculeMappingObject.shared()?.getMoleculeClass(molecule) as? ModelMoleculeViewProtocol.Type else {
let name = moleculeClass.nameForReuse(with: molecule, delegateObject) ?? molecule.moleculeName else {
return nil return nil
} }
return name return moleculeClass.nameForReuse(with: molecule, delegateObject) ?? molecule.moleculeName
} }
public func updateView(_ size: CGFloat) { public func updateView(_ size: CGFloat) {

View File

@ -10,7 +10,7 @@ import Foundation
@objcMembers public class StackItemModel: ContainerModel, StackItemModelProtocol, MoleculeModelProtocol { @objcMembers public class StackItemModel: ContainerModel, StackItemModelProtocol, MoleculeModelProtocol {
public static var identifier: String = "simpleStackItem" public static var identifier: String = "simpleStackItem"
public var moleculeName: String? = StackItemModel.identifier public var moleculeName: String = StackItemModel.identifier
public var backgroundColor: Color? public var backgroundColor: Color?
public var spacing: CGFloat? public var spacing: CGFloat?
public var percent: Int? public var percent: Int?

View File

@ -10,7 +10,7 @@ import Foundation
public struct ActionDetailWithImageModel: MoleculeModelProtocol { public struct ActionDetailWithImageModel: MoleculeModelProtocol {
public static var identifier: String = "actionDetailWithImage" public static var identifier: String = "actionDetailWithImage"
public var moleculeName: String? = ActionDetailWithImageModel.identifier public var moleculeName: String = ActionDetailWithImageModel.identifier
public var backgroundColor: Color? public var backgroundColor: Color?
public var headlineBodyButton: HeadlineBodyButtonModel public var headlineBodyButton: HeadlineBodyButtonModel
public var image: ImageViewModel public var image: ImageViewModel

View File

@ -9,7 +9,7 @@
import Foundation import Foundation
public struct HeadlineBodyLinkToggleModel: MoleculeModelProtocol { public struct HeadlineBodyLinkToggleModel: MoleculeModelProtocol {
public static var identifier: String = "headlineBodyLinkToggle" public static var identifier: String = "headlineBodyLinkToggle"
public var moleculeName: String? = HeadlineBodyLinkToggleModel.identifier public var moleculeName: String = HeadlineBodyLinkToggleModel.identifier
public var backgroundColor: Color? public var backgroundColor: Color?
public var headlineBodyLink: HeadlineBodyLinkModel public var headlineBodyLink: HeadlineBodyLinkModel
public var toggle: ToggleModel public var toggle: ToggleModel

View File

@ -11,7 +11,7 @@ import Foundation
open class HeadlineBodyToggleModel: MoleculeModelProtocol { open class HeadlineBodyToggleModel: MoleculeModelProtocol {
public static var identifier: String = "headlineBodyToggle" public static var identifier: String = "headlineBodyToggle"
public var moleculeName: String? = HeadlineBodyToggleModel.identifier public var moleculeName: String = HeadlineBodyToggleModel.identifier
open var backgroundColor: Color? open var backgroundColor: Color?
open var headlineBody: HeadlineBodyModel open var headlineBody: HeadlineBodyModel
open var toggle: ToggleModel open var toggle: ToggleModel

View File

@ -10,7 +10,7 @@ import Foundation
public class LabelToggleModel: MoleculeModelProtocol { public class LabelToggleModel: MoleculeModelProtocol {
public static var identifier: String = "labelToggle" public static var identifier: String = "labelToggle"
public var moleculeName: String? = LabelToggleModel.identifier public var moleculeName: String = LabelToggleModel.identifier
public var backgroundColor: Color? public var backgroundColor: Color?
public var label: LabelModel public var label: LabelModel
public var toggle: ToggleModel public var toggle: ToggleModel

View File

@ -10,6 +10,6 @@ import UIKit
public class ScrollerModel: MoleculeContainerModel, MoleculeModelProtocol { public class ScrollerModel: MoleculeContainerModel, MoleculeModelProtocol {
public static var identifier: String = "scroller" public static var identifier: String = "scroller"
public var moleculeName: String? = ScrollerModel.identifier public var moleculeName: String = ScrollerModel.identifier
public var backgroundColor: Color? public var backgroundColor: Color?
} }

View File

@ -14,7 +14,7 @@ public class EyebrowHeadlineBodyLinkModel: MoleculeModelProtocol {
//-------------------------------------------------- //--------------------------------------------------
public static var identifier: String = "eyebrowHeadlineBodyLink" public static var identifier: String = "eyebrowHeadlineBodyLink"
public var moleculeName: String? = EyebrowHeadlineBodyLinkModel.identifier public var moleculeName: String = EyebrowHeadlineBodyLinkModel.identifier
public var backgroundColor: Color? public var backgroundColor: Color?
public var eyebrow: LabelModel? public var eyebrow: LabelModel?
public var headline: LabelModel? public var headline: LabelModel?

View File

@ -10,7 +10,7 @@ import Foundation
public struct HeadlineBodyButtonModel: MoleculeModelProtocol { public struct HeadlineBodyButtonModel: MoleculeModelProtocol {
public static var identifier: String = "headlineBodyButton" public static var identifier: String = "headlineBodyButton"
public var moleculeName: String? = HeadlineBodyButtonModel.identifier public var moleculeName: String = HeadlineBodyButtonModel.identifier
public var backgroundColor: Color? public var backgroundColor: Color?
public var headlineBody: HeadlineBodyModel public var headlineBody: HeadlineBodyModel

View File

@ -10,7 +10,7 @@ import Foundation
public struct HeadlineBodyLinkModel: MoleculeModelProtocol { public struct HeadlineBodyLinkModel: MoleculeModelProtocol {
public static var identifier: String = "headlineBodyLink" public static var identifier: String = "headlineBodyLink"
public var moleculeName: String? = HeadlineBodyLinkModel.identifier public var moleculeName: String = HeadlineBodyLinkModel.identifier
public var headlineBody: HeadlineBodyModel public var headlineBody: HeadlineBodyModel
public var link: LinkModel public var link: LinkModel
public var backgroundColor: Color? public var backgroundColor: Color?

View File

@ -10,7 +10,7 @@ import Foundation
@objcMembers open class HeadlineBodyModel: MoleculeModelProtocol { @objcMembers open class HeadlineBodyModel: MoleculeModelProtocol {
public static var identifier: String = "headlineBody" public static var identifier: String = "headlineBody"
public var moleculeName: String? = HeadlineBodyModel.identifier public var moleculeName: String = HeadlineBodyModel.identifier
public var headline: LabelModel? public var headline: LabelModel?
public var body: LabelModel? public var body: LabelModel?
public var style: String? public var style: String?

View File

@ -14,8 +14,7 @@ open class StringAndMoleculeStack: MoleculeStackView {
guard let model = stackModel else { return } guard let model = stackModel else { return }
for stackItemModel in model.molecules { for stackItemModel in model.molecules {
guard let stringAndMoleculeModel = stackItemModel.molecule as? StringAndMoleculeModel, guard let stringAndMoleculeModel = stackItemModel.molecule as? StringAndMoleculeModel,
let moleculeName = stringAndMoleculeModel.molecule.moleculeName, let molecule = MVMCoreUIMoleculeMappingObject.shared()?.createMolecule(forName: stringAndMoleculeModel.molecule.moleculeName) as? (UIView & ModelMoleculeViewProtocol) else {
let molecule = MVMCoreUIMoleculeMappingObject.shared()?.createMolecule(forName: moleculeName) as? (UIView & ModelMoleculeViewProtocol) else {
// Throw error // Throw error
return return
} }

View File

@ -158,11 +158,10 @@ open class Carousel: View {
// MARK: - Convenience // MARK: - Convenience
/// Returns the (identifier, class) of the molecule for the given map. /// Returns the (identifier, class) of the molecule for the given map.
func getMoleculeInfo(with molecule: MoleculeModelProtocol, delegateObject: MVMCoreUIDelegateObject?) -> (identifier: String, class: AnyClass, molecule: MoleculeModelProtocol)? { func getMoleculeInfo(with molecule: MoleculeModelProtocol, delegateObject: MVMCoreUIDelegateObject?) -> (identifier: String, class: AnyClass, molecule: MoleculeModelProtocol)? {
guard let className = MVMCoreUIMoleculeMappingObject.shared()?.getMoleculeClass(molecule) , guard let className = MVMCoreUIMoleculeMappingObject.shared()?.getMoleculeClass(molecule) else {
let moleculeName = (className as? ModelMoleculeViewProtocol.Type)?.nameForReuse(with: molecule, delegateObject) ?? molecule.moleculeName else {
return nil return nil
} }
return (moleculeName, className, molecule) return ((className as? ModelMoleculeViewProtocol.Type)?.nameForReuse(with: molecule, delegateObject) ?? molecule.moleculeName, className, molecule)
} }
/// Sets the alignment from the string. /// Sets the alignment from the string.

View File

@ -162,13 +162,11 @@ open class Stack<T>: Container where T: (StackModelProtocol & MoleculeModelProto
} }
var name = "stack<" var name = "stack<"
for case let item in model.molecules { for case let item in model.molecules {
if let moleculeName = item.moleculeName { if let moleculeClass = MVMCoreUIMoleculeMappingObject.shared()?.moleculeMapping[item.moleculeName] as? ModelMoleculeViewProtocol.Type,
if let moleculeClass = MVMCoreUIMoleculeMappingObject.shared()?.moleculeMapping[moleculeName] as? ModelMoleculeViewProtocol.Type, let nameForReuse = moleculeClass.nameForReuse(with: item, delegateObject) {
let nameForReuse = moleculeClass.nameForReuse(with: item, delegateObject) { name.append(nameForReuse + ",")
name.append(nameForReuse + ",") } else {
} else { name.append(item.moleculeName + ",")
name.append(moleculeName + ",")
}
} }
} }
name.append(">") name.append(">")

View File

@ -16,10 +16,7 @@ public extension MVMCoreUIMoleculeMappingObject {
} }
func getMoleculeClass(_ model: MoleculeModelProtocol) -> AnyClass? { func getMoleculeClass(_ model: MoleculeModelProtocol) -> AnyClass? {
if let moleculeName = model.moleculeName { return moleculeMapping.object(forKey: model.moleculeName) as? AnyClass
return moleculeMapping.object(forKey: moleculeName) as? AnyClass
}
return nil
} }
func createMolecule(_ model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> (UIView & MVMCoreUIMoleculeViewProtocol)? { func createMolecule(_ model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> (UIView & MVMCoreUIMoleculeViewProtocol)? {
@ -27,8 +24,7 @@ public extension MVMCoreUIMoleculeMappingObject {
} }
func createMolecule(_ model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ constrainIfNeeded: Bool) -> (UIView & MVMCoreUIMoleculeViewProtocol)? { func createMolecule(_ model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ constrainIfNeeded: Bool) -> (UIView & MVMCoreUIMoleculeViewProtocol)? {
guard let moleculeName = model.moleculeName, guard let molecule = createMolecule(forName: model.moleculeName) else {
let molecule = createMolecule(forName: moleculeName) else {
return nil return nil
} }

View File

@ -13,9 +13,9 @@ open class ModalMoleculeListTemplate: MoleculeListTemplate {
public var closeButton: MFCustomButton? public var closeButton: MFCustomButton?
override open func handleNewData() { override open func handleNewData() {
super.newDataBuildScreen() super.handleNewData()
closeButton = MVMCoreUICommonViewsUtility.addCloseButton(to: view, action: { [weak self] _ in closeButton = MVMCoreUICommonViewsUtility.addCloseButton(to: view, action: { [weak self] _ in
self?.dismiss() MVMCoreNavigationHandler.shared()?.removeCurrentViewController()
}, verticalCentered: false) }, verticalCentered: false)
} }
} }

View File

@ -215,10 +215,8 @@ open class MoleculeListTemplate: ThreeLayerTableViewController, TemplateProtocol
func getMoleculeInfo(with listItem: (ListItemModelProtocol & MoleculeModelProtocol)?) -> (identifier: String, class: AnyClass, molecule: ListItemModelProtocol & MoleculeModelProtocol)? { func getMoleculeInfo(with listItem: (ListItemModelProtocol & MoleculeModelProtocol)?) -> (identifier: String, class: AnyClass, molecule: ListItemModelProtocol & MoleculeModelProtocol)? {
guard let listItem = listItem, guard let listItem = listItem,
let moleculeClass = MVMCoreUIMoleculeMappingObject.shared()?.getMoleculeClass(listItem), let moleculeClass = MVMCoreUIMoleculeMappingObject.shared()?.getMoleculeClass(listItem) else { return nil }
let moleculeName = (moleculeClass as? ModelMoleculeViewProtocol.Type)?.nameForReuse(with: listItem, delegateObject() as? MVMCoreUIDelegateObject) ?? listItem.moleculeName let moleculeName = (moleculeClass as? ModelMoleculeViewProtocol.Type)?.nameForReuse(with: listItem, delegateObject() as? MVMCoreUIDelegateObject) ?? listItem.moleculeName
else { return nil }
return (moleculeName, moleculeClass, listItem) return (moleculeName, moleculeClass, listItem)
} }