#include "lvgl.h"
#include "img_def.h"
#include "lv_common_function.h"

#if 0
#define     IMG_DISTANCE_L        img_A_002
#define     IMG_CALORIE_L         img_A_001
#define     IMG_STEP_L            img_A_003
#define     IMG_DISTANCE_H        img_A_006
#define     IMG_CALORIE_H         img_A_004
#define     IMG_STEP_H            img_A_005

#define     LV_FONT_BIG           LV_FONT_DEFAULT
#define     LV_FONT_MEDIUM        &arialuni_field_bbp2_32px
#define     LV_FONT_SMALL         LV_FONT_DEFAULT

#define     LV_FONT_NUMBER_BIG    &HarmonyOS_number_50px


LV_FONT_DECLARE(HarmonyOS_number_50px);
LV_FONT_DECLARE(arialuni_field_bbp2_32px);


static lv_obj_t *create_exercise_info_list(lv_obj_t *parent,uint32_t value,lv_img_src_t *img_src,uint8_t *title,lv_color_t color,uint8_t *unit)
{
    lv_obj_t *obj_cont = lv_obj_create(parent);
    lv_obj_remove_style_all(obj_cont);
    // lv_obj_set_scrollbar_mode(obj_cont, LV_SCROLLBAR_MODE_OFF);
    lv_obj_set_size(obj_cont,LV_PCT(100),100);

    lv_obj_t *obj_img = lv_img_create(obj_cont);
    lv_img_set_src(obj_img,img_src);
    lv_obj_align(obj_img,LV_ALIGN_LEFT_MID,18,0);

    lv_obj_t *title_label = lv_label_create(obj_cont);
    lv_obj_set_style_text_font(title_label,LV_FONT_BIG,0);
    lv_obj_set_style_text_color(title_label,color,0);
    lv_label_set_text(title_label,title);
    lv_obj_align(title_label,LV_ALIGN_TOP_LEFT,109,5);

    lv_obj_t *value_label = lv_label_create(obj_cont);
    lv_obj_set_style_text_font(value_label,LV_FONT_NUMBER_BIG,0);
    lv_label_set_text_fmt(value_label,"%d",value);
    lv_obj_align(value_label,LV_ALIGN_BOTTOM_LEFT,102,-5);

    lv_obj_t *unit_label = lv_label_create(obj_cont);
    lv_label_set_text(unit_label,unit);
    // lv_obj_align(unit_label,LV_ALIGN_BOTTOM_RIGHT,-30,0);
    lv_obj_align_to(unit_label,value_label,LV_ALIGN_OUT_RIGHT_BOTTOM,10,5);
    return obj_cont;
}

bool btn_flag;
static void btn_event_cb(lv_event_t *e)
{
    lv_obj_t *obj_img = lv_event_get_user_data(e);
    if(btn_flag)
        lv_img_set_src(obj_img,IMG_STEP_H);
    else
        lv_img_set_src(obj_img,IMG_CALORIE_H);
    btn_flag = !btn_flag;
}

