progress
This commit is contained in:
53
src/main.rs
53
src/main.rs
@@ -3,6 +3,7 @@ use futures::{FutureExt, StreamExt};
|
||||
|
||||
use ratatui::{
|
||||
DefaultTerminal, Frame,
|
||||
prelude::Rect,
|
||||
prelude::*,
|
||||
style::Stylize,
|
||||
text::Line,
|
||||
@@ -68,20 +69,43 @@ impl App {
|
||||
let text = "Hello, Ratatui!\n\n\
|
||||
Created using https://github.com/ratatui/templates\n\
|
||||
Press `Esc`, `Ctrl-C` or `q` to stop running.";
|
||||
let layout = Layout::default()
|
||||
.direction(Direction::Vertical)
|
||||
.constraints(vec![
|
||||
Constraint::Percentage(33),
|
||||
Constraint::Percentage(33),
|
||||
Constraint::Percentage(33),
|
||||
])
|
||||
.split(frame.area());
|
||||
frame.render_widget(
|
||||
Paragraph::new(text)
|
||||
.block(Block::bordered().title(title))
|
||||
.centered(),
|
||||
layout[1],
|
||||
)
|
||||
let h_contraint = Constraint::Max(75);
|
||||
let v_contraint = Constraint::Max(35);
|
||||
|
||||
let rec = Layout::new(Direction::Vertical, [v_contraint]).flex(layout::Flex::Center);
|
||||
let rec_split: [Rect; 1] = rec.areas(frame.area());
|
||||
|
||||
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),
|
||||
])
|
||||
.flex(layout::Flex::SpaceBetween)
|
||||
.areas(inner);
|
||||
|
||||
// frame.render_widget(
|
||||
// Paragraph::new(text)
|
||||
// .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`].
|
||||
@@ -105,6 +129,7 @@ impl App {
|
||||
(_, KeyCode::Esc | KeyCode::Char('q'))
|
||||
| (KeyModifiers::CONTROL, KeyCode::Char('c') | KeyCode::Char('C')) => self.quit(),
|
||||
// Add other key handlers here.
|
||||
(_, KeyCode::Tab) => {}
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user