required identifiers
This commit is contained in:
parent
db542b170d
commit
18dcf3072f
@ -10,7 +10,7 @@ import UIKit
|
||||
|
||||
@objcMembers public class ActionCollapseNotificationModel: ActionModelProtocol {
|
||||
public static var identifier: String = "collapseNotification"
|
||||
public var actionType: String?
|
||||
public var actionType: String
|
||||
public var extraParameters: JSONValueDictionary?
|
||||
public var analyticsData: JSONValueDictionary?
|
||||
public var title: String?
|
||||
|
||||
@ -18,7 +18,7 @@ public class ActionOpenPanelModel: ActionModelProtocol {
|
||||
}
|
||||
|
||||
public static var identifier: String = "openPanel"
|
||||
public var actionType: String?
|
||||
public var actionType: String = ActionOpenPanelModel.identifier
|
||||
public var panel: Panel
|
||||
public var extraParameters: JSONValueDictionary?
|
||||
public var analyticsData: JSONValueDictionary?
|
||||
|
||||
@ -10,7 +10,7 @@ import Foundation
|
||||
|
||||
@objcMembers public class ActionTopAlertModel: ActionModelProtocol {
|
||||
public static var identifier: String = "topAlert"
|
||||
public var actionType: String?
|
||||
public var actionType: String = ActionTopAlertModel.identifier
|
||||
public var pageType: String
|
||||
public var extraParameters: JSONValueDictionary?
|
||||
public var analyticsData: JSONValueDictionary?
|
||||
|
||||
@ -12,7 +12,7 @@ import UIKit
|
||||
|
||||
public static var identifier: String = "textField"
|
||||
public var backgroundColor: Color?
|
||||
public var moleculeName: String? = TextFieldModel.identifier
|
||||
public var moleculeName: String = TextFieldModel.identifier
|
||||
public var editable: Bool?
|
||||
public var disabled: Bool?
|
||||
public var errorMsg: String?
|
||||
|
||||
@ -11,7 +11,7 @@ import Foundation
|
||||
@objcMembers public class ImageViewModel: MoleculeModelProtocol {
|
||||
public static var identifier: String = "image"
|
||||
public var backgroundColor: Color?
|
||||
public var moleculeName: String? = ImageViewModel.identifier
|
||||
public var moleculeName: String = ImageViewModel.identifier
|
||||
public var image: String
|
||||
public var accessibilityText: String?
|
||||
public var fallbackImage: String?
|
||||
|
||||
@ -14,7 +14,7 @@ import UIKit
|
||||
//--------------------------------------------------
|
||||
|
||||
public static var identifier: String = "leftRightLabelView"
|
||||
public var moleculeName: String? = LeftRightLabelModel.identifier
|
||||
public var moleculeName: String = LeftRightLabelModel.identifier
|
||||
public var backgroundColor: Color?
|
||||
public var leftText: LabelModel
|
||||
public var rightText: LabelModel?
|
||||
|
||||
@ -186,7 +186,7 @@ import UIKit
|
||||
navigationItem.accessibilityLabel = navigationItemModel.title
|
||||
|
||||
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
|
||||
navigationController.navigationBar.tintColor = tint
|
||||
|
||||
@ -2,13 +2,13 @@ import Foundation
|
||||
|
||||
|
||||
public protocol MoleculeModelProtocol: ModelProtocol {
|
||||
var moleculeName: String? { get }
|
||||
var moleculeName: String { get }
|
||||
var backgroundColor: Color? { get set }
|
||||
}
|
||||
|
||||
public extension MoleculeModelProtocol {
|
||||
|
||||
var moleculeName: String? {
|
||||
var moleculeName: String {
|
||||
get { return Self.identifier }
|
||||
}
|
||||
|
||||
|
||||
@ -11,7 +11,7 @@ import Foundation
|
||||
@objcMembers public class DoughnutChartModel: MoleculeModelProtocol {
|
||||
public var backgroundColor: Color?
|
||||
public static var identifier: String = "doughnutChart"
|
||||
public var moleculeName: String? = DoughnutChartModel.identifier
|
||||
public var moleculeName: String = DoughnutChartModel.identifier
|
||||
public var title: LabelModel?
|
||||
public var subtitle: LabelModel?
|
||||
public var sections: [DoughnutChartItemModel]
|
||||
@ -25,7 +25,7 @@ import Foundation
|
||||
@objcMembers public class DoughnutChartItemModel: MoleculeModelProtocol {
|
||||
public var backgroundColor: Color?
|
||||
public static var identifier: String = "doughnutChartItem"
|
||||
public var moleculeName: String? = DoughnutChartItemModel.identifier
|
||||
public var moleculeName: String = DoughnutChartItemModel.identifier
|
||||
public var label: LabelModel
|
||||
@Percent public var percent: CGFloat
|
||||
public var color: Color
|
||||
|
||||
@ -10,7 +10,7 @@ import Foundation
|
||||
|
||||
public struct ImageHeadlineBodyModel: MoleculeModelProtocol {
|
||||
public static var identifier: String = "imageHeadlineBody"
|
||||
public var moleculeName: String? = ImageHeadlineBodyModel.identifier
|
||||
public var moleculeName: String = ImageHeadlineBodyModel.identifier
|
||||
public var backgroundColor: Color?
|
||||
public var image: ImageViewModel
|
||||
public var headlineBody: HeadlineBodyModel
|
||||
|
||||
@ -116,11 +116,10 @@ open class MoleculeCollectionViewCell: UICollectionViewCell, MVMCoreUIMoleculeVi
|
||||
|
||||
public class func nameForReuse(_ model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> String? {
|
||||
guard let molecule = (model as? CarouselItemModel)?.molecule,
|
||||
let moleculeClass = MVMCoreUIMoleculeMappingObject.shared()?.getMoleculeClass(molecule) as? ModelMoleculeViewProtocol.Type,
|
||||
let name = moleculeClass.nameForReuse(with: molecule, delegateObject) ?? molecule.moleculeName else {
|
||||
let moleculeClass = MVMCoreUIMoleculeMappingObject.shared()?.getMoleculeClass(molecule) as? ModelMoleculeViewProtocol.Type else {
|
||||
return nil
|
||||
}
|
||||
return name
|
||||
return moleculeClass.nameForReuse(with: molecule, delegateObject) ?? molecule.moleculeName
|
||||
}
|
||||
|
||||
public func updateView(_ size: CGFloat) {
|
||||
|
||||
@ -10,7 +10,7 @@ import Foundation
|
||||
|
||||
@objcMembers public class StackItemModel: ContainerModel, StackItemModelProtocol, MoleculeModelProtocol {
|
||||
public static var identifier: String = "simpleStackItem"
|
||||
public var moleculeName: String? = StackItemModel.identifier
|
||||
public var moleculeName: String = StackItemModel.identifier
|
||||
public var backgroundColor: Color?
|
||||
public var spacing: CGFloat?
|
||||
public var percent: Int?
|
||||
|
||||
@ -10,7 +10,7 @@ import Foundation
|
||||
|
||||
public struct ActionDetailWithImageModel: MoleculeModelProtocol {
|
||||
public static var identifier: String = "actionDetailWithImage"
|
||||
public var moleculeName: String? = ActionDetailWithImageModel.identifier
|
||||
public var moleculeName: String = ActionDetailWithImageModel.identifier
|
||||
public var backgroundColor: Color?
|
||||
public var headlineBodyButton: HeadlineBodyButtonModel
|
||||
public var image: ImageViewModel
|
||||
|
||||
@ -9,7 +9,7 @@
|
||||
import Foundation
|
||||
public struct HeadlineBodyLinkToggleModel: MoleculeModelProtocol {
|
||||
public static var identifier: String = "headlineBodyLinkToggle"
|
||||
public var moleculeName: String? = HeadlineBodyLinkToggleModel.identifier
|
||||
public var moleculeName: String = HeadlineBodyLinkToggleModel.identifier
|
||||
public var backgroundColor: Color?
|
||||
public var headlineBodyLink: HeadlineBodyLinkModel
|
||||
public var toggle: ToggleModel
|
||||
|
||||
@ -11,7 +11,7 @@ import Foundation
|
||||
|
||||
open class HeadlineBodyToggleModel: MoleculeModelProtocol {
|
||||
public static var identifier: String = "headlineBodyToggle"
|
||||
public var moleculeName: String? = HeadlineBodyToggleModel.identifier
|
||||
public var moleculeName: String = HeadlineBodyToggleModel.identifier
|
||||
open var backgroundColor: Color?
|
||||
open var headlineBody: HeadlineBodyModel
|
||||
open var toggle: ToggleModel
|
||||
|
||||
@ -10,7 +10,7 @@ import Foundation
|
||||
|
||||
public class LabelToggleModel: MoleculeModelProtocol {
|
||||
public static var identifier: String = "labelToggle"
|
||||
public var moleculeName: String? = LabelToggleModel.identifier
|
||||
public var moleculeName: String = LabelToggleModel.identifier
|
||||
public var backgroundColor: Color?
|
||||
public var label: LabelModel
|
||||
public var toggle: ToggleModel
|
||||
|
||||
@ -10,6 +10,6 @@ import UIKit
|
||||
|
||||
public class ScrollerModel: MoleculeContainerModel, MoleculeModelProtocol {
|
||||
public static var identifier: String = "scroller"
|
||||
public var moleculeName: String? = ScrollerModel.identifier
|
||||
public var moleculeName: String = ScrollerModel.identifier
|
||||
public var backgroundColor: Color?
|
||||
}
|
||||
|
||||
@ -14,7 +14,7 @@ public class EyebrowHeadlineBodyLinkModel: MoleculeModelProtocol {
|
||||
//--------------------------------------------------
|
||||
|
||||
public static var identifier: String = "eyebrowHeadlineBodyLink"
|
||||
public var moleculeName: String? = EyebrowHeadlineBodyLinkModel.identifier
|
||||
public var moleculeName: String = EyebrowHeadlineBodyLinkModel.identifier
|
||||
public var backgroundColor: Color?
|
||||
public var eyebrow: LabelModel?
|
||||
public var headline: LabelModel?
|
||||
|
||||
@ -10,7 +10,7 @@ import Foundation
|
||||
|
||||
public struct HeadlineBodyButtonModel: MoleculeModelProtocol {
|
||||
public static var identifier: String = "headlineBodyButton"
|
||||
public var moleculeName: String? = HeadlineBodyButtonModel.identifier
|
||||
public var moleculeName: String = HeadlineBodyButtonModel.identifier
|
||||
public var backgroundColor: Color?
|
||||
|
||||
public var headlineBody: HeadlineBodyModel
|
||||
|
||||
@ -10,7 +10,7 @@ import Foundation
|
||||
|
||||
public struct HeadlineBodyLinkModel: MoleculeModelProtocol {
|
||||
public static var identifier: String = "headlineBodyLink"
|
||||
public var moleculeName: String? = HeadlineBodyLinkModel.identifier
|
||||
public var moleculeName: String = HeadlineBodyLinkModel.identifier
|
||||
public var headlineBody: HeadlineBodyModel
|
||||
public var link: LinkModel
|
||||
public var backgroundColor: Color?
|
||||
|
||||
@ -10,7 +10,7 @@ import Foundation
|
||||
|
||||
@objcMembers open class HeadlineBodyModel: MoleculeModelProtocol {
|
||||
public static var identifier: String = "headlineBody"
|
||||
public var moleculeName: String? = HeadlineBodyModel.identifier
|
||||
public var moleculeName: String = HeadlineBodyModel.identifier
|
||||
public var headline: LabelModel?
|
||||
public var body: LabelModel?
|
||||
public var style: String?
|
||||
|
||||
@ -14,8 +14,7 @@ open class StringAndMoleculeStack: MoleculeStackView {
|
||||
guard let model = stackModel else { return }
|
||||
for stackItemModel in model.molecules {
|
||||
guard let stringAndMoleculeModel = stackItemModel.molecule as? StringAndMoleculeModel,
|
||||
let moleculeName = stringAndMoleculeModel.molecule.moleculeName,
|
||||
let molecule = MVMCoreUIMoleculeMappingObject.shared()?.createMolecule(forName: moleculeName) as? (UIView & ModelMoleculeViewProtocol) else {
|
||||
let molecule = MVMCoreUIMoleculeMappingObject.shared()?.createMolecule(forName: stringAndMoleculeModel.molecule.moleculeName) as? (UIView & ModelMoleculeViewProtocol) else {
|
||||
// Throw error
|
||||
return
|
||||
}
|
||||
|
||||
@ -158,11 +158,10 @@ open class Carousel: View {
|
||||
// MARK: - Convenience
|
||||
/// Returns the (identifier, class) of the molecule for the given map.
|
||||
func getMoleculeInfo(with molecule: MoleculeModelProtocol, delegateObject: MVMCoreUIDelegateObject?) -> (identifier: String, class: AnyClass, molecule: MoleculeModelProtocol)? {
|
||||
guard let className = MVMCoreUIMoleculeMappingObject.shared()?.getMoleculeClass(molecule) ,
|
||||
let moleculeName = (className as? ModelMoleculeViewProtocol.Type)?.nameForReuse(with: molecule, delegateObject) ?? molecule.moleculeName else {
|
||||
guard let className = MVMCoreUIMoleculeMappingObject.shared()?.getMoleculeClass(molecule) else {
|
||||
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.
|
||||
|
||||
@ -162,13 +162,11 @@ open class Stack<T>: Container where T: (StackModelProtocol & MoleculeModelProto
|
||||
}
|
||||
var name = "stack<"
|
||||
for case let item in model.molecules {
|
||||
if let moleculeName = item.moleculeName {
|
||||
if let moleculeClass = MVMCoreUIMoleculeMappingObject.shared()?.moleculeMapping[moleculeName] as? ModelMoleculeViewProtocol.Type,
|
||||
let nameForReuse = moleculeClass.nameForReuse(with: item, delegateObject) {
|
||||
name.append(nameForReuse + ",")
|
||||
} else {
|
||||
name.append(moleculeName + ",")
|
||||
}
|
||||
if let moleculeClass = MVMCoreUIMoleculeMappingObject.shared()?.moleculeMapping[item.moleculeName] as? ModelMoleculeViewProtocol.Type,
|
||||
let nameForReuse = moleculeClass.nameForReuse(with: item, delegateObject) {
|
||||
name.append(nameForReuse + ",")
|
||||
} else {
|
||||
name.append(item.moleculeName + ",")
|
||||
}
|
||||
}
|
||||
name.append(">")
|
||||
|
||||
@ -16,10 +16,7 @@ public extension MVMCoreUIMoleculeMappingObject {
|
||||
}
|
||||
|
||||
func getMoleculeClass(_ model: MoleculeModelProtocol) -> AnyClass? {
|
||||
if let moleculeName = model.moleculeName {
|
||||
return moleculeMapping.object(forKey: moleculeName) as? AnyClass
|
||||
}
|
||||
return nil
|
||||
return moleculeMapping.object(forKey: model.moleculeName) as? AnyClass
|
||||
}
|
||||
|
||||
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)? {
|
||||
guard let moleculeName = model.moleculeName,
|
||||
let molecule = createMolecule(forName: moleculeName) else {
|
||||
guard let molecule = createMolecule(forName: model.moleculeName) else {
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
@ -13,9 +13,9 @@ open class ModalMoleculeListTemplate: MoleculeListTemplate {
|
||||
public var closeButton: MFCustomButton?
|
||||
|
||||
override open func handleNewData() {
|
||||
super.newDataBuildScreen()
|
||||
super.handleNewData()
|
||||
closeButton = MVMCoreUICommonViewsUtility.addCloseButton(to: view, action: { [weak self] _ in
|
||||
self?.dismiss()
|
||||
MVMCoreNavigationHandler.shared()?.removeCurrentViewController()
|
||||
}, verticalCentered: false)
|
||||
}
|
||||
}
|
||||
|
||||
@ -215,10 +215,8 @@ open class MoleculeListTemplate: ThreeLayerTableViewController, TemplateProtocol
|
||||
func getMoleculeInfo(with listItem: (ListItemModelProtocol & MoleculeModelProtocol)?) -> (identifier: String, class: AnyClass, molecule: ListItemModelProtocol & MoleculeModelProtocol)? {
|
||||
|
||||
guard let listItem = listItem,
|
||||
let moleculeClass = MVMCoreUIMoleculeMappingObject.shared()?.getMoleculeClass(listItem),
|
||||
let moleculeName = (moleculeClass as? ModelMoleculeViewProtocol.Type)?.nameForReuse(with: listItem, delegateObject() as? MVMCoreUIDelegateObject) ?? listItem.moleculeName
|
||||
else { return nil }
|
||||
|
||||
let moleculeClass = MVMCoreUIMoleculeMappingObject.shared()?.getMoleculeClass(listItem) else { return nil }
|
||||
let moleculeName = (moleculeClass as? ModelMoleculeViewProtocol.Type)?.nameForReuse(with: listItem, delegateObject() as? MVMCoreUIDelegateObject) ?? listItem.moleculeName
|
||||
return (moleculeName, moleculeClass, listItem)
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user