import Panel from "../views/Panel";
export default class ToastPanel extends Panel {
    public msgLb:eui.Label;
    public bgRect:eui.Rect;

    private mdata:any;
    public get skinKey() { return 'ToastPanel' }

    start(data) {
        this.mdata = data;
        this.percentHeight = 100;

    }

    onSkinComplete() {
        super.onSkinComplete();
        this.pMask.visible = false;
        this.showAct();
        
        this.once(egret.Event.ADDED_TO_STAGE, this.onLoad, this);
        if (this.stage) {
            this.onLoad();
        }
    }

    initEvents() {
        super.initEvents();
    }

    removeEvents() {
        super.removeEvents();
    }

    private ontap_this():void{

    }

    private onLoad():void{
  
        console.log("pMask",this.pMask);
        if(this.mdata && this.mdata.msg == "Not Login"){
            this.hidePanel();
            return;
        }
        if(this.mdata){
            this.msgLb.text = this.mdata.msg;
            this.bgRect.width = this.msgLb.width+80;
            this.bgRect.height = this.msgLb.height+40;
        }
        
        setTimeout(function(){
            egret.Tween.get(this).to({alpha:0}, 500, egret.Ease.quintOut).call(function(){
                this.onTouchTap();
            }.bind(this));
        }.bind(this), 3000);
        
    }

}