add protocol func into view

This commit is contained in:
panxi 2019-12-12 17:22:26 -05:00
parent 8d811f229f
commit 52186bf089
9 changed files with 34 additions and 28 deletions

View File

@ -577,7 +577,6 @@
01EB368B23609801006832FA /* MoleculeStackModel.swift */, 01EB368B23609801006832FA /* MoleculeStackModel.swift */,
01EB368C23609801006832FA /* HeaderModel.swift */, 01EB368C23609801006832FA /* HeaderModel.swift */,
012A88EB238F084D00FE3DA1 /* FooterModel.swift */, 012A88EB238F084D00FE3DA1 /* FooterModel.swift */,
01EB368D23609801006832FA /* HeadlineBodyModel.swift */,
017BEB3F23620A230024EF95 /* TextFieldModel.swift */, 017BEB3F23620A230024EF95 /* TextFieldModel.swift */,
017BEB4123620AD20024EF95 /* FormModelProtocol.swift */, 017BEB4123620AD20024EF95 /* FormModelProtocol.swift */,
017BEB7A236763000024EF95 /* LineModel.swift */, 017BEB7A236763000024EF95 /* LineModel.swift */,
@ -664,6 +663,7 @@
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
D2A638FC22CA98280052ED1F /* HeadlineBody.swift */, D2A638FC22CA98280052ED1F /* HeadlineBody.swift */,
01EB368D23609801006832FA /* HeadlineBodyModel.swift */,
D22479952316AF6D003FCCF9 /* HeadlineBodyTextButton.swift */, D22479952316AF6D003FCCF9 /* HeadlineBodyTextButton.swift */,
D27CD40F2339057800C1DC07 /* EyebrowHeadlineBodyLink.swift */, D27CD40F2339057800C1DC07 /* EyebrowHeadlineBodyLink.swift */,
); );

View File

@ -99,7 +99,7 @@ open class CaretView: View {
//------------------------------------------------------ //------------------------------------------------------
// Default values for view. // Default values for view.
@objc open func setAsMolecule() { @objc open override func setAsMolecule() {
defaultState() defaultState()
} }

View File

@ -64,7 +64,7 @@ open class DashLine: View {
//------------------------------------------------------ //------------------------------------------------------
// Default values for view. // Default values for view.
@objc open func setAsMolecule() { @objc open override func setAsMolecule() {
backgroundColor = .clear backgroundColor = .clear
isHidden = false isHidden = false
} }

View File

@ -12,9 +12,12 @@ import Foundation
public static var identifier: String { public static var identifier: String {
get { return "dashLine" } get { return "dashLine" }
} }
public var moleculeName: String = ""
public var backgroundColor: String? public var backgroundColor: String?
public var dashColor: String = "" public var dashColor: String
public var isHidden: Bool? public var isHidden: Bool?
public init(dashColor: String) {
self.dashColor = dashColor
}
} }

View File

@ -66,5 +66,9 @@ extension View: MVMCoreUIMoleculeViewProtocol {
open func reset() { open func reset() {
backgroundColor = .clear backgroundColor = .clear
} }
open func setAsMolecule() {
}
} }

View File

