refac(env): rename wait duration to rest duration
This commit is contained in:
parent
acd1a87e63
commit
9955c966be
|
@ -22,8 +22,8 @@ impl AppDelegate<state::App> for Delegate {
|
|||
Handled::Yes
|
||||
}
|
||||
_ if cmd.is(cmd::OPEN_IDLE_WINDOW) => {
|
||||
let (widget_id, wait_duration) = *cmd.get_unchecked(cmd::OPEN_IDLE_WINDOW);
|
||||
ctx.new_window(win::rest::create(widget_id, wait_duration));
|
||||
let (widget_id, rest_duration) = *cmd.get_unchecked(cmd::OPEN_IDLE_WINDOW);
|
||||
ctx.new_window(win::rest::create(widget_id, rest_duration));
|
||||
Handled::Yes
|
||||
}
|
||||
_ => Handled::No,
|
||||
|
|
12
src/env.rs
12
src/env.rs
|
@ -8,14 +8,14 @@ pub const TIMER_POSTPONE_DURATION: Key<f64> = Key::new("hwt.env.comp.timer.postp
|
|||
pub const MICRO_BREAK_TIMER_DURATION: Key<f64> = Key::new("hwt.env.widget.micro_break.duration");
|
||||
pub const MICRO_BREAK_TIMER_POSTPONE_DURATION: Key<f64> =
|
||||
Key::new("hwt.env.widget.micro_break.postpone_duration");
|
||||
pub const MICRO_BREAK_TIMER_WAIT_DURATION: Key<f64> =
|
||||
Key::new("hwt.env.widget.micro_break.wait_duration");
|
||||
pub const MICRO_BREAK_TIMER_REST_DURATION: Key<f64> =
|
||||
Key::new("hwt.env.widget.micro_break.rest_duration");
|
||||
|
||||
pub const REST_BREAK_TIMER_DURATION: Key<f64> = Key::new("hwt.env.widget.rest_break.duration");
|
||||
pub const REST_BREAK_TIMER_POSTPONE_DURATION: Key<f64> =
|
||||
Key::new("hwt.env.widget.rest_break.postpone_duration");
|
||||
pub const REST_BREAK_TIMER_WAIT_DURATION: Key<f64> =
|
||||
Key::new("hwt.env.widget.rest_break.wait_duration");
|
||||
pub const REST_BREAK_TIMER_REST_DURATION: Key<f64> =
|
||||
Key::new("hwt.env.widget.rest_break.rest_duration");
|
||||
|
||||
pub const BREAK_NOTIFIER_TIMER_DURATION: Key<f64> = Key::new("hwt.env.widget.notifier.duration");
|
||||
|
||||
|
@ -38,11 +38,11 @@ pub fn configure(env: &mut Env, _data: &state::App) {
|
|||
|
||||
env.set(MICRO_BREAK_TIMER_DURATION, 10.0);
|
||||
env.set(MICRO_BREAK_TIMER_POSTPONE_DURATION, 10.0);
|
||||
env.set(MICRO_BREAK_TIMER_WAIT_DURATION, 30.0);
|
||||
env.set(MICRO_BREAK_TIMER_REST_DURATION, 30.0);
|
||||
|
||||
env.set(REST_BREAK_TIMER_DURATION, mins(45.0));
|
||||
env.set(REST_BREAK_TIMER_POSTPONE_DURATION, mins(5.0));
|
||||
env.set(REST_BREAK_TIMER_WAIT_DURATION, mins(10.0));
|
||||
env.set(REST_BREAK_TIMER_REST_DURATION, mins(10.0));
|
||||
|
||||
env.set(BREAK_NOTIFIER_TIMER_DURATION, 10.0);
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@ use crate::state;
|
|||
use druid::widget::Flex;
|
||||
use druid::{MenuDesc, Target, Widget, WidgetExt, WidgetId, WindowDesc};
|
||||
|
||||
pub fn create(parent_widget_id: WidgetId, wait_duration: f64) -> WindowDesc<state::App> {
|
||||
pub fn create(parent_widget_id: WidgetId, rest_duration: f64) -> WindowDesc<state::App> {
|
||||
let win_width = 450.0;
|
||||
let win_height = 200.0;
|
||||
|
||||
|
@ -13,7 +13,7 @@ pub fn create(parent_widget_id: WidgetId, wait_duration: f64) -> WindowDesc<stat
|
|||
let x = (rect.width() - win_width) / 2.0;
|
||||
let y = (rect.height() - win_height) / 2.0;
|
||||
|
||||
return WindowDesc::new(move || build(parent_widget_id, wait_duration))
|
||||
return WindowDesc::new(move || build(parent_widget_id, rest_duration))
|
||||
.show_titlebar(false)
|
||||
.menu(MenuDesc::empty())
|
||||
.set_position((x, y))
|
||||
|
@ -21,13 +21,13 @@ pub fn create(parent_widget_id: WidgetId, wait_duration: f64) -> WindowDesc<stat
|
|||
.window_size((win_width, win_height));
|
||||
}
|
||||
|
||||
fn build(parent_widget_id: WidgetId, wait_duration: f64) -> impl Widget<state::App> {
|
||||
fn build(parent_widget_id: WidgetId, rest_duration: f64) -> impl Widget<state::App> {
|
||||
Flex::column()
|
||||
.with_child(build_idle_timer(parent_widget_id, wait_duration).lens(state::App::notifier))
|
||||
.with_child(build_idle_timer(parent_widget_id, rest_duration).lens(state::App::notifier))
|
||||
.padding((8.0, 8.0))
|
||||
}
|
||||
|
||||
fn build_idle_timer(parent_widget_id: WidgetId, wait_duration: f64) -> impl Widget<state::Timer> {
|
||||
fn build_idle_timer(parent_widget_id: WidgetId, rest_duration: f64) -> impl Widget<state::Timer> {
|
||||
comp::timer::build()
|
||||
.controller(comp::timer::TimerController::new(move |ctx| {
|
||||
ctx.submit_command(cmd::DEINIT_COMP.to(Target::Widget(ctx.widget_id())));
|
||||
|
@ -41,6 +41,6 @@ fn build_idle_timer(parent_widget_id: WidgetId, wait_duration: f64) -> impl Widg
|
|||
env::TIMER_INIT_DURATION,
|
||||
env.get(env::BREAK_NOTIFIER_TIMER_DURATION),
|
||||
);
|
||||
env.set(env::TIMER_DURATION, wait_duration)
|
||||
env.set(env::TIMER_DURATION, rest_duration)
|
||||
})
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue