This commit is contained in:
2026-01-03 20:49:05 +00:00
parent 52cdf63640
commit 7b6279ef3b

View File

@@ -1,3 +1,4 @@
use color_eyre::owo_colors::OwoColorize;
use crossterm::event::{Event, EventStream, KeyCode, KeyEvent, KeyEventKind, KeyModifiers}; use crossterm::event::{Event, EventStream, KeyCode, KeyEvent, KeyEventKind, KeyModifiers};
use futures::{FutureExt, StreamExt}; use futures::{FutureExt, StreamExt};
@@ -35,8 +36,16 @@ pub enum screen {
Battery, Battery,
} }
#[derive(Debug, Default)]
pub enum widget {
#[default]
Empty,
Battery,
}
#[derive(Debug, Default)] #[derive(Debug, Default)]
pub struct AppState { pub struct AppState {
selection: i32,
active_screen: screen, active_screen: screen,
} }
@@ -88,23 +97,63 @@ impl App {
.flex(layout::Flex::SpaceBetween) .flex(layout::Flex::SpaceBetween)
.areas(inner); .areas(inner);
let meow: [Rect; 2] =
Layout::horizontal([Constraint::Percentage(45), Constraint::Percentage(45)])
.flex(layout::Flex::SpaceBetween)
.areas(selection_boxes[0]);
let meow2: [Rect; 2] =
Layout::horizontal([Constraint::Percentage(45), Constraint::Percentage(45)])
.flex(layout::Flex::SpaceBetween)
.areas(selection_boxes[1]);
let meow3: [Rect; 2] =
Layout::horizontal([Constraint::Percentage(45), Constraint::Percentage(45)])
.flex(layout::Flex::SpaceBetween)
.areas(selection_boxes[2]);
let rah: [Rect; 6] = [meow[0], meow[1], meow2[0], meow2[1], meow3[0], meow3[1]];
// frame.render_widget( // frame.render_widget(
// Paragraph::new(text) // Paragraph::new(text)
// .block(Block::bordered().title(title)) // .block(Block::bordered().title(title))
// .centered(), // .centered(),
// rec_2_split[0], // rec_2_split[0],
// ); // );
let dashboard_boards: [screen; 1] = [screen::Battery]; let dashboard_boards: [widget; 6] = [
widget::Battery,
widget::Empty,
widget::Empty,
widget::Empty,
widget::Empty,
widget::Empty,
];
let mut index = 0;
for (x) in (dashboard_boards) { for (x) in (dashboard_boards) {
let mut selected: bool = false;
if index == self.state.selection {
selected = true;
}
let style_selected: Style = {
if selected {
Style::new().blue()
} else {
Style::new().white()
}
};
match x { match x {
screen::Battery => { widget::Battery => {
let text = Paragraph::new("Battery widget!") let text = Paragraph::new("Battery widget!")
.block(Block::bordered()) .block(Block::bordered().border_style(style_selected))
.centered(); .centered();
frame.render_widget(text, selection_boxes[0]); frame.render_widget(text, rah[index as usize]);
}
widget::Empty => {
let text = Paragraph::new("Empty")
.block(Block::bordered().border_style(style_selected))
.centered();
frame.render_widget(text, rah[index as usize]);
} }
_ => {} _ => {}
} }
index += 1;
} }
} }
@@ -129,7 +178,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) => {} (_, KeyCode::Tab) => self.state.selection += 1,
_ => {} _ => {}
} }
} }