1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
#![allow(unused_must_use)]
use chrono::NaiveDate;
use cursive::views::{Dialog, LinearLayout};
use cursive::Cursive;
mod habit;
use crate::habit::Habit;
mod views;
use crate::views::bitview::BitView;
use crate::views::countview::CountView;
mod theme;
enum ViewMode {
Daily,
Monthly,
}
fn main() {
let mut work_out: Habit<bool> = Habit::new("gymming", true);
work_out.insert_entry(NaiveDate::from_ymd(2020, 2, 4), true);
work_out.insert_entry(NaiveDate::from_ymd(2020, 2, 2), true);
work_out.insert_entry(NaiveDate::from_ymd(2020, 2, 3), true);
work_out.insert_entry(NaiveDate::from_ymd(2020, 2, 1), true);
work_out.insert_entry(NaiveDate::from_ymd(2020, 2, 5), false);
work_out.insert_entry(NaiveDate::from_ymd(2020, 2, 8), false);
work_out.insert_entry(NaiveDate::from_ymd(2020, 2, 11), false);
let mut again: Habit<u32> = Habit::new("reading", 5);
again.insert_entry(NaiveDate::from_ymd(2020, 2, 4), 4);
again.insert_entry(NaiveDate::from_ymd(2020, 2, 2), 2);
again.insert_entry(NaiveDate::from_ymd(2020, 2, 7), 5);
let mut s = Cursive::default();
let gym_view = BitView::new(work_out);
let gym_title = gym_view.get_title();
let reading_view = CountView::new(again);
let reading_title = reading_view.get_title();
s.add_global_callback('q', |a| a.quit());
s.add_layer(
LinearLayout::horizontal()
.child(Dialog::around(gym_view).title(gym_title))
.child(Dialog::around(reading_view).title(reading_title)),
);
s.set_theme(theme::theme_gen());
s.run();
}
|