// Learn TypeScript:
//  - https://docs.cocos.com/creator/manual/en/scripting/typescript.html
// Learn Attribute:
//  - https://docs.cocos.com/creator/manual/en/scripting/reference/attributes.html
// Learn life-cycle callbacks:
//  - https://docs.cocos.com/creator/manual/en/scripting/life-cycle-callbacks.html

const {ccclass, property} = cc._decorator;

@ccclass
export default class LoadingView extends cc.Component {

    @property(cc.ProgressBar)
    pregressBar: cc.ProgressBar = null;

    @property(cc.Label)
    label: cc.Label = null;

    // LIFE-CYCLE CALLBACKS:

    onLoad () {
        LoadingView.instance=this;
    }

    start () {
        this.label.string="";
    }
    // update (dt) {}

    /**
     * 更新进度
     * @param progress 
     */
    UpdateProgress(progress:number):void{
        this.pregressBar.progress=progress;
    }

    /**
     * 更新文本
     * @param label
     */
    UpdateLabel(label:string):void{
        this.label.string=label;
    }

    Show():void{
        this.node.active=true;
    }

    Hide():void{
        this.node.active=false;
    }
    
    private static instance:LoadingView;
    public static get single(){
        return this.instance;
    }
}
