Merge branch 'bugfix/view_init_model_method_fix' into 'develop'

View init model method fix

See merge request BPHV_MIPS/mvm_core_ui!608
This commit is contained in:
Pfeil, Scott Robert 2020-10-21 11:51:37 -04:00
commit 78ce6848b5
23 changed files with 71 additions and 323 deletions

View File

@ -74,23 +74,6 @@ import UIKit
private weak var widthConstraint: NSLayoutConstraint?
private weak var heightConstraint: NSLayoutConstraint?
//--------------------------------------------------
// MARK: - Initializers
//--------------------------------------------------
@objc public override init(frame: CGRect) {
super.init(frame: frame)
}
@objc public convenience init() {
self.init(frame: .zero)
}
@objc required public init?(coder: NSCoder) {
super.init(coder: coder)
fatalError("DigitBox does not support xibs.")
}
//--------------------------------------------------
// MARK: - Lifecycle
//--------------------------------------------------

View File

@ -79,18 +79,6 @@ open class Arrow: View {
widthConstraint?.isActive = true
}
//--------------------------------------------------
// MARK: - Initializers
//--------------------------------------------------
public override init(frame: CGRect) {
super.init(frame: frame)
}
public required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
//--------------------------------------------------
// MARK: - Lifecycle
//--------------------------------------------------

View File

@ -73,30 +73,6 @@
layoutIfNeeded()
}
//--------------------------------------------------
// MARK: - Initializers
//--------------------------------------------------
public override init(frame: CGRect) {
super.init(frame: frame)
setupView()
}
public convenience init() {
self.init(frame: .zero)
}
public convenience init(position: CheckboxPosition) {
self.init(frame: .zero)
alignCheckbox(position)
}
required public init?(coder: NSCoder) {
super.init(coder: coder)
fatalError("xib file is not implemented for CheckboxLabel")
}
//--------------------------------------------------
// MARK: - Methods
//--------------------------------------------------

View File

