Cleanup
This commit is contained in:
parent
db0cb77756
commit
016c6edc06
@ -8,10 +8,11 @@
|
|||||||
|
|
||||||
public typealias ButtonBlock = (Button) -> ()
|
public typealias ButtonBlock = (Button) -> ()
|
||||||
|
|
||||||
@objcMembers open class Button: UIButton, MFButtonProtocol {
|
@objcMembers open class Button: UIButton, MFButtonProtocol, ModelMoleculeViewProtocol {
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
// MARK: - Properties
|
// MARK: - Properties
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
|
public var model: MoleculeModelProtocol?
|
||||||
public var actionModel: ActionModelProtocol?
|
public var actionModel: ActionModelProtocol?
|
||||||
|
|
||||||
private var initialSetupPerformed = false
|
private var initialSetupPerformed = false
|
||||||
@ -80,6 +81,26 @@ public typealias ButtonBlock = (Button) -> ()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// MARK:- ModelMoleculeViewProtocol
|
||||||
|
public func setWithModel(_ model: MoleculeModelProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) {
|
||||||
|
self.model = model
|
||||||
|
if let backgroundColor = model?.backgroundColor {
|
||||||
|
self.backgroundColor = backgroundColor.uiColor
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class func nameForReuse(_ model: MoleculeModelProtocol?, _ delegateObject: MVMCoreUIDelegateObject?) -> String? {
|
||||||
|
return model?.moleculeName
|
||||||
|
}
|
||||||
|
|
||||||
|
public class func estimatedHeight(forRow molecule: MoleculeModelProtocol?, delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
public class func requiredModules(_ molecule: MoleculeModelProtocol?, delegateObject: MVMCoreUIDelegateObject?, error: AutoreleasingUnsafeMutablePointer<MVMCoreErrorObject?>?) -> [String]? {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// MARK: - MVMCoreViewProtocol
|
// MARK: - MVMCoreViewProtocol
|
||||||
@ -96,9 +117,15 @@ extension Button: MVMCoreViewProtocol {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// MARK: - MVMCoreUIMoleculeViewProtocol
|
||||||
|
extension Button: MVMCoreUIMoleculeViewProtocol {
|
||||||
|
public func reset() {
|
||||||
|
backgroundColor = .clear
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// MARK: AppleGuidelinesProtocol
|
// MARK: AppleGuidelinesProtocol
|
||||||
extension Button: AppleGuidelinesProtocol {
|
extension Button: AppleGuidelinesProtocol {
|
||||||
|
|
||||||
override open func point(inside point: CGPoint, with event: UIEvent?) -> Bool {
|
override open func point(inside point: CGPoint, with event: UIEvent?) -> Bool {
|
||||||
return Self.acceptablyOutsideBounds(point: point, bounds: bounds)
|
return Self.acceptablyOutsideBounds(point: point, bounds: bounds)
|
||||||
}
|
}
|
||||||
|
|||||||
@ -12,8 +12,7 @@ import UIKit
|
|||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
// MARK: - Properties
|
// MARK: - Properties
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
|
open var json: [AnyHashable: Any]?
|
||||||
public var json: [AnyHashable: Any]?
|
|
||||||
public var model: MoleculeModelProtocol?
|
public var model: MoleculeModelProtocol?
|
||||||
|
|
||||||
private var initialSetupPerformed = false
|
private var initialSetupPerformed = false
|
||||||
@ -42,13 +41,13 @@ import UIKit
|
|||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
|
|
||||||
public func initialSetup() {
|
public func initialSetup() {
|
||||||
|
|
||||||
if !initialSetupPerformed {
|
if !initialSetupPerformed {
|
||||||
initialSetupPerformed = true
|
initialSetupPerformed = true
|
||||||
setupView()
|
setupView()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// MARK:- ModelMoleculeViewProtocol
|
||||||
public func setWithModel(_ model: MoleculeModelProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) {
|
public func setWithModel(_ model: MoleculeModelProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) {
|
||||||
self.model = model
|
self.model = model
|
||||||
if let backgroundColor = model?.backgroundColor {
|
if let backgroundColor = model?.backgroundColor {
|
||||||
@ -56,13 +55,22 @@ import UIKit
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public class func nameForReuse(_ model: MoleculeModelProtocol?, _ delegateObject: MVMCoreUIDelegateObject?) -> String? {
|
||||||
|
return model?.moleculeName
|
||||||
|
}
|
||||||
|
|
||||||
|
public class func estimatedHeight(forRow molecule: MoleculeModelProtocol?, delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
public class func requiredModules(_ molecule: MoleculeModelProtocol?, delegateObject: MVMCoreUIDelegateObject?, error: AutoreleasingUnsafeMutablePointer<MVMCoreErrorObject?>?) -> [String]? {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// MARK: - AppleGuidelinesProtocol
|
// MARK: - AppleGuidelinesProtocol
|
||||||
extension Control: AppleGuidelinesProtocol {
|
extension Control: AppleGuidelinesProtocol {
|
||||||
|
|
||||||
override open func point(inside point: CGPoint, with event: UIEvent?) -> Bool {
|
override open func point(inside point: CGPoint, with event: UIEvent?) -> Bool {
|
||||||
|
|
||||||
return Self.acceptablyOutsideBounds(point: point, bounds: bounds)
|
return Self.acceptablyOutsideBounds(point: point, bounds: bounds)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -81,15 +89,14 @@ extension Control: MVMCoreViewProtocol {
|
|||||||
|
|
||||||
// MARK: - MVMCoreUIMoleculeViewProtocol
|
// MARK: - MVMCoreUIMoleculeViewProtocol
|
||||||
extension Control: MVMCoreUIMoleculeViewProtocol {
|
extension Control: MVMCoreUIMoleculeViewProtocol {
|
||||||
|
open func setWithJSON(_ json: [AnyHashable: Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) {
|
||||||
|
self.json = json
|
||||||
|
|
||||||
|
if let backgroundColorString = json?.optionalStringForKey(KeyBackgroundColor) {
|
||||||
|
backgroundColor = UIColor.mfGet(forHex: backgroundColorString)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public func setWithJSON(_ json: [AnyHashable: Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) {
|
|
||||||
self.json = json
|
|
||||||
|
|
||||||
if let backgroundColorString = json?.optionalStringForKey(KeyBackgroundColor) {
|
|
||||||
backgroundColor = UIColor.mfGet(forHex: backgroundColorString)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public func reset() {
|
public func reset() {
|
||||||
backgroundColor = .clear
|
backgroundColor = .clear
|
||||||
}
|
}
|
||||||
|
|||||||
@ -33,13 +33,13 @@ import UIKit
|
|||||||
}
|
}
|
||||||
|
|
||||||
public func initialSetup() {
|
public func initialSetup() {
|
||||||
|
|
||||||
if !initialSetupPerformed {
|
if !initialSetupPerformed {
|
||||||
initialSetupPerformed = true
|
initialSetupPerformed = true
|
||||||
setupView()
|
setupView()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// MARK:- ModelMoleculeViewProtocol
|
||||||
open func setWithModel(_ model: MoleculeModelProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) {
|
open func setWithModel(_ model: MoleculeModelProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) {
|
||||||
self.model = model
|
self.model = model
|
||||||
if let backgroundColor = model?.backgroundColor {
|
if let backgroundColor = model?.backgroundColor {
|
||||||
|
|||||||
@ -9,6 +9,11 @@
|
|||||||
import Foundation
|
import Foundation
|
||||||
|
|
||||||
public extension MVMCoreUIMoleculeMappingObject {
|
public extension MVMCoreUIMoleculeMappingObject {
|
||||||
|
|
||||||
|
func register<M: Model, V: MVMCoreUIMoleculeViewProtocol>(viewClass: V.Type, viewModelClass: M.Type) {
|
||||||
|
ModelRegistry.register(viewModelClass)
|
||||||
|
MVMCoreUIMoleculeMappingObject.shared()?.moleculeMapping.setObject(viewClass, forKey: viewModelClass.identifier as NSString)
|
||||||
|
}
|
||||||
|
|
||||||
func getMoleculeClass(_ model: MoleculeModelProtocol) -> AnyClass? {
|
func getMoleculeClass(_ model: MoleculeModelProtocol) -> AnyClass? {
|
||||||
if let moleculeName = model.moleculeName {
|
if let moleculeName = model.moleculeName {
|
||||||
|
|||||||
@ -10,24 +10,17 @@ import Foundation
|
|||||||
|
|
||||||
@objcMembers public class MoleculeObjectMapping: NSObject {
|
@objcMembers public class MoleculeObjectMapping: NSObject {
|
||||||
public static func registerObjects() {
|
public static func registerObjects() {
|
||||||
let mapping = MVMCoreUIMoleculeMappingObject.shared()?.moleculeMapping
|
MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: MoleculeStackView.self, viewModelClass: MoleculeStackModel.self)
|
||||||
ModelRegistry.register(MoleculeStackModel.self)
|
MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: Stack<StackModel>.self, viewModelClass: StackModel.self)
|
||||||
mapping?.setObject(MoleculeStackView.self, forKey: MoleculeStackModel.identifier as NSString)
|
MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: MoleculeStackItem.self, viewModelClass: MoleculeStackItemModel.self)
|
||||||
ModelRegistry.register(StackModel.self)
|
MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: StackItem.self, viewModelClass: StackItemModel.self)
|
||||||
mapping?.setObject(Stack<StackModel>.self, forKey: StackModel.identifier as NSString)
|
MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: StringAndMoleculeView.self, viewModelClass: StringAndMoleculeModel.self)
|
||||||
ModelRegistry.register(StackItemModel.self)
|
MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: UnOrderedList.self, viewModelClass: UnOrderedListModel.self)
|
||||||
mapping?.setObject(StackItem.self, forKey: StackItemModel.identifier as NSString)
|
MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: NumberedList.self, viewModelClass: NumberedListModel.self)
|
||||||
ModelRegistry.register(StringAndMoleculeModel.self)
|
MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: Label.self, viewModelClass: LabelModel.self)
|
||||||
mapping?.setObject(StringAndMoleculeView.self, forKey: StringAndMoleculeModel.identifier as NSString)
|
MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: HeaderView.self, viewModelClass: HeaderModel.self)
|
||||||
ModelRegistry.register(UnOrderedListModel.self)
|
MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: FooterView.self, viewModelClass: FooterModel.self)
|
||||||
mapping?.setObject(UnOrderedList.self, forKey: UnOrderedListModel.identifier as NSString)
|
MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: HeadlineBody.self, viewModelClass: HeadlineBodyModel.self)
|
||||||
ModelRegistry.register(NumberedListModel.self)
|
|
||||||
mapping?.setObject(NumberedList.self, forKey: NumberedListModel.identifier as NSString)
|
|
||||||
|
|
||||||
ModelRegistry.register(LabelModel.self)
|
|
||||||
ModelRegistry.register(HeaderModel.self)
|
|
||||||
ModelRegistry.register(FooterModel.self)
|
|
||||||
ModelRegistry.register(HeadlineBodyModel.self)
|
|
||||||
ModelRegistry.register(MoleculeStackItemModel.self)
|
ModelRegistry.register(MoleculeStackItemModel.self)
|
||||||
ModelRegistry.register(TextFieldModel.self)
|
ModelRegistry.register(TextFieldModel.self)
|
||||||
ModelRegistry.register(ProgressBarModel.self)
|
ModelRegistry.register(ProgressBarModel.self)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user