aboutsummaryrefslogtreecommitdiff
path: root/src/main.rs
blob: 9b896a0528a4e2cc4af2df9d16352b9e46afcfa6 (plain)
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#![allow(unused_must_use)]

use chrono::NaiveDate;

use cursive::theme::Color::*;
use cursive::theme::PaletteColor::*;
use cursive::theme::{BaseColor, BorderStyle, Palette, Theme};
use cursive::views::{Dialog, LinearLayout};
use cursive::Cursive;

mod habit;
use crate::habit::Habit;

mod views;
use crate::views::BitView;

enum ViewMode {
    Daily,
    Monthly,
}

fn pallete_gen() -> Palette {
    let mut p = Palette::default();
    p[Background] = Dark(BaseColor::Black);
    p[Shadow] = Light(BaseColor::Black);
    p[View] = Dark(BaseColor::Black);
    p[Primary] = Dark(BaseColor::White);
    p[Secondary] = Light(BaseColor::Black);
    p[Tertiary] = Dark(BaseColor::Green);
    p[TitlePrimary] = Light(BaseColor::White);
    p[Highlight] = Dark(BaseColor::Red);
    p[HighlightInactive] = Dark(BaseColor::Black);

    return p;
}

fn theme_gen() -> Theme {
    let mut t = Theme::default();
    t.shadow = false;
    t.borders = BorderStyle::Simple;
    t.palette = pallete_gen();
    return t;
}

fn main() {
    let mut work_out: Habit<bool> = Habit::new("gymming");
    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<bool> = Habit::new("reading");
    again.insert_entry(NaiveDate::from_ymd(2020, 2, 4), true);
    again.insert_entry(NaiveDate::from_ymd(2020, 2, 2), true);

    let mut s = Cursive::default();

    let gym_view = BitView::new(work_out);
    let gym_title = gym_view.get_title();

    let reading_view = BitView::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_gen());
    s.run();
}