
import AppFacade from "./AppFacade";
import ViewMgr from "./Manager/ViewMgr";
import View from "./BaseView/View";
import IController from "./Interface/IController";


//controller操作数据model和view

export default class Controller implements IController{
    protected constructor(){}
    protected static _inst=null
    public static get Inst():Controller{
        if(this._inst==null){
            this._inst=new Controller()
        }
        return this._inst
    }
    public async init() {}
    public release() {}

    // public async getView(viewName:string,type:typeof View){
    //     let view=AppFacade.getMgr(ViewMgr).openView(viewName,type)
    //     if(!view.IsStartLoad){
    //         await view.loadViewClone(cc.find("Canvas/"+viewName),false);
    //     }
    // }

    public async getView(viewName:string,type:typeof View){
        let view=AppFacade.getMgr(ViewMgr).openView(viewName,type)
        if(!view.IsStartLoad){
            await view.loadViewClone(cc.find("Canvas/"+viewName),false);
        }
        // await view.updateData()
        // view.open()
        return view;
    }    

    // public async getView(viewName:string,type:typeof View,resName:string){
    //     let view=AppFacade.getMgr(ViewMgr).openView(viewName,type)
    //     if(!view.IsStartLoad){
    //         await view.loadViewAsync(ResConst.PrefabsABName,resName)
    //     }
    //     // await view.updateData()
    //     // view.open()
    //     return view;
    // }
}