From e5086439a1e29e9e89bfd9b3528726301877cf3d Mon Sep 17 00:00:00 2001 From: Klesti Selimaj Date: Wed, 15 Jul 2026 20:11:25 +0200 Subject: [PATCH] Updated layout --- src/formatting.rs | 15 ++++----------- src/main.rs | 43 ++++++++++++++++++++++--------------------- src/types.rs | 10 ++-------- 3 files changed, 28 insertions(+), 40 deletions(-) diff --git a/src/formatting.rs b/src/formatting.rs index 00b677d..db0936f 100644 --- a/src/formatting.rs +++ b/src/formatting.rs @@ -1,5 +1,5 @@ use crate::types::{ - Account, ActivePosition, EventLog, LogKind, Signal, SignalKind, System, WatchListItem, + ActivePosition, EventLog, LogKind, MarketOverview, Signal, SignalKind, Status, WatchListItem, }; pub trait Formatted { @@ -78,20 +78,13 @@ impl Formatted for ActivePosition { pub struct Property(&'static str, String); -impl Formatted for Account { +impl Formatted for MarketOverview { fn get_formatted(&self) -> Vec { - vec![ - Property("Equity", format_f64(self.equity)), - Property("Liquid", format_f64(self.liquid)), - Property("Unreal", format_f64(self.unreal)), - Property("Realized", format_f64(self.realized)), - Property("Margin", format_f64(self.margin)), - ] - .get_formatted() + vec![Property("Equity", format_f64(1.0))].get_formatted() } } -impl Formatted for System { +impl Formatted for Status { fn get_formatted(&self) -> Vec { vec![ Property("Feed", format!("{:?}", self.feed)), diff --git a/src/main.rs b/src/main.rs index 587c3d6..42bf9c3 100644 --- a/src/main.rs +++ b/src/main.rs @@ -5,14 +5,21 @@ use std::any::Any; use chrono::{Local, Utc}; use pulse_ui::{ - App, layout::{LayoutItem, layout}, state::{Refresh, State}, unit::Size, widget::{ - align::{Center, End}, input::{Input, InputState}, outline::{Outline, VLine}, spaced::SpacedColumns, + App, + layout::{LayoutItem, layout}, + state::{Refresh, State}, + unit::Size, + widget::{ + align::End, + input::{Input, InputState}, + outline::{Outline, VLine}, + spaced::SpacedColumns, }, }; use crate::{ formatting::{Formatted, apply_padding}, - types::{Account, ActivePosition, EventLog, Signal, System, WatchListItem}, + types::{ActivePosition, EventLog, MarketOverview, Signal, Status, WatchListItem}, }; pub struct PulseTradeApp { @@ -21,8 +28,8 @@ pub struct PulseTradeApp { active_positions: State>, logs: State>, signals: State>, - account: State, - system: State, + market_overview: State, + status: State, } impl App for PulseTradeApp { @@ -188,8 +195,8 @@ impl App for PulseTradeApp { ( LayoutItem::Widget(Size::Flex(1)), Box::new(format![ - " ACCOUNT\n{}", - apply_padding(self.account.lock().await.get_formatted()).join("\n") + " MARKET OVERVIEW\n{}", + apply_padding(self.market_overview.lock().await.get_formatted()).join("\n") ]), ), ]), @@ -198,10 +205,6 @@ impl App for PulseTradeApp { layout.draw( 4, SpacedColumns(vec![ - ( - LayoutItem::Widget(Size::Flex(1)), - Box::new(vec![" ACTIVE STRATEGIES"].join("\n")), - ), ( LayoutItem::Widget(Size::Flex(1)), Box::new(format!( @@ -209,11 +212,15 @@ impl App for PulseTradeApp { apply_padding(self.signals.lock().await.get_formatted()).join("\n") )), ), + ( + LayoutItem::Widget(Size::Flex(1)), + Box::new(vec![" INSPECTOR"].join("\n")), + ), ( LayoutItem::Widget(Size::Flex(1)), Box::new(format![ - " SYSTEM\n{}", - apply_padding(self.system.lock().await.get_formatted()).join("\n") + " STATUS\n{}", + apply_padding(self.status.lock().await.get_formatted()).join("\n") ]), ), ]), @@ -239,14 +246,8 @@ async fn main() { active_positions: ctx.use_state(Vec::new()), signals: ctx.use_state(Vec::new()), logs: ctx.use_state(Vec::new()), - account: ctx.use_state(Account { - equity: 25_483.21, - liquid: 11_928.43, - unreal: 483.12, - realized: 2_182.49, - margin: 0.0, - }), - system: ctx.use_state(System { + market_overview: ctx.use_state(MarketOverview {}), + status: ctx.use_state(Status { feed: types::Feed::Connected, exchange: "Binance".to_string(), dex: "DEX SCREENER".to_string(), diff --git a/src/types.rs b/src/types.rs index 758d400..27832d1 100644 --- a/src/types.rs +++ b/src/types.rs @@ -10,13 +10,7 @@ pub struct ActivePosition { pub amount: f64, } -pub struct Account { - pub equity: f64, - pub liquid: f64, - pub unreal: f64, - pub realized: f64, - pub margin: f64, -} +pub struct MarketOverview {} #[derive(Debug, Clone, Copy)] pub enum Feed { @@ -26,7 +20,7 @@ pub enum Feed { Failed, } -pub struct System { +pub struct Status { pub feed: Feed, pub exchange: String, pub dex: String,