@ -24,22 +24,6 @@ open class DashLine: View {
@objc private var dashLayer: CAShapeLayer?
//------------------------------------------------------
// MARK: - Initializer
//------------------------------------------------------
public override init(frame: CGRect) {
super.init(frame: .zero)
}
public convenience init() {
self.init(frame: .zero)
}
required public init?(coder: NSCoder) {
super.init(coder: coder)
}
//------------------------------------------------------
// MARK: - Lifecycle
//------------------------------------------------------

View File

@ -46,22 +46,6 @@
rightTextLabelLeading?.isActive = false
}
//------------------------------------------------------
// MARK: - Initialization
//------------------------------------------------------
public convenience init() {
self.init(frame: .zero)
}
public override init(frame: CGRect) {
super.init(frame: frame)
}
required public init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
}
override open func setupView() {
super.setupView()

View File

@ -14,19 +14,9 @@ import Foundation
//--------------------------------------------------
public let headlineBody = HeadlineBody(frame: .zero)
public let buttons = TwoButtonView(frame: .zero)
public let stack: Stack<StackModel>
//-------------------------------------------------------
// MARK: - Initializers
//-------------------------------------------------------
public override init(frame: CGRect) {
stack = Stack<StackModel>.createStack(with: [headlineBody, buttons], spacing: Padding.Eighteen)
super.init(frame: frame)
}
public required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
public lazy var stack: Stack<StackModel> = {
return Stack<StackModel>.createStack(with: [headlineBody, buttons], spacing: Padding.Eighteen)
}()
//-------------------------------------------------------
// MARK: - View Lifecycle

View File

@ -16,20 +16,9 @@ import Foundation
public let headlineBody = HeadlineBody()
public let buttons = TwoButtonView()
public let stack: Stack<StackModel>
//-------------------------------------------------------
// MARK: - Initializers
//-------------------------------------------------------
public override init(frame: CGRect) {
stack = Stack<StackModel>.createStack(with: [headlineBody, buttons], spacing: PaddingDefaultVerticalSpacing3)
super.init(frame: frame)
}
public required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
public lazy var stack: Stack<StackModel> = {
return Stack<StackModel>.createStack(with: [headlineBody, buttons], spacing: PaddingDefaultVerticalSpacing3)
}()
//-------------------------------------------------------
// MARK: - Lifecycle

View File

@ -13,19 +13,9 @@ import Foundation
//--------------------------------------------------
public let headlineBody = HeadlineBody()
public let caretLink = CaretLink()
public let stack: Stack<StackModel>
//-------------------------------------------------------
// MARK: - Initializers
//-------------------------------------------------------
public override init(frame: CGRect) {
stack = Stack<StackModel>.createStack(with: [headlineBody, caretLink])
super.init(frame: frame)
}
public required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
public lazy var stack: Stack<StackModel> = {
return Stack<StackModel>.createStack(with: [headlineBody, caretLink])
}()
//-------------------------------------------------------
// MARK: - Lifecycle

View File

@ -14,19 +14,9 @@ import Foundation
//--------------------------------------------------
public let headlineBody = HeadlineBody()
public let link = Link()
public let stack: Stack<StackModel>
//-------------------------------------------------------
// MARK: - Initializers
//-------------------------------------------------------
public override init(frame: CGRect) {
stack = Stack<StackModel>.createStack(with: [headlineBody, link])
super.init(frame: frame)
}
public required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
public lazy var stack: Stack<StackModel> = {
return Stack<StackModel>.createStack(with: [headlineBody, link])
}()
//-------------------------------------------------------
// MARK: - Lifecycle

View File

@ -21,31 +21,26 @@ import Foundation
public let subBody3 = Label(fontStyle: .RegularMicro)
public let verticalLine1 = Line()
public let verticalLine2 = Line()
public let verticalStack1: Stack<StackModel>
public let verticalStack2: Stack<StackModel>
public let verticalStack3: Stack<StackModel>
public let horizontalStack: Stack<StackModel>
public let stack: Stack<StackModel>
//-------------------------------------------------------
// MARK: - Initializers
//-------------------------------------------------------
public override init(frame: CGRect) {
verticalStack1 = Stack<StackModel>.createStack(with: [body, subBody], spacing: 0)
verticalStack2 = Stack<StackModel>.createStack(with: [body2, subBody2], spacing: 0)
verticalStack3 = Stack<StackModel>.createStack(with: [body3, subBody3], spacing: 0)
horizontalStack = Stack<StackModel>.createStack(with: [(view: verticalStack1, model: StackItemModel(percent: 29, verticalAlignment: .top)), (view: verticalLine1, model: StackItemModel(verticalAlignment: .top)),
(view: verticalStack2, model: StackItemModel(horizontalAlignment: .leading, verticalAlignment: .top)),
(view: verticalLine2, model: StackItemModel(verticalAlignment: .top)),
(view: verticalStack3, model: StackItemModel(percent: 32, verticalAlignment: .top))],
axis: .horizontal)
stack = Stack<StackModel>.createStack(with: [headline, horizontalStack], spacing: 8)
super.init(frame: frame)
}
public required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
public lazy var verticalStack1: Stack<StackModel> = {
return Stack<StackModel>.createStack(with: [body, subBody], spacing: 0)
}()
public lazy var verticalStack2: Stack<StackModel> = {
return Stack<StackModel>.createStack(with: [body2, subBody2], spacing: 0)
}()
public lazy var verticalStack3: Stack<StackModel> = {
return Stack<StackModel>.createStack(with: [body3, subBody3], spacing: 0)
}()
public lazy var horizontalStack: Stack<StackModel> = {
return Stack<StackModel>.createStack(with: [(view: verticalStack1, model: StackItemModel(percent: 29, verticalAlignment: .top)),
(view: verticalLine1, model: StackItemModel(verticalAlignment: .top)),
(view: verticalStack2, model: StackItemModel(horizontalAlignment: .leading, verticalAlignment: .top)),
(view: verticalLine2, model: StackItemModel(verticalAlignment: .top)),
(view: verticalStack3, model: StackItemModel(percent: 32, verticalAlignment: .top))],
axis: .horizontal)
}()
public lazy var stack: Stack<StackModel> = {
return Stack<StackModel>.createStack(with: [headline, horizontalStack], spacing: 8)
}()
//-------------------------------------------------------
// MARK: - Lifecycle

View File

@ -16,22 +16,11 @@ import Foundation
public let headlineBody = HeadlineBody()
public let button = PillButton()
public let stack: Stack<StackModel>
//-------------------------------------------------------
// MARK: - Initializers
//-------------------------------------------------------
public override init(frame: CGRect) {
stack = Stack<StackModel>.createStack(with: [(view: headlineBody, model: StackItemModel(horizontalAlignment: .fill)),
(view: button, model: StackItemModel(spacing: spacingBetwenHeadlineBodyAndButton, horizontalAlignment: .leading))],
axis: .vertical)
super.init(frame: frame)
}
public required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
public lazy var stack: Stack<StackModel> = {
return Stack<StackModel>.createStack(with: [(view: headlineBody, model: StackItemModel(horizontalAlignment: .fill)),
(view: button, model: StackItemModel(spacing: spacingBetwenHeadlineBodyAndButton, horizontalAlignment: .leading))],
axis: .vertical)
}()
//------------------------------------------------------
// MARK: - Constants

View File

@ -15,21 +15,11 @@ import Foundation
public let headline = Label(fontStyle: .Title2XLarge)
public let subHeadline = Label(fontStyle: .RegularTitleLarge)
public let body = Label(fontStyle: .RegularBodySmall)
public let stack: Stack<StackModel>
//-------------------------------------------------------
// MARK: - Initializers
//-------------------------------------------------------
public override init(frame: CGRect) {
stack = Stack<StackModel>.createStack(with: [(view: headline, model: StackItemModel()),
(view: subHeadline, model: StackItemModel(spacing: 16)),
(view: body, model: StackItemModel(spacing: 8))])
super.init(frame: frame)
}
public required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
public lazy var stack: Stack<StackModel> = {
return Stack<StackModel>.createStack(with: [(view: headline, model: StackItemModel()),
(view: subHeadline, model: StackItemModel(spacing: 16)),
(view: body, model: StackItemModel(spacing: 8))])
}()
//-------------------------------------------------------
// MARK: - Lifecycle

View File

@ -16,26 +16,17 @@ import Foundation
public let headline = Label(fontStyle: .BoldTitleLarge)
public let subHeadline = Label(fontStyle: .RegularTitleLarge)
public let body = Label(fontStyle: .RegularBodySmall)
public let verticalStack: Stack<StackModel>
public var stack: Stack<StackModel>
//-------------------------------------------------------
// MARK: - Initializers
//-------------------------------------------------------
public override init(frame: CGRect) {
verticalStack = Stack<StackModel>.createStack(with: [(view: headline, model: StackItemModel()),
(view: subHeadline, model: StackItemModel()),
(view: body, model: StackItemModel(horizontalAlignment: .fill))],
axis: .vertical, spacing: 0)
stack = Stack<StackModel>.createStack(with: [(view: planLabel, model: StackItemModel(horizontalAlignment: .fill, verticalAlignment: .leading)),
(view: verticalStack, model: StackItemModel(horizontalAlignment: .fill, verticalAlignment: .leading))],
axis: .horizontal)
super.init(frame: frame)
}
public required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
public lazy var verticalStack: Stack<StackModel> = {
return Stack<StackModel>.createStack(with: [(view: headline, model: StackItemModel()),
(view: subHeadline, model: StackItemModel()),
(view: body, model: StackItemModel(horizontalAlignment: .fill))],
axis: .vertical, spacing: 0)
}()
public lazy var stack: Stack<StackModel> = {
return Stack<StackModel>.createStack(with: [(view: planLabel, model: StackItemModel(horizontalAlignment: .fill, verticalAlignment: .leading)),
(view: verticalStack, model: StackItemModel(horizontalAlignment: .fill, verticalAlignment: .leading))],
axis: .horizontal)
}()
//-------------------------------------------------------
// MARK: - Lifecycle

View File

@ -49,22 +49,6 @@ open class DoughnutChart: View {
}
}
//--------------------------------------------------
// MARK: - Initializers
//--------------------------------------------------
public override init(frame: CGRect) {
super.init(frame: .zero)
}
public convenience init() {
self.init(frame: .zero)
}
public required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
//--------------------------------------------------
// MARK: - Lifecycle
//--------------------------------------------------

