VCConfirmMucDaChon.swift 2.36 KB
import UIKit
import GeneralUtils

class VCConfirmMucDaChon: UIViewController, IVCLoadDataTableViewUIThread {
    @IBOutlet weak var topMargin: NSLayoutConstraint!
    @IBOutlet weak var tableView: UITableViewLoadDataFromUIThread!
    @IBOutlet weak var vTopLogo: VTopLogo!

    static func getInstance() -> VCConfirmMucDaChon {
        let storyboard: UIStoryboard = UIStoryboard(name: "Main", bundle: nil)
        let vcOpen = storyboard.instantiateViewController(withIdentifier: "VCConfirmMucDaChon") as! VCConfirmMucDaChon
        return vcOpen
    }

    override func viewDidLoad() {
        super.viewDidLoad()
        vTopLogo.leftBtnClick = {
            self.btnLeftClick(self.vTopLogo)
        }
        tableView.emptyText = LocalizedString("list_empty")
        CellMucChupWithCamera.registerClass(tableView: tableView, forCellReuseIdentifier: "CellMucChupWithCamera")
        self.tableView.separatorStyle = UITableViewCellSeparatorStyle.singleLine
        self.tableView.allowsSelection = false
        self.tableView.rowHeight = UITableViewAutomaticDimension
        self.tableView.estimatedRowHeight = 150
    }

    override func viewWillAppear(_ animated: Bool) {
        super.viewWillAppear(animated)
        tableView.initAndLoadData(self)
    }

    @IBAction func btnRightClick(_ sender: Any) {
        _ = getVcRoot()?.changeCurrentController(VCSettingBienQC.getInstance())
    }

    @IBAction func btnLeftClick(_ sender: Any) {
        _ = getVcRoot()?.changeCurrentController(VCChonMucChup.getInstance())
    }

    //region ============== TableView Data =========

    func loadDataOnUI(complete: @escaping ([Any]?) -> ()) {
        if let list = getVcRoot()?.mucChups {
            var mucChups = [ShootItem]()
            for item in list {
                if item.willShoot == 1 { mucChups.append(item) }
            }
            complete(mucChups)
        } else {
            complete(nil)
        }
    }

    func getAllCell() -> [BaseCell] {
        var baseCells: [BaseCell] = [BaseCell]();
        baseCells.append(BaseCell(type: 0, identifier: "CellMucChupWithCamera"))
        return baseCells
    }

    func getTypeOfData(baseobj: Any) -> Int {
        return 0
    }

    func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
    }

    //endregion

    func getVcRoot() -> VCRootCreateNew? {
        return self.parent as? VCRootCreateNew
    }
}