From 743733f126d52b96cf5ea9332eb15886d581514e Mon Sep 17 00:00:00 2001 From: Akshay Date: Mon, 10 Feb 2020 20:59:14 +0530 Subject: refactor out themes --- src/main.rs | 30 +++--------------------------- src/theme.rs | 26 ++++++++++++++++++++++++++ 2 files changed, 29 insertions(+), 27 deletions(-) create mode 100644 src/theme.rs diff --git a/src/main.rs b/src/main.rs index 9b896a0..a3bbed6 100644 --- a/src/main.rs +++ b/src/main.rs @@ -2,9 +2,6 @@ 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; @@ -14,34 +11,13 @@ use crate::habit::Habit; mod views; use crate::views::BitView; +mod theme; + 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 = Habit::new("gymming"); work_out.insert_entry(NaiveDate::from_ymd(2020, 2, 4), true); @@ -71,6 +47,6 @@ fn main() { .child(Dialog::around(reading_view).title(reading_title)), ); - s.set_theme(theme_gen()); + s.set_theme(theme::theme_gen()); s.run(); } diff --git a/src/theme.rs b/src/theme.rs new file mode 100644 index 0000000..5c4072b --- /dev/null +++ b/src/theme.rs @@ -0,0 +1,26 @@ +use cursive::theme::Color::*; +use cursive::theme::PaletteColor::*; +use cursive::theme::{BaseColor, BorderStyle, Palette, Theme}; + +pub 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; +} + +pub fn theme_gen() -> Theme { + let mut t = Theme::default(); + t.shadow = false; + t.borders = BorderStyle::Simple; + t.palette = pallete_gen(); + return t; +} -- cgit v1.2.3