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 {
|
||||
fn render(self, area: Rect, buf: &mut Buffer) {
|
||||
let [top, _middle, bottom] =
|
||||
Layout::vertical([Constraint::Min(5), Constraint::Min(10), Constraint::Min(3)])
|
||||
.split(area)
|
||||
.as_array()
|
||||
.cloned()
|
||||
.unwrap();
|
||||
let main_layout =
|
||||
Layout::vertical([Constraint::Min(5), Constraint::Min(10), Constraint::Min(3)]);
|
||||
let [top, _middle, bottom] = main_layout.areas(area);
|
||||
|
||||
let [footer_left, footer_right] =
|
||||
Layout::horizontal([Constraint::Percentage(30), Constraint::Percentage(70)])
|
||||
.split(bottom)
|
||||
.as_array()
|
||||
.cloned()
|
||||
.unwrap();
|
||||
let footer_layout =
|
||||
Layout::horizontal([Constraint::Percentage(30), Constraint::Percentage(70)]);
|
||||
let [footer_left, footer_right] = footer_layout.areas(bottom);
|
||||
|
||||
let [_header_left, header_right] =
|
||||
Layout::horizontal([Constraint::Percentage(50), Constraint::Percentage(50)])
|
||||
.split(top)
|
||||
.as_array()
|
||||
.cloned()
|
||||
.unwrap();
|
||||
let header_layout =
|
||||
Layout::horizontal([Constraint::Percentage(50), Constraint::Percentage(50)]);
|
||||
let [_header_left, header_right] = header_layout.areas(top);
|
||||
|
||||
let mode = self.screen.last().unwrap();
|
||||
match mode {
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
#![feature(slice_as_array)]
|
||||
|
||||
use frontend::App;
|
||||
use joecalsend::{Config, error, models::Device};
|
||||
use local_ip_address::local_ip;
|
||||
|
|
Loading…
Reference in a new issue