import { _decorator, Component, Node, ProgressBarComponent, LabelComponent } from 'cc';
const { ccclass, property } = _decorator;

@ccclass('LoadingView')
export class LoadingView extends Component {
    @property(ProgressBarComponent)
    pregressBar:ProgressBarComponent = null;

    @property(LabelComponent)
    label: LabelComponent = 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;
    }
}
