Reformat code
This commit is contained in:
1 parent
a36613b238
commit
5817bfcd46
14 files changed
+75
-83
No files matched your search
+1
-1
@@ -172,7 +172,7 @@ impl DeckData {
|
||||
let query = dictionary.query_par(Arc::new(move |word| {
|
||||
let mut more = rhai::Map::new();
|
||||
for kv in &word.additional {
|
||||
more.insert(fields[&kv.0].clone().into(), kv.1.clone().into());
|
||||
more.insert(fields[kv.0].clone().into(), kv.1.clone().into());
|
||||
}
|
||||
let mut scope = Scope::new();
|
||||
let group_name = groups[groups
|
||||
|
||||
@@ -93,8 +93,8 @@ fn load_old_schema(connection: &Connection) -> Result<ImportData, NotificationDa
|
||||
}
|
||||
Err(IncorrectAnkiFile)
|
||||
}
|
||||
fn load_new_schema(connection: &Connection) -> Result<ImportData, NotificationData> {
|
||||
return Err(IncorrectAnkiFile);
|
||||
fn load_new_schema(_: &Connection) -> Result<ImportData, NotificationData> {
|
||||
Err(IncorrectAnkiFile)
|
||||
}
|
||||
pub fn get_words_of_group(
|
||||
connection: &Connection,
|
||||
|
||||
@@ -54,7 +54,7 @@ pub async fn load_data(id: String, temp: bool) -> MaybeError {
|
||||
.map_err(|e| WebApiUnavailable)?
|
||||
.bytes()
|
||||
.await
|
||||
.map_err(|e| WebApiUnavailable)?
|
||||
.map_err(|_| WebApiUnavailable)?
|
||||
.to_vec();
|
||||
let data = decompress(data)?;
|
||||
|
||||
@@ -64,7 +64,7 @@ pub async fn load_data(id: String, temp: bool) -> MaybeError {
|
||||
|
||||
tokio::fs::write(db_file, data)
|
||||
.await
|
||||
.map_err(|e| PermissionDenied)?;
|
||||
.map_err(|_| PermissionDenied)?;
|
||||
|
||||
let version_url = format!("{API_URL}{id}/version");
|
||||
let version = client
|
||||
|
||||
@@ -152,7 +152,7 @@ impl NavigatedPage<DictionaryMessage> for DictionaryState {
|
||||
}
|
||||
ExtendedEdit(i) => {
|
||||
self.word_editor = Some(self.editor_for_word(i));
|
||||
if let Some((_, _, index)) = self.selected_cell.clone() {
|
||||
if let Some((_, _, index)) = self.selected_cell {
|
||||
self.selected_cell = Some((i, TotalLine, index))
|
||||
}
|
||||
}
|
||||
@@ -500,9 +500,9 @@ impl DictionaryState {
|
||||
|
||||
let word_line_data = WordLineState {
|
||||
is_included: self.included.contains(word_handle),
|
||||
key: word.key.clone().into(),
|
||||
value: word.value.clone().into(),
|
||||
tags: word.tags.clone().into(),
|
||||
key: word.key.clone(),
|
||||
value: word.value.clone(),
|
||||
tags: word.tags.clone(),
|
||||
handle: *word_handle,
|
||||
selection,
|
||||
number: i,
|
||||
|
||||
@@ -9,11 +9,11 @@ use crate::pages::dictionary_quiz::DictionaryQuizMessage::*;
|
||||
use crate::pages::quiz::Score;
|
||||
use crate::styling::*;
|
||||
use crate::{jl_button, jl_text_input};
|
||||
use iced::Background::Color;
|
||||
use iced::border::Radius;
|
||||
use iced::widget::container::Style;
|
||||
use iced::widget::{Row, container, row, space, text, text_input};
|
||||
use iced::{Border, Element, Fill, Task, Theme, alignment};
|
||||
use iced::widget::{container, row, space, text, Row};
|
||||
use iced::Background::Color;
|
||||
use iced::{alignment, Border, Element, Fill, Task, Theme};
|
||||
use rand::prelude::SliceRandom;
|
||||
|
||||
pub struct DictionaryQuizState {
|
||||
|
||||
+7
-9
@@ -1,24 +1,22 @@
|
||||
use crate::app::AppState;
|
||||
use crate::core::deck::DeckData;
|
||||
use crate::core::srs::WordOpenMode;
|
||||
use crate::data::Id;
|
||||
use crate::data::entities::{CustomField, DeckSettings, EntityHandle, Exam, ExamEntry, WordData};
|
||||
use crate::data::entities::{CustomField, DeckSettings, EntityHandle, ExamEntry, WordData};
|
||||
use crate::data::repositories::Repository;
|
||||
use crate::data::Id;
|
||||
use crate::navigation::Page::PreviousPage;
|
||||
use crate::navigation::{KeyPressedPage, NavigatedPage, Page, RootMessage};
|
||||
use crate::pages::exam::ExamMessage::*;
|
||||
use crate::pages::repetition::{RepetitionMessage, play_sound};
|
||||
use crate::pages::repetition::play_sound;
|
||||
use crate::styling::*;
|
||||
use crate::{push_error, push_error_task};
|
||||
use iced::widget::space::horizontal;
|
||||
use iced::widget::{button, column, container, progress_bar, row, text, tooltip};
|
||||
use iced::{Element, Task};
|
||||
use iced_core::keyboard::key::Physical::Code;
|
||||
use iced_core::keyboard::Event;
|
||||
use iced_core::widget::text::Style;
|
||||
use iced_core::Alignment::Center;
|
||||
use iced_core::Length::Fill;
|
||||
use iced_core::keyboard::Event;
|
||||
use iced_core::keyboard::key::Physical::Code;
|
||||
use iced_core::widget::text::Style;
|
||||
use iced_core::{Theme, keyboard};
|
||||
use iced_core::{keyboard, Theme};
|
||||
use rand::prelude::SliceRandom;
|
||||
use rand::rng;
|
||||
use rodio::MixerDeviceSink;
|
||||
|
||||
+6
-6
@@ -1,7 +1,7 @@
|
||||
use crate::app::AppState;
|
||||
use crate::data::Id;
|
||||
use crate::data::entities::{DeckSettings, EntityHandle, Exam, ExamEntry, WordData};
|
||||
use crate::data::repositories::{BatchedRepository, Repository};
|
||||
use crate::data::Id;
|
||||
use crate::navigation::Page::PreviousPage;
|
||||
use crate::navigation::{NavigatedPage, Page, RootMessage};
|
||||
use crate::notification::MaybeError;
|
||||
@@ -10,7 +10,7 @@ use crate::pages::exams::ExamsMessage::*;
|
||||
use crate::pages::repetitions::Style;
|
||||
use crate::push_error;
|
||||
use crate::styling::{
|
||||
BUTTON_RADIUS, DEFAULT_SPACING, HALF_SPACING, QUARTER_SPACING, back_overlay, cta_button,
|
||||
back_overlay, cta_button, BUTTON_RADIUS, DEFAULT_SPACING, HALF_SPACING, QUARTER_SPACING,
|
||||
};
|
||||
use crate::{jl_button, push_error_task};
|
||||
use chrono::{Local, Utc};
|
||||
@@ -18,8 +18,8 @@ use iced::widget::button::Status;
|
||||
use iced::widget::container::bordered_box;
|
||||
use iced::widget::space::horizontal;
|
||||
use iced::widget::{
|
||||
Column, button, center, center_x, column, container, row, rule, scrollable, space, text,
|
||||
tooltip,
|
||||
button, center_x, column, container, row, rule, scrollable, space, text, tooltip,
|
||||
Column,
|
||||
};
|
||||
use iced::{Element, Task};
|
||||
use iced_core::Alignment::*;
|
||||
@@ -172,7 +172,7 @@ impl ExamsState {
|
||||
.iter(&state.exam.read())
|
||||
.cloned()
|
||||
.zip(handles)
|
||||
.map(|(e, h)| (h, ExamExtended::from(e, &state)))
|
||||
.map(|(e, h)| (h, ExamExtended::from(e, state)))
|
||||
.collect()
|
||||
}
|
||||
}
|
||||
@@ -338,7 +338,7 @@ impl ExamsState {
|
||||
.into()
|
||||
}
|
||||
|
||||
fn exam_ongoing_view(&self, exam: &ExamExtended) -> Element<'_, ExamsMessage> {
|
||||
fn exam_ongoing_view(&self, _: &ExamExtended) -> Element<'_, ExamsMessage> {
|
||||
center_x(
|
||||
button("Продолжить экзамен")
|
||||
.style(cta_button)
|
||||
|
||||
+1
-1
@@ -15,7 +15,7 @@ use crate::{jl_text_input, push_error};
|
||||
use iced::widget::button::danger;
|
||||
use iced::widget::container::success;
|
||||
use iced::widget::{
|
||||
Row, button, checkbox, column, container, progress_bar, row, rule, text, text_input,
|
||||
Row, button, checkbox, column, container, progress_bar, row, rule, text,
|
||||
};
|
||||
use iced::widget::{scrollable, space};
|
||||
use iced::{Element, Task};
|
||||
|
||||
@@ -12,10 +12,10 @@ use crate::{push_error, push_error_task};
|
||||
use iced::widget::button::danger;
|
||||
use iced::widget::space::horizontal;
|
||||
use iced::widget::text_input::Catalog;
|
||||
use iced::widget::{button, column, row, scrollable, space, text, text_input};
|
||||
use iced::widget::{button, column, row, scrollable, space, text};
|
||||
use iced::{Element, Task};
|
||||
use iced_core::Length::Fill;
|
||||
use iced_core::{Padding, Theme, color};
|
||||
use iced_core::{color, Padding, Theme};
|
||||
use std::sync::Arc;
|
||||
use std::time::Duration;
|
||||
|
||||
|
||||
@@ -76,10 +76,7 @@ impl NavigatedPage<RepetitionsMessage> for RepetitionsState {
|
||||
)))
|
||||
} else if let GoToExams = message {
|
||||
Some(Exams(ExamsState::new(self.selected_deck_handle.unwrap(), self.state.clone())))
|
||||
} else
|
||||
{
|
||||
None
|
||||
}
|
||||
} else { None }
|
||||
}
|
||||
fn navigated(&mut self) {
|
||||
if let Some(index) = self.selected_deck_handle {
|
||||
|
||||
+2
-2
@@ -5,7 +5,7 @@ use crate::data_provider::web_api::*;
|
||||
use crate::jl_button;
|
||||
use crate::navigation::Page::PreviousPage;
|
||||
use crate::navigation::{NavigatedPage, Page, RootMessage};
|
||||
use crate::notification::{MaybeError, NotificationData, NotificationRequest};
|
||||
use crate::notification::{NotificationData, NotificationRequest};
|
||||
use crate::pages::sync::SyncMessage::*;
|
||||
use crate::styling::*;
|
||||
use crate::{push_error, push_error_task};
|
||||
@@ -107,7 +107,7 @@ impl NavigatedPage<SyncMessage> for SyncState {
|
||||
return Task::batch([
|
||||
Task::future(async {
|
||||
tokio::time::sleep(Duration::from_millis(3000)).await;
|
||||
return RootMessage::Sync(ResetRealLoad);
|
||||
RootMessage::Sync(ResetRealLoad)
|
||||
}),
|
||||
Task::done(RootMessage::PushNotification(NotificationRequest::Warning(LocalVersionChanged)))
|
||||
]);
|
||||
|
||||
+1
-3
@@ -138,9 +138,7 @@ impl<Message: std::clone::Clone> WordEditor<Message> {
|
||||
impl<Message: std::clone::Clone> WordEditor<Message> {
|
||||
fn get_view_for_more(&self, value: (&Id, &String)) -> Element<'_, WordMessage> {
|
||||
let field = self.fields.iter().find(|f| f.id == *value.0).unwrap();
|
||||
match value.0 {
|
||||
_ => self.additional_field(value.1, field.name.as_str(), value.0.clone()),
|
||||
}
|
||||
self.additional_field(value.1, field.name.as_str(), *value.0)
|
||||
}
|
||||
|
||||
fn additional_field(&self, value: &str, name: &str, id: Id) -> Element<'_, WordMessage> {
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
use crate::data::entities::{CustomField, DeckSettings, WordData};
|
||||
use crate::data::Id;
|
||||
use iced::widget::{button, center, column, rule, space, text};
|
||||
use crate::styling::HALF_SPACING;
|
||||
use iced::widget::{button, center, column, rule, text};
|
||||
use iced_core::Alignment::Center;
|
||||
use iced_core::Length::Fill;
|
||||
use crate::styling::HALF_SPACING;
|
||||
|
||||
pub fn word_display<'a, T: 'a + Clone>(
|
||||
deck: &DeckSettings,
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
use iced::widget::MouseArea;
|
||||
use iced_core::widget::{Operation, Tree, tree};
|
||||
use iced_core::widget::{tree, Operation, Tree};
|
||||
use iced_core::{
|
||||
Clipboard, Element, Event, Layout, Length, Point, Rectangle, Shell, Size, Vector, Widget,
|
||||
layout, mouse, overlay, renderer, touch,
|
||||
layout, mouse, overlay, renderer, touch, Clipboard, Element, Event, Layout, Length, Point,
|
||||
Rectangle, Shell, Size, Vector, Widget,
|
||||
};
|
||||
|
||||
pub fn hard_mouse_area<'a, Message, Theme, Renderer>(
|
||||
@@ -161,6 +160,42 @@ where
|
||||
Renderer: renderer::Renderer,
|
||||
Message: Clone,
|
||||
{
|
||||
fn size(&self) -> Size<Length> {
|
||||
self.content.as_widget().size()
|
||||
}
|
||||
|
||||
fn layout(
|
||||
&mut self,
|
||||
tree: &mut Tree,
|
||||
renderer: &Renderer,
|
||||
limits: &layout::Limits,
|
||||
) -> layout::Node {
|
||||
self.content
|
||||
.as_widget_mut()
|
||||
.layout(&mut tree.children[0], renderer, limits)
|
||||
}
|
||||
|
||||
fn draw(
|
||||
&self,
|
||||
tree: &Tree,
|
||||
renderer: &mut Renderer,
|
||||
theme: &Theme,
|
||||
renderer_style: &renderer::Style,
|
||||
layout: Layout<'_>,
|
||||
cursor: mouse::Cursor,
|
||||
viewport: &Rectangle,
|
||||
) {
|
||||
self.content.as_widget().draw(
|
||||
&tree.children[0],
|
||||
renderer,
|
||||
theme,
|
||||
renderer_style,
|
||||
layout,
|
||||
cursor,
|
||||
viewport,
|
||||
);
|
||||
}
|
||||
|
||||
fn tag(&self) -> tree::Tag {
|
||||
tree::Tag::of::<State>()
|
||||
}
|
||||
@@ -177,21 +212,6 @@ where
|
||||
tree.diff_children(std::slice::from_ref(&self.content));
|
||||
}
|
||||
|
||||
fn size(&self) -> Size<Length> {
|
||||
self.content.as_widget().size()
|
||||
}
|
||||
|
||||
fn layout(
|
||||
&mut self,
|
||||
tree: &mut Tree,
|
||||
renderer: &Renderer,
|
||||
limits: &layout::Limits,
|
||||
) -> layout::Node {
|
||||
self.content
|
||||
.as_widget_mut()
|
||||
.layout(&mut tree.children[0], renderer, limits)
|
||||
}
|
||||
|
||||
fn operate(
|
||||
&mut self,
|
||||
tree: &mut Tree,
|
||||
@@ -231,7 +251,7 @@ where
|
||||
}
|
||||
|
||||
if self.on_enter.is_none()
|
||||
&& let Event::Mouse(mouse::Event::CursorEntered { .. }) = event
|
||||
&& let Event::Mouse(mouse::Event::CursorEntered) = event
|
||||
{
|
||||
self.content.as_widget_mut().update(
|
||||
&mut tree.children[0],
|
||||
@@ -245,7 +265,7 @@ where
|
||||
);
|
||||
}
|
||||
if self.on_exit.is_none()
|
||||
&& let Event::Mouse(mouse::Event::CursorLeft { .. }) = event
|
||||
&& let Event::Mouse(mouse::Event::CursorLeft) = event
|
||||
{
|
||||
self.content.as_widget_mut().update(
|
||||
&mut tree.children[0],
|
||||
@@ -290,27 +310,6 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
fn draw(
|
||||
&self,
|
||||
tree: &Tree,
|
||||
renderer: &mut Renderer,
|
||||
theme: &Theme,
|
||||
renderer_style: &renderer::Style,
|
||||
layout: Layout<'_>,
|
||||
cursor: mouse::Cursor,
|
||||
viewport: &Rectangle,
|
||||
) {
|
||||
self.content.as_widget().draw(
|
||||
&tree.children[0],
|
||||
renderer,
|
||||
theme,
|
||||
renderer_style,
|
||||
layout,
|
||||
cursor,
|
||||
viewport,
|
||||
);
|
||||
}
|
||||
|
||||
fn overlay<'b>(
|
||||
&'b mut self,
|
||||
tree: &'b mut Tree,
|
||||
|
||||
Reference in new issue
Block a user