diff options
author | Akshay <[email protected]> | 2020-07-11 17:47:45 +0100 |
---|---|---|
committer | Akshay <[email protected]> | 2020-07-11 17:47:45 +0100 |
commit | ce6db76dc3d8f2f8b43a2e8769cf17416e57a065 (patch) | |
tree | 6383763aa474040d4a0060de24871a60e7231781 /src/views.rs | |
parent | 33d9ba70bee7e6271404d1db7b2724885ee5c9e8 (diff) |
begin work on month mode
Diffstat (limited to 'src/views.rs')
-rw-r--r-- | src/views.rs | 51 |
1 files changed, 31 insertions, 20 deletions
diff --git a/src/views.rs b/src/views.rs index d25e59b..facbd55 100644 --- a/src/views.rs +++ b/src/views.rs | |||
@@ -7,7 +7,7 @@ use cursive::{Printer, Vec2}; | |||
7 | use chrono::prelude::*; | 7 | use chrono::prelude::*; |
8 | use chrono::{Duration, Local, NaiveDate}; | 8 | use chrono::{Duration, Local, NaiveDate}; |
9 | 9 | ||
10 | use crate::habit::{Bit, Count, Habit, TrackEvent}; | 10 | use crate::habit::{Bit, Count, Habit, TrackEvent, ViewMode}; |
11 | use crate::CONFIGURATION; | 11 | use crate::CONFIGURATION; |
12 | 12 | ||
13 | pub trait ShadowView { | 13 | pub trait ShadowView { |
@@ -62,26 +62,37 @@ where | |||
62 | }, | 62 | }, |
63 | ); | 63 | ); |
64 | 64 | ||
65 | let mut i = 1; | 65 | // fn draw_day(&self, p: &Printer) { }; |
66 | while let Some(d) = NaiveDate::from_ymd_opt(year, month, i) { | 66 | // fn draw_month(&self, p: &Printer) {}; |
67 | let day_style; | 67 | |
68 | if self.reached_goal(d) { | 68 | // match self.view_mode() { |
69 | day_style = goal_reached_style; | 69 | // ViewMode::Day => draw_day(self, p), |
70 | } else { | 70 | // ViewMode::Month => |
71 | day_style = todo_style; | 71 | // } |
72 | } | 72 | |
73 | let coords: Vec2 = ((i % 7) * 3, i / 7 + 2).into(); | 73 | let draw_day = |p: &Printer| { |
74 | if let Some(c) = self.get_by_date(d) { | 74 | let mut i = 1; |
75 | printer.with_style(day_style, |p| { | 75 | while let Some(d) = NaiveDate::from_ymd_opt(year, month, i) { |
76 | p.print(coords, &format!("{:^3}", c)); | 76 | let day_style; |
77 | }); | 77 | if self.reached_goal(d) { |
78 | } else { | 78 | day_style = goal_reached_style; |
79 | printer.with_style(future_style, |p| { | 79 | } else { |
80 | p.print(coords, &format!("{:^3}", CONFIGURATION.future_chr)); | 80 | day_style = todo_style; |
81 | }); | 81 | } |
82 | let coords: Vec2 = ((i % 7) * 3, i / 7 + 2).into(); | ||
83 | if let Some(c) = self.get_by_date(d) { | ||
84 | printer.with_style(day_style, |p| { | ||
85 | p.print(coords, &format!("{:^3}", c)); | ||
86 | }); | ||
87 | } else { | ||
88 | printer.with_style(future_style, |p| { | ||
89 | p.print(coords, &format!("{:^3}", CONFIGURATION.future_chr)); | ||
90 | }); | ||
91 | } | ||
92 | i += 1; | ||
82 | } | 93 | } |
83 | i += 1; | 94 | }; |
84 | } | 95 | draw_day(printer); |
85 | } | 96 | } |
86 | 97 | ||
87 | fn required_size(&mut self, _: Vec2) -> Vec2 { | 98 | fn required_size(&mut self, _: Vec2) -> Vec2 { |