From 872297132d9d1fa39545fee54a1a25a95bdbe22d Mon Sep 17 00:00:00 2001 From: Akshay Date: Fri, 10 Jul 2020 21:52:05 +0530 Subject: use strikethrough for completion --- src/views.rs | 34 ++++++++++++++++++---------------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/src/views.rs b/src/views.rs index 81eaf6c..64c85ce 100644 --- a/src/views.rs +++ b/src/views.rs @@ -1,6 +1,6 @@ use cursive::direction::Direction; use cursive::event::{Event, EventResult, Key}; -use cursive::theme::Style; +use cursive::theme::{Effect, Style}; use cursive::view::View; use cursive::{Printer, Vec2}; @@ -39,24 +39,26 @@ where let todo_style = Style::from(CONFIGURATION.todo_color); let future_style = Style::from(CONFIGURATION.future_color); - let goal_reached_today = self.reached_goal(Local::now().naive_utc().date()); - if goal_reached_today { - printer.with_style(goal_reached_style, |p| p.print((0, 0), "[x]")); - } else { - printer.with_style(todo_style, |p| p.print((0, 0), "[ ]")); - } + let done_today_style = Style::from(Effect::Strikethrough); + + let goal_status = + self.view_month_offset() == 0 && self.reached_goal(Local::now().naive_utc().date()); printer.with_style( - if !printer.focused { - future_style - } else { - Style::none() - }, + Style::merge(&[ + if goal_status { + done_today_style + } else { + Style::none() + }, + if !printer.focused { + future_style + } else { + Style::none() + }, + ]), |p| { - p.print( - (4, 0), - &format!("{:width$}", self.name(), width = CONFIGURATION.view_width), - ) + p.print((0, 0), &format!(" {} ", self.name())); }, ); -- cgit v1.2.3