From a97a4d42bb30b76589c7195de8b10ca3c2090deb Mon Sep 17 00:00:00 2001
From: Akshay <nerdy@peppe.rs>
Date: Mon, 29 Jun 2020 15:28:24 +0530
Subject: change drawing logic

---
 src/views.rs | 42 +++++++++++++++++-------------------------
 1 file changed, 17 insertions(+), 25 deletions(-)

(limited to 'src')

diff --git a/src/views.rs b/src/views.rs
index 975864c..b18e960 100644
--- a/src/views.rs
+++ b/src/views.rs
@@ -47,33 +47,25 @@ where
             },
         );
 
-        for i in 1..=31 {
-            let day = NaiveDate::from_ymd_opt(year, month, i);
+        let mut i = 1;
+        while let Some(d) = NaiveDate::from_ymd_opt(year, month, i) {
             let day_style;
-
-            if let Some(d) = day {
-                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));
-                    });
-                }
-                //printer.with_style(day_style, |p| {
-                //        p.print(coords, &format!("{:^3}", c));
-                //    } else {
-                //        p.print(coords, &format!("{:^3}", CONFIGURATION.future_chr));
-                //    }
-                //});
+            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;
         }
     }
     fn required_size(&mut self, _: Vec2) -> Vec2 {
-- 
cgit v1.2.3