#include <Widget/IconToggle/IconToggle.hpp>
#include <Widget/Layout/CompoundWidget/TemperatureScaleSelector/TemperatureScaleSelector.hpp>
#include <Widget/Layout/Row/Row.hpp>
#include <Settings/Settings.hpp>

TemperatureScaleSelector::TemperatureScaleSelector()
{
    auto onUpdated = []()
    {
        settings.save();
    };

    addChildren(
        new Row(
            (new IconToggle<TemperatureScale>(settings.preferredTemperatureScale, TemperatureScale::Celsius, Material::tempCelsius))
                ->withChangedCallback(onUpdated),
            (new IconToggle<TemperatureScale>(settings.preferredTemperatureScale, TemperatureScale::Fahrenheit, Material::tempFahrenheit))
                ->withChangedCallback(onUpdated),
            (new IconToggle<TemperatureScale>(settings.preferredTemperatureScale, TemperatureScale::Kelvin, Material::tempKelvin))
                ->withChangedCallback(onUpdated)
        )
    );
}