- Refactor `AppManifest`: add new fields and rename existing ones - Parse and validate the manifest from an app that is being installed. - Remove deprecated `scoped()` from `Lock` - Create `Tactility/Paths.h` - App loading at boot now properly parses the manifest files of external apps - Properly lock both source and destination locations during app install - Remove LVGL path variants from `AppPaths` and `ServicePaths` - Removed `xPath` base classes for apps and services. There's now `AppPaths` and `ServicePaths`. - Renamed app and service paths: "data" and "system" paths are now "user data" and "assets"
72 lines
2.3 KiB
C++
72 lines
2.3 KiB
C++
#include <Tactility/Assets.h>
|
|
#include <Tactility/app/AppManifest.h>
|
|
#include <Tactility/lvgl/Toolbar.h>
|
|
#include <Tactility/service/loader/Loader.h>
|
|
#include <Tactility/settings/Time.h>
|
|
|
|
#include <lvgl.h>
|
|
|
|
namespace tt::app::timedatesettings {
|
|
|
|
constexpr auto* TAG = "TimeDate";
|
|
|
|
extern const AppManifest manifest;
|
|
|
|
class TimeDateSettingsApp : public App {
|
|
|
|
Mutex mutex = Mutex(Mutex::Type::Recursive);
|
|
|
|
static void onTimeFormatChanged(lv_event_t* event) {
|
|
auto* widget = lv_event_get_target_obj(event);
|
|
bool show_24 = lv_obj_has_state(widget, LV_STATE_CHECKED);
|
|
settings::setTimeFormat24Hour(show_24);
|
|
}
|
|
|
|
public:
|
|
|
|
void onShow(AppContext& app, lv_obj_t* parent) override {
|
|
lv_obj_set_flex_flow(parent, LV_FLEX_FLOW_COLUMN);
|
|
lv_obj_set_style_pad_row(parent, 0, LV_STATE_DEFAULT);
|
|
|
|
lvgl::toolbar_create(parent, app);
|
|
|
|
auto* main_wrapper = lv_obj_create(parent);
|
|
lv_obj_set_flex_flow(main_wrapper, LV_FLEX_FLOW_COLUMN);
|
|
lv_obj_set_width(main_wrapper, LV_PCT(100));
|
|
lv_obj_set_flex_grow(main_wrapper, 1);
|
|
|
|
auto* time_format_wrapper = lv_obj_create(main_wrapper);
|
|
lv_obj_set_width(time_format_wrapper, LV_PCT(100));
|
|
lv_obj_set_height(time_format_wrapper, LV_SIZE_CONTENT);
|
|
lv_obj_set_style_pad_all(time_format_wrapper, 0, 0);
|
|
lv_obj_set_style_border_width(time_format_wrapper, 0, 0);
|
|
|
|
auto* time_24h_label = lv_label_create(time_format_wrapper);
|
|
lv_label_set_text(time_24h_label, "24-hour clock");
|
|
lv_obj_align(time_24h_label, LV_ALIGN_LEFT_MID, 0, 0);
|
|
|
|
auto* time_24h_switch = lv_switch_create(time_format_wrapper);
|
|
lv_obj_align(time_24h_switch, LV_ALIGN_RIGHT_MID, 0, 0);
|
|
lv_obj_add_event_cb(time_24h_switch, onTimeFormatChanged, LV_EVENT_VALUE_CHANGED, nullptr);
|
|
if (settings::isTimeFormat24Hour()) {
|
|
lv_obj_add_state(time_24h_switch, LV_STATE_CHECKED);
|
|
} else {
|
|
lv_obj_remove_state(time_24h_switch, LV_STATE_CHECKED);
|
|
}
|
|
}
|
|
};
|
|
|
|
extern const AppManifest manifest = {
|
|
.appId = "TimeDateSettings",
|
|
.appName = "Time & Date",
|
|
.appIcon = TT_ASSETS_APP_ICON_TIME_DATE_SETTINGS,
|
|
.appCategory = Category::Settings,
|
|
.createApp = create<TimeDateSettingsApp>
|
|
};
|
|
|
|
void start() {
|
|
service::loader::startApp(manifest.appId);
|
|
}
|
|
|
|
} // namespace
|