72 lines
2.0 KiB
C++
72 lines
2.0 KiB
C++
#pragma once
|
|
|
|
#include "ui/ui_app.h"
|
|
#include "ui/app_registry.h"
|
|
#include "ui/page_stack.h"
|
|
#include "external/mtr/mtr.h"
|
|
#include "external/mtr/line_info.h"
|
|
#include "external/mtr/station_info.h"
|
|
#include "network/network.h"
|
|
#include <memory>
|
|
#include <string>
|
|
|
|
/**
|
|
* @brief MTR Next Train application
|
|
*
|
|
* Provides multi-page navigation for:
|
|
* 1. Line selection - choose MTR line
|
|
* 2. Station selection - choose station within selected line
|
|
* 3. Arrival display - show real-time train arrival information
|
|
*/
|
|
class MtrApp : public UIApp {
|
|
public:
|
|
MtrApp();
|
|
virtual ~MtrApp() = default;
|
|
|
|
esp_err_t init(lv_obj_t* container) override;
|
|
esp_err_t deinit(void) override;
|
|
std::string get_name(void) const override;
|
|
bool on_back_button_pressed(void) override;
|
|
void handle_event(uint32_t event_type, void* event_data) override;
|
|
|
|
// Set network handler (must be called before using app)
|
|
void set_network_handler(NetworkHandler* handler) { _network_handler = handler; }
|
|
|
|
private:
|
|
std::unique_ptr<MTRNextTrainHandler> _mtr_handler;
|
|
std::unique_ptr<PageStack> _page_stack;
|
|
NetworkHandler* _network_handler = nullptr;
|
|
|
|
// Current selection state
|
|
std::string _selected_line_code;
|
|
std::string _selected_station_code;
|
|
LineInfo* _selected_line_info = nullptr;
|
|
std::vector<LineInfo> _all_lines;
|
|
|
|
// Page builders
|
|
void build_line_selection_page(lv_obj_t* page_container);
|
|
void build_station_selection_page(lv_obj_t* page_container);
|
|
void build_arrival_page(lv_obj_t* page_container);
|
|
|
|
// Event handlers
|
|
static void line_button_event_cb(lv_event_t* e);
|
|
static void station_button_event_cb(lv_event_t* e);
|
|
static void refresh_button_event_cb(lv_event_t* e);
|
|
|
|
// Helper functions
|
|
void load_arrival_data(lv_obj_t* page_container);
|
|
uint32_t parse_color_hex(const char* hex_str);
|
|
};
|
|
|
|
/**
|
|
* @brief AppDescriptor for MtrApp
|
|
*/
|
|
class MtrAppDescriptor : public AppDescriptor {
|
|
public:
|
|
MtrAppDescriptor();
|
|
void draw_icon(lv_obj_t* parent) override;
|
|
|
|
private:
|
|
static MtrApp* _app_instance;
|
|
};
|