#pragma once

#include "Widget.hpp"
#include <ctime>

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

    lv_obj_t* create(lv_obj_t* parent) override;
    void applyStyle() override;
    void onKnxTime(const struct tm& value, TextSource source) override;

private:
    void drawFace();
    void updateHands(const struct tm& time);

    lv_obj_t* hourHand_ = nullptr;
    lv_obj_t* minuteHand_ = nullptr;
    lv_obj_t* secondHand_ = nullptr;
    lv_obj_t* centerDot_ = nullptr;
    
    // Cache current time to avoid redrawing if not changed
    int lastHour_ = -1;
    int lastMinute_ = -1;
    int lastSecond_ = -1;
};
