#pragma once

#include "Widget.hpp"

class ButtonWidget : public Widget {
public:
    explicit ButtonWidget(const WidgetConfig& config);
    ~ButtonWidget() override;

    lv_obj_t* create(lv_obj_t* parent) override;
    void applyStyle() override;
    void onKnxSwitch(bool value) override;
    bool evaluateConditions(float primaryValue, float secondaryValue, float tertiaryValue) override;

    // Check if button is in checked state
    bool isChecked() const;

private:
    lv_obj_t* contentContainer_ = nullptr;
    lv_obj_t* label_ = nullptr;
    lv_obj_t* iconLabel_ = nullptr;
    lv_obj_t* shadowObj_ = nullptr;  // Fake shadow rectangle behind button

    void setupFlexLayout();
    void applyTextAlignment();
    void createFakeShadow(lv_obj_t* parent);
    void applyFakeShadowStyle();
    void updateIcon(uint32_t codepoint);
    static int encodeUtf8(uint32_t codepoint, char* buf);
    static void clickCallback(lv_event_t* e);
};
