import { _decorator, Component, instantiate, Node, Prefab, ScrollView } from 'cc';
import { config } from '../config';
import { widget_item } from './widget_item';
const { ccclass, property } = _decorator;

@ccclass('widget_list')
export class widget_list extends Component {
    @property(Prefab) item_prefab:Prefab = null;
    protected start(): void {
        this.initView()
    }
    public initView(){
        config.init()
        this.node.getComponent(ScrollView).content.removeAllChildren()
        config.Widget_Type.forEach((v,k)=>{
            let item:Node = instantiate(this.item_prefab)
            item.parent = this.node.getComponent(ScrollView).content
            item.getComponent(widget_item).initView(v)
        })
    }
}


