import { _decorator, Button, Component, Node } from 'cc';
import { UtilsPanel } from '../scene/script/UtilsPanel';
import { Config, nav_info } from '../scene/script/NavInfo';
import { Utils } from '../scene/script/Utils';
const { ccclass, property } = _decorator;

@ccclass('Share')
export class Share extends Component {
	private node_go: Node = null;
	// private node_go1: Node = null;

    protected onLoad(){
		UtilsPanel.getAllNeedCom(this, this.node, true);
        UtilsPanel.addBtnEvent(this.node_go, this.onGoClick, this);
        // UtilsPanel.addBtnEvent(this.node_go1, this.onGoClick, this).transition = Button.Transition.NONE;
	}
    
    private onGoClick(){
        let str = Config.copy_prefix + "pddshare&" + nav_info.user_id;
        Utils.copyToZone(str, this, this.onCopy);
	}
    public onCopy(succ:boolean){
        if(succ){
            console.log("copy succ")
            nav_info.scene.showTip(" تم نسخها إلى الحافظة ");
            Utils.tryStartApp();
        }
        else{
            // nav_info.scene.showTip("copy fail");
        }
    }

}


