import UIKit import GeneralUtils class VCChonMucChup: UIViewController, IVCLoadDataTableViewUIThread { @IBOutlet weak var topMargin: NSLayoutConstraint! @IBOutlet weak var tableView: UITableViewLoadDataFromUIThread! @IBOutlet weak var vTopLogo: VTopLogo! static func getInstance() -> VCChonMucChup { let storyboard: UIStoryboard = UIStoryboard(name: "Main", bundle: nil) let vcOpen = storyboard.instantiateViewController(withIdentifier: "VCChonMucChup") as! VCChonMucChup return vcOpen } override func viewDidLoad() { super.viewDidLoad() vTopLogo.leftBtnClick = { self.btnLeftClick(self.vTopLogo) } tableView.emptyText = "Empty" CellChonMucChup.registerClass(tableView: tableView, forCellReuseIdentifier: "CellChonMucChup") self.tableView.separatorStyle = UITableViewCellSeparatorStyle.singleLine 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(VCConfirmMucDaChon.getInstance()) } @IBAction func btnLeftClick(_ sender: Any) { _ = getVcRoot()?.changeCurrentController(VCNhapMucChup.getInstance()) } //region ============== TableView Data ========= func loadDataOnUI(complete: @escaping ([Any]?) -> ()) { complete(getVcRoot()?.mucChups) } func getAllCell() -> [BaseCell] { var baseCells: [BaseCell] = [BaseCell](); baseCells.append(BaseCell(type: 0, identifier: "CellChonMucChup")) return baseCells } func getTypeOfData(baseobj: Any) -> Int { return 0 } func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { if let mucChup = self.tableView.getItem(indexPath) as? ShootItem { if mucChup.willShoot == 1 { mucChup.willShoot = nil } else { mucChup.willShoot = 1 } self.tableView.reloadRows(at: [indexPath], with: .none) } } //endregion func getVcRoot() -> VCRootCreateNew? { return self.parent as? VCRootCreateNew } }