import { _decorator, Component, EditBox, Node, Toggle } from 'cc';
import { att_ani_data } from '../../../data/data';
import { tools } from '../../tools';
const { ccclass, property } = _decorator;

@ccclass('new_animation')
export class new_animation extends Component {
    @property(Node) btn_sure:Node = null;
    @property(Node) btn_cancel:Node = null; 
    @property(Node) eb_ani_name:Node = null;
    @property(Node) eb_ani_id:Node = null;
    private m_data:att_ani_data = null;
    private m_create_call = null;
    public initView(create_call){
        this.m_create_call =create_call;
        this.btn_sure.on(Node.EventType.TOUCH_END,()=>{
            if(this.eb_ani_name.getComponent(EditBox).string.length<=0){
                return tools.showToast("必须要填写动画名字")
            }
            this.m_data.ani_name = this.eb_ani_name.getComponent(EditBox).string;
            if(this.m_create_call !=null ){
                this.m_create_call(this.m_data)
            }
            this.node.active =false;
        })
        this.btn_cancel.on(Node.EventType.TOUCH_END,()=>{
            this.node.active = false;
        })
    }

    public show(ani_id:number,binding_widget_id:number){
        this.m_data = new att_ani_data;
        this.node.active = true;
        this.m_data.ani_name = this.eb_ani_name.getComponent(EditBox).string;
        this.m_data.ani_id = ani_id;
        this.eb_ani_id.getComponent(EditBox).placeholder = this.m_data.ani_id.toString()
        this.m_data.binding_widget_id = binding_widget_id;
    }
}


