feat(travel): Implement settings UI and web server for MTR route configuration
- Added MainUIHandler class to manage the main UI and polling for arrival data. - Introduced SettingsUI class for displaying QR code and configuration options. - Created SettingsUIHandler to manage settings UI lifecycle and web server interactions. - Developed WebHandler to handle HTTP requests for MTR route settings, including adding and removing routes. - Implemented web endpoints for fetching MTR lines, routes, and saving settings. - Enhanced UI with responsive design for e-ink displays and added error handling for web interactions.
This commit is contained in:
72
main/ui/apps/travel/app.h
Normal file
72
main/ui/apps/travel/app.h
Normal file
@@ -0,0 +1,72 @@
|
||||
#pragma once
|
||||
|
||||
#include "ui/apps/app.h"
|
||||
#include "ui/apps/travel/settings/settings_handler.h"
|
||||
#include "ui/apps/travel/ui/main_handler.h"
|
||||
#include "ui/apps/travel/ui/settings_handler.h"
|
||||
#include "io/nvs_handler.h"
|
||||
#include "network/network.h"
|
||||
#include <string>
|
||||
#include <memory>
|
||||
|
||||
// Forward declarations
|
||||
namespace travel {
|
||||
class MainUIHandler;
|
||||
class SettingsUIHandler;
|
||||
class SettingHandler;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Travel App - MTR Station Arrival Time Display
|
||||
*
|
||||
* Displays estimated arrival times for configured MTR routes.
|
||||
* Features:
|
||||
* - Support for all MTR lines from assets
|
||||
* - Save up to 5 (station, destination) route pairs
|
||||
* - Poll every 30 seconds (configurable 10-120s)
|
||||
* - Traditional Chinese by default
|
||||
* - E-ink optimized (no animations, static layout)
|
||||
* - Web-based configuration via QR code
|
||||
*/
|
||||
class TravelApp : public UIApp {
|
||||
public:
|
||||
TravelApp();
|
||||
~TravelApp() override;
|
||||
|
||||
esp_err_t init(lv_obj_t* container, InteractionHandler* interaction_handler) override;
|
||||
esp_err_t deinit(void) override;
|
||||
std::string get_name(void) const override;
|
||||
bool on_back_button_pressed(void) override;
|
||||
|
||||
// Set network handler for API calls
|
||||
void set_network_handler(NetworkHandler* network_handler);
|
||||
|
||||
private:
|
||||
// UI handlers
|
||||
std::unique_ptr<travel::MainUIHandler> main_ui_handler_;
|
||||
std::unique_ptr<travel::SettingsUIHandler> settings_ui_handler_;
|
||||
|
||||
// Current page tracking
|
||||
enum class Page {
|
||||
MAIN,
|
||||
SETTINGS
|
||||
};
|
||||
Page current_page_;
|
||||
|
||||
// Settings handler (shared across handlers)
|
||||
std::unique_ptr<travel::SettingHandler> setting_handler_;
|
||||
|
||||
// Network handler (not owned, set externally)
|
||||
NetworkHandler* network_handler_;
|
||||
|
||||
// Interaction handler (not owned)
|
||||
InteractionHandler* interaction_handler_;
|
||||
|
||||
static constexpr const char* NVS_NAMESPACE = "travel_app";
|
||||
|
||||
// Private methods
|
||||
void show_settings_page();
|
||||
|
||||
// UI callback forwarders
|
||||
static void on_settings_button_clicked_static(void* user_data);
|
||||
};
|
||||
Reference in New Issue
Block a user