//
//  VKBookingViewController.swift
//  Em-call
//
//  Created by Alex Sh on 14.02.2022.
//

import UIKit

class VKBookingViewController: UIViewController,UITableViewDataSource, UITableViewDelegate {

    @IBOutlet weak var emergency: UILabel!
    @IBOutlet weak var worker: UILabel!
    @IBOutlet weak var workLocation: UILabel!
    @IBOutlet weak var date_time: UILabel!
    @IBOutlet weak var cost: UILabel!
    @IBOutlet weak var costType: UILabel!
    
    @IBOutlet weak var tableViewWork: UITableView!
    @IBOutlet weak var segmentControl: UISegmentedControl!
    let cellReuseIdentifier = "cell"
    
    override func viewDidLoad() {
        super.viewDidLoad()
        self.navigationItem.title = "BOOKING"
        segmentControl.addTarget(self, action: #selector(segmentAction(_:)), for: .valueChanged)
        self.tableViewWork.register(UITableViewCell.self, forCellReuseIdentifier: cellReuseIdentifier)
        tableViewWork.rowHeight = 60

        tableViewWork.delegate = self
        tableViewWork.dataSource = self
        tableViewWork.isHidden = true
        // self.title = "Booking"
    }
    
    override func viewWillAppear(_ animated: Bool) {
        self.navigationController?.navigationBar.topItem?.title = "BOOKING"
        self.navigationController?.navigationItem.title = "BOOKING"
        self.navigationController?.navigationBar.titleTextAttributes = [.foregroundColor : UIColor.black]
        self.navigationController?.navigationBar.barTintColor = UIColor.white
    }
    
    @objc func segmentAction(_ segmentedControl: UISegmentedControl) {
            switch (segmentedControl.selectedSegmentIndex) {
            case 0:
                tableViewWork.isHidden = true
                workLocation.text = "22 Dorlan ave, Manchester"
                date_time.text = "As soon as possible"
                cost.text = "100"
                costType.text = "Approximate price"
                break // Uno
            case 1:
                tableViewWork.isHidden = false
                workLocation.text = "22 Dorlan ave"
                date_time.text = "18 feb, 18:00"
                cost.text = "200"
                costType.text = "Total price"
            
                break // Dos
 
            default:
                break
            }
        }
    func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        return 2
    }
    
    func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        let cell = tableView.dequeueReusableCell(withIdentifier: cellReuseIdentifier, for: indexPath)
       // let track = trackList[indexPath.row]
      /*  var content = cell.defaultContentConfiguration()
        content.text = "Work"
        content.secondaryText = "___________"
        cell.contentConfiguration = content
        */
        cell.textLabel?.text        = "Work"
         cell.detailTextLabel?.text  = "___________"
        cell.accessoryType = UITableViewCell.AccessoryType.disclosureIndicator
 
        return cell
    }
    /*
    // MARK: - Navigation

    // In a storyboard-based application, you will often want to do a little preparation before navigation
    override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
        // Get the new view controller using segue.destination.
        // Pass the selected object to the new view controller.
    }
    */

}
