mvm_core_ui/MVMCoreUI/Models/MoleculeProtocol.swift
2019-12-04 12:38:57 -05:00

48 lines
1.2 KiB
Swift

import Foundation
public protocol MoleculeProtocol: Model {
var moleculeName: String? { get }
var backgroundColor: String? { get }
var dictionary: [AnyHashable: Any]? { get }
var molecule: MoleculeProtocol? { get }
var useHorizontalMargins: Bool? { get }
var useVerticalMargins: Bool? { get }
var horizontalAlignment: String? { get }
var verticalAlignment: String? { get }
}
extension MoleculeProtocol {
public var moleculeName: String? {
get { return Self.identifier }
}
public var molecule: MoleculeProtocol? {
get { return nil }
}
public var backgroundColor: String? {
get { return toJSON()?["backgroundColor"] as? String }
}
public var useHorizontalMargins: Bool? {
get { return toJSON()?["useHorizontalMargins"] as? Bool }
}
public var useVerticalMargins: Bool? {
get { return toJSON()?["useVerticalMargins"] as? Bool }
}
public var horizontalAlignment: String? {
get { return toJSON()?["horizontalAlignment"] as? String }
}
public var verticalAlignment: String? {
get { return toJSON()?["verticalAlignment"] as? String }
}
public var dictionary: [AnyHashable: Any]? {
return toJSON()
}
}