@ -9,7 +9,7 @@
import UIKit import UIKit
@objcMembers open class HeadlineBodyButton: ViewConstrainingView { @objcMembers open class HeadlineBodyButton: View {
//------------------------------------------------------ //------------------------------------------------------
// MARK: - Outlets // MARK: - Outlets
//------------------------------------------------------ //------------------------------------------------------
@ -33,7 +33,7 @@ import UIKit
// MARK: - Initialization // MARK: - Initialization
//------------------------------------------------------ //------------------------------------------------------
public init() { public override init() {
super.init(frame: .zero) super.init(frame: .zero)
} }

View File

@ -59,7 +59,7 @@ import UIKit
return 30 return 30
} }
open func setAsMolecule() { open override func setAsMolecule() {
headlineBody.setAsMolecule() headlineBody.setAsMolecule()
(mvmSwitch as MVMCoreUIMoleculeViewProtocol).setAsMolecule?() (mvmSwitch as MVMCoreUIMoleculeViewProtocol).setAsMolecule?()
headlineBody.styleListItem() headlineBody.styleListItem()

View File

@ -8,7 +8,7 @@
import UIKit import UIKit
open class HeadlineBody: ViewConstrainingView, ModelMoleculeViewProtocol { open class HeadlineBody: View {
let headlineLabel = Label.commonLabelH2(true) let headlineLabel = Label.commonLabelH2(true)
let messageLabel = Label.commonLabelB2(true) let messageLabel = Label.commonLabelB2(true)
var spaceBetweenLabelsConstant = PaddingTwo var spaceBetweenLabelsConstant = PaddingTwo
@ -81,7 +81,7 @@ open class HeadlineBody: ViewConstrainingView, ModelMoleculeViewProtocol {
let view = MVMCoreUICommonViewsUtility.commonView() let view = MVMCoreUICommonViewsUtility.commonView()
addSubview(view) addSubview(view)
pinView(toSuperView: view) NSLayoutConstraint.constraintPinSubview(toSuperview: view)
view.addSubview(headlineLabel) view.addSubview(headlineLabel)
view.addSubview(messageLabel) view.addSubview(messageLabel)
@ -119,9 +119,9 @@ open class HeadlineBody: ViewConstrainingView, ModelMoleculeViewProtocol {
} }
} }
public func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [String : AnyHashable]?) { public override func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [String : AnyHashable]?) {
setUpWithModel(model, delegateObject, additionalData) super.setWithModel(model, delegateObject, additionalData)
guard let headlineBodyModel = model as? HeadlineBodyModel else { guard let headlineBodyModel = model as? HeadlineBodyModel else {
return return
} }
@ -131,25 +131,26 @@ open class HeadlineBody: ViewConstrainingView, ModelMoleculeViewProtocol {
headlineLabel.setWithModel(headlineBodyModel.headline, delegateObject, additionalData) headlineLabel.setWithModel(headlineBodyModel.headline, delegateObject, additionalData)
messageLabel.setWithModel(headlineBodyModel.body, delegateObject, additionalData) messageLabel.setWithModel(headlineBodyModel.body, delegateObject, additionalData)
} }
// // MARK: - MVMCoreUIMoleculeViewProtocol
// open override func setWithJSON(_ json: [AnyHashable: Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) { // MARK: - MVMCoreUIMoleculeViewProtocol
// super.setWithJSON(json, delegateObject: delegateObject, additionalData: additionalData) open override func setWithJSON(_ json: [AnyHashable: Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) {
// super.setWithJSON(json, delegateObject: delegateObject, additionalData: additionalData)
// style(with: json?.optionalStringForKey("style"))
// style(with: json?.optionalStringForKey("style"))
// let headlineJSON = json?.optionalDictionaryForKey("headline")
// headlineLabel.setWithJSON(headlineJSON, delegateObject: delegateObject, additionalData: additionalData) let headlineJSON = json?.optionalDictionaryForKey("headline")
// headlineLabel.setWithJSON(headlineJSON, delegateObject: delegateObject, additionalData: additionalData)
// let bodyJSON = json?.optionalDictionaryForKey("body")
// messageLabel.setWithJSON(bodyJSON, delegateObject: delegateObject, additionalData: additionalData) let bodyJSON = json?.optionalDictionaryForKey("body")
// } messageLabel.setWithJSON(bodyJSON, delegateObject: delegateObject, additionalData: additionalData)
}
open override func reset() { open override func reset() {
super.reset() super.reset()
stylePageHeader() stylePageHeader()
} }
public override class func estimatedHeight(forRow json: [AnyHashable : Any]?, delegateObject: MVMCoreUIDelegateObject?) -> CGFloat { public class func estimatedHeight(forRow json: [AnyHashable : Any]?, delegateObject: MVMCoreUIDelegateObject?) -> CGFloat {
return 58 return 58
} }
} }

View File

@ -15,11 +15,9 @@ import Foundation
public var style: String? public var style: String?
public var backgroundColor: String? public var backgroundColor: String?
public init(headline: LabelModel, body: LabelModel, style: String?, backgroundColor: String?) { public init(headline: LabelModel, body: LabelModel) {
self.headline = headline self.headline = headline
self.body = body self.body = body
self.style = style
self.backgroundColor = backgroundColor
} }
} }