187 lines
No EOL
5.8 KiB
Text
187 lines
No EOL
5.8 KiB
Text
// Main Entry Point - Following Feature-Sliced Design
|
|
// This is the root file that main.rs imports
|
|
// Following the pattern from moonlogs: index -> app -> pages/widgets/entities/shared
|
|
|
|
import { App } from "app/index.slint";
|
|
import { Palette } from "std-widgets.slint";
|
|
import { NewTokenUiData, CexUpdatedUiData, MaxDepthReachedUiData } from "shared/types/token.slint";
|
|
|
|
export component MainWindow inherits Window {
|
|
// Window properties
|
|
preferred-width: 1280px;
|
|
preferred-height: 1024px;
|
|
min-width: 1080px;
|
|
min-height: 800px;
|
|
no-frame: true;
|
|
background: Palette.background;
|
|
|
|
// Theme state
|
|
in-out property <bool> is-dark-mode: true;
|
|
|
|
// Application state management
|
|
in-out property <string> app-state: "loading"; // "loading", "login", "authenticated"
|
|
in-out property <bool> is-authenticated: false;
|
|
in-out property <string> user-email: "";
|
|
in-out property <string> sidebar-state: "full"; // "full", "icon-only", or "hidden"
|
|
|
|
// Loading state
|
|
in-out property <bool> is-loading: true;
|
|
in-out property <bool> has-connection-error: false;
|
|
in-out property <string> loading-status: "Initializing your trading environment...";
|
|
|
|
// Navigation state
|
|
in-out property <string> current-page: "Dashboard";
|
|
in-out property <string> user-initials: "JD";
|
|
|
|
// Hunting ground properties - using correct types
|
|
in-out property <[NewTokenUiData]> new-tokens: [];
|
|
in-out property <[CexUpdatedUiData]> cex-tokens: [];
|
|
in-out property <[MaxDepthReachedUiData]> analysis-tokens: [];
|
|
in-out property <int> current-time: 0;
|
|
|
|
// Callbacks for application state
|
|
callback health-check-completed(bool); // true if healthy, false if error
|
|
callback retry-health-check();
|
|
callback login-attempt(string, string);
|
|
callback logout-requested();
|
|
callback authenticate-user(string);
|
|
|
|
// Callbacks for window controls
|
|
callback start-drag-window();
|
|
callback minimize-window();
|
|
callback maximize-window();
|
|
callback close-window();
|
|
callback theme-toggle-clicked();
|
|
|
|
// Callbacks for navigation
|
|
callback navigation-changed(string);
|
|
callback toggle-sidebar();
|
|
|
|
// Callbacks for hunting ground
|
|
callback refresh-hunting-ground();
|
|
callback clear-column(string);
|
|
|
|
// Other callbacks
|
|
callback logout-clicked();
|
|
callback buy-clicked();
|
|
callback sell-clicked();
|
|
callback clear-new-tokens();
|
|
callback clear-cex-tokens();
|
|
callback clear-analysis-tokens();
|
|
|
|
// Public function that can be called from Rust to toggle theme
|
|
public function toggle_theme() {
|
|
root.is-dark-mode = !root.is-dark-mode;
|
|
if (root.is-dark-mode) {
|
|
Palette.color-scheme = ColorScheme.dark;
|
|
} else {
|
|
Palette.color-scheme = ColorScheme.light;
|
|
}
|
|
debug("Theme toggled from Rust. New state: " + (root.is-dark-mode ? "dark" : "light"));
|
|
}
|
|
|
|
TouchArea {
|
|
width: 100%;
|
|
height: 100%;
|
|
moved => {
|
|
if (self.pressed) {
|
|
start-drag-window();
|
|
}
|
|
}
|
|
}
|
|
|
|
// App component handles all the UI following FSD layers
|
|
App {
|
|
width: 100%;
|
|
height: 100%;
|
|
|
|
// Theme state
|
|
is-dark-mode: root.is-dark-mode;
|
|
|
|
// Application state management
|
|
app-state: root.app-state;
|
|
is-authenticated: root.is-authenticated;
|
|
user-email: root.user-email;
|
|
sidebar-state: root.sidebar-state;
|
|
|
|
// Loading state
|
|
is-loading: root.is-loading;
|
|
has-connection-error: root.has-connection-error;
|
|
loading-status: root.loading-status;
|
|
|
|
// Navigation state
|
|
current-page: root.current-page;
|
|
user-initials: root.user-initials;
|
|
|
|
// Hunting ground properties
|
|
new-tokens: root.new-tokens;
|
|
cex-tokens: root.cex-tokens;
|
|
analysis-tokens: root.analysis-tokens;
|
|
current-time: root.current-time;
|
|
|
|
// Forward all callbacks to main.rs
|
|
health-check-completed(healthy) => {
|
|
root.health-check-completed(healthy);
|
|
}
|
|
retry-health-check => {
|
|
root.retry-health-check();
|
|
}
|
|
login-attempt(email, password) => {
|
|
root.login-attempt(email, password);
|
|
}
|
|
logout-requested => {
|
|
root.logout-requested();
|
|
}
|
|
authenticate-user(email) => {
|
|
root.authenticate-user(email);
|
|
}
|
|
navigation-changed(page) => {
|
|
root.current-page = page;
|
|
root.navigation-changed(page);
|
|
}
|
|
toggle-sidebar => {
|
|
if (root.sidebar-state == "full") {
|
|
root.sidebar-state = "icon-only";
|
|
} else {
|
|
root.sidebar-state = "full";
|
|
}
|
|
}
|
|
theme-toggle-clicked => {
|
|
root.toggle_theme();
|
|
}
|
|
logout-clicked => {
|
|
root.logout-clicked();
|
|
}
|
|
buy-clicked => {
|
|
root.buy-clicked();
|
|
}
|
|
sell-clicked => {
|
|
root.sell-clicked();
|
|
}
|
|
start-drag-window => {
|
|
root.start-drag-window();
|
|
}
|
|
minimize-window => {
|
|
root.minimize-window();
|
|
}
|
|
maximize-window => {
|
|
root.maximize-window();
|
|
}
|
|
close-window => {
|
|
root.close-window();
|
|
}
|
|
refresh-hunting-ground => {
|
|
root.refresh-hunting-ground();
|
|
}
|
|
clear-new-tokens => {
|
|
root.clear-new-tokens();
|
|
}
|
|
clear-cex-tokens => {
|
|
root.clear-cex-tokens();
|
|
}
|
|
clear-analysis-tokens => {
|
|
root.clear-analysis-tokens();
|
|
}
|
|
}
|
|
}
|
|
|