//
//  LineViewController.swift
//  VDSSample
//
//  Created by Nadigadda, Sumanth on 24/03/23.
//

import Foundation
import VDS

class LineViewController: BaseViewController<Line> {
    
    let lineView = Line()
    
    lazy var lineStylePickerView = {
        PickerSelectorView(title: "primary",
                            picker: self.picker,
                           items: Line.Style.allCases)
    }()
    
    override func viewDidLoad() {
        super.viewDidLoad()
        
        addContentTopView(view: component)
        setupPicker()
    }
    
    override func setupForm() {
        super.setupForm()
        addFormRow(label: "Surface", view: surfacePickerSelectorView)
        addFormRow(label: "Style", view: lineStylePickerView)
    }
    
    func setupPicker() {
        surfacePickerSelectorView.onPickerDidSelect = { [weak self] item in
            self?.component.surface = item
            self?.contentTopView.backgroundColor = item.color
        }
        
        lineStylePickerView.onPickerDidSelect = { [weak self] item in
            self?.component.style = item
        }
    }
}
