#pragma once

#include "display/ui/components/steps_strip.h"
#include "display/ui/home/home_model.h"

#include "lvgl.h"

#include <array>
#include <cstddef>
#include <cstdint>
#include <vector>

namespace hwdisplay::ui {

// LVGL-only rendering. Created and updated exclusively on the display thread.
class HomeView {
public:
    bool Create(lv_obj_t* parent);
    void Render(const HomeModel& model);
    void SetFaceFrameBuffer(uint8_t* pixels, size_t bytes);
    void ShowFaceFrame(const uint8_t* bgra, size_t bytes);
    void Destroy();

    static constexpr int kFaceWidth = 280;
    static constexpr int kFaceHeight = 188;
    static constexpr size_t kFaceBytes = kFaceWidth * kFaceHeight * 4;

private:
    lv_obj_t* root_ = nullptr;
    lv_obj_t* status_ = nullptr;
    lv_obj_t* cue_ = nullptr;
    lv_obj_t* face_canvas_ = nullptr;
    lv_obj_t* face_hint_ = nullptr;
    lv_obj_t* face_guide_ = nullptr;
    lv_obj_t* face_result_box_ = nullptr;
    lv_obj_t* face_result_icon_ = nullptr;
    lv_obj_t* face_result_main_ = nullptr;
    lv_obj_t* face_result_detail_ = nullptr;
    std::array<lv_point_precise_t, 49> guide_points_{};
    std::vector<uint8_t> own_face_buffer_;
    uint8_t* external_face_buffer_ = nullptr;
    size_t external_face_bytes_ = 0;
    components::StepsStrip steps_;
};

}  // namespace hwdisplay::ui
