import { _decorator, Component, Node, Event } from "cc";

import { game } from "cc";
import { instantiate } from "cc";

import { Vec3 } from "cc";
import { Sprite } from "cc";
import BaseUI from "../../scripts/base/BaseUI";
import UIUtils from "../../scripts/base/UIUtils";
import { Hall } from "../hall/Hall";
const { ccclass, property } = _decorator;

@ccclass("GameDetailLayer")
export class GameDetailLayer extends BaseUI {
  static async show(gameId: number, sourceIcon: Node) {
    let layer = await Hall.ins.showLayer("prefab/layer/GameDetailLayer");
    layer.getComponent(GameDetailLayer).init(gameId, sourceIcon);
  }

  private gameId: number = 0;
  // private sourceNode: Node = null;
  init(gameId: number, sourceNode: Node) {
    this.gameId = gameId;
    // this.sourceNode = sourceNode;

    // let newIcon = instantiate(sourceNode);
    // newIcon.parent = this.sourceNode;
    // UIUtils.moveToNewParent(this.FindNode("icon_slot"), newIcon);
    // UIUtils.AnimBezierMoveAndScale(
    //   newIcon,
    //   new Vec3(0, 0, 0),
    //   0.3,
    //   0.3,
    //   () => {}
    // );
  }
  private close() {
    this.closePage();

    // let icon = this.FindNode("icon_slot").children[0];
    // UIUtils.moveToNewParent(this.sourceNode, icon);
    // this.node.active = false;
    // let self = this;
    // this.sourceNode.getComponent(Sprite).enabled = false;
    // UIUtils.AnimBezierMoveAndScale(icon, new Vec3(0, 0, 0), 0.8, 0.3, () => {
    //   icon.destroy();

    //   self.sourceNode.getComponent(Sprite).enabled = true;
    //   UIUtils.closeUI(self.node);
    // });
  }
  protected onBtnClick(name: string, event: Event, customEventData: any): void {
    if (name === "btn_close") {
      this.close();
    }
    //   super.onBtnClick(name, event, customEventData);
  }
}
