Compare commits
No commits in common. "74e9b1ddbf3e945ae9409cab0569dd94b2d8dd55" and "2a3eee895d47228e961e8b63dec8108669b3c817" have entirely different histories.
74e9b1ddbf
...
2a3eee895d
3 changed files with 44 additions and 40 deletions
|
@ -266,17 +266,26 @@ 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 main_layout =
|
let [top, _middle, bottom] =
|
||||||
Layout::vertical([Constraint::Min(5), Constraint::Min(10), Constraint::Min(3)]);
|
Layout::vertical([Constraint::Min(5), Constraint::Min(10), Constraint::Min(3)])
|
||||||
let [top, _middle, bottom] = main_layout.areas(area);
|
.split(area)
|
||||||
|
.as_array()
|
||||||
|
.cloned()
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
let footer_layout =
|
let [footer_left, footer_right] =
|
||||||
Layout::horizontal([Constraint::Percentage(30), Constraint::Percentage(70)]);
|
Layout::horizontal([Constraint::Percentage(30), Constraint::Percentage(70)])
|
||||||
let [footer_left, footer_right] = footer_layout.areas(bottom);
|
.split(bottom)
|
||||||
|
.as_array()
|
||||||
|
.cloned()
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
let header_layout =
|
let [_header_left, header_right] =
|
||||||
Layout::horizontal([Constraint::Percentage(50), Constraint::Percentage(50)]);
|
Layout::horizontal([Constraint::Percentage(50), Constraint::Percentage(50)])
|
||||||
let [_header_left, header_right] = header_layout.areas(top);
|
.split(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::{Constraint, Rect},
|
layout::Rect,
|
||||||
style::Stylize,
|
style::Stylize,
|
||||||
text::{Line, ToLine},
|
text::Line,
|
||||||
widgets::{Block, Borders, List, ListItem, Padding, Row, Table, Widget},
|
widgets::{Block, Borders, List, ListItem, Padding, Widget},
|
||||||
};
|
};
|
||||||
|
|
||||||
use super::Peers;
|
use super::Peers;
|
||||||
|
@ -47,41 +47,34 @@ 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 = "UDP socket".yellow();
|
let udp = Line::default().spans(vec![
|
||||||
let udp = udp.to_line().left_aligned();
|
"UDP socket:".to_string().yellow(),
|
||||||
let uaddr = format!("{:?}", joecalsend::LISTENING_SOCKET_ADDR).yellow();
|
format!("{:?}", joecalsend::LISTENING_SOCKET_ADDR).yellow(),
|
||||||
let udp = Row::new(vec![udp.into(), uaddr.to_line().right_aligned()]);
|
]);
|
||||||
|
let multicast: Line = format!(
|
||||||
let mip = format!(
|
"Multicast address:\t\t {:?}:{}",
|
||||||
"{:?}:{:?}",
|
|
||||||
joecalsend::MULTICAST_IP,
|
joecalsend::MULTICAST_IP,
|
||||||
joecalsend::DEFAULT_PORT
|
joecalsend::DEFAULT_PORT
|
||||||
)
|
)
|
||||||
.yellow();
|
.yellow()
|
||||||
let multicast = "Multicast address".yellow();
|
.into();
|
||||||
let multicast = Row::new(vec![
|
let http: Line = format!(
|
||||||
multicast.to_line().left_aligned(),
|
"HTTP address:\t\t\t {:?}",
|
||||||
mip.to_line().right_aligned(),
|
joecalsend::LISTENING_SOCKET_ADDR
|
||||||
]);
|
)
|
||||||
|
.yellow()
|
||||||
let haddr = format!("{:?}", joecalsend::LISTENING_SOCKET_ADDR).yellow();
|
.into();
|
||||||
let http = "HTTP address".yellow();
|
let items = [
|
||||||
let http = Row::new(vec![
|
ListItem::new(udp),
|
||||||
http.to_line().left_aligned(),
|
ListItem::new(multicast),
|
||||||
haddr.to_line().right_aligned(),
|
ListItem::new(http),
|
||||||
]);
|
];
|
||||||
|
|
||||||
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);
|
||||||
let table = Table::new(rows, widths).block(block);
|
list.render(area, buf);
|
||||||
table.render(area, buf);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
#![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