Sort apps on Desktop and Settings (#87)
- Sort apps by name - Make manifest IDs consistent - Updated screenshots - Renamed Screenshot app so it always renders at the bottom of the app list
This commit is contained in:
committed by
GitHub
parent
caa8756998
commit
76c14a5f47
@@ -2,6 +2,7 @@
|
||||
#include "Assets.h"
|
||||
#include "Check.h"
|
||||
#include "lvgl.h"
|
||||
#include <algorithm>
|
||||
#include "Services/Loader/Loader.h"
|
||||
|
||||
namespace tt::app::desktop {
|
||||
@@ -27,14 +28,26 @@ static void desktop_show(TT_UNUSED App app, lv_obj_t* parent) {
|
||||
lv_obj_set_size(list, LV_PCT(100), LV_PCT(100));
|
||||
lv_obj_center(list);
|
||||
|
||||
auto manifests = app_manifest_registry_get();
|
||||
std::sort(manifests.begin(), manifests.end(), SortAppManifestByName);
|
||||
|
||||
lv_list_add_text(list, "User");
|
||||
app_manifest_registry_for_each_of_type(AppTypeUser, list, create_app_widget);
|
||||
for (const auto& manifest: manifests) {
|
||||
if (manifest->type == AppTypeUser) {
|
||||
create_app_widget(manifest, list);
|
||||
}
|
||||
}
|
||||
|
||||
lv_list_add_text(list, "System");
|
||||
app_manifest_registry_for_each_of_type(AppTypeSystem, list, create_app_widget);
|
||||
for (const auto& manifest: manifests) {
|
||||
if (manifest->type == AppTypeSystem) {
|
||||
create_app_widget(manifest, list);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
extern const AppManifest manifest = {
|
||||
.id = "desktop",
|
||||
.id = "Desktop",
|
||||
.name = "Desktop",
|
||||
.type = AppTypeDesktop,
|
||||
.on_show = &desktop_show,
|
||||
|
||||
@@ -121,7 +121,7 @@ static void app_hide(TT_UNUSED App app) {
|
||||
}
|
||||
|
||||
extern const AppManifest manifest = {
|
||||
.id = "display",
|
||||
.id = "Display",
|
||||
.name = "Display",
|
||||
.icon = TT_ASSETS_APP_ICON_DISPLAY_SETTINGS,
|
||||
.type = AppTypeSettings,
|
||||
|
||||
@@ -222,7 +222,7 @@ static void on_stop(App app) {
|
||||
// endregion Lifecycle
|
||||
|
||||
extern const AppManifest manifest = {
|
||||
.id = "files",
|
||||
.id = "Files",
|
||||
.name = "Files",
|
||||
.icon = TT_ASSETS_APP_ICON_FILES,
|
||||
.type = AppTypeSystem,
|
||||
|
||||
@@ -201,7 +201,7 @@ static void on_stop(App app) {
|
||||
// endregion App lifecycle
|
||||
|
||||
extern const AppManifest manifest = {
|
||||
.id = "gpio",
|
||||
.id = "Gpio",
|
||||
.name = "GPIO",
|
||||
.type = AppTypeSystem,
|
||||
.on_start = &on_start,
|
||||
|
||||
@@ -110,7 +110,7 @@ static void app_stop(App app) {
|
||||
}
|
||||
|
||||
extern const AppManifest manifest = {
|
||||
.id = "power",
|
||||
.id = "Power",
|
||||
.name = "Power",
|
||||
.icon = TT_ASSETS_APP_ICON_POWER_SETTINGS,
|
||||
.type = AppTypeSettings,
|
||||
|
||||
@@ -18,8 +18,8 @@ static void on_stop(App app) {
|
||||
}
|
||||
|
||||
extern const AppManifest manifest = {
|
||||
.id = "screenshot",
|
||||
.name = "Screenshot",
|
||||
.id = "Screenshot",
|
||||
.name = "_Screenshot", // So it gets put at the bottom of the desktop and becomes less visible on small screen devices
|
||||
.icon = LV_SYMBOL_IMAGE,
|
||||
.type = AppTypeSystem,
|
||||
.on_start = &on_start,
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
#include "AppManifestRegistry.h"
|
||||
#include "Assets.h"
|
||||
#include "Check.h"
|
||||
#include "lvgl.h"
|
||||
#include "Services/Loader/Loader.h"
|
||||
#include "Ui/Toolbar.h"
|
||||
#include "lvgl.h"
|
||||
#include <algorithm>
|
||||
|
||||
namespace tt::app::settings {
|
||||
|
||||
@@ -32,11 +33,17 @@ static void on_show(App app, lv_obj_t* parent) {
|
||||
lv_obj_set_width(list, LV_PCT(100));
|
||||
lv_obj_set_flex_grow(list, 1);
|
||||
|
||||
app_manifest_registry_for_each_of_type(AppTypeSettings, list, create_app_widget);
|
||||
auto manifests = app_manifest_registry_get();
|
||||
std::sort(manifests.begin(), manifests.end(), SortAppManifestByName);
|
||||
for (const auto& manifest: manifests) {
|
||||
if (manifest->type == AppTypeSettings) {
|
||||
create_app_widget(manifest, list);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
extern const AppManifest manifest = {
|
||||
.id = "settings",
|
||||
.id = "Settings",
|
||||
.name = "Settings",
|
||||
.icon = TT_ASSETS_APP_ICON_SETTINGS,
|
||||
.type = AppTypeSystem,
|
||||
|
||||
@@ -102,7 +102,7 @@ static void on_show(App app, lv_obj_t* parent) {
|
||||
}
|
||||
|
||||
extern const AppManifest manifest = {
|
||||
.id = "systeminfo",
|
||||
.id = "SystemInfo",
|
||||
.name = "System Info",
|
||||
.icon = TT_ASSETS_APP_ICON_SYSTEM_INFO,
|
||||
.type = AppTypeSystem,
|
||||
|
||||
@@ -133,7 +133,7 @@ static void app_stop(App app) {
|
||||
}
|
||||
|
||||
extern const AppManifest manifest = {
|
||||
.id = "wifi_connect",
|
||||
.id = "WifiConnect",
|
||||
.name = "Wi-Fi Connect",
|
||||
.icon = LV_SYMBOL_WIFI,
|
||||
.type = AppTypeSettings,
|
||||
|
||||
@@ -26,7 +26,7 @@ static void on_connect(const char* ssid) {
|
||||
Bundle bundle;
|
||||
bundle.putString(WIFI_CONNECT_PARAM_SSID, ssid);
|
||||
bundle.putString(WIFI_CONNECT_PARAM_PASSWORD, "");
|
||||
service::loader::start_app("wifi_connect", false, bundle);
|
||||
service::loader::start_app("WifiConnect", false, bundle);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user