This commit is contained in:
Jens K.
2024-12-14 18:24:51 +01:00
committed by GitHub
parent 6c7bedabe3
commit b7d6a6c139
7 changed files with 268 additions and 54 deletions

View File

@@ -1,4 +1,5 @@
use crate::{
args::Args,
constants::TICK_VALUE_MS,
events::{Event, EventHandler, Events},
terminal::Terminal,
@@ -7,7 +8,7 @@ use crate::{
countdown::{Countdown, CountdownWidget},
footer::Footer,
header::Header,
pomodoro::{Pomodoro, PomodoroWidget},
pomodoro::{Pomodoro, PomodoroArgs, PomodoroWidget},
timer::{Timer, TimerWidget},
},
};
@@ -44,29 +45,26 @@ pub struct App {
pomodoro: Pomodoro,
}
impl Default for App {
fn default() -> Self {
impl App {
pub fn new(args: Args) -> Self {
Self {
mode: Mode::Running,
content: Content::Countdown,
show_menu: false,
countdown: Countdown::new(Clock::<clock::Countdown>::new(
Duration::from_secs(10 * 60 /* 10min */),
args.countdown,
Duration::from_millis(TICK_VALUE_MS),
)),
timer: Timer::new(Clock::<clock::Timer>::new(
Duration::ZERO,
Duration::from_millis(TICK_VALUE_MS),
)),
pomodoro: Pomodoro::new(),
pomodoro: Pomodoro::new(PomodoroArgs {
work: args.work,
pause: args.pause,
}),
}
}
}
impl App {
pub fn new() -> Self {
Self::default()
}
pub async fn run(&mut self, mut terminal: Terminal, mut events: Events) -> Result<()> {
while self.is_running() {