#include <Widget/Label/Label.hpp>
#include <Widget/Layout/Column/Column.hpp>
#include <Widget/Layout/CompoundWidget/ListView/ListView.hpp>
#include <Widget/Layout/CompoundWidget/WorldStatsTab/WorldStatsTab.hpp>
#include <Widget/Layout/Row/Row.hpp>
#include <Widget/Layout/ScrollPanel/ScrollPanel.hpp>
#include <Widget/Panel/Panel.hpp>

WorldStatsTab::WorldStatsTab(World &world)
{
    std::vector<Widget*> rows;

    World::StatList stats;
    world.getWorldStats(stats);

    for (const auto& [label, widget] : stats)
    {
        rows.push_back(
            new Row(
                new Label(label),
                Layout::WithProportion<1>(),
                new Panel(),
                widget
            )
        );
    }

    addChildren(
        new ScrollPanel(
            100,
            new Column(
                new ListView(rows)
            )
        )
    );
}