#pragma once

#include "Widget.hpp"

class LabelWidget : public Widget {
public:
    explicit LabelWidget(const WidgetConfig& config);

    lv_obj_t* create(lv_obj_t* parent) override;
    void applyStyle() override;

    // KNX updates
    void onKnxValue(float value) override;
    void onKnxSwitch(bool value) override;
    void onKnxText(const char* text) override;
    void onKnxTime(const struct tm& value, TextSource source) override;

private:
    lv_obj_t* container_ = nullptr;
    lv_obj_t* textLabel_ = nullptr;
    lv_obj_t* iconLabel_ = nullptr;

    void setupFlexLayout();
    static int encodeUtf8(uint32_t codepoint, char* buf);
};
