//
//  ListTwoColumnDropdownSelectors.swift
//  MVMCoreUI
//
//  Created by Kruthika KP on 27/04/20.
//  Copyright © 2020 Verizon Wireless. All rights reserved.
//


@objcMembers public class ListTwoColumnDropdownSelectors: TableViewCell {
    //-------------------------------------------------------
    // MARK: - Outlets
    //-------------------------------------------------------
    
    public let leftDropDown = ItemDropdownEntryField()
    public let rightDropDown = ItemDropdownEntryField()
    var stack: Stack<StackModel>
    
    //-------------------------------------------------------
    // MARK: - Initializers
    //-------------------------------------------------------
    
    public override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
        stack = Stack<StackModel>.createStack(with: [(view: leftDropDown, model: StackItemModel(percent: 50, horizontalAlignment: .fill)),
                                                     (view: rightDropDown, model: StackItemModel(percent: 50, horizontalAlignment: .fill))],
                                              axis: .horizontal, spacing: Padding.Component.gutterForApplicationWidth)
        super.init(style: style, reuseIdentifier: reuseIdentifier)
    }
    
    public required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    //-------------------------------------------------------
    // MARK: - Lifecycle
    //-------------------------------------------------------
    
    open override func setupView() {
        super.setupView()
        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? ListTwoColumnDropdownSelectorsModel else { return }
        
        leftDropDown.set(with:model.leftDropDown, delegateObject, additionalData)
        rightDropDown.set(with:model.rightDropDown, delegateObject, additionalData)
    }
    
    open override class func estimatedHeight(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? {
        return 121
    }
}
