//
//  HeadersH2Buttons.swift
//  MVMCoreUI
//
//  Created by Lekshmi S on 10/03/20.
//  Copyright © 2020 Verizon Wireless. All rights reserved.
//

import Foundation


@objcMembers open class HeadersH2Buttons: HeaderView {
    //--------------------------------------------------
    // MARK: - Outlets
    //--------------------------------------------------
    
    public let headlineBody = HeadlineBody()
    public let buttons = TwoButtonView()
    public lazy var stack: Stack<StackModel> = {
        return Stack<StackModel>.createStack(with: [headlineBody, buttons], spacing: PaddingDefaultVerticalSpacing3)
      }()
    
    //-------------------------------------------------------
    // MARK: - Lifecycle
    //-------------------------------------------------------
    
    open override func setupView() {
        super.setupView()
        headlineBody.stylePageHeader()
        addMolecule(stack)
        stack.restack()
    }
    
    //----------------------------------------------------
    // MARK: - Molecule
    //------------------------------------------------------
    
    open override func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) {
        super.set(with: model, delegateObject, additionalData)
        
        guard let model = model as? HeadersH2ButtonsModel else { return }
        
        headlineBody.set(with: model.headlineBody, delegateObject, additionalData)
        buttons.set(with: model.buttons, delegateObject, additionalData)
    }
    
    open override class func estimatedHeight(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? {
        return 121
    }
    
    open override func reset() {
        super.reset()
        headlineBody.stylePageHeader()
    }
}