void fr_lv_app_exercise_func(lv_obj_t *parent, lv_point_t *top)
{
    UI_PARENT_INIT(parent);
    if(!lv_obj_is_valid(parent))
        return;

    lv_obj_t *obj_img = lv_img_create(parent);
    lv_img_set_src(obj_img,IMG_DISTANCE_H);
    lv_obj_align(obj_img,LV_ALIGN_TOP_MID,0,18);

    lv_obj_t *btn = lv_btn_create(parent);
    lv_obj_set_size(btn,90,90);
    lv_obj_add_event_cb(btn,btn_event_cb,LV_EVENT_CLICKED,obj_img);

    lv_obj_t *label = lv_label_create(parent);
    lv_obj_set_width(label,203);
    lv_label_set_long_mode(label,LV_LABEL_LONG_SCROLL);
    lv_obj_set_style_text_font(label,LV_FONT_MEDIUM,0);
    lv_label_set_text_fmt(label,"%s",lan_str_table[STR_ID_FOCUS_BREATHING][1]);
    lv_obj_center(label);

    #if 0
    //-------------------------------------------
    lv_obj_t *label1 = lv_label_create(parent);
    lv_obj_align(label1,LV_ALIGN_TOP_LEFT,28,19);
    lv_obj_set_width(label1,203);
    lv_label_set_long_mode(label1,LV_LABEL_LONG_SCROLL);
    lv_label_set_text(label1,"Daily exercise");

    lv_obj_t *label2 = lv_label_create(parent);
    lv_obj_align(label2,LV_ALIGN_TOP_LEFT,260,20);
    lv_label_set_text_fmt(label2,"%02d:%02d",10,9);

    //bigest
    lv_obj_t *arc = lv_arc_create(parent);
    lv_obj_set_size(arc,328,328);
    lv_arc_set_rotation(arc, 270);
    lv_arc_set_bg_angles(arc, 0, 360);
    lv_arc_set_value(arc,50);
    lv_obj_remove_style(arc, NULL, LV_PART_KNOB);
    lv_obj_clear_flag(arc, LV_OBJ_FLAG_CLICKABLE);
    lv_obj_set_pos(arc,20,91);
    // lv_obj_set_style_arc_color(arc,lv_color_darken(lv_color_make(0x31,0x07,0x12),LV_OPA_70),0);
    lv_obj_set_style_arc_color(arc,lv_color_make(0x31,0x07,0x12),0);
    lv_obj_set_style_arc_color(arc,lv_color_make(0xf6,0x23,0x5c),LV_PART_INDICATOR);
    lv_obj_set_style_arc_width(arc,28,LV_PART_MAIN);
    lv_obj_set_style_arc_width(arc,28,LV_PART_INDICATOR);
    lv_obj_t *img =  lv_img_create(parent);
    lv_img_set_src(img,IMG_CALORIE_L);
    lv_obj_set_pos(img,175,95);

    arc = lv_arc_create(parent);
    lv_obj_set_size(arc,244,244);
    lv_arc_set_rotation(arc, 270);
    lv_arc_set_bg_angles(arc, 0, 360);
    lv_arc_set_value(arc,50);
    lv_obj_remove_style(arc, NULL, LV_PART_KNOB);
    lv_obj_clear_flag(arc, LV_OBJ_FLAG_CLICKABLE);
    lv_obj_set_pos(arc,62,134);
    lv_obj_set_style_arc_color(arc,lv_color_make(0x23,0x33,0x03),0);
    lv_obj_set_style_arc_color(arc,lv_color_make(0xaf,0xff,0x10),LV_PART_INDICATOR);
    lv_obj_set_style_arc_width(arc,28,LV_PART_MAIN);
    lv_obj_set_style_arc_width(arc,28,LV_PART_INDICATOR);
    img =  lv_img_create(parent);
    lv_img_set_src(img,IMG_STEP_L);
    lv_obj_set_pos(img,175,138);

    arc = lv_arc_create(parent);
    lv_obj_set_size(arc,156,156);
    lv_arc_set_rotation(arc, 270);
    lv_arc_set_bg_angles(arc, 0, 360);
    lv_arc_set_value(arc,50);
    lv_obj_remove_style(arc, NULL, LV_PART_KNOB);
    lv_obj_clear_flag(arc, LV_OBJ_FLAG_CLICKABLE);
    lv_obj_set_pos(arc,106,179);
    lv_obj_set_style_arc_color(arc,lv_color_make(0x03,0x2f,0x31),0);
    lv_obj_set_style_arc_color(arc,lv_color_make(0x11,0xeb,0xf7),LV_PART_INDICATOR);
    lv_obj_set_style_arc_width(arc,28,LV_PART_MAIN);
    lv_obj_set_style_arc_width(arc,28,LV_PART_INDICATOR);
    img =  lv_img_create(parent);
    lv_img_set_src(img,IMG_DISTANCE_L);
    lv_obj_set_pos(img,175,183);

    //---------------------------------------------------------------------
    lv_color_t title_color = lv_color_make(0xf6,0x23,0x5c);
    lv_obj_t *calories_obj = create_exercise_info_list(parent,10349,IMG_CALORIE_H,"Calories",title_color,"kcal");
    lv_obj_set_pos(calories_obj,0,499);

    title_color = lv_color_make(0xaf,0xff,0x10);
    lv_obj_t *step_obj = create_exercise_info_list(parent,10549,IMG_STEP_H,"Steps",title_color,"steps");
    lv_obj_set_pos(step_obj,0,657);

    title_color = lv_color_make(0x11,0xeb,0xf7);
    lv_obj_t *distance_obj = create_exercise_info_list(parent,10149,IMG_DISTANCE_H,"Distance",title_color,"km");
    lv_obj_set_pos(distance_obj,0,820);
    //---------------------------------------------------------------------
    #endif


}


#endif