View File

@ -15,19 +15,6 @@ import UIKit
var delegateObject: MVMCoreUIDelegateObject?
let label = Label()
// MARK: - Inits
public init() {
super.init(frame: .zero)
}
public override init(frame: CGRect) {
super.init(frame: frame)
}
required public init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
}
public override func updateView(_ size: CGFloat) {
super.updateView(size)
radioButton.updateView(size)

View File

@ -23,22 +23,6 @@ import UIKit
private var equalWidthConstraint: NSLayoutConstraint?
//--------------------------------------------------
// MARK: - Initializers
//--------------------------------------------------
public init() {
super.init(frame: .zero)
}
required public init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
}
public override init(frame: CGRect) {
super.init(frame: frame)
}
//--------------------------------------------------
// MARK: - Lifecycle
//--------------------------------------------------

View File

@ -17,22 +17,6 @@ import Foundation
open var leftLink = Link()
open var rightLink = Link()
private var stack = UIStackView()
//--------------------------------------------------
// MARK: - Initializers
//--------------------------------------------------
public init() {
super.init(frame: .zero)
}
required public init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
}
public override init(frame: CGRect) {
super.init(frame: frame)
}
//--------------------------------------------------
// MARK: - MVMCoreViewProtocol

View File

@ -29,22 +29,6 @@ import UIKit
var imageLeadingConstraint: NSLayoutConstraint?
//------------------------------------------------------
// MARK: - Initialization
//------------------------------------------------------
public init() {
super.init(frame: .zero)
}
public override init(frame: CGRect) {
super.init(frame: frame)
}
required public init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
}
//------------------------------------------------------
// MARK: - View Lifecycle
//------------------------------------------------------

