// This file was generated by SquareLine Studio
// SquareLine Studio version: SquareLine Studio 1.6.0
// LVGL version: 8.3.11
// Project name: Lcd_Pro

#include "../ui.h"
#include "ui_ScreenSet.h"  // 引入ScreenSet的函数声明

extern void init_spiffs_image_list(void);
extern void update_ui_ImgBle(const char *img_name);
extern void free_spiffs_image_list(void);
extern const char* get_next_image(void);
extern const char* get_prev_image(void);

lv_obj_t *ui_ScreenImg = NULL;lv_obj_t *ui_ImgBle = NULL;
// event funtions
void ui_event_ScreenImg( lv_event_t * e) {
    lv_event_code_t event_code = lv_event_get_code(e);

if ( event_code == LV_EVENT_GESTURE &&  lv_indev_get_gesture_dir(lv_indev_get_act()) == LV_DIR_TOP  ) {
lv_indev_wait_release(lv_indev_get_act());
      _ui_screen_change( &ui_ScreenHome, LV_SCR_LOAD_ANIM_NONE, 0, 0, &ui_ScreenHome_screen_init);
}
if ( event_code == LV_EVENT_GESTURE &&  lv_indev_get_gesture_dir(lv_indev_get_act()) == LV_DIR_BOTTOM  ) {
lv_indev_wait_release(lv_indev_get_act());
      // 设置返回到Img界面
      ui_ScreenSet_set_previous(&ui_ScreenImg, &ui_ScreenImg_screen_init);
      _ui_screen_change( &ui_ScreenSet, LV_SCR_LOAD_ANIM_NONE, 0, 0, &ui_ScreenSet_screen_init);
}
if ( event_code == LV_EVENT_GESTURE &&  lv_indev_get_gesture_dir(lv_indev_get_act()) == LV_DIR_LEFT  ) {
lv_indev_wait_release(lv_indev_get_act());
      const char *next_img = get_next_image();
      if(next_img) {
          update_ui_ImgBle(next_img);
      }
}
if ( event_code == LV_EVENT_GESTURE &&  lv_indev_get_gesture_dir(lv_indev_get_act()) == LV_DIR_RIGHT  ) {
lv_indev_wait_release(lv_indev_get_act());
      const char *prev_img = get_prev_image();
      if(prev_img) {
          update_ui_ImgBle(prev_img);
      }
}
}

// build funtions

void ui_ScreenImg_screen_init(void)
{
ui_ScreenImg = lv_obj_create(NULL);
lv_obj_clear_flag( ui_ScreenImg, LV_OBJ_FLAG_SCROLLABLE );    /// Flags

ui_ImgBle = lv_img_create(ui_ScreenImg);
lv_img_set_src(ui_ImgBle, &ui_img_s1_png);
lv_obj_set_width( ui_ImgBle, 360);
lv_obj_set_height( ui_ImgBle, 360);
lv_obj_set_align( ui_ImgBle, LV_ALIGN_CENTER );
lv_obj_set_flex_flow(ui_ImgBle,LV_FLEX_FLOW_ROW);
lv_obj_set_flex_align(ui_ImgBle, LV_FLEX_ALIGN_START, LV_FLEX_ALIGN_START, LV_FLEX_ALIGN_START);
lv_obj_add_flag( ui_ImgBle, LV_OBJ_FLAG_ADV_HITTEST );   /// Flags
lv_obj_clear_flag( ui_ImgBle, LV_OBJ_FLAG_SCROLLABLE );    /// Flags

lv_obj_add_event_cb(ui_ScreenImg, ui_event_ScreenImg, LV_EVENT_ALL, NULL);

init_spiffs_image_list();
update_ui_ImgBle("default.jpg");
}

void ui_ScreenImg_screen_destroy(void)
{
   if (ui_ScreenImg) lv_obj_del(ui_ScreenImg);

// NULL screen variables
ui_ScreenImg= NULL;
ui_ImgBle= NULL;

free_spiffs_image_list();
}
