import Panel from "../views/Panel";
import LineLayoutGroup from "../components/LayoutGroup";
import ListenMusicItem from "../item/ListenMusicItem";
import { DataManager } from "../../libs/tw/manager/DataManager";
import { NetName } from "../../libs/tw/enum/NetName";

export default class ListenMusicPanel extends Panel {
    public get skinKey() { return "ListenMusicPanel" }
    public get groupName() { return "listen_music_panel" }

    public scroller: eui.Scroller;
    public scrollerGroup: eui.Group;
    public list: eui.List;

    onSkinComplete() {
        super.onSkinComplete();
        this.list.itemRenderer = ListenMusicItem;
        let data2 = [];
       /*  for (let i = 0; i <= 1000; i++) {
            data2.push({
                musicName: i.toString(),
                singer: "杨丞琳",
                favorite: true
            });
        } */
        let lists=DataManager.ins.getData(NetName.FORFAVOR_KUWO).data;

        lists.forEach((list,i) => {
            data2.push({
                musicName: list.name,
                singer: list.artist,
                albumpic: list.albumpic,
                musicrid: list.musicrid,
                index:i,
                favorite: false
            });
        });
        this.list.dataProvider = new eui.ArrayCollection(data2);

        /* let list = new LineLayoutGroup();
        list.addChild(new ListenMusicItem({
            musicName: "缺氧",
            singer: "杨丞琳",
            favorite: true
        }));
        list.addChild(new ListenMusicItem({
            musicName: "缺氧",
            singer: "杨丞琳",
            favorite: false
        }));
        list.addChild(new ListenMusicItem({
            musicName: "缺氧",
            singer: "杨丞琳",
            favorite: true
        }));
        list.addChild(new ListenMusicItem({
            musicName: "缺氧4",
            singer: "杨丞琳",
            favorite: false
        }));
        list.addChild(new ListenMusicItem({
            musicName: "缺氧3",
            singer: "杨丞琳",
            favorite: false
        }));
        list.addChild(new ListenMusicItem({
            musicName: "缺氧2",
            singer: "杨丞琳",
            favorite: false
        }));
        list.addChild(new ListenMusicItem({
            musicName: "缺氧",
            singer: "杨丞琳",
            favorite: false
        }));
        list.addChild(new ListenMusicItem({
            musicName: "缺氧33",
            singer: "杨丞琳",
            favorite: true
        }));
        list.addChild(new ListenMusicItem({
            musicName: "缺氧dd",
            singer: "杨丞琳",
            favorite: false
        }));
        this.scroller.viewport = list;
        this.scroller.addChild(list); */
    }
}
