
import Panel from "../views/Panel";
import PanelCtrl from "../ctrls/panelCtrl";
import { DataManager } from "../../libs/tw/manager/DataManager";
import SceneCtrl from "../ctrls/sceneCtrl";
import { ModuleTypes } from "../types/sceneTypes";
import { Buried } from "../../libs/tw/util/Buried";
import { NetManager } from "../../libs/tw/manager/NetManager";
import Loading from "../loading/Loading";

export default class IosNoLoginPanel extends Panel {

    public okBtn:eui.Button;//取消按钮
    public closeBtn:eui.Button;//确定按钮
    
    //public titileLab:eui.Label;//标题
    //public contentLab:eui.Label;//内容

    public pupGroup:eui.Group;
    public clickGroup:eui.Group;
    private mData:any;

    public bg:eui.Image;
    private bgTexture:egret.Texture;
    public get skinKey() { return 'IosNoLoginPanel' }
    public get groupName() { return 'noIos_panel' }
    
    constructor(data?){
        super(data);
        this.mData = data;
    }

    protected async preLoadRes() {
        this.bgTexture = await RES.getResAsync('noIos_jpg');
        return new Promise(function (resolve, reject) {
            resolve();
        });
    }
    onSkinComplete():void{
        super.onSkinComplete();
        this.bg.texture =  this.bgTexture;
        this.once(egret.Event.ADDED_TO_STAGE,this.onLoad,this);
		if(this.stage){
			this.onLoad();
        }
        this.showAct();
    }

    start():void{
        this.percentHeight = 100;
        
    }
    private onLoad():void{
        //this.pMask.alpha = 0;
        this.init();
    }   
    private init(){
        
        // if(this.mData && this.mData.title){
        //     this.titileLab.text = this.mData.title;
        // }
        // if(this.mData && this.mData.content){
        //     this.contentLab.text = this.mData.content;
        // }
    }
    initEvents():void{
        super.initEvents();
        this.closeBtn.addEventListener(egret.TouchEvent.TOUCH_TAP, this.onTap_ok, this);
        this.okBtn.addEventListener(egret.TouchEvent.TOUCH_TAP, this.onTap_ok, this);
       
    }

    removeEvents():void{
        super.removeEvents();
        this.okBtn.removeEventListener(egret.TouchEvent.TOUCH_TAP, this.onTap_ok, this);
        this.closeBtn.removeEventListener(egret.TouchEvent.TOUCH_TAP, this.onTap_ok, this);
       
    }

    onTap_ok(e:egret.TouchEvent){
        this.pupGroup.visible = false;
        this.pMask.alpha = 0;
        setTimeout(() => {
            this.clickGroup.addEventListener(egret.TouchEvent.TOUCH_TAP, this.onTap_openPup, this);
        }, 300);
       
    }
    onTap_openPup(){
        this.clickGroup.removeEventListener(egret.TouchEvent.TOUCH_TAP, this.onTap_openPup, this);
        this.pupGroup.visible = true;
        this.pMask.alpha = 1;
    }
}