aboutsummaryrefslogtreecommitdiff
path: root/src/habit/bit.rs
diff options
context:
space:
mode:
authorAkshay <[email protected]>2021-02-06 13:30:40 +0000
committerAkshay <[email protected]>2021-02-21 05:13:14 +0000
commit53f7a679a0cf7a510de13d67cf370988f71c0d08 (patch)
treeb43b30df476d76d0a18feb7c6e7e00fd3ac4dae4 /src/habit/bit.rs
parent9cdef4e296c77fb94d99553de05ba1aaa6c81ed8 (diff)
deprecate view_month_offset in favor of cursor
Diffstat (limited to 'src/habit/bit.rs')
-rw-r--r--src/habit/bit.rs37
1 files changed, 8 insertions, 29 deletions
diff --git a/src/habit/bit.rs b/src/habit/bit.rs
index 7fe6fd9..da64ece 100644
--- a/src/habit/bit.rs
+++ b/src/habit/bit.rs
@@ -1,13 +1,12 @@
1use std::collections::HashMap; 1use std::collections::HashMap;
2use std::default::Default;
2 3
3use chrono::NaiveDate; 4use chrono::NaiveDate;
4use cursive::direction::Absolute;
5use serde::{Deserialize, Serialize}; 5use serde::{Deserialize, Serialize};
6 6
7use crate::app::Cursor;
8use crate::habit::prelude::default_auto; 7use crate::habit::prelude::default_auto;
9use crate::habit::traits::Habit; 8use crate::habit::traits::Habit;
10use crate::habit::{TrackEvent, ViewMode}; 9use crate::habit::{InnerData, TrackEvent};
11use crate::CONFIGURATION; 10use crate::CONFIGURATION;
12 11
13#[derive(Copy, Clone, Debug, Serialize, Deserialize)] 12#[derive(Copy, Clone, Debug, Serialize, Deserialize)]
@@ -44,13 +43,7 @@ pub struct Bit {
44 auto: bool, 43 auto: bool,
45 44
46 #[serde(skip)] 45 #[serde(skip)]
47 view_month_offset: u32, 46 inner_data: InnerData,
48
49 #[serde(skip)]
50 cursor: Cursor,
51
52 #[serde(skip)]
53 view_mode: ViewMode,
54} 47}
55 48
56impl Bit { 49impl Bit {
@@ -60,9 +53,7 @@ impl Bit {
60 stats: HashMap::new(), 53 stats: HashMap::new(),
61 goal: CustomBool(true), 54 goal: CustomBool(true),
62 auto, 55 auto,
63 view_month_offset: 0, 56 inner_data: Default::default(),
64 cursor: Cursor::new(),
65 view_mode: ViewMode::Day,
66 }; 57 };
67 } 58 }
68} 59}
@@ -124,23 +115,11 @@ impl Habit for Bit {
124 } 115 }
125 } 116 }
126 } 117 }
127 fn set_view_month_offset(&mut self, offset: u32) { 118 fn inner_data_ref(&self) -> &InnerData {
128 self.view_month_offset = offset; 119 &self.inner_data
129 }
130 fn view_month_offset(&self) -> u32 {
131 self.view_month_offset
132 }
133 fn move_cursor(&mut self, d: Absolute) {
134 self.cursor.do_move(d);
135 }
136 fn cursor(&self) -> Cursor {
137 self.cursor
138 }
139 fn set_view_mode(&mut self, mode: ViewMode) {
140 self.view_mode = mode;
141 } 120 }
142 fn view_mode(&self) -> ViewMode { 121 fn inner_data_mut_ref(&mut self) -> &mut InnerData {
143 self.view_mode 122 &mut self.inner_data
144 } 123 }
145 fn is_auto(&self) -> bool { 124 fn is_auto(&self) -> bool {
146 self.auto 125 self.auto