import { _decorator, Component, instantiate, Node, Prefab } from 'cc';
import { base_ui } from '../../fw/base_ui';
import { reward_tips_item } from './reward_tips_item';
import { mail_rewards_item_data } from '../../data';
const { ccclass, property } = _decorator;

@ccclass('reward_tips_view')
export class reward_tips_view extends base_ui {
    @property(Node) public_bg:Node = null
    @property(Node) list_content:Node = null
    @property(Prefab) reward_item:Prefab = null
    start() {
        this.onButtonListen(this.public_bg, ()=>{
            this.close()
        })
    }

    initView(data_list:mail_rewards_item_data[]) {
        this.list_content.removeAllChildren()
        for (let index = 0; index < data_list.length; index++) {
            const element = data_list[index];
            let item = instantiate(this.reward_item)
            item.parent = this.list_content
            item.getComponent(reward_tips_item).initView(element)
        }
    }
}

