Updated layout

This commit is contained in:
2026-07-15 20:11:25 +02:00
parent 9ef47f7483
commit e5086439a1
3 changed files with 28 additions and 40 deletions
+4 -11
View File
@@ -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<String> {
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<String> {
vec![
Property("Feed", format!("{:?}", self.feed)),
+22 -21
View File
@@ -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<Vec<ActivePosition>>,
logs: State<Vec<EventLog>>,
signals: State<Vec<Signal>>,
account: State<Account>,
system: State<System>,
market_overview: State<MarketOverview>,
status: State<Status>,
}
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(),
+2 -8
View File
@@ -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,