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

@ccclass('dialog_view')
export class dialog_view extends Component {
    @property(Node) btn_sure:Node = null;
    @property(Node) btn_cancel:Node = null;
    @property(Node) lab_title:Node = null;
    private m_sure_call = null;
    private m_cancel_call = null;
    public show(title:string,sure_call,cancel_call){
        this.m_sure_call = sure_call;
        this.m_cancel_call = cancel_call;
        this.lab_title.getComponent(Label).string = title;
        this.btn_sure.on(Node.EventType.TOUCH_END,()=>{
            if(this.m_sure_call!=null){
                this.m_sure_call()
            }
            this.close()

        })
        this.btn_cancel.on(Node.EventType.TOUCH_END,()=>{
            if(this.m_cancel_call!=null){
                this.m_cancel_call()
            }
            this.close()
        })
    }
    close(){
        this.node.removeFromParent()
    }
}


