From ce6db76dc3d8f2f8b43a2e8769cf17416e57a065 Mon Sep 17 00:00:00 2001 From: Akshay Date: Sat, 11 Jul 2020 22:17:45 +0530 Subject: begin work on month mode --- src/views.rs | 51 +++++++++++++++++++++++++++++++-------------------- 1 file changed, 31 insertions(+), 20 deletions(-) (limited to 'src/views.rs') 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}; use chrono::prelude::*; use chrono::{Duration, Local, NaiveDate}; -use crate::habit::{Bit, Count, Habit, TrackEvent}; +use crate::habit::{Bit, Count, Habit, TrackEvent, ViewMode}; use crate::CONFIGURATION; pub trait ShadowView { @@ -62,26 +62,37 @@ where }, ); - let mut i = 1; - while let Some(d) = NaiveDate::from_ymd_opt(year, month, i) { - let day_style; - if self.reached_goal(d) { - day_style = goal_reached_style; - } else { - day_style = todo_style; - } - let coords: Vec2 = ((i % 7) * 3, i / 7 + 2).into(); - if let Some(c) = self.get_by_date(d) { - printer.with_style(day_style, |p| { - p.print(coords, &format!("{:^3}", c)); - }); - } else { - printer.with_style(future_style, |p| { - p.print(coords, &format!("{:^3}", CONFIGURATION.future_chr)); - }); + // fn draw_day(&self, p: &Printer) { }; + // fn draw_month(&self, p: &Printer) {}; + + // match self.view_mode() { + // ViewMode::Day => draw_day(self, p), + // ViewMode::Month => + // } + + let draw_day = |p: &Printer| { + let mut i = 1; + while let Some(d) = NaiveDate::from_ymd_opt(year, month, i) { + let day_style; + if self.reached_goal(d) { + day_style = goal_reached_style; + } else { + day_style = todo_style; + } + let coords: Vec2 = ((i % 7) * 3, i / 7 + 2).into(); + if let Some(c) = self.get_by_date(d) { + printer.with_style(day_style, |p| { + p.print(coords, &format!("{:^3}", c)); + }); + } else { + printer.with_style(future_style, |p| { + p.print(coords, &format!("{:^3}", CONFIGURATION.future_chr)); + }); + } + i += 1; } - i += 1; - } + }; + draw_day(printer); } fn required_size(&mut self, _: Vec2) -> Vec2 { -- cgit v1.2.3 From 0b18c65466a59b1c9f8d1bfbe596fc2750571dfb Mon Sep 17 00:00:00 2001 From: Akshay Date: Sun, 12 Jul 2020 09:30:29 +0530 Subject: fix trait bounds bug, prep for view modes --- src/views.rs | 47 ++++++++++++++++++++++++----------------------- 1 file changed, 24 insertions(+), 23 deletions(-) (limited to 'src/views.rs') 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}; use chrono::prelude::*; use chrono::{Duration, Local, NaiveDate}; -use crate::habit::{Bit, Count, Habit, TrackEvent, ViewMode}; +use crate::habit::{Bit, Count, Habit, TrackEvent}; + use crate::CONFIGURATION; pub trait ShadowView { @@ -70,29 +71,29 @@ where // ViewMode::Month => // } - let draw_day = |p: &Printer| { - let mut i = 1; - while let Some(d) = NaiveDate::from_ymd_opt(year, month, i) { - let day_style; - if self.reached_goal(d) { - day_style = goal_reached_style; - } else { - day_style = todo_style; - } - let coords: Vec2 = ((i % 7) * 3, i / 7 + 2).into(); - if let Some(c) = self.get_by_date(d) { - printer.with_style(day_style, |p| { - p.print(coords, &format!("{:^3}", c)); - }); - } else { - printer.with_style(future_style, |p| { - p.print(coords, &format!("{:^3}", CONFIGURATION.future_chr)); - }); - } - i += 1; + //let draw_day = |printer: &Printer| { + let mut i = 1; + while let Some(d) = NaiveDate::from_ymd_opt(year, month, i) { + let day_style; + if self.reached_goal(d) { + day_style = goal_reached_style; + } else { + day_style = todo_style; } - }; - draw_day(printer); + let coords: Vec2 = ((i % 7) * 3, i / 7 + 2).into(); + if let Some(c) = self.get_by_date(d) { + printer.with_style(day_style, |p| { + p.print(coords, &format!("{:^3}", c)); + }); + } else { + printer.with_style(future_style, |p| { + p.print(coords, &format!("{:^3}", CONFIGURATION.future_chr)); + }); + } + i += 1; + } + //}; + //draw_day(printer); } fn required_size(&mut self, _: Vec2) -> Vec2 { -- cgit v1.2.3