This commit is contained in:
2026-01-01 22:16:41 +00:00
parent 7cf9fb7e04
commit 52cdf63640

View File

@@ -3,6 +3,7 @@ use futures::{FutureExt, StreamExt};
use ratatui::{ use ratatui::{
DefaultTerminal, Frame, DefaultTerminal, Frame,
prelude::Rect,
prelude::*, prelude::*,
style::Stylize, style::Stylize,
text::Line, text::Line,
@@ -68,20 +69,43 @@ impl App {
let text = "Hello, Ratatui!\n\n\ let text = "Hello, Ratatui!\n\n\
Created using https://github.com/ratatui/templates\n\ Created using https://github.com/ratatui/templates\n\
Press `Esc`, `Ctrl-C` or `q` to stop running."; Press `Esc`, `Ctrl-C` or `q` to stop running.";
let layout = Layout::default() let h_contraint = Constraint::Max(75);
.direction(Direction::Vertical) let v_contraint = Constraint::Max(35);
.constraints(vec![
Constraint::Percentage(33), let rec = Layout::new(Direction::Vertical, [v_contraint]).flex(layout::Flex::Center);
Constraint::Percentage(33), let rec_split: [Rect; 1] = rec.areas(frame.area());
Constraint::Percentage(33),
let rec_2 = Layout::horizontal([h_contraint]).flex(layout::Flex::Center);
let rec_2_split: [Rect; 1] = rec_2.areas(rec_split[0]);
let inner: Rect = rec_2_split[0];
let selection_boxes: [Rect; 3] = Layout::vertical([
Constraint::Percentage(30),
Constraint::Percentage(30),
Constraint::Percentage(30),
]) ])
.split(frame.area()); .flex(layout::Flex::SpaceBetween)
frame.render_widget( .areas(inner);
Paragraph::new(text)
.block(Block::bordered().title(title)) // frame.render_widget(
.centered(), // Paragraph::new(text)
layout[1], // .block(Block::bordered().title(title))
) // .centered(),
// rec_2_split[0],
// );
let dashboard_boards: [screen; 1] = [screen::Battery];
for (x) in (dashboard_boards) {
match x {
screen::Battery => {
let text = Paragraph::new("Battery widget!")
.block(Block::bordered())
.centered();
frame.render_widget(text, selection_boxes[0]);
}
_ => {}
}
}
} }
/// Reads the crossterm events and updates the state of [`App`]. /// Reads the crossterm events and updates the state of [`App`].
@@ -105,6 +129,7 @@ impl App {
(_, KeyCode::Esc | KeyCode::Char('q')) (_, KeyCode::Esc | KeyCode::Char('q'))
| (KeyModifiers::CONTROL, KeyCode::Char('c') | KeyCode::Char('C')) => self.quit(), | (KeyModifiers::CONTROL, KeyCode::Char('c') | KeyCode::Char('C')) => self.quit(),
// Add other key handlers here. // Add other key handlers here.
(_, KeyCode::Tab) => {}
_ => {} _ => {}
} }
} }