more args: mode, style, decis (#20)
This commit is contained in:
@@ -9,26 +9,7 @@ use ratatui::{
|
||||
widgets::StatefulWidget,
|
||||
};
|
||||
|
||||
use crate::utils::center_horizontal;
|
||||
|
||||
#[derive(Debug, Copy, Clone)]
|
||||
pub enum Style {
|
||||
Default,
|
||||
Empty,
|
||||
Thick,
|
||||
Cross,
|
||||
}
|
||||
|
||||
impl Style {
|
||||
pub fn next(&self) -> Self {
|
||||
match self {
|
||||
Style::Default => Style::Empty,
|
||||
Style::Empty => Style::Thick,
|
||||
Style::Thick => Style::Cross,
|
||||
Style::Cross => Style::Default,
|
||||
}
|
||||
}
|
||||
}
|
||||
use crate::{args::ClockStyle, utils::center_horizontal};
|
||||
|
||||
#[derive(Debug, Copy, Clone, Display, PartialEq, Eq)]
|
||||
pub enum Time {
|
||||
@@ -100,7 +81,7 @@ pub struct Clock<T> {
|
||||
current_value: Duration,
|
||||
mode: Mode,
|
||||
format: Format,
|
||||
pub style: Style,
|
||||
pub style: ClockStyle,
|
||||
pub with_decis: bool,
|
||||
phantom: PhantomData<T>,
|
||||
}
|
||||
@@ -108,7 +89,7 @@ pub struct Clock<T> {
|
||||
pub struct ClockArgs {
|
||||
pub initial_value: Duration,
|
||||
pub tick_value: Duration,
|
||||
pub style: Style,
|
||||
pub style: ClockStyle,
|
||||
pub with_decis: bool,
|
||||
}
|
||||
|
||||
@@ -571,12 +552,12 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
fn get_digit_symbol(&self, style: &Style) -> &str {
|
||||
fn get_digit_symbol(&self, style: &ClockStyle) -> &str {
|
||||
match &style {
|
||||
Style::Default => "█",
|
||||
Style::Empty => "░",
|
||||
Style::Cross => "╬",
|
||||
Style::Thick => "┃",
|
||||
ClockStyle::Bold => "█",
|
||||
ClockStyle::Empty => "░",
|
||||
ClockStyle::Cross => "╬",
|
||||
ClockStyle::Thick => "┃",
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -8,13 +8,12 @@ use ratatui::{
|
||||
use std::cmp::max;
|
||||
|
||||
use crate::{
|
||||
args::ClockStyle,
|
||||
events::{Event, EventHandler},
|
||||
utils::center,
|
||||
widgets::clock::{self, Clock, ClockWidget},
|
||||
};
|
||||
|
||||
use super::clock::Style;
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct Countdown {
|
||||
clock: Clock<clock::Countdown>,
|
||||
@@ -25,7 +24,7 @@ impl Countdown {
|
||||
Self { clock }
|
||||
}
|
||||
|
||||
pub fn set_style(&mut self, style: Style) {
|
||||
pub fn set_style(&mut self, style: ClockStyle) {
|
||||
self.clock.style = style;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
use std::collections::BTreeMap;
|
||||
|
||||
use crate::app::Content;
|
||||
use crate::args::Content;
|
||||
use ratatui::{
|
||||
buffer::Buffer,
|
||||
layout::{Constraint, Layout, Rect},
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
use crate::{
|
||||
args::ClockStyle,
|
||||
constants::TICK_VALUE_MS,
|
||||
events::{Event, EventHandler},
|
||||
utils::center,
|
||||
@@ -15,7 +16,7 @@ use std::{cmp::max, time::Duration};
|
||||
|
||||
use strum::Display;
|
||||
|
||||
use super::clock::{ClockArgs, Style};
|
||||
use super::clock::ClockArgs;
|
||||
|
||||
#[derive(Debug, Clone, Display, Hash, Eq, PartialEq)]
|
||||
enum Mode {
|
||||
@@ -47,7 +48,7 @@ pub struct Pomodoro {
|
||||
pub struct PomodoroArgs {
|
||||
pub work: Duration,
|
||||
pub pause: Duration,
|
||||
pub style: Style,
|
||||
pub style: ClockStyle,
|
||||
pub with_decis: bool,
|
||||
}
|
||||
|
||||
@@ -82,7 +83,7 @@ impl Pomodoro {
|
||||
self.clock_map.get(&self.mode)
|
||||
}
|
||||
|
||||
pub fn set_style(&mut self, style: Style) {
|
||||
pub fn set_style(&mut self, style: crate::args::ClockStyle) {
|
||||
self.clock_map.work.style = style;
|
||||
self.clock_map.pause.style = style;
|
||||
}
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
use crate::{
|
||||
args::ClockStyle,
|
||||
events::{Event, EventHandler},
|
||||
utils::center,
|
||||
widgets::clock::{self, Clock, ClockWidget, Style},
|
||||
widgets::clock::{self, Clock, ClockWidget},
|
||||
};
|
||||
use ratatui::{
|
||||
buffer::Buffer,
|
||||
@@ -22,7 +23,7 @@ impl Timer {
|
||||
Self { clock }
|
||||
}
|
||||
|
||||
pub fn set_style(&mut self, style: Style) {
|
||||
pub fn set_style(&mut self, style: ClockStyle) {
|
||||
self.clock.style = style;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user