Super repetitions optimization
This commit is contained in:
+9
-9
@@ -14,10 +14,7 @@ use iced::widget::button::{danger, Status};
|
||||
pub use iced::widget::button::{Catalog, Style};
|
||||
use iced::widget::container::bordered_box;
|
||||
use iced::widget::tooltip::Position::Top;
|
||||
use iced::widget::{
|
||||
button, column, container, radio, row, scrollable, space, svg, text, text_input, tooltip, Column,
|
||||
Row,
|
||||
};
|
||||
use iced::widget::{button, column, container, lazy, radio, row, scrollable, space, svg, text, text_input, tooltip, Column, Row};
|
||||
use iced::{Background, Border, Center, Color, Element, Fill, Length, Shadow, Task, Theme};
|
||||
use iced_core::border::Radius;
|
||||
use iced_core::svg::Handle;
|
||||
@@ -267,14 +264,15 @@ impl RepetitionsState {
|
||||
.spacing(DEFAULT_SPACING)
|
||||
.into()
|
||||
}
|
||||
|
||||
fn activity_bar(&self, set: &CardSetSettings) -> Element<'_, RepetitionsMessage> {
|
||||
const MAX_DAY_COUNT: f32 = 128.0;
|
||||
|
||||
let state = self.state.lock().unwrap();
|
||||
let history = state.activity.get(&set.id);
|
||||
let mut counts: Vec<u32> = vec![0; 30 * 7];
|
||||
|
||||
let now = Local::now().date_naive();
|
||||
|
||||
|
||||
if let Some(history) = history {
|
||||
for (date, activity) in history {
|
||||
let distance = now - *date;
|
||||
@@ -291,6 +289,7 @@ impl RepetitionsState {
|
||||
}
|
||||
}
|
||||
|
||||
lazy((counts, now), |(counts, now)| {
|
||||
let mut row = Row::new()
|
||||
.padding(Padding {
|
||||
top: 0.0,
|
||||
@@ -300,14 +299,13 @@ impl RepetitionsState {
|
||||
})
|
||||
.spacing(QUARTER_SPACING);
|
||||
|
||||
const MAX_DAY_COUNT: f32 = 128.0;
|
||||
|
||||
let mut iter = counts.into_iter();
|
||||
for i in 0..30 {
|
||||
let mut column = Column::new().spacing(QUARTER_SPACING);
|
||||
|
||||
for j in 0..7 {
|
||||
let value = iter.next().unwrap() as f32;
|
||||
let value = *iter.next().unwrap() as f32;
|
||||
let k = (value / MAX_DAY_COUNT).min(1.0) * 0.9 + 0.1;
|
||||
|
||||
let date = now.clone().checked_sub_days(Days::new(30 * 7 - i * 7 - j - 1)).unwrap();
|
||||
@@ -333,7 +331,9 @@ impl RepetitionsState {
|
||||
|
||||
row = row.push(column);
|
||||
}
|
||||
scrollable(column!["Карта активности", row].spacing(QUARTER_SPACING).align_x(Center)).into()
|
||||
scrollable(column!["Карта активности", row].spacing(QUARTER_SPACING).align_x(Center))
|
||||
}).into()
|
||||
|
||||
}
|
||||
|
||||
fn words_words_view(&self, set: &CardSetSettings) -> Element<'_, RepetitionsMessage> {
|
||||
|
||||
Reference in New Issue
Block a user