#include "display/ui/components/preparation_cards.h"

#include "display/ui/components/primitives.h"
#include "display/ui/theme.h"

LV_FONT_DECLARE(lv_font_home_22)
LV_FONT_DECLARE(lv_font_home_32)
LV_IMAGE_DECLARE(hw_prep_wet_image);
LV_IMAGE_DECLARE(hw_prep_soap_image);

namespace hwdisplay::ui::components {
namespace {

void Card(lv_obj_t* parent, int x, uint32_t color, const char* number,
          const char* heading, const char* description, const lv_image_dsc_t* icon) {
    lv_obj_t* card = Box(parent, x, 173, 354, 244, color, 25);
    if (!card) return;
    lv_obj_set_style_bg_grad_color(card, lv_color_hex(theme::kWhite), 0);
    lv_obj_set_style_bg_grad_dir(card, LV_GRAD_DIR_VER, 0);
    lv_obj_set_style_shadow_color(card, lv_color_hex(0xB4DAD3), 0);
    lv_obj_set_style_shadow_opa(card, LV_OPA_20, 0);
    lv_obj_set_style_shadow_width(card, 18, 0);
    lv_obj_set_style_shadow_ofs_y(card, 7, 0);

    lv_obj_t* image = lv_image_create(card);
    if (image) {
        lv_obj_remove_flag(image, LV_OBJ_FLAG_CLICKABLE);
        lv_image_set_src(image, icon);
        lv_obj_set_pos(image, 174, 84);
    }
    Box(card, 22, 22, 30, 30, theme::kWhite, 11);
    Text(card, 30, 23, number, &lv_font_home_22, theme::kTeal);
    Text(card, 22, 64, heading, &lv_font_home_32, theme::kInk);
    Text(card, 22, 111, description, &lv_font_home_22, theme::kMuted);
}

}  // namespace

void RenderPreparationCards(lv_obj_t* parent) {
    if (!parent) return;
    Box(parent, 38, 82, 16, 3, 0x38C8AD, LV_RADIUS_CIRCLE);
    Text(parent, 62, 71, "洗手前，先做两件事", &lv_font_home_22, theme::kTeal);
    Text(parent, 38, 108, "准备好小手和洗手液", &lv_font_home_32, theme::kInk);

    Card(parent, 38, 0xE7F8FF, "1", "先湿湿手", "用清水打湿双手", &hw_prep_wet_image);
    Card(parent, 409, 0xE6FBF0, "2", "再取洗手液", "让小手有满满泡泡", &hw_prep_soap_image);

    Text(parent, 38, 435, "跟着画面做好准备", &lv_font_home_22, theme::kMuted);
    Box(parent, 635, 426, 127, 37, theme::kTealSoft, 19);
    Box(parent, 649, 441, 8, 8, 0x24B998, LV_RADIUS_CIRCLE);
    Text(parent, 666, 431, "即将开始", &lv_font_home_22, theme::kTeal);
}

}  // namespace hwdisplay::ui::components
