|
|
@@ -1,14 +1,21 @@
|
|
|
+// list on left
|
|
|
+// info page on right
|
|
|
+// when selected takes up full page
|
|
|
use crate::app::App;
|
|
|
use tui::{
|
|
|
backend::Backend,
|
|
|
+ layout::{Constraint, Direction, Layout},
|
|
|
style::{Color, Modifier, Style},
|
|
|
text::Spans,
|
|
|
- widgets::{Block, Borders, List, ListItem},
|
|
|
+ widgets::{Block, List, ListItem, Paragraph},
|
|
|
Frame,
|
|
|
};
|
|
|
|
|
|
pub fn ui<B: Backend>(f: &mut Frame<B>, app: &mut App) {
|
|
|
- let size = f.size();
|
|
|
+ let slice = Layout::default()
|
|
|
+ .direction(Direction::Horizontal)
|
|
|
+ .constraints([Constraint::Percentage(50), Constraint::Percentage(50)].as_ref())
|
|
|
+ .split(f.size());
|
|
|
|
|
|
let nodes: Vec<ListItem> = app
|
|
|
.node_list
|
|
|
@@ -22,12 +29,22 @@ pub fn ui<B: Backend>(f: &mut Frame<B>, app: &mut App) {
|
|
|
})
|
|
|
.collect();
|
|
|
|
|
|
- // 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())
|
|
|
.highlight_style(Style::default().bg(Color::Black).add_modifier(Modifier::BOLD))
|
|
|
.highlight_symbol(">> ");
|
|
|
|
|
|
- // Render the item list
|
|
|
- f.render_stateful_widget(nodes, size, &mut app.node_list.state);
|
|
|
+ f.render_stateful_widget(nodes, slice[0], &mut app.node_list.state);
|
|
|
+
|
|
|
+ let mut info_vec = Vec::new();
|
|
|
+ for val in app.node_list.nodes.values() {
|
|
|
+ info_vec.push(Spans::from(val.to_string()))
|
|
|
+ }
|
|
|
+
|
|
|
+ let graph = Paragraph::new(info_vec)
|
|
|
+ .block(Block::default())
|
|
|
+ .style(Style::default());
|
|
|
+
|
|
|
+ // TODO: make this a stateful widget that changes with scroll
|
|
|
+ f.render_widget(graph, slice[1]);
|
|
|
}
|