import { _decorator, Component, Label, Node, Sprite } from 'cc';
import { mail_rewards_item_data } from '../../data';
import { tools } from '../../tools';
const { ccclass, property } = _decorator;

@ccclass('mailbox_reward_item')
export class mailbox_reward_item extends Component {
    @property(Node) img_icon_mask:Node = null
    @property(Node) img_icon:Node = null
    @property(Node) lab_count:Node = null
    @property(Node) lab_name:Node = null

    private m_data:mail_rewards_item_data = null
    
    initView(data:mail_rewards_item_data, is_receive:boolean) {
        this.m_data = data
        tools.loadRemoteImg(data.icon, (d)=>{
            this.img_icon.getComponent(Sprite).spriteFrame = d.sf
        })
        this.lab_count.getComponent(Label).string = data.quantity + ''
        this.lab_name.getComponent(Label).string = data.name

        this.img_icon_mask.active = is_receive
    }

    public getData():mail_rewards_item_data {
        return this.m_data
    }
}

