mirror of
https://github.com/darkrenaissance/darkfi.git
synced 2026-04-28 03:00:18 -04:00
map: render node info panel
This commit is contained in:
@@ -1,24 +1,25 @@
|
||||
#[derive(Clone)]
|
||||
pub struct NodeInfoView {
|
||||
pub index: usize,
|
||||
pub infos: Vec<NodeInfo>,
|
||||
}
|
||||
|
||||
impl NodeInfoView {
|
||||
pub fn new(_infos: Vec<NodeInfo>) -> NodeInfoView {
|
||||
pub fn new(infos: Vec<NodeInfo>) -> NodeInfoView {
|
||||
let index = 0;
|
||||
NodeInfoView { index }
|
||||
NodeInfoView { index, infos }
|
||||
}
|
||||
|
||||
pub fn next(&mut self) {
|
||||
//self.index = (self.index + 1) % self.info.len();
|
||||
self.index = (self.index + 1) % self.infos.len();
|
||||
}
|
||||
|
||||
pub fn previous(&mut self) {
|
||||
//if self.index > 0 {
|
||||
// self.index -= 1;
|
||||
//} else {
|
||||
// self.index = self.info.len() - 1;
|
||||
//}
|
||||
if self.index > 0 {
|
||||
self.index -= 1;
|
||||
} else {
|
||||
self.index = self.infos.len() - 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,13 +1,10 @@
|
||||
use crate::{
|
||||
app::App,
|
||||
//node_info::{NodeInfo, NodeInfoView},
|
||||
};
|
||||
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, Borders, List, ListItem, Paragraph},
|
||||
Frame,
|
||||
};
|
||||
|
||||
@@ -34,12 +31,11 @@ pub fn ui<B: Backend>(f: &mut Frame<B>, app: &mut App) {
|
||||
|
||||
f.render_stateful_widget(nodes, slice[0], &mut app.node_list.state);
|
||||
|
||||
//// call make info here
|
||||
//let text: Vec<Spans> = app.node_info.info.iter().map(|i| Spans::from(i.to_string())).collect();
|
||||
let info: Vec<Spans> =
|
||||
app.node_info.infos.iter().map(|info| Spans::from(info.connections.to_string())).collect();
|
||||
|
||||
//let graph = Paragraph::new(text)
|
||||
// .block(Block::default().borders(Borders::ALL))
|
||||
// .style(Style::default().fg(Color::LightCyan).add_modifier(Modifier::BOLD));
|
||||
let graph =
|
||||
Paragraph::new(info).block(Block::default().borders(Borders::ALL)).style(Style::default());
|
||||
|
||||
//f.render_widget(graph, slice[1]);
|
||||
f.render_widget(graph, slice[1]);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user