Files
liu weikai 8ebc1b67ac Improve chat history and Wi-Fi runtime UX
Add paged chat conversation storage and presentation, preserve MQTT ingress labels, and improve conversation bubble alignment/contrast.

Introduce a unified TopBar power presenter with debounced battery status updates.

Expand Wi-Fi runtime profile handling, settings backup coverage, and Reticulum directory support.
2026-07-10 13:52:00 +08:00

64 lines
1.6 KiB
C++

/**
* @file top_bar.h
* @brief Shared top bar widget (back button + centered title + right status)
*/
#pragma once
#include "lvgl.h"
#include <cstdint>
namespace ui
{
namespace widgets
{
struct TopBarConfig
{
lv_obj_t* back_btn_override = nullptr; // Use existing back button (keeps its style)
lv_obj_t* title_label_override = nullptr; // Use existing title label if provided
bool create_back = true; // Create new back button when no override
bool power_indicator = true; // Presenter owns right label as battery/status power slot
lv_coord_t height = 0; // 0 = use current page profile height
};
struct TopBar
{
lv_obj_t* container = nullptr;
lv_obj_t* back_btn = nullptr;
lv_obj_t* title_label = nullptr;
lv_obj_t* right_label = nullptr;
void (*back_cb)(void*) = nullptr;
void* back_user_data = nullptr;
};
constexpr uint16_t kTopBarHeight = 30;
/**
* @brief Initialize a top bar on the given parent
*/
void top_bar_init(TopBar& bar, lv_obj_t* parent, const TopBarConfig& config = {});
/**
* @brief Update title text (center label)
*/
void top_bar_set_title(TopBar& bar, const char* title);
/**
* @brief Update right-side text (status/battery/etc)
*/
void top_bar_set_right_text(TopBar& bar, const char* text);
/**
* @brief Update right-side text using the top bar chrome font directly
*/
void top_bar_set_right_text_ascii(TopBar& bar, const char* text);
/**
* @brief Set back button callback
*/
void top_bar_set_back_callback(TopBar& bar, void (*cb)(void*), void* user_data);
} // namespace widgets
} // namespace ui