//
//  YourItemListVC.swift
//  OrderPicky
//
//  Created by ANGEL FS on 12/02/22.
//

import UIKit

class YourItemListVC: UIViewController {

    @IBOutlet weak var orderDetailTable: UITableView!
    @IBOutlet weak var deliverToView: UIView!
    @IBOutlet weak var searchBar: UISearchBar!
    
    override func viewDidLoad() {
        super.viewDidLoad()

        self.viewLoadingProperties()
    }
    
    @IBAction func backBtnTapped(_ sender: Any) {
        self.navigationController?.popViewController(animated: true)
    }
    
    @IBAction func proceedBtnTapped(_ sender: Any) {
        let nextVC = self.storyboard?.instantiateViewController(withIdentifier: "yourOrder")as! YourOrderVC
        self.navigationController?.pushViewController(nextVC, animated: true)
    }
    

}

extension YourItemListVC
{
    func viewLoadingProperties()
    {
        self.orderDetailTable.register(UINib(nibName: "OrderDetailTVC", bundle: nil), forCellReuseIdentifier: "orderDetail")
        self.deliverToView.dropShadow()
        self.searchBar.barTintColor = UIColor.white
        self.searchBar.setBackgroundImage(UIImage.init(), for: UIBarPosition.any, barMetrics: UIBarMetrics.default)
        self.searchBar.dropShadow()
    }
}

extension YourItemListVC : UITableViewDelegate , UITableViewDataSource
{
    func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        return 5
    }
    
    func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        let cell = tableView.dequeueReusableCell(withIdentifier: "orderDetail")as! OrderDetailTVC
        if indexPath.row == 4
        {
            cell.addItemView.isHidden = false
        }
        else
        {
            cell.addItemView.isHidden = true
        }
        return cell
    }
    
    func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
        return 75
    }
    
}
