| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263 |
- // first one selected
- // list on left
- // info page on right
- // when selected takes up full page
- // identifier is random string
- //
- // event handler for the list
- // when the list is selected
- // updates a hashmap that keep track of selected??
- use crate::app::App;
- use tui::{
- backend::Backend,
- layout::{Constraint, Direction, Layout},
- style::{Color, Modifier, Style},
- text::Spans,
- widgets::{Block, List, ListItem},
- Frame,
- };
- pub fn ui<B: Backend>(f: &mut Frame<B>, app: &mut App) {
- let slice = Layout::default()
- .direction(Direction::Horizontal)
- .margin(1)
- .constraints([Constraint::Percentage(50), Constraint::Percentage(50)].as_ref())
- .split(f.size());
- let nodes: Vec<ListItem> = app
- .node_list
- .nodes
- .iter()
- .map(|(id, info)| {
- let line1 = Spans::from(id.to_string());
- let line2 = Spans::from(info.to_string());
- ListItem::new(vec![line1, line2]).style(Style::default())
- })
- .collect();
- let nodes = List::new(nodes)
- .block(Block::default())
- .highlight_style(Style::default().fg(Color::LightCyan).add_modifier(Modifier::BOLD));
- f.render_stateful_widget(nodes, slice[0], &mut app.node_list.state);
- let node_info: Vec<ListItem> = app
- .node_list
- .node_info
- .info
- .iter()
- .map(|i| {
- let line1 = Spans::from(i.to_string());
- ListItem::new(vec![line1]).style(Style::default())
- })
- .collect();
- let node_info = List::new(node_info)
- .block(Block::default())
- .highlight_style(Style::default().fg(Color::LightCyan).add_modifier(Modifier::BOLD));
- f.render_stateful_widget(node_info, slice[1], &mut app.node_list.state);
- }
|