aboutsummaryrefslogtreecommitdiff
path: root/src/views.rs
diff options
context:
space:
mode:
authorAkshay <[email protected]>2020-07-12 05:00:29 +0100
committerAkshay <[email protected]>2020-07-12 05:00:29 +0100
commit0b18c65466a59b1c9f8d1bfbe596fc2750571dfb (patch)
tree7ce5dce6c70c4212153812bab78d2f3c3f462694 /src/views.rs
parentfbb0c754f4029cc93033ff4aabb28a8ab9c1e7e7 (diff)
fix trait bounds bug, prep for view modes
Diffstat (limited to 'src/views.rs')
-rw-r--r--src/views.rs47
1 files changed, 24 insertions, 23 deletions
diff --git a/src/views.rs b/src/views.rs
index facbd55..3e623a9 100644
--- a/src/views.rs
+++ b/src/views.rs
@@ -7,7 +7,8 @@ use cursive::{Printer, Vec2};
7use chrono::prelude::*; 7use chrono::prelude::*;
8use chrono::{Duration, Local, NaiveDate}; 8use chrono::{Duration, Local, NaiveDate};
9 9
10use crate::habit::{Bit, Count, Habit, TrackEvent, ViewMode}; 10use crate::habit::{Bit, Count, Habit, TrackEvent};
11
11use crate::CONFIGURATION; 12use crate::CONFIGURATION;
12 13
13pub trait ShadowView { 14pub trait ShadowView {
@@ -70,29 +71,29 @@ where
70 // ViewMode::Month => 71 // ViewMode::Month =>
71 // } 72 // }
72 73
73 let draw_day = |p: &Printer| { 74 //let draw_day = |printer: &Printer| {
74 let mut i = 1; 75 let mut i = 1;
75 while let Some(d) = NaiveDate::from_ymd_opt(year, month, i) { 76 while let Some(d) = NaiveDate::from_ymd_opt(year, month, i) {
76 let day_style; 77 let day_style;
77 if self.reached_goal(d) { 78 if self.reached_goal(d) {
78 day_style = goal_reached_style; 79 day_style = goal_reached_style;
79 } else { 80 } else {
80 day_style = todo_style; 81 day_style = todo_style;
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;
93 } 82 }
94 }; 83 let coords: Vec2 = ((i % 7) * 3, i / 7 + 2).into();
95 draw_day(printer); 84 if let Some(c) = self.get_by_date(d) {
85 printer.with_style(day_style, |p| {
86 p.print(coords, &format!("{:^3}", c));
87 });
88 } else {
89 printer.with_style(future_style, |p| {
90 p.print(coords, &format!("{:^3}", CONFIGURATION.future_chr));
91 });
92 }
93 i += 1;
94 }
95 //};
96 //draw_day(printer);
96 } 97 }
97 98
98 fn required_size(&mut self, _: Vec2) -> Vec2 { 99 fn required_size(&mut self, _: Vec2) -> Vec2 {