View File

@ -29,22 +29,6 @@ import UIKit
var buttonTopConstraint: NSLayoutConstraint?
//------------------------------------------------------
// MARK: - Initialization
//------------------------------------------------------
public convenience init() {
self.init(frame: .zero)
}
public override init(frame: CGRect) {
super.init(frame: frame)
}
required public init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
}
//------------------------------------------------------
// MARK: - View Lifecycle
//------------------------------------------------------

View File

@ -36,6 +36,13 @@ open class StringAndMoleculeView: View {
fatalError("init(coder:) has not been implemented")
}
public required init(model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?) {
let moleculeModel = model as? StringAndMoleculeModel
label.text = moleculeModel?.string
self.molecule = moleculeModel?.molecule as! MoleculeViewProtocol
super.init(model: model, delegateObject, additionalData)
}
override public func setupView() {
super.setupView()
guard subviews.count == 0 else {

View File

@ -20,22 +20,6 @@ open class ThreeHeadlineBodyLink: View {
public let body = Label(fontStyle: .RegularBodySmall)
public let link = Link()
//------------------------------------------------------
// MARK: - Initialization
//------------------------------------------------------
public convenience init() {
self.init(frame: .zero)
}
public override init(frame: CGRect) {
super.init(frame: frame)
}
required public init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
}
//------------------------------------------------------
// MARK: - Lifecycle
//------------------------------------------------------

View File

@ -113,6 +113,11 @@ open class Stack<T>: Container where T: (StackModelProtocol & MoleculeModelProto
fatalError("init(coder:) has not been implemented")
}
public required init(model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) {
super.init(frame: .zero)
set(with: model, delegateObject, additionalData)
}
/// Returns a Stack created with a StackModel and StackItems containing the passed in views.
public static func createStack(with views: [UIView], axis: NSLayoutConstraint.Axis? = nil, spacing: CGFloat? = nil) -> Stack<StackModel> {
var items: [StackItem] = []

View File

@ -43,6 +43,12 @@ import UIKit
}
}
public required init(model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) {
super.init(frame: .zero)
initialSetup()
set(with: model, delegateObject, additionalData)
}
//--------------------------------------------------
// MARK: - MoleculeViewProtocol
//--------------------------------------------------