|
@@ -2,7 +2,7 @@ use crate::app::App;
|
|
|
use tui::{
|
|
use tui::{
|
|
|
backend::Backend,
|
|
backend::Backend,
|
|
|
style::{Color, Modifier, Style},
|
|
style::{Color, Modifier, Style},
|
|
|
- text::{Spans},
|
|
|
|
|
|
|
+ text::Spans,
|
|
|
widgets::{Block, Borders, List, ListItem},
|
|
widgets::{Block, Borders, List, ListItem},
|
|
|
Frame,
|
|
Frame,
|
|
|
};
|
|
};
|
|
@@ -10,22 +10,24 @@ use tui::{
|
|
|
pub fn ui<B: Backend>(f: &mut Frame<B>, app: &mut App) {
|
|
pub fn ui<B: Backend>(f: &mut Frame<B>, app: &mut App) {
|
|
|
let size = f.size();
|
|
let size = f.size();
|
|
|
|
|
|
|
|
- let items: Vec<ListItem> = app
|
|
|
|
|
|
|
+ let nodes: Vec<ListItem> = app
|
|
|
|
|
+ .node_list
|
|
|
.nodes
|
|
.nodes
|
|
|
- .items
|
|
|
|
|
.iter()
|
|
.iter()
|
|
|
- .map(|i| {
|
|
|
|
|
- let lines = vec![Spans::from(i.to_string())];
|
|
|
|
|
- ListItem::new(lines).style(Style::default())
|
|
|
|
|
|
|
+ .map(|(id, info)| {
|
|
|
|
|
+ let line1 = vec![Spans::from(id.to_string())];
|
|
|
|
|
+ let line2 = vec![Spans::from(info.to_string())];
|
|
|
|
|
+ ListItem::new(line1).style(Style::default());
|
|
|
|
|
+ ListItem::new(line2).style(Style::default())
|
|
|
})
|
|
})
|
|
|
.collect();
|
|
.collect();
|
|
|
|
|
|
|
|
- // Create a List from all list items and highlight the currently selected one
|
|
|
|
|
- let items = List::new(items)
|
|
|
|
|
|
|
+ // Create a List from all list nodes and highlight the currently selected one
|
|
|
|
|
+ let nodes = List::new(nodes)
|
|
|
.block(Block::default().borders(Borders::ALL).title("List of nodes"))
|
|
.block(Block::default().borders(Borders::ALL).title("List of nodes"))
|
|
|
.highlight_style(Style::default().bg(Color::Black).add_modifier(Modifier::BOLD))
|
|
.highlight_style(Style::default().bg(Color::Black).add_modifier(Modifier::BOLD))
|
|
|
.highlight_symbol(">> ");
|
|
.highlight_symbol(">> ");
|
|
|
|
|
|
|
|
// Render the item list
|
|
// Render the item list
|
|
|
- f.render_stateful_widget(items, size, &mut app.nodes.state);
|
|
|
|
|
|
|
+ f.render_stateful_widget(nodes, size, &mut app.node_list.state);
|
|
|
}
|
|
}
|