aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/views.rs17
1 files changed, 12 insertions, 5 deletions
diff --git a/src/views.rs b/src/views.rs
index 77006b7..81eaf6c 100644
--- a/src/views.rs
+++ b/src/views.rs
@@ -5,7 +5,7 @@ use cursive::view::View;
5use cursive::{Printer, Vec2}; 5use cursive::{Printer, Vec2};
6 6
7use chrono::prelude::*; 7use chrono::prelude::*;
8use chrono::{Local, NaiveDate}; 8use chrono::{Duration, Local, NaiveDate};
9 9
10use crate::habit::{Bit, Count, Habit, TrackEvent}; 10use crate::habit::{Bit, Count, Habit, TrackEvent};
11use crate::CONFIGURATION; 11use crate::CONFIGURATION;
@@ -25,7 +25,13 @@ where
25 T::HabitType: std::fmt::Display, 25 T::HabitType: std::fmt::Display,
26{ 26{
27 fn draw(&self, printer: &Printer) { 27 fn draw(&self, printer: &Printer) {
28 let now = Local::now(); 28 let now = if self.view_month_offset() == 0 {
29 Local::today()
30 } else {
31 Local::today()
32 .checked_sub_signed(Duration::weeks(4 * self.view_month_offset() as i64))
33 .unwrap()
34 };
29 let year = now.year(); 35 let year = now.year();
30 let month = now.month(); 36 let month = now.month();
31 37
@@ -35,9 +41,9 @@ where
35 41
36 let goal_reached_today = self.reached_goal(Local::now().naive_utc().date()); 42 let goal_reached_today = self.reached_goal(Local::now().naive_utc().date());
37 if goal_reached_today { 43 if goal_reached_today {
38 printer.with_style(goal_reached_style, |p| p.print((0, 0), "o")); 44 printer.with_style(goal_reached_style, |p| p.print((0, 0), "[x]"));
39 } else { 45 } else {
40 printer.with_style(todo_style, |p| p.print((0, 0), "x")); 46 printer.with_style(todo_style, |p| p.print((0, 0), "[ ]"));
41 } 47 }
42 48
43 printer.with_style( 49 printer.with_style(
@@ -48,7 +54,7 @@ where
48 }, 54 },
49 |p| { 55 |p| {
50 p.print( 56 p.print(
51 (2, 0), 57 (4, 0),
52 &format!("{:width$}", self.name(), width = CONFIGURATION.view_width), 58 &format!("{:width$}", self.name(), width = CONFIGURATION.view_width),
53 ) 59 )
54 }, 60 },
@@ -75,6 +81,7 @@ where
75 i += 1; 81 i += 1;
76 } 82 }
77 } 83 }
84
78 fn required_size(&mut self, _: Vec2) -> Vec2 { 85 fn required_size(&mut self, _: Vec2) -> Vec2 {
79 (25, 6).into() 86 (25, 6).into()
80 } 87 }