diff --git a/pulse-ui/src/widget/dynamic.rs b/pulse-ui/src/widget/dynamic.rs index 9b76bb4..939e481 100644 --- a/pulse-ui/src/widget/dynamic.rs +++ b/pulse-ui/src/widget/dynamic.rs @@ -1,8 +1,8 @@ use crate::{unit::Rect, widget::Widget}; -pub struct Dynamic(pub fn(Rect) -> Box); +pub struct Dynamic(pub fn(Rect) -> W); -impl Widget for Dynamic { +impl Widget for Dynamic { fn render(&self, scope: &mut crate::render::RenderScope) { (self.0)(scope.rect).render(scope); } diff --git a/src/main.rs b/src/main.rs index 2ce7d3b..87e87ab 100644 --- a/src/main.rs +++ b/src/main.rs @@ -3,7 +3,7 @@ use std::any::Any; use pulse_ui::{ App, layout::{LayoutItem, layout}, - state::{Refresh, State}, + state::Refresh, unit::Size, widget::{ align::Center, @@ -12,9 +12,7 @@ use pulse_ui::{ }, }; -pub struct PulseTradeApp { - count: State, -} +pub struct PulseTradeApp {} impl App for PulseTradeApp { async fn init(&mut self, ctx: &pulse_ui::state::Context) {} @@ -24,11 +22,7 @@ impl App for PulseTradeApp { 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 { @@ -61,7 +55,7 @@ impl App for PulseTradeApp { async fn render(&mut self, layout: pulse_ui::layout::Allocation) { 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(2, Center(format!("14:32:51 UTC"))); layout.draw_frame(3, VLine); @@ -74,15 +68,41 @@ impl App for PulseTradeApp { SpacedColumns(vec![ ( 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)), - 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)), - 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] async fn main() { - pulse_ui::run(|ctx| PulseTradeApp { - count: ctx.use_state(0), - }) - .await; + pulse_ui::run(|_ctx| PulseTradeApp {}).await; }