Compare commits
2 commits
2a3eee895d
...
74e9b1ddbf
Author | SHA1 | Date | |
---|---|---|---|
|
74e9b1ddbf | ||
|
2f88b3b2c2 |
3 changed files with 40 additions and 44 deletions
|
@ -266,26 +266,17 @@ static LOGGING_MENU: LazyLock<Line> = LazyLock::new(|| {
|
||||||
|
|
||||||
impl Widget for &App {
|
impl Widget for &App {
|
||||||
fn render(self, area: Rect, buf: &mut Buffer) {
|
fn render(self, area: Rect, buf: &mut Buffer) {
|
||||||
let [top, _middle, bottom] =
|
let main_layout =
|
||||||
Layout::vertical([Constraint::Min(5), Constraint::Min(10), Constraint::Min(3)])
|
Layout::vertical([Constraint::Min(5), Constraint::Min(10), Constraint::Min(3)]);
|
||||||
.split(area)
|
let [top, _middle, bottom] = main_layout.areas(area);
|
||||||
.as_array()
|
|
||||||
.cloned()
|
|
||||||
.unwrap();
|
|
||||||
|
|
||||||
let [footer_left, footer_right] =
|
let footer_layout =
|
||||||
Layout::horizontal([Constraint::Percentage(30), Constraint::Percentage(70)])
|
Layout::horizontal([Constraint::Percentage(30), Constraint::Percentage(70)]);
|
||||||
.split(bottom)
|
let [footer_left, footer_right] = footer_layout.areas(bottom);
|
||||||
.as_array()
|
|
||||||
.cloned()
|
|
||||||
.unwrap();
|
|
||||||
|
|
||||||
let [_header_left, header_right] =
|
let header_layout =
|
||||||
Layout::horizontal([Constraint::Percentage(50), Constraint::Percentage(50)])
|
Layout::horizontal([Constraint::Percentage(50), Constraint::Percentage(50)]);
|
||||||
.split(top)
|
let [_header_left, header_right] = header_layout.areas(top);
|
||||||
.as_array()
|
|
||||||
.cloned()
|
|
||||||
.unwrap();
|
|
||||||
|
|
||||||
let mode = self.screen.last().unwrap();
|
let mode = self.screen.last().unwrap();
|
||||||
match mode {
|
match mode {
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
use ratatui::{
|
use ratatui::{
|
||||||
buffer::Buffer,
|
buffer::Buffer,
|
||||||
layout::Rect,
|
layout::{Constraint, Rect},
|
||||||
style::Stylize,
|
style::Stylize,
|
||||||
text::Line,
|
text::{Line, ToLine},
|
||||||
widgets::{Block, Borders, List, ListItem, Padding, Widget},
|
widgets::{Block, Borders, List, ListItem, Padding, Row, Table, Widget},
|
||||||
};
|
};
|
||||||
|
|
||||||
use super::Peers;
|
use super::Peers;
|
||||||
|
@ -47,34 +47,41 @@ impl Widget for NetworkInfoWidget {
|
||||||
// let rows = Rows::new(rect);
|
// let rows = Rows::new(rect);
|
||||||
// let mut table = Table::default();
|
// let mut table = Table::default();
|
||||||
|
|
||||||
let udp = Line::default().spans(vec![
|
let udp = "UDP socket".yellow();
|
||||||
"UDP socket:".to_string().yellow(),
|
let udp = udp.to_line().left_aligned();
|
||||||
format!("{:?}", joecalsend::LISTENING_SOCKET_ADDR).yellow(),
|
let uaddr = format!("{:?}", joecalsend::LISTENING_SOCKET_ADDR).yellow();
|
||||||
]);
|
let udp = Row::new(vec![udp.into(), uaddr.to_line().right_aligned()]);
|
||||||
let multicast: Line = format!(
|
|
||||||
"Multicast address:\t\t {:?}:{}",
|
let mip = format!(
|
||||||
|
"{:?}:{:?}",
|
||||||
joecalsend::MULTICAST_IP,
|
joecalsend::MULTICAST_IP,
|
||||||
joecalsend::DEFAULT_PORT
|
joecalsend::DEFAULT_PORT
|
||||||
)
|
)
|
||||||
.yellow()
|
.yellow();
|
||||||
.into();
|
let multicast = "Multicast address".yellow();
|
||||||
let http: Line = format!(
|
let multicast = Row::new(vec![
|
||||||
"HTTP address:\t\t\t {:?}",
|
multicast.to_line().left_aligned(),
|
||||||
joecalsend::LISTENING_SOCKET_ADDR
|
mip.to_line().right_aligned(),
|
||||||
)
|
]);
|
||||||
.yellow()
|
|
||||||
.into();
|
let haddr = format!("{:?}", joecalsend::LISTENING_SOCKET_ADDR).yellow();
|
||||||
let items = [
|
let http = "HTTP address".yellow();
|
||||||
ListItem::new(udp),
|
let http = Row::new(vec![
|
||||||
ListItem::new(multicast),
|
http.to_line().left_aligned(),
|
||||||
ListItem::new(http),
|
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 title = Line::from(" Listeners ".bold()).centered();
|
||||||
|
|
||||||
let block = Block::default()
|
let block = Block::default()
|
||||||
.title(title)
|
.title(title)
|
||||||
.borders(Borders::all())
|
.borders(Borders::all())
|
||||||
.padding(Padding::uniform(1));
|
.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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
#![feature(slice_as_array)]
|
|
||||||
|
|
||||||
use frontend::App;
|
use frontend::App;
|
||||||
use joecalsend::{Config, error, models::Device};
|
use joecalsend::{Config, error, models::Device};
|
||||||
use local_ip_address::local_ip;
|
use local_ip_address::local_ip;
|
||||||
|
|
Loading…
Reference in a new issue