VCListCtruong.swift 2.06 KB
import UIKit
import GeneralUtils

class VCListCtruong: UIViewController, IVCLoadDataTableViewUIThread {
    @IBOutlet weak var tableView: UITableViewLoadDataFromUIThread!
    @IBOutlet weak var vTopLogo: VTopLogo!

    static func openController(_ viewController: UIViewController) {
        let storyboard: UIStoryboard = UIStoryboard(name: "Main", bundle: nil)
        let vcOpen = storyboard.instantiateViewController(withIdentifier: "VCListCtruong") as! VCListCtruong
        viewController.present(vcOpen, animated: true, completion: nil)
    }

    override func viewDidLoad() {
        super.viewDidLoad()
        self.tableView.separatorStyle = UITableViewCellSeparatorStyle.none
        self.tableView.rowHeight = 95//UITableViewAutomaticDimension
        self.tableView.estimatedRowHeight = 95
        tableView.emptyText = LocalizedString("list_empty")
        tableView.initAndLoadData(self)
        vTopLogo.leftBtnClick = { self.dismiss(animated: true) }
    }
    override var prefersStatusBarHidden: Bool {
        return true
    }
    //region TableView ========
    func loadDataOnUI(complete: @escaping ([Any]?) -> ()) {
//        complete(AppUtils.getListCtruong())
        NetWorkUtils.excuteHttpGet(urlStr: Constants.PathManager.ROOT_SERVER + "api/regulations/get/" + getIDWork(), completeArray: { (result: [CongTruong]?, errorText: String?) in
            complete(result)
        })
    }

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

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

    func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
        if let cTruong = self.tableView.getItem(indexPath) as? CongTruong {
            VCShootItemList.openController(self, cTruong: cTruong, tableViewListCtruong: self.tableView)
        }
    }
    //endregion
    override open var supportedInterfaceOrientations: UIInterfaceOrientationMask {
        return UIInterfaceOrientationMask.portrait
    }
}