implement data model binding
This commit is contained in:
98
src/data_models.h
Normal file
98
src/data_models.h
Normal file
@@ -0,0 +1,98 @@
|
||||
#pragma once
|
||||
|
||||
#include <RmlUi/Core.h>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
// Settings data model
|
||||
struct SettingsData {
|
||||
bool wifi = true;
|
||||
bool bluetooth = false;
|
||||
bool airplane_mode = false;
|
||||
bool location = true;
|
||||
bool dark_mode = true;
|
||||
bool notifications = true;
|
||||
bool do_not_disturb = false;
|
||||
|
||||
// User profile
|
||||
Rml::String user_name = "User Name";
|
||||
Rml::String user_email = "user@example.com";
|
||||
|
||||
// Device info
|
||||
Rml::String wifi_network = "Home_Network";
|
||||
int battery_percent = 85;
|
||||
Rml::String battery_remaining = "About 12h remaining";
|
||||
Rml::String storage_used = "45.2 GB used of 128 GB";
|
||||
};
|
||||
|
||||
// Phone state data model
|
||||
struct PhoneData {
|
||||
Rml::String dial_number = "";
|
||||
bool is_calling = false;
|
||||
Rml::String call_contact = "";
|
||||
Rml::String call_duration = "00:00";
|
||||
};
|
||||
|
||||
// Messages data model
|
||||
struct Message {
|
||||
Rml::String from;
|
||||
Rml::String text;
|
||||
Rml::String time;
|
||||
};
|
||||
|
||||
struct Conversation {
|
||||
int id;
|
||||
Rml::String name;
|
||||
Rml::String color;
|
||||
Rml::String last_message;
|
||||
Rml::String time;
|
||||
int unread;
|
||||
std::vector<Message> messages;
|
||||
};
|
||||
|
||||
// Contact data model
|
||||
struct Contact {
|
||||
int id;
|
||||
Rml::String name;
|
||||
Rml::String phone;
|
||||
Rml::String email;
|
||||
Rml::String color;
|
||||
Rml::String initial;
|
||||
};
|
||||
|
||||
// Browser data model
|
||||
struct BrowserTab {
|
||||
Rml::String url;
|
||||
Rml::String title;
|
||||
bool is_loading;
|
||||
};
|
||||
|
||||
struct BrowserData {
|
||||
Rml::String current_url = "example.com";
|
||||
Rml::String page_title = "Example Domain";
|
||||
Rml::String page_content = "This domain is for use in illustrative examples.";
|
||||
std::vector<BrowserTab> tabs;
|
||||
int current_tab = 0;
|
||||
bool can_go_back = false;
|
||||
bool can_go_forward = false;
|
||||
};
|
||||
|
||||
// Global data instances
|
||||
extern SettingsData g_settings;
|
||||
extern PhoneData g_phone;
|
||||
extern BrowserData g_browser;
|
||||
extern std::vector<Conversation> g_conversations;
|
||||
extern std::vector<Contact> g_contacts;
|
||||
extern int g_selected_conversation;
|
||||
extern int g_selected_contact;
|
||||
|
||||
// Data model handles
|
||||
extern Rml::DataModelHandle g_settings_model;
|
||||
extern Rml::DataModelHandle g_phone_model;
|
||||
extern Rml::DataModelHandle g_messages_model;
|
||||
extern Rml::DataModelHandle g_contacts_model;
|
||||
extern Rml::DataModelHandle g_browser_model;
|
||||
|
||||
// Functions
|
||||
void initializeSampleData();
|
||||
void setupDataModels(Rml::Context* context);
|
||||
Reference in New Issue
Block a user