Formatting
This commit is contained in:
1 parent
dddac01bdf
commit
10cf7f0d2e
29 files changed
+138
-138
No files matched your search
@@ -1,8 +1,9 @@
|
||||
use crate::data::entities::WordData;
|
||||
use crate::navigation::Page::PreviousPage;
|
||||
use crate::navigation::RootMessage;
|
||||
use crate::navigation::*;
|
||||
use crate::pages::dictionary::split_with_coma;
|
||||
use crate::pages::dictionary_quiz::DictionaryQuizMessage::*;
|
||||
use crate::navigation::Page::PreviousPage;
|
||||
use crate::navigation::*;
|
||||
use crate::pages::quiz::Score;
|
||||
use crate::styling::*;
|
||||
use iced::Background::Color;
|
||||
@@ -11,7 +12,6 @@ use iced::widget::container::Style;
|
||||
use iced::widget::{Row, button, container, row, space, text, text_input};
|
||||
use iced::{Border, Element, Fill, Task, Theme, alignment};
|
||||
use rand::prelude::SliceRandom;
|
||||
use crate::data::entities::WordData;
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct DictionaryQuizState {
|
||||
@@ -147,7 +147,8 @@ impl DictionaryQuizState {
|
||||
self.score.total += 1;
|
||||
}
|
||||
if self.answer.to_lowercase() == self.correct.to_lowercase()
|
||||
|| split_with_coma(self.correct.to_lowercase().as_str()).contains(&self.answer.to_lowercase())
|
||||
|| split_with_coma(self.correct.to_lowercase().as_str())
|
||||
.contains(&self.answer.to_lowercase())
|
||||
{
|
||||
if !self.is_help {
|
||||
self.score.correct += 1;
|
||||
|
||||
@@ -1,6 +1,10 @@
|
||||
use crate::data_provider::history::{get_history_of_set};
|
||||
use crate::app::AppState;
|
||||
use crate::data::INVALID_ID;
|
||||
use crate::data::entities::{HistoryItem, WordData};
|
||||
use crate::data_provider::history::get_history_of_set;
|
||||
use crate::navigation::*;
|
||||
use crate::styling::*;
|
||||
use HistoryMessage::Back;
|
||||
use chrono::Local;
|
||||
use iced::alignment::Horizontal::Center;
|
||||
use iced::widget::space::horizontal;
|
||||
@@ -8,10 +12,6 @@ use iced::widget::*;
|
||||
use iced::{Element, Fill, FillPortion, Task};
|
||||
use parking_lot::Mutex;
|
||||
use std::sync::Arc;
|
||||
use HistoryMessage::Back;
|
||||
use crate::app::AppState;
|
||||
use crate::data::entities::{HistoryItem, WordData};
|
||||
use crate::data::INVALID_ID;
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct HistoryState {
|
||||
|
||||
+10
-9
@@ -1,10 +1,13 @@
|
||||
use crate::app::AppState;
|
||||
use crate::data::entities::{WordData, WordGroup};
|
||||
use crate::data_provider::import::{ImportData, ImportGroup, get_words_of_group, load_groups};
|
||||
use crate::data_provider::words::{add_group, add_words};
|
||||
use crate::pages::import::ImportMessage::*;
|
||||
use crate::data::entities::{WordData, WordGroup};
|
||||
use crate::fs::*;
|
||||
use crate::navigation::{NavigatedPage, Page, RootMessage};
|
||||
use crate::notification::NotificationData::OpenFileError;
|
||||
use crate::notification::{MaybeError, NotificationData};
|
||||
use crate::pages::import::ImportMessage::*;
|
||||
use crate::push_error;
|
||||
use crate::styling::*;
|
||||
use iced::widget::button::danger;
|
||||
use iced::widget::container::success;
|
||||
@@ -16,6 +19,7 @@ use iced::{Element, Task};
|
||||
use iced_core::Alignment::Center;
|
||||
use iced_core::Length::Fill;
|
||||
use iced_core::Padding;
|
||||
use log::info;
|
||||
use parking_lot::Mutex;
|
||||
use rfd::AsyncFileDialog;
|
||||
use rusqlite::Connection;
|
||||
@@ -23,12 +27,8 @@ use std::fs::{File, OpenOptions};
|
||||
use std::io::BufReader;
|
||||
use std::path::PathBuf;
|
||||
use std::sync::Arc;
|
||||
use log::info;
|
||||
use tokio::task::spawn_blocking;
|
||||
use zip::ZipArchive;
|
||||
use crate::app::AppState;
|
||||
use crate::fs::*;
|
||||
use crate::push_error;
|
||||
|
||||
const DEFAULT_FIELDS: [&str; 6] = ["key", "value", "tags", "reading", "context", "description"];
|
||||
|
||||
@@ -433,7 +433,8 @@ impl ImportState {
|
||||
async move {
|
||||
spawn_blocking(move || {
|
||||
let temp_file_path = temp_import_path();
|
||||
let connection = Connection::open(&temp_file_path).map_err(|_| OpenFileError)?;
|
||||
let connection =
|
||||
Connection::open(&temp_file_path).map_err(|_| OpenFileError)?;
|
||||
let import_list = get_words_of_group(&connection, group.id)?;
|
||||
let mut words_list = Vec::with_capacity(import_list.len());
|
||||
|
||||
@@ -500,8 +501,8 @@ impl ImportState {
|
||||
},
|
||||
|r: Result<(), NotificationData>| match r {
|
||||
Ok(_) => RootMessage::Import(ImportFinished),
|
||||
Err(err) => push_error!(err)
|
||||
}
|
||||
Err(err) => push_error!(err),
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
+2
-3
@@ -1,4 +1,5 @@
|
||||
|
||||
use crate::app::USER_FONT;
|
||||
use crate::core::kana_set::KanaSet;
|
||||
use crate::navigation::Page::PreviousPage;
|
||||
use crate::navigation::{NavigatedPage, Page, RootMessage};
|
||||
use crate::pages::quiz::QuizMessage::*;
|
||||
@@ -6,8 +7,6 @@ use crate::styling::*;
|
||||
use iced::widget::*;
|
||||
use iced::{Element, Fill, Task, alignment};
|
||||
use rand::seq::SliceRandom;
|
||||
use crate::app::USER_FONT;
|
||||
use crate::core::kana_set::KanaSet;
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct QuizState {
|
||||
|
||||
@@ -334,10 +334,7 @@ pub enum RepetitionMessage {
|
||||
PlayFinished,
|
||||
}
|
||||
|
||||
async fn play_sound(
|
||||
sink: Arc<Option<MixerDeviceSink>>,
|
||||
text: String,
|
||||
) -> MaybeError {
|
||||
async fn play_sound(sink: Arc<Option<MixerDeviceSink>>, text: String) -> MaybeError {
|
||||
let data = get_voice(text.as_str()).await?;
|
||||
spawn_blocking(move || {
|
||||
if let Some(sink) = sink.as_ref()
|
||||
|
||||
@@ -13,7 +13,7 @@ use iced::widget::text_input::Catalog;
|
||||
use iced::widget::{button, column, row, scrollable, space, text, text_input};
|
||||
use iced::{Element, Task};
|
||||
use iced_core::Length::Fill;
|
||||
use iced_core::{color, Padding, Theme};
|
||||
use iced_core::{Padding, Theme, color};
|
||||
use parking_lot::Mutex;
|
||||
use std::sync::Arc;
|
||||
use std::time::Duration;
|
||||
@@ -63,12 +63,12 @@ impl NavigatedPage<RepetitionSettingsMessage> for RepetitionSettingsState {
|
||||
Save => {
|
||||
let mut state = self.state.lock();
|
||||
if let Err(e) = update_deck(&mut self.set, &state.connection) {
|
||||
return push_error_task!(e)
|
||||
return push_error_task!(e);
|
||||
}
|
||||
if self.filter_changed
|
||||
&& let Err(e) = update_deck_stats(&self.set, &state)
|
||||
{
|
||||
return push_error_task!(e)
|
||||
return push_error_task!(e);
|
||||
}
|
||||
state.decks[self.index] = self.set.clone();
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
use crate::app::AppState;
|
||||
use crate::core::srs::{AppendMode, OrderMode};
|
||||
use crate::data::entities::{CardStatistics, DeckSettings};
|
||||
use crate::data::Id;
|
||||
use crate::data::entities::{CardStatistics, DeckSettings};
|
||||
use crate::data_provider::card_sets::update_deck;
|
||||
use crate::data_provider::card_stats::{add_stat_list, load_stats_of_deck};
|
||||
use crate::navigation::Page::{History, PreviousPage, Repetition, RepetitionSettings};
|
||||
@@ -16,17 +16,17 @@ use crate::push_error_task;
|
||||
use crate::styling::*;
|
||||
use chrono::{Days, Local, Utc};
|
||||
use hashbrown::{HashMap, HashSet};
|
||||
use iced::widget::button::{danger, Status};
|
||||
pub use iced::widget::button::{Catalog, Style};
|
||||
use iced::widget::button::{Status, danger};
|
||||
use iced::widget::tooltip::Position::Top;
|
||||
use iced::widget::{
|
||||
button, column, container, lazy, radio, row, scrollable, space, svg, text, text_input, tooltip,
|
||||
Column, Row,
|
||||
Column, Row, button, column, container, lazy, radio, row, scrollable, space, svg, text,
|
||||
text_input, tooltip,
|
||||
};
|
||||
use iced::{Background, Border, Center, Color, Element, Fill, Length, Shadow, Task, Theme};
|
||||
use iced_core::Padding;
|
||||
use iced_core::border::Radius;
|
||||
use iced_core::svg::Handle;
|
||||
use iced_core::Padding;
|
||||
use parking_lot::Mutex;
|
||||
use std::ops::Deref;
|
||||
use std::sync::Arc;
|
||||
@@ -53,7 +53,7 @@ impl NavigatedPage<RepetitionsMessage> for RepetitionsState {
|
||||
|
||||
let selected_set = self.selected_deck_mut().unwrap();
|
||||
if selected_set.append_mode == AppendMode::Full {
|
||||
if let Err(_err) = Self::append_all_words(&mut clone.lock(), selected_set){
|
||||
if let Err(_err) = Self::append_all_words(&mut clone.lock(), selected_set) {
|
||||
return None;
|
||||
}
|
||||
selected_set.existing_words_indices = selected_set.available_words_indices.clone();
|
||||
|
||||
@@ -1,12 +1,15 @@
|
||||
use crate::pages::dictionary::DictionaryState;
|
||||
use crate::app::AppState;
|
||||
use crate::core::kana_set::{KanaSet, KanaType};
|
||||
use crate::navigation::Page::*;
|
||||
use crate::navigation::{NavigatedPage, Page, RootMessage};
|
||||
use crate::pages::dictionary::DictionaryState;
|
||||
use crate::pages::quiz::QuizState;
|
||||
use crate::pages::randomizer::RandomizerState;
|
||||
use crate::pages::repetitions::RepetitionsState;
|
||||
use crate::pages::selector::SelectorMessage::ChangeMode;
|
||||
use crate::styling::*;
|
||||
use crate::pages::sync::SyncState;
|
||||
use crate::pages::writing::WritingState;
|
||||
use crate::styling::*;
|
||||
use iced::widget::button::{Status, Style};
|
||||
use iced::widget::*;
|
||||
use iced::{Element, Task, alignment};
|
||||
@@ -15,9 +18,6 @@ use iced_core::Background;
|
||||
use iced_core::Color;
|
||||
use parking_lot::Mutex;
|
||||
use std::sync::Arc;
|
||||
use crate::app::AppState;
|
||||
use crate::core::kana_set::{KanaSet, KanaType};
|
||||
use crate::pages::quiz::QuizState;
|
||||
|
||||
pub struct SelectorState {
|
||||
pub set: KanaSet,
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
|
||||
use crate::core::kana_set::KanaSet;
|
||||
use crate::navigation::Page::PreviousPage;
|
||||
use crate::navigation::{NavigatedPage, Page, RootMessage};
|
||||
use crate::styling::*;
|
||||
use iced::widget::*;
|
||||
use iced::{Element, Fill, Task, alignment};
|
||||
use rand::seq::SliceRandom;
|
||||
use crate::core::kana_set::KanaSet;
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct WritingState {
|
||||
|
||||
Reference in new issue
Block a user