use crate::app::App; use tui::{ backend::Backend, layout::{Constraint, Direction, Layout}, style::{Color, Modifier, Style}, text::Spans, widgets::{Block, Borders, List, ListItem, Paragraph}, Frame, }; pub fn ui(f: &mut Frame, app: &mut App) { let slice = Layout::default() .direction(Direction::Horizontal) .margin(2) .constraints([Constraint::Percentage(50), Constraint::Percentage(50)].as_ref()) .split(f.size()); let nodes: Vec = app .node_list .node_id .iter() .map(|id| { let line1 = Spans::from(id.to_string()); ListItem::new(vec![line1]).style(Style::default()) }) .collect(); let nodes = List::new(nodes) .block(Block::default().borders(Borders::ALL)) .highlight_style(Style::default().fg(Color::LightCyan).add_modifier(Modifier::BOLD)); f.render_stateful_widget(nodes, slice[0], &mut app.node_list.state); let info: Vec = app.node_info.infos.iter().map(|info| Spans::from(info.connections.to_string())).collect(); let graph = Paragraph::new(info).block(Block::default().borders(Borders::ALL)).style(Style::default()); f.render_widget(graph, slice[1]); }