Account status

This commit is contained in:
2026-07-15 10:23:51 +02:00
parent 42284ac748
commit 87b561693f
2 changed files with 36 additions and 19 deletions
+2 -2
View File
@@ -1,8 +1,8 @@
use crate::{unit::Rect, widget::Widget}; use crate::{unit::Rect, widget::Widget};
pub struct Dynamic(pub fn(Rect) -> Box<dyn Widget>); pub struct Dynamic<W: Widget>(pub fn(Rect) -> W);
impl Widget for Dynamic { impl<W: Widget> Widget for Dynamic<W> {
fn render(&self, scope: &mut crate::render::RenderScope) { fn render(&self, scope: &mut crate::render::RenderScope) {
(self.0)(scope.rect).render(scope); (self.0)(scope.rect).render(scope);
} }
+33 -16
View File
@@ -3,7 +3,7 @@ use std::any::Any;
use pulse_ui::{ use pulse_ui::{
App, App,
layout::{LayoutItem, layout}, layout::{LayoutItem, layout},
state::{Refresh, State}, state::Refresh,
unit::Size, unit::Size,
widget::{ widget::{
align::Center, align::Center,
@@ -12,9 +12,7 @@ use pulse_ui::{
}, },
}; };
pub struct PulseTradeApp { pub struct PulseTradeApp {}
count: State<i32>,
}
impl App for PulseTradeApp { impl App for PulseTradeApp {
async fn init(&mut self, ctx: &pulse_ui::state::Context) {} async fn init(&mut self, ctx: &pulse_ui::state::Context) {}
@@ -24,12 +22,8 @@ impl App for PulseTradeApp {
return; return;
} }
*self.count.lock().await += 1;
if *self.count.lock().await > 10 {
ctx.close().await; ctx.close().await;
} }
}
async fn layout(&self) -> pulse_ui::layout::LayoutItem { async fn layout(&self) -> pulse_ui::layout::LayoutItem {
LayoutItem::Frame { LayoutItem::Frame {
@@ -61,7 +55,7 @@ impl App for PulseTradeApp {
async fn render(&mut self, layout: pulse_ui::layout::Allocation) { async fn render(&mut self, layout: pulse_ui::layout::Allocation) {
layout.draw_frame(0, Outline); layout.draw_frame(0, Outline);
layout.draw(0, format!("PULSETRADER v0.1.0")); layout.draw(0, format!(" PULSE TRADER v0.1.0"));
layout.draw(1, Center("LIVE".to_string())); layout.draw(1, Center("LIVE".to_string()));
layout.draw(2, Center(format!("14:32:51 UTC"))); layout.draw(2, Center(format!("14:32:51 UTC")));
layout.draw_frame(3, VLine); layout.draw_frame(3, VLine);
@@ -74,15 +68,41 @@ impl App for PulseTradeApp {
SpacedColumns(vec![ SpacedColumns(vec![
( (
LayoutItem::Widget(Size::Flex(1)), LayoutItem::Widget(Size::Flex(1)),
Box::new(SpacedRows(vec![])), Box::new(
vec![
"WATCHLIST",
"BTC 118,402.12 ▲ 0.82%",
"ETH 3,912.48 ▼ 0.41%",
"SOL 182.91 ▲ 2.18%",
"XRP 2.84 ▲ 1.22%",
]
.join("\n"),
),
), ),
( (
LayoutItem::Widget(Size::Flex(1)), LayoutItem::Widget(Size::Flex(1)),
Box::new(SpacedRows(vec![])), Box::new(
vec![
"ACTIVE POSITIONS",
"BTC +4,120.40 20,000.00",
"SOL +2,435.40 20,000.00",
]
.join("\n"),
),
), ),
( (
LayoutItem::Widget(Size::Flex(1)), LayoutItem::Widget(Size::Flex(1)),
Box::new(SpacedRows(vec![])), Box::new(
vec![
"ACCOUNT",
"Equity: $25,483.21",
"Liquid: $11,928.43",
"Unreal: +$483.12",
"Realized: +$2,182.49",
"Margin: 0.00%",
]
.join("\n"),
),
), ),
]), ]),
); );
@@ -108,8 +128,5 @@ impl App for PulseTradeApp {
#[tokio::main] #[tokio::main]
async fn main() { async fn main() {
pulse_ui::run(|ctx| PulseTradeApp { pulse_ui::run(|_ctx| PulseTradeApp {}).await;
count: ctx.use_state(0),
})
.await;
} }