aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/main.rs51
1 files changed, 25 insertions, 26 deletions
diff --git a/src/main.rs b/src/main.rs
index 128df03..2b70033 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -2,51 +2,50 @@
2 2
3use chrono::NaiveDate; 3use chrono::NaiveDate;
4 4
5use cursive::views::{Dialog, LinearLayout}; 5use cursive::views::{Dialog, EditView, LinearLayout, ListView, SelectView};
6use cursive::Cursive; 6use cursive::Cursive;
7 7
8mod habit; 8mod habit;
9use crate::habit::Habit; 9use crate::habit::{Habit, HabitTrait, HabitType};
10 10
11mod views; 11mod views;
12use crate::views::bitview::BitView; 12use crate::views::habitview::HabitView;
13use crate::views::countview::CountView;
14 13
15mod theme; 14mod theme;
16 15
17enum ViewMode { 16struct App {
18 Daily, 17 habits: Vec<Habit>,
19 Monthly, 18 status: String,
20} 19}
21 20
22fn main() { 21fn main() {
23 let mut work_out: Habit<bool> = Habit::new("gymming", true);
24 work_out.insert_entry(NaiveDate::from_ymd(2020, 2, 4), true);
25 work_out.insert_entry(NaiveDate::from_ymd(2020, 2, 2), true);
26 work_out.insert_entry(NaiveDate::from_ymd(2020, 2, 3), true);
27 work_out.insert_entry(NaiveDate::from_ymd(2020, 2, 1), true);
28 work_out.insert_entry(NaiveDate::from_ymd(2020, 2, 5), false);
29 work_out.insert_entry(NaiveDate::from_ymd(2020, 2, 8), false);
30 work_out.insert_entry(NaiveDate::from_ymd(2020, 2, 11), false);
31
32 let mut again: Habit<u32> = Habit::new("reading", 5);
33 again.insert_entry(NaiveDate::from_ymd(2020, 2, 4), 4);
34 again.insert_entry(NaiveDate::from_ymd(2020, 2, 2), 2);
35 again.insert_entry(NaiveDate::from_ymd(2020, 2, 7), 5);
36
37 let mut s = Cursive::default(); 22 let mut s = Cursive::default();
38 23
39 let gym_view = BitView::new(work_out); 24 let mut gymming = Habit::new("gym", HabitType::Count(5));
40 let gym_title = gym_view.get_title(); 25 gymming.insert_entry(NaiveDate::from_ymd(2020, 2, 11), HabitType::Count(7));
26 gymming.insert_entry(NaiveDate::from_ymd(2020, 2, 12), HabitType::Count(8));
27 gymming.insert_entry(NaiveDate::from_ymd(2020, 2, 13), HabitType::Count(9));
28 gymming.insert_entry(NaiveDate::from_ymd(2020, 2, 14), HabitType::Count(10));
29 gymming.insert_entry(NaiveDate::from_ymd(2020, 2, 15), HabitType::Count(11));
30
31 let mut reading = Habit::new("read", HabitType::Count(5));
32 reading.insert_entry(NaiveDate::from_ymd(2020, 2, 11), HabitType::Bit(true));
33 reading.insert_entry(NaiveDate::from_ymd(2020, 2, 12), HabitType::Bit(false));
34 reading.insert_entry(NaiveDate::from_ymd(2020, 2, 13), HabitType::Bit(true));
35 reading.insert_entry(NaiveDate::from_ymd(2020, 2, 14), HabitType::Bit(false));
36 reading.insert_entry(NaiveDate::from_ymd(2020, 2, 15), HabitType::Bit(true));
37
38 let gym_title = gymming.get_name();
39 let gym_view = HabitView::new(gymming);
41 40
42 let reading_view = CountView::new(again); 41 let read_title = reading.get_name();
43 let reading_title = reading_view.get_title(); 42 let read_view = HabitView::new(reading);
44 43
45 s.add_global_callback('q', |a| a.quit()); 44 s.add_global_callback('q', |a| a.quit());
46 s.add_layer( 45 s.add_layer(
47 LinearLayout::horizontal() 46 LinearLayout::horizontal()
48 .child(Dialog::around(gym_view).title(gym_title)) 47 .child(Dialog::around(gym_view).title(gym_title))
49 .child(Dialog::around(reading_view).title(reading_title)), 48 .child(Dialog::around(read_view).title(read_title)),
50 ); 49 );
51 50
52 s.set_theme(theme::theme_gen()); 51 s.set_theme(theme::theme_gen());