code cleanup and identation

This commit is contained in:
Subhankar Acharya 2020-03-06 16:19:54 +05:30
parent b4f36b03c7
commit c891b6763e
2 changed files with 30 additions and 25 deletions

View File

@ -14,36 +14,36 @@ import Foundation
// MARK: - Outlets // MARK: - Outlets
//----------------------------------------------------- //-----------------------------------------------------
var stack: Stack<StackModel> var stack: Stack<StackModel>
let headlineBody = HeadlineBody() let headlineBody = HeadlineBody(frame: .zero)
//----------------------------------------------------- //-----------------------------------------------------
// MARK: - Initializers // MARK: - Initializers
//----------------------------------------------------- //-----------------------------------------------------
public override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) { public override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
stack = Stack<StackModel>.createStack(with: [headlineBody]) stack = Stack<StackModel>.createStack(with: [headlineBody])
super.init(style: style, reuseIdentifier: reuseIdentifier) super.init(style: style, reuseIdentifier: reuseIdentifier)
} }
public required init?(coder aDecoder: NSCoder) { public required init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented") fatalError("init(coder:) has not been implemented")
} }
//----------------------------------------------------- //-----------------------------------------------------
// MARK: - View Lifecycle // MARK: - View Lifecycle
//----------------------------------------------------- //-----------------------------------------------------
override open func setupView() { override open func setupView() {
super.setupView() super.setupView()
addMolecule(stack) addMolecule(stack)
} }
open override func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?){ open override func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?){
super.set(with: model, delegateObject, additionalData) super.set(with: model, delegateObject, additionalData)
guard let model = model as? ListOneColumnFullWidthTextBodyTextModel else { return } guard let model = model as? ListOneColumnFullWidthTextBodyTextModel else { return }
headlineBody.set(with: model.headlineBody, delegateObject, additionalData) headlineBody.set(with: model.headlineBody, delegateObject, additionalData)
stack.restack() stack.restack()
}
}
open override class func estimatedHeight(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? { open override class func estimatedHeight(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? {
return 90 return 90
} }
} }

View File

@ -11,16 +11,22 @@ import Foundation
public class ListOneColumnFullWidthTextBodyTextModel: ListItemModel, MoleculeModelProtocol { public class ListOneColumnFullWidthTextBodyTextModel: ListItemModel, MoleculeModelProtocol {
public static var identifier: String = "list1CFWBdy" public static var identifier: String = "list1CFWBdy"
public var headlineBody: HeadlineBodyModel public var headlineBody: HeadlineBodyModel
public init(headlineBody: HeadlineBodyModel) { public init(headlineBody: HeadlineBodyModel) {
self.headlineBody = headlineBody self.headlineBody = headlineBody
super.init() super.init()
setDefaults()
}
// Defaults to set
override public func setDefaults() {
super.setDefaults()
headlineBody.style = "item"
} }
private enum CodingKeys: String, CodingKey { private enum CodingKeys: String, CodingKey {
case moleculeName case moleculeName
case headlineBody case headlineBody
} }
required public init(from decoder: Decoder) throws { required public init(from decoder: Decoder) throws {
@ -34,6 +40,5 @@ public class ListOneColumnFullWidthTextBodyTextModel: ListItemModel, MoleculeMod
var container = encoder.container(keyedBy: CodingKeys.self) var container = encoder.container(keyedBy: CodingKeys.self)
try container.encode(moleculeName, forKey: .moleculeName) try container.encode(moleculeName, forKey: .moleculeName)
try container.encode(headlineBody, forKey: .headlineBody) try container.encode(headlineBody, forKey: .headlineBody)
} }
} }