Event handling (#5)
- Refactor `event` handling (heavily inspired by [crates-tui](https://github.com/ratatui/crates-tui/) via [Tui with Terminal and EventHandler](https://ratatui.rs/recipes/apps/terminal-and-event-handler/)) - Refactor widget structure - Disable `nixos-unstable` temporarily - Add `.rustfmt.toml`
This commit is contained in:
23
src/widgets/countdown.rs
Normal file
23
src/widgets/countdown.rs
Normal file
@@ -0,0 +1,23 @@
|
||||
use ratatui::{
|
||||
buffer::Buffer,
|
||||
layout::Rect,
|
||||
widgets::{Paragraph, Widget},
|
||||
};
|
||||
|
||||
#[derive(Debug, Default, Clone, PartialEq, Eq)]
|
||||
pub struct Countdown {
|
||||
headline: String,
|
||||
}
|
||||
|
||||
impl Countdown {
|
||||
pub const fn new(headline: String) -> Self {
|
||||
Self { headline }
|
||||
}
|
||||
}
|
||||
|
||||
impl Widget for Countdown {
|
||||
fn render(self, area: Rect, buf: &mut Buffer) {
|
||||
let h = Paragraph::new(self.headline).centered();
|
||||
h.render(area, buf);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user