use a table for the network info
This commit is contained in:
parent
2f88b3b2c2
commit
74e9b1ddbf
1 changed files with 31 additions and 24 deletions
|
@ -1,9 +1,9 @@
|
|||
use ratatui::{
|
||||
buffer::Buffer,
|
||||
layout::Rect,
|
||||
layout::{Constraint, Rect},
|
||||
style::Stylize,
|
||||
text::Line,
|
||||
widgets::{Block, Borders, List, ListItem, Padding, Widget},
|
||||
text::{Line, ToLine},
|
||||
widgets::{Block, Borders, List, ListItem, Padding, Row, Table, Widget},
|
||||
};
|
||||
|
||||
use super::Peers;
|
||||
|
@ -47,34 +47,41 @@ impl Widget for NetworkInfoWidget {
|
|||
// let rows = Rows::new(rect);
|
||||
// let mut table = Table::default();
|
||||
|
||||
let udp = Line::default().spans(vec![
|
||||
"UDP socket:".to_string().yellow(),
|
||||
format!("{:?}", joecalsend::LISTENING_SOCKET_ADDR).yellow(),
|
||||
]);
|
||||
let multicast: Line = format!(
|
||||
"Multicast address:\t\t {:?}:{}",
|
||||
let udp = "UDP socket".yellow();
|
||||
let udp = udp.to_line().left_aligned();
|
||||
let uaddr = format!("{:?}", joecalsend::LISTENING_SOCKET_ADDR).yellow();
|
||||
let udp = Row::new(vec![udp.into(), uaddr.to_line().right_aligned()]);
|
||||
|
||||
let mip = format!(
|
||||
"{:?}:{:?}",
|
||||
joecalsend::MULTICAST_IP,
|
||||
joecalsend::DEFAULT_PORT
|
||||
)
|
||||
.yellow()
|
||||
.into();
|
||||
let http: Line = format!(
|
||||
"HTTP address:\t\t\t {:?}",
|
||||
joecalsend::LISTENING_SOCKET_ADDR
|
||||
)
|
||||
.yellow()
|
||||
.into();
|
||||
let items = [
|
||||
ListItem::new(udp),
|
||||
ListItem::new(multicast),
|
||||
ListItem::new(http),
|
||||
];
|
||||
.yellow();
|
||||
let multicast = "Multicast address".yellow();
|
||||
let multicast = Row::new(vec![
|
||||
multicast.to_line().left_aligned(),
|
||||
mip.to_line().right_aligned(),
|
||||
]);
|
||||
|
||||
let haddr = format!("{:?}", joecalsend::LISTENING_SOCKET_ADDR).yellow();
|
||||
let http = "HTTP address".yellow();
|
||||
let http = Row::new(vec![
|
||||
http.to_line().left_aligned(),
|
||||
haddr.to_line().right_aligned(),
|
||||
]);
|
||||
|
||||
let rows = vec![udp, multicast, http];
|
||||
let widths = vec![Constraint::Percentage(50), Constraint::Percentage(50)];
|
||||
|
||||
let title = Line::from(" Listeners ".bold()).centered();
|
||||
|
||||
let block = Block::default()
|
||||
.title(title)
|
||||
.borders(Borders::all())
|
||||
.padding(Padding::uniform(1));
|
||||
let list = List::new(items).block(block);
|
||||
list.render(area, buf);
|
||||
|
||||
let table = Table::new(rows, widths).block(block);
|
||||
table.render(area, buf);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue