Ken Van Hoeylandt 5880e841a3
Implemented Files app (#33)
- Created Files app to browse PC and ESP32 files.
- Refactored toolbars so it's now a proper widget and allows for changing its properties from the app
- Toolbar now has extra action buttons
- Settings app now has a proper icon
- Minor cleanup in Desktop app
2024-02-06 23:18:34 +01:00

43 lines
1.3 KiB
C

#include "app_manifest_registry.h"
#include "check.h"
#include "lvgl.h"
#include "services/loader/loader.h"
static void on_app_pressed(lv_event_t* e) {
lv_event_code_t code = lv_event_get_code(e);
if (code == LV_EVENT_CLICKED) {
const AppManifest* manifest = lv_event_get_user_data(e);
loader_start_app(manifest->id, false, NULL);
}
}
static void create_app_widget(const AppManifest* manifest, void* parent) {
tt_check(parent);
lv_obj_t* list = (lv_obj_t*)parent;
const char* icon = manifest->icon ?: LV_SYMBOL_FILE;
lv_obj_t* btn = lv_list_add_btn(list, icon, manifest->name);
lv_obj_add_event_cb(btn, &on_app_pressed, LV_EVENT_CLICKED, (void*)manifest);
}
static void desktop_show(TT_UNUSED App app, TT_UNUSED lv_obj_t* parent) {
lv_obj_t* list = lv_list_create(parent);
lv_obj_set_size(list, LV_PCT(100), LV_PCT(100));
lv_obj_center(list);
lv_list_add_text(list, "System");
tt_app_manifest_registry_for_each_of_type(AppTypeSystem, list, create_app_widget);
lv_list_add_text(list, "User");
tt_app_manifest_registry_for_each_of_type(AppTypeUser, list, create_app_widget);
}
const AppManifest desktop_app = {
.id = "desktop",
.name = "Desktop",
.icon = NULL,
.type = AppTypeDesktop,
.on_start = NULL,
.on_stop = NULL,
.on_show = &desktop_show,
.on_hide = NULL
};