import { _decorator, Component, Node } from 'cc';
import { base_ui } from '../fw/base_ui';
import { userDataManager } from '../manager/userDataManager';
const { ccclass, property } = _decorator;

@ccclass('restart_view')
export class restart_view extends base_ui {
    @property(Node) btn_close:Node = null
    @property(Node) btn_look_video:Node = null
    @property(Node) btn_share:Node = null
    private m_look_video_cb = null
    private m_share_cb = null
    start() {
        this.onButtonListen(this.btn_close, ()=>{
            this.close()
        })
        this.onButtonListen(this.btn_look_video, ()=>{
            if(this.m_look_video_cb){
                this.m_look_video_cb(this)
            }
        })
        this.onButtonListen(this.btn_share, ()=>{
            if(this.m_share_cb) {
                this.m_share_cb(this)
            }
        })
    }

    public closeSelf() {
        this.close()
    }

    initView(look_video_cb,share_cb) {
        this.m_look_video_cb = look_video_cb
        this.m_share_cb = share_cb
        if(userDataManager.isTodayCanShare()) {
            this.btn_share.active = true
        } else {
            this.btn_share.active = false
            this.btn_look_video.setPosition(0, this.btn_look_video.getPosition().y)
        }
    }
}

