Data provider refactor #11
No files matched your search
+12
-12
@@ -1,21 +1,21 @@
|
|||||||
use chrono::NaiveDate;
|
use crate::data::Id;
|
||||||
use hashbrown::HashMap;
|
|
||||||
use iced::{keyboard, window, Subscription};
|
|
||||||
use iced_core::{Font, Size, Theme};
|
|
||||||
use iced_core::window::Position;
|
|
||||||
#[cfg(target_os = "linux")]
|
|
||||||
use iced_core::window::settings::PlatformSpecific;
|
|
||||||
use log::info;
|
|
||||||
use rusqlite::Connection;
|
|
||||||
use crate::data::entities::DeckSettings;
|
use crate::data::entities::DeckSettings;
|
||||||
|
use crate::data::entities::{WordData, WordGroup};
|
||||||
use crate::data_provider::card_sets::load_sets;
|
use crate::data_provider::card_sets::load_sets;
|
||||||
use crate::data_provider::settings::get_setting;
|
use crate::data_provider::settings::get_setting;
|
||||||
use crate::data_provider::sqlite::default_connection;
|
use crate::data_provider::sqlite::default_connection;
|
||||||
use crate::data_provider::words::{load_word_groups, load_words};
|
use crate::data_provider::words::{load_word_groups, load_words};
|
||||||
use crate::data::entities::{ WordData, WordGroup};
|
|
||||||
use crate::data::Id;
|
|
||||||
use crate::navigation::{AppSettings, RootMessage, ScreenState};
|
|
||||||
use crate::navigation::RootMessage::Keyboard;
|
use crate::navigation::RootMessage::Keyboard;
|
||||||
|
use crate::navigation::{AppSettings, RootMessage, ScreenState};
|
||||||
|
use chrono::NaiveDate;
|
||||||
|
use hashbrown::HashMap;
|
||||||
|
use iced::{Subscription, keyboard, window};
|
||||||
|
use iced_core::window::Position;
|
||||||
|
#[cfg(target_os = "linux")]
|
||||||
|
use iced_core::window::settings::PlatformSpecific;
|
||||||
|
use iced_core::{Font, Size, Theme};
|
||||||
|
use log::info;
|
||||||
|
use rusqlite::Connection;
|
||||||
pub const USER_FONT: Font = Font::with_name("Noto Sans JP");
|
pub const USER_FONT: Font = Font::with_name("Noto Sans JP");
|
||||||
|
|
||||||
pub fn start() -> iced::Result {
|
pub fn start() -> iced::Result {
|
||||||
|
|||||||
+1
-1
@@ -1,3 +1,3 @@
|
|||||||
|
pub mod deck;
|
||||||
pub mod kana_set;
|
pub mod kana_set;
|
||||||
pub mod srs;
|
pub mod srs;
|
||||||
pub mod deck;
|
|
||||||
@@ -198,4 +198,4 @@ impl PartialEq<Self> for KanaSet {
|
|||||||
fn eq(&self, other: &Self) -> bool {
|
fn eq(&self, other: &Self) -> bool {
|
||||||
self.name == other.name
|
self.name == other.name
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+1
-2
@@ -161,8 +161,7 @@ impl WorstWordsSRSModule {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
fn fill_pool(&mut self, set: &[CardStatistics]) {
|
fn fill_pool(&mut self, set: &[CardStatistics]) {
|
||||||
let mut sorted = set.iter().enumerate()
|
let mut sorted = set.iter().enumerate().collect::<Vec<_>>();
|
||||||
.collect::<Vec<_>>();
|
|
||||||
sorted.sort_by_key(|c| c.1.score);
|
sorted.sort_by_key(|c| c.1.score);
|
||||||
let mut worst = sorted[0..self.pool_size]
|
let mut worst = sorted[0..self.pool_size]
|
||||||
.iter()
|
.iter()
|
||||||
|
|||||||
+3
-3
@@ -1,10 +1,10 @@
|
|||||||
pub mod entities;
|
pub mod entities;
|
||||||
|
|
||||||
|
use rusqlite::ToSql;
|
||||||
|
use rusqlite::types::{FromSql, FromSqlError, FromSqlResult, ToSqlOutput, ValueRef};
|
||||||
use std::fmt::{Display, Formatter};
|
use std::fmt::{Display, Formatter};
|
||||||
use std::num::ParseIntError;
|
use std::num::ParseIntError;
|
||||||
use std::str::FromStr;
|
use std::str::FromStr;
|
||||||
use rusqlite::ToSql;
|
|
||||||
use rusqlite::types::{FromSql, FromSqlError, FromSqlResult, ToSqlOutput, ValueRef};
|
|
||||||
|
|
||||||
#[derive(Clone, PartialEq, Eq, Debug, Hash, Copy, Ord, PartialOrd, Default)]
|
#[derive(Clone, PartialEq, Eq, Debug, Hash, Copy, Ord, PartialOrd, Default)]
|
||||||
pub struct Id(pub(crate) u32);
|
pub struct Id(pub(crate) u32);
|
||||||
@@ -59,4 +59,4 @@ impl Id {
|
|||||||
pub(crate) fn is_valid(self) -> bool {
|
pub(crate) fn is_valid(self) -> bool {
|
||||||
self.0 != 0
|
self.0 != 0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -111,7 +111,7 @@ impl DeckSettings {
|
|||||||
|
|
||||||
let result = engine.eval_ast_with_scope::<bool>(&mut scope, &ast);
|
let result = engine.eval_ast_with_scope::<bool>(&mut scope, &ast);
|
||||||
if let Ok(result) = result {
|
if let Ok(result) = result {
|
||||||
return result
|
return result;
|
||||||
}
|
}
|
||||||
false
|
false
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
use crate::core::srs::OrderMode;
|
use crate::core::srs::OrderMode;
|
||||||
|
|
||||||
use crate::data::entities::DeckSettings;
|
use crate::data::entities::DeckSettings;
|
||||||
use rusqlite::Connection;
|
|
||||||
use crate::notification::{MaybeError, NotificationData};
|
|
||||||
use crate::notification::NotificationData::{DbLoadError, DbSaveError};
|
use crate::notification::NotificationData::{DbLoadError, DbSaveError};
|
||||||
|
use crate::notification::{MaybeError, NotificationData};
|
||||||
|
use rusqlite::Connection;
|
||||||
|
|
||||||
pub fn load_sets(connection: &Connection) -> Result<Vec<DeckSettings>, NotificationData> {
|
pub fn load_sets(connection: &Connection) -> Result<Vec<DeckSettings>, NotificationData> {
|
||||||
let mut stmt = connection
|
let mut stmt = connection
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
use crate::data::entities::{CardStatistics, DeckSettings};
|
use crate::data::entities::{CardStatistics, DeckSettings};
|
||||||
use crate::notification::{MaybeError, NotificationData};
|
|
||||||
use crate::notification::NotificationData::{DbLoadError, DbSaveError};
|
use crate::notification::NotificationData::{DbLoadError, DbSaveError};
|
||||||
|
use crate::notification::{MaybeError, NotificationData};
|
||||||
use log::info;
|
use log::info;
|
||||||
use rusqlite::{Connection, params};
|
use rusqlite::{Connection, params};
|
||||||
use std::time::Instant;
|
use std::time::Instant;
|
||||||
@@ -32,7 +32,9 @@ pub fn load_stats_of_deck(
|
|||||||
|
|
||||||
pub fn add_stat_list(stats: &mut [CardStatistics], connection: &mut Connection) -> MaybeError {
|
pub fn add_stat_list(stats: &mut [CardStatistics], connection: &mut Connection) -> MaybeError {
|
||||||
let time = Instant::now();
|
let time = Instant::now();
|
||||||
let tx = connection.transaction().expect("Failed to create transaction");
|
let tx = connection
|
||||||
|
.transaction()
|
||||||
|
.expect("Failed to create transaction");
|
||||||
let count = stats.len();
|
let count = stats.len();
|
||||||
|
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -2,8 +2,8 @@ use crate::core::srs::WordOpenMode;
|
|||||||
use crate::data::Id;
|
use crate::data::Id;
|
||||||
use crate::data::entities::HistoryItem;
|
use crate::data::entities::HistoryItem;
|
||||||
use crate::fs::*;
|
use crate::fs::*;
|
||||||
use crate::notification::{MaybeError, NotificationData};
|
|
||||||
use crate::notification::NotificationData::PermissionDenied;
|
use crate::notification::NotificationData::PermissionDenied;
|
||||||
|
use crate::notification::{MaybeError, NotificationData};
|
||||||
use chrono::DateTime;
|
use chrono::DateTime;
|
||||||
use std::fs::{File, OpenOptions};
|
use std::fs::{File, OpenOptions};
|
||||||
use std::io::Write;
|
use std::io::Write;
|
||||||
@@ -29,7 +29,6 @@ fn append_lines_if_exists(path: PathBuf, lines: &mut Vec<String>) -> MaybeError
|
|||||||
.for_each(|i| lines.push(i));
|
.for_each(|i| lines.push(i));
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn parse_history_items(strings: Vec<String>) -> Vec<HistoryItem> {
|
fn parse_history_items(strings: Vec<String>) -> Vec<HistoryItem> {
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
|
use crate::helpers::into_result;
|
||||||
use crate::notification::NotificationData;
|
use crate::notification::NotificationData;
|
||||||
|
use crate::notification::NotificationData::IncorrectAnkiFile;
|
||||||
use hashbrown::HashMap;
|
use hashbrown::HashMap;
|
||||||
use log::info;
|
use log::info;
|
||||||
use rusqlite::Connection;
|
use rusqlite::Connection;
|
||||||
use serde_json::Value;
|
use serde_json::Value;
|
||||||
use crate::helpers::into_result;
|
|
||||||
use crate::notification::NotificationData::IncorrectAnkiFile;
|
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub struct ImportData(pub(crate) Vec<ImportGroup>);
|
pub struct ImportData(pub(crate) Vec<ImportGroup>);
|
||||||
@@ -29,8 +29,7 @@ pub fn load_groups(connection: &Connection) -> Result<ImportData, NotificationDa
|
|||||||
let json_models: String = connection
|
let json_models: String = connection
|
||||||
.query_one("select models from col", (), |row| row.get(0))
|
.query_one("select models from col", (), |row| row.get(0))
|
||||||
.map_err(|_| IncorrectAnkiFile)?;
|
.map_err(|_| IncorrectAnkiFile)?;
|
||||||
let raw: Value = serde_json::from_str(json_models.as_str())
|
let raw: Value = serde_json::from_str(json_models.as_str()).map_err(|_| IncorrectAnkiFile)?;
|
||||||
.map_err(|_| IncorrectAnkiFile)?;
|
|
||||||
let sets = raw.as_object();
|
let sets = raw.as_object();
|
||||||
if let Some(sets) = sets {
|
if let Some(sets) = sets {
|
||||||
let mut total_data = ImportData(vec![]);
|
let mut total_data = ImportData(vec![]);
|
||||||
@@ -48,14 +47,13 @@ pub fn load_groups(connection: &Connection) -> Result<ImportData, NotificationDa
|
|||||||
for (_, collection) in sets {
|
for (_, collection) in sets {
|
||||||
let fields_property = collection.get("fields");
|
let fields_property = collection.get("fields");
|
||||||
if let Some(fields_property) = fields_property {
|
if let Some(fields_property) = fields_property {
|
||||||
let fields = into_result(fields_property
|
let fields = into_result(fields_property.as_array(), IncorrectAnkiFile)?
|
||||||
.as_array(), IncorrectAnkiFile)?
|
|
||||||
.iter()
|
.iter()
|
||||||
.filter_map(|x| x.get("name"))
|
.filter_map(|x| x.get("name"))
|
||||||
.map(|x| x.as_str().unwrap().to_string())
|
.map(|x| x.as_str().unwrap().to_string())
|
||||||
.collect();
|
.collect();
|
||||||
let id = collection.get("id");
|
let id = collection.get("id");
|
||||||
if id.is_none() || id.unwrap().as_u64().is_none(){
|
if id.is_none() || id.unwrap().as_u64().is_none() {
|
||||||
return Err(IncorrectAnkiFile);
|
return Err(IncorrectAnkiFile);
|
||||||
}
|
}
|
||||||
let id = id.unwrap().as_u64().unwrap();
|
let id = id.unwrap().as_u64().unwrap();
|
||||||
@@ -80,12 +78,15 @@ pub fn load_groups(connection: &Connection) -> Result<ImportData, NotificationDa
|
|||||||
total_data.0.push(group);
|
total_data.0.push(group);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return Ok(total_data)
|
return Ok(total_data);
|
||||||
}
|
}
|
||||||
Err(IncorrectAnkiFile)
|
Err(IncorrectAnkiFile)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_words_of_group(connection: &Connection, group_id: u64) -> Result<Vec<ImportNote>, NotificationData> {
|
pub fn get_words_of_group(
|
||||||
|
connection: &Connection,
|
||||||
|
group_id: u64,
|
||||||
|
) -> Result<Vec<ImportNote>, NotificationData> {
|
||||||
let mut count_stmt = connection
|
let mut count_stmt = connection
|
||||||
.prepare("select tags, flds from notes where mid == ?1;")
|
.prepare("select tags, flds from notes where mid == ?1;")
|
||||||
.map_err(|_| IncorrectAnkiFile)?;
|
.map_err(|_| IncorrectAnkiFile)?;
|
||||||
|
|||||||
@@ -17,11 +17,7 @@ pub fn get_setting(key: String, connection: &Connection) -> Option<String> {
|
|||||||
None
|
None
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn set_setting(
|
pub fn set_setting(key: String, value: String, connection: &Connection) -> MaybeError {
|
||||||
key: String,
|
|
||||||
value: String,
|
|
||||||
connection: &Connection,
|
|
||||||
) -> MaybeError {
|
|
||||||
let current = get_settings_list(connection)?;
|
let current = get_settings_list(connection)?;
|
||||||
if current.contains(&key) {
|
if current.contains(&key) {
|
||||||
update_settings(key, value, connection)?;
|
update_settings(key, value, connection)?;
|
||||||
@@ -39,11 +35,7 @@ pub fn delete_settings(key: String, connection: &Connection) -> MaybeError {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn create_settings(
|
fn create_settings(key: String, value: String, connection: &Connection) -> MaybeError {
|
||||||
key: String,
|
|
||||||
value: String,
|
|
||||||
connection: &Connection,
|
|
||||||
) -> MaybeError {
|
|
||||||
connection
|
connection
|
||||||
.execute(
|
.execute(
|
||||||
"INSERT into settings (id, value) VALUES (?1, ?2)",
|
"INSERT into settings (id, value) VALUES (?1, ?2)",
|
||||||
@@ -53,11 +45,7 @@ fn create_settings(
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn update_settings(
|
fn update_settings(key: String, value: String, connection: &Connection) -> MaybeError {
|
||||||
key: String,
|
|
||||||
value: String,
|
|
||||||
connection: &Connection,
|
|
||||||
) -> MaybeError {
|
|
||||||
connection
|
connection
|
||||||
.execute(
|
.execute(
|
||||||
"update settings
|
"update settings
|
||||||
|
|||||||
@@ -1,12 +1,14 @@
|
|||||||
use rusqlite::Connection;
|
|
||||||
use crate::fs::*;
|
use crate::fs::*;
|
||||||
|
use rusqlite::Connection;
|
||||||
|
|
||||||
pub fn create_db() {
|
pub fn create_db() {
|
||||||
let db_file = db_path();
|
let db_file = db_path();
|
||||||
if !db_file.exists() {
|
if !db_file.exists() {
|
||||||
std::fs::File::create(&db_file).expect("Database file creation failed");
|
std::fs::File::create(&db_file).expect("Database file creation failed");
|
||||||
let connection = Connection::open(&db_file).expect("Connection open failed");
|
let connection = Connection::open(&db_file).expect("Connection open failed");
|
||||||
connection.execute("PRAGMA foreign_keys = ON;", []).expect("Failed to set PRAGMA");
|
connection
|
||||||
|
.execute("PRAGMA foreign_keys = ON;", [])
|
||||||
|
.expect("Failed to set PRAGMA");
|
||||||
|
|
||||||
create_tables(&connection);
|
create_tables(&connection);
|
||||||
}
|
}
|
||||||
@@ -52,6 +54,8 @@ fn make_card_stats(conn: &Connection) -> Result<(), rusqlite::Error> {
|
|||||||
pub fn default_connection() -> Connection {
|
pub fn default_connection() -> Connection {
|
||||||
let db_file = db_path();
|
let db_file = db_path();
|
||||||
let connection = Connection::open(db_file).expect("Failed to open database");
|
let connection = Connection::open(db_file).expect("Failed to open database");
|
||||||
connection.execute("PRAGMA foreign_keys = ON;", []).expect("Failed to set PRAGMA");
|
connection
|
||||||
|
.execute("PRAGMA foreign_keys = ON;", [])
|
||||||
|
.expect("Failed to set PRAGMA");
|
||||||
connection
|
connection
|
||||||
}
|
}
|
||||||
@@ -1,10 +1,10 @@
|
|||||||
|
use crate::fs::*;
|
||||||
|
use crate::notification::NotificationData;
|
||||||
|
use crate::notification::NotificationData::*;
|
||||||
use reqwest::Client;
|
use reqwest::Client;
|
||||||
use sha2::{Digest, Sha256};
|
use sha2::{Digest, Sha256};
|
||||||
use std::fs::File;
|
use std::fs::File;
|
||||||
use std::io::BufReader;
|
use std::io::BufReader;
|
||||||
use crate::fs::*;
|
|
||||||
use crate::notification::NotificationData;
|
|
||||||
use crate::notification::NotificationData::*;
|
|
||||||
|
|
||||||
pub async fn get_voice(text: &str) -> Result<BufReader<File>, NotificationData> {
|
pub async fn get_voice(text: &str) -> Result<BufReader<File>, NotificationData> {
|
||||||
let mut path = voice_dir()?;
|
let mut path = voice_dir()?;
|
||||||
@@ -19,7 +19,11 @@ pub async fn get_voice(text: &str) -> Result<BufReader<File>, NotificationData>
|
|||||||
.send()
|
.send()
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
let query = query.map_err(|_| VoiceVoxUnavailable)?.text().await.map_err(|_| VoiceVoxUnavailable)?;
|
let query = query
|
||||||
|
.map_err(|_| VoiceVoxUnavailable)?
|
||||||
|
.text()
|
||||||
|
.await
|
||||||
|
.map_err(|_| VoiceVoxUnavailable)?;
|
||||||
// Synthesis
|
// Synthesis
|
||||||
let audio = client
|
let audio = client
|
||||||
.post(format!("{engine_url}/synthesis?speaker=11"))
|
.post(format!("{engine_url}/synthesis?speaker=11"))
|
||||||
@@ -32,8 +36,12 @@ pub async fn get_voice(text: &str) -> Result<BufReader<File>, NotificationData>
|
|||||||
.await
|
.await
|
||||||
.map_err(|_| VoiceVoxUnavailable)?;
|
.map_err(|_| VoiceVoxUnavailable)?;
|
||||||
|
|
||||||
tokio::fs::write(&path, &audio).await.map_err(|_| PermissionDenied)?;
|
tokio::fs::write(&path, &audio)
|
||||||
|
.await
|
||||||
|
.map_err(|_| PermissionDenied)?;
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(BufReader::new(File::open(path).map_err(|_| PermissionDenied)?))
|
Ok(BufReader::new(
|
||||||
|
File::open(path).map_err(|_| PermissionDenied)?,
|
||||||
|
))
|
||||||
}
|
}
|
||||||
@@ -5,7 +5,7 @@ use log::info;
|
|||||||
use std::io;
|
use std::io;
|
||||||
use tokio::fs::{File, OpenOptions};
|
use tokio::fs::{File, OpenOptions};
|
||||||
use tokio::io::{AsyncReadExt, AsyncWriteExt};
|
use tokio::io::{AsyncReadExt, AsyncWriteExt};
|
||||||
use zstd::{Decoder, Encoder, DEFAULT_COMPRESSION_LEVEL};
|
use zstd::{DEFAULT_COMPRESSION_LEVEL, Decoder, Encoder};
|
||||||
|
|
||||||
// const API_URL: &str = "http://127.0.0.1:8089/";
|
// const API_URL: &str = "http://127.0.0.1:8089/";
|
||||||
const API_URL: &str = "https://learning.micialware.ru/";
|
const API_URL: &str = "https://learning.micialware.ru/";
|
||||||
|
|||||||
+12
-13
@@ -1,6 +1,6 @@
|
|||||||
use crate::data::entities::{WordData, WordGroup};
|
use crate::data::entities::{WordData, WordGroup};
|
||||||
use crate::notification::{MaybeError, NotificationData};
|
|
||||||
use crate::notification::NotificationData::{DbLoadError, DbSaveError};
|
use crate::notification::NotificationData::{DbLoadError, DbSaveError};
|
||||||
|
use crate::notification::{MaybeError, NotificationData};
|
||||||
use rusqlite::{Connection, params};
|
use rusqlite::{Connection, params};
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
|
|
||||||
@@ -22,10 +22,7 @@ pub fn add_word(word: &mut WordData, connection: &Connection) -> MaybeError {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn add_words(
|
pub fn add_words(words: &mut [WordData], connection: &mut Connection) -> MaybeError {
|
||||||
words: &mut [WordData],
|
|
||||||
connection: &mut Connection,
|
|
||||||
) -> MaybeError {
|
|
||||||
let tx = connection.transaction().map_err(|_| DbLoadError)?;
|
let tx = connection.transaction().map_err(|_| DbLoadError)?;
|
||||||
let count = words.len();
|
let count = words.len();
|
||||||
|
|
||||||
@@ -44,7 +41,7 @@ pub fn add_words(
|
|||||||
serde_json::to_string(&word.additional).unwrap_or_default(),
|
serde_json::to_string(&word.additional).unwrap_or_default(),
|
||||||
word.group_id
|
word.group_id
|
||||||
])
|
])
|
||||||
.map_err(|_| DbSaveError)?;
|
.map_err(|_| DbSaveError)?;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -102,14 +99,17 @@ pub fn load_words(connection: &Connection) -> Result<Vec<WordData>, Notification
|
|||||||
key: row.get(1)?,
|
key: row.get(1)?,
|
||||||
value: row.get(2)?,
|
value: row.get(2)?,
|
||||||
tags: row.get(3)?,
|
tags: row.get(3)?,
|
||||||
additional: serde_json::from_str::<HashMap<String, String>>(&additional).unwrap_or_default(),
|
additional: serde_json::from_str::<HashMap<String, String>>(&additional)
|
||||||
|
.unwrap_or_default(),
|
||||||
group_id: row.get(5)?,
|
group_id: row.get(5)?,
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
.map_err(|_| DbLoadError)?;
|
.map_err(|_| DbLoadError)?;
|
||||||
|
|
||||||
let mut buffer = Vec::with_capacity(1024);
|
let mut buffer = Vec::with_capacity(1024);
|
||||||
word_iter.filter_map(|res| res.ok()).for_each(|i| buffer.push(i));
|
word_iter
|
||||||
|
.filter_map(|res| res.ok())
|
||||||
|
.for_each(|i| buffer.push(i));
|
||||||
|
|
||||||
Ok(buffer)
|
Ok(buffer)
|
||||||
}
|
}
|
||||||
@@ -128,7 +128,9 @@ pub fn load_word_groups(connection: &Connection) -> Result<Vec<WordGroup>, Notif
|
|||||||
.map_err(|_| DbLoadError)?;
|
.map_err(|_| DbLoadError)?;
|
||||||
|
|
||||||
let mut buffer = Vec::with_capacity(8);
|
let mut buffer = Vec::with_capacity(8);
|
||||||
group_iter.filter_map(|res| res.ok()).for_each(|i| buffer.push(i));
|
group_iter
|
||||||
|
.filter_map(|res| res.ok())
|
||||||
|
.for_each(|i| buffer.push(i));
|
||||||
|
|
||||||
Ok(buffer)
|
Ok(buffer)
|
||||||
}
|
}
|
||||||
@@ -146,10 +148,7 @@ pub fn add_group(group: &mut WordGroup, connection: &Connection) -> MaybeError {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn update_group(
|
pub fn update_group(group: &mut WordGroup, connection: &Connection) -> MaybeError {
|
||||||
group: &mut WordGroup,
|
|
||||||
connection: &Connection,
|
|
||||||
) -> MaybeError {
|
|
||||||
if !group.id.is_valid() {
|
if !group.id.is_valid() {
|
||||||
Ok(add_group(group, connection)?)
|
Ok(add_group(group, connection)?)
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
use std::fs;
|
|
||||||
use std::path::PathBuf;
|
|
||||||
use crate::notification::NotificationData;
|
use crate::notification::NotificationData;
|
||||||
use crate::notification::NotificationData::PermissionDenied;
|
use crate::notification::NotificationData::PermissionDenied;
|
||||||
|
use std::fs;
|
||||||
|
use std::path::PathBuf;
|
||||||
|
|
||||||
pub fn app_data_dir() -> PathBuf {
|
pub fn app_data_dir() -> PathBuf {
|
||||||
let mut dir = dirs::data_dir().expect("Unsupported OS");
|
let mut dir = dirs::data_dir().expect("Unsupported OS");
|
||||||
@@ -14,10 +14,10 @@ pub fn app_data_dir() -> PathBuf {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn db_path() -> PathBuf {
|
pub fn db_path() -> PathBuf {
|
||||||
app_data_dir().join("data.db")
|
app_data_dir().join("data.db")
|
||||||
}
|
}
|
||||||
pub fn temp_db_path() -> PathBuf {
|
pub fn temp_db_path() -> PathBuf {
|
||||||
app_data_dir().join("data.db.tmp")
|
app_data_dir().join("data.db.tmp")
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn temp_import_path() -> PathBuf {
|
pub fn temp_import_path() -> PathBuf {
|
||||||
@@ -42,4 +42,4 @@ pub fn voice_dir() -> Result<PathBuf, NotificationData> {
|
|||||||
fs::create_dir_all(directory.clone()).map_err(|_| PermissionDenied)?;
|
fs::create_dir_all(directory.clone()).map_err(|_| PermissionDenied)?;
|
||||||
}
|
}
|
||||||
Ok(directory)
|
Ok(directory)
|
||||||
}
|
}
|
||||||
+8
-7
@@ -2,22 +2,23 @@
|
|||||||
macro_rules! push_error_task {
|
macro_rules! push_error_task {
|
||||||
($e:expr) => {
|
($e:expr) => {
|
||||||
iced::Task::done(push_error!($e))
|
iced::Task::done(push_error!($e))
|
||||||
}
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
#[macro_export]
|
#[macro_export]
|
||||||
macro_rules! push_error {
|
macro_rules! push_error {
|
||||||
($e:expr) => {
|
($e:expr) => {
|
||||||
$crate::navigation::RootMessage::PushNotification($crate::notification::NotificationRequest::Error($e))
|
$crate::navigation::RootMessage::PushNotification(
|
||||||
}
|
$crate::notification::NotificationRequest::Error($e),
|
||||||
|
)
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
pub fn into_result<R, E>(option: Option<R>, error: E) -> Result<R, E>{
|
pub fn into_result<R, E>(option: Option<R>, error: E) -> Result<R, E> {
|
||||||
if let Some(r) = option {
|
if let Some(r) = option {
|
||||||
Ok(r)
|
Ok(r)
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
Err(error)
|
Err(error)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+6
-7
@@ -1,14 +1,14 @@
|
|||||||
#![windows_subsystem = "windows"]
|
#![windows_subsystem = "windows"]
|
||||||
mod data_provider;
|
|
||||||
pub mod notification;
|
|
||||||
pub mod app;
|
pub mod app;
|
||||||
mod styling;
|
|
||||||
mod pages;
|
|
||||||
mod navigation;
|
|
||||||
mod fs;
|
|
||||||
mod core;
|
mod core;
|
||||||
mod data;
|
mod data;
|
||||||
|
mod data_provider;
|
||||||
|
mod fs;
|
||||||
pub mod helpers;
|
pub mod helpers;
|
||||||
|
mod navigation;
|
||||||
|
pub mod notification;
|
||||||
|
mod pages;
|
||||||
|
mod styling;
|
||||||
|
|
||||||
use crate::app::start;
|
use crate::app::start;
|
||||||
use mimalloc::MiMalloc;
|
use mimalloc::MiMalloc;
|
||||||
@@ -16,7 +16,6 @@ use mimalloc::MiMalloc;
|
|||||||
#[global_allocator]
|
#[global_allocator]
|
||||||
static GLOBAL: MiMalloc = MiMalloc;
|
static GLOBAL: MiMalloc = MiMalloc;
|
||||||
|
|
||||||
|
|
||||||
fn main() -> iced::Result {
|
fn main() -> iced::Result {
|
||||||
env_logger::init();
|
env_logger::init();
|
||||||
start()
|
start()
|
||||||
|
|||||||
+4
-3
@@ -1,4 +1,4 @@
|
|||||||
use crate::app::{fill_state, AppState};
|
use crate::app::{AppState, fill_state};
|
||||||
use crate::data::Id;
|
use crate::data::Id;
|
||||||
use crate::data_provider::history::get_history_of_set;
|
use crate::data_provider::history::get_history_of_set;
|
||||||
use crate::data_provider::sqlite::{create_db, default_connection};
|
use crate::data_provider::sqlite::{create_db, default_connection};
|
||||||
@@ -109,8 +109,9 @@ impl ScreenState {
|
|||||||
create_db();
|
create_db();
|
||||||
info!("Db created");
|
info!("Db created");
|
||||||
let state = ScreenState::default();
|
let state = ScreenState::default();
|
||||||
let reading_additional_task =
|
let reading_additional_task = Task::perform(Self::load_additional_data(), |data| {
|
||||||
Task::perform(Self::load_additional_data(), |data| data.unwrap_or_else(|err| push_error!(err)));
|
data.unwrap_or_else(|err| push_error!(err))
|
||||||
|
});
|
||||||
|
|
||||||
let mut final_task = reading_additional_task;
|
let mut final_task = reading_additional_task;
|
||||||
let state_guard = state.app_state.lock();
|
let state_guard = state.app_state.lock();
|
||||||
|
|||||||
+4
-2
@@ -109,7 +109,9 @@ impl NotificationManager {
|
|||||||
iced::widget::button("✕")
|
iced::widget::button("✕")
|
||||||
.on_press(NotificationMessage::Remove(*id))
|
.on_press(NotificationMessage::Remove(*id))
|
||||||
.style(iced::widget::button::text)
|
.style(iced::widget::button::text)
|
||||||
].align_y(Center).width(300)
|
]
|
||||||
|
.align_y(Center)
|
||||||
|
.width(300)
|
||||||
.padding(HALF_SPACING),
|
.padding(HALF_SPACING),
|
||||||
);
|
);
|
||||||
container
|
container
|
||||||
@@ -193,4 +195,4 @@ pub enum NotificationData {
|
|||||||
CompressError,
|
CompressError,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub type MaybeError = Result<(), NotificationData>;
|
pub type MaybeError = Result<(), NotificationData>;
|
||||||
@@ -1,8 +1,9 @@
|
|||||||
|
use crate::data::entities::WordData;
|
||||||
|
use crate::navigation::Page::PreviousPage;
|
||||||
use crate::navigation::RootMessage;
|
use crate::navigation::RootMessage;
|
||||||
|
use crate::navigation::*;
|
||||||
use crate::pages::dictionary::split_with_coma;
|
use crate::pages::dictionary::split_with_coma;
|
||||||
use crate::pages::dictionary_quiz::DictionaryQuizMessage::*;
|
use crate::pages::dictionary_quiz::DictionaryQuizMessage::*;
|
||||||
use crate::navigation::Page::PreviousPage;
|
|
||||||
use crate::navigation::*;
|
|
||||||
use crate::pages::quiz::Score;
|
use crate::pages::quiz::Score;
|
||||||
use crate::styling::*;
|
use crate::styling::*;
|
||||||
use iced::Background::Color;
|
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::widget::{Row, button, container, row, space, text, text_input};
|
||||||
use iced::{Border, Element, Fill, Task, Theme, alignment};
|
use iced::{Border, Element, Fill, Task, Theme, alignment};
|
||||||
use rand::prelude::SliceRandom;
|
use rand::prelude::SliceRandom;
|
||||||
use crate::data::entities::WordData;
|
|
||||||
|
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
pub struct DictionaryQuizState {
|
pub struct DictionaryQuizState {
|
||||||
@@ -147,7 +147,8 @@ impl DictionaryQuizState {
|
|||||||
self.score.total += 1;
|
self.score.total += 1;
|
||||||
}
|
}
|
||||||
if self.answer.to_lowercase() == self.correct.to_lowercase()
|
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 {
|
if !self.is_help {
|
||||||
self.score.correct += 1;
|
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::navigation::*;
|
||||||
use crate::styling::*;
|
use crate::styling::*;
|
||||||
|
use HistoryMessage::Back;
|
||||||
use chrono::Local;
|
use chrono::Local;
|
||||||
use iced::alignment::Horizontal::Center;
|
use iced::alignment::Horizontal::Center;
|
||||||
use iced::widget::space::horizontal;
|
use iced::widget::space::horizontal;
|
||||||
@@ -8,10 +12,6 @@ use iced::widget::*;
|
|||||||
use iced::{Element, Fill, FillPortion, Task};
|
use iced::{Element, Fill, FillPortion, Task};
|
||||||
use parking_lot::Mutex;
|
use parking_lot::Mutex;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use HistoryMessage::Back;
|
|
||||||
use crate::app::AppState;
|
|
||||||
use crate::data::entities::{HistoryItem, WordData};
|
|
||||||
use crate::data::INVALID_ID;
|
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub struct HistoryState {
|
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::import::{ImportData, ImportGroup, get_words_of_group, load_groups};
|
||||||
use crate::data_provider::words::{add_group, add_words};
|
use crate::data_provider::words::{add_group, add_words};
|
||||||
use crate::pages::import::ImportMessage::*;
|
use crate::fs::*;
|
||||||
use crate::data::entities::{WordData, WordGroup};
|
|
||||||
use crate::navigation::{NavigatedPage, Page, RootMessage};
|
use crate::navigation::{NavigatedPage, Page, RootMessage};
|
||||||
use crate::notification::NotificationData::OpenFileError;
|
use crate::notification::NotificationData::OpenFileError;
|
||||||
use crate::notification::{MaybeError, NotificationData};
|
use crate::notification::{MaybeError, NotificationData};
|
||||||
|
use crate::pages::import::ImportMessage::*;
|
||||||
|
use crate::push_error;
|
||||||
use crate::styling::*;
|
use crate::styling::*;
|
||||||
use iced::widget::button::danger;
|
use iced::widget::button::danger;
|
||||||
use iced::widget::container::success;
|
use iced::widget::container::success;
|
||||||
@@ -16,6 +19,7 @@ use iced::{Element, Task};
|
|||||||
use iced_core::Alignment::Center;
|
use iced_core::Alignment::Center;
|
||||||
use iced_core::Length::Fill;
|
use iced_core::Length::Fill;
|
||||||
use iced_core::Padding;
|
use iced_core::Padding;
|
||||||
|
use log::info;
|
||||||
use parking_lot::Mutex;
|
use parking_lot::Mutex;
|
||||||
use rfd::AsyncFileDialog;
|
use rfd::AsyncFileDialog;
|
||||||
use rusqlite::Connection;
|
use rusqlite::Connection;
|
||||||
@@ -23,12 +27,8 @@ use std::fs::{File, OpenOptions};
|
|||||||
use std::io::BufReader;
|
use std::io::BufReader;
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use log::info;
|
|
||||||
use tokio::task::spawn_blocking;
|
use tokio::task::spawn_blocking;
|
||||||
use zip::ZipArchive;
|
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"];
|
const DEFAULT_FIELDS: [&str; 6] = ["key", "value", "tags", "reading", "context", "description"];
|
||||||
|
|
||||||
@@ -433,7 +433,8 @@ impl ImportState {
|
|||||||
async move {
|
async move {
|
||||||
spawn_blocking(move || {
|
spawn_blocking(move || {
|
||||||
let temp_file_path = temp_import_path();
|
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 import_list = get_words_of_group(&connection, group.id)?;
|
||||||
let mut words_list = Vec::with_capacity(import_list.len());
|
let mut words_list = Vec::with_capacity(import_list.len());
|
||||||
|
|
||||||
@@ -500,8 +501,8 @@ impl ImportState {
|
|||||||
},
|
},
|
||||||
|r: Result<(), NotificationData>| match r {
|
|r: Result<(), NotificationData>| match r {
|
||||||
Ok(_) => RootMessage::Import(ImportFinished),
|
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::Page::PreviousPage;
|
||||||
use crate::navigation::{NavigatedPage, Page, RootMessage};
|
use crate::navigation::{NavigatedPage, Page, RootMessage};
|
||||||
use crate::pages::quiz::QuizMessage::*;
|
use crate::pages::quiz::QuizMessage::*;
|
||||||
@@ -6,8 +7,6 @@ use crate::styling::*;
|
|||||||
use iced::widget::*;
|
use iced::widget::*;
|
||||||
use iced::{Element, Fill, Task, alignment};
|
use iced::{Element, Fill, Task, alignment};
|
||||||
use rand::seq::SliceRandom;
|
use rand::seq::SliceRandom;
|
||||||
use crate::app::USER_FONT;
|
|
||||||
use crate::core::kana_set::KanaSet;
|
|
||||||
|
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
pub struct QuizState {
|
pub struct QuizState {
|
||||||
|
|||||||
@@ -334,10 +334,7 @@ pub enum RepetitionMessage {
|
|||||||
PlayFinished,
|
PlayFinished,
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn play_sound(
|
async fn play_sound(sink: Arc<Option<MixerDeviceSink>>, text: String) -> MaybeError {
|
||||||
sink: Arc<Option<MixerDeviceSink>>,
|
|
||||||
text: String,
|
|
||||||
) -> MaybeError {
|
|
||||||
let data = get_voice(text.as_str()).await?;
|
let data = get_voice(text.as_str()).await?;
|
||||||
spawn_blocking(move || {
|
spawn_blocking(move || {
|
||||||
if let Some(sink) = sink.as_ref()
|
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::widget::{button, column, row, scrollable, space, text, text_input};
|
||||||
use iced::{Element, Task};
|
use iced::{Element, Task};
|
||||||
use iced_core::Length::Fill;
|
use iced_core::Length::Fill;
|
||||||
use iced_core::{color, Padding, Theme};
|
use iced_core::{Padding, Theme, color};
|
||||||
use parking_lot::Mutex;
|
use parking_lot::Mutex;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
@@ -63,12 +63,12 @@ impl NavigatedPage<RepetitionSettingsMessage> for RepetitionSettingsState {
|
|||||||
Save => {
|
Save => {
|
||||||
let mut state = self.state.lock();
|
let mut state = self.state.lock();
|
||||||
if let Err(e) = update_deck(&mut self.set, &state.connection) {
|
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
|
if self.filter_changed
|
||||||
&& let Err(e) = update_deck_stats(&self.set, &state)
|
&& 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();
|
state.decks[self.index] = self.set.clone();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
use crate::app::AppState;
|
use crate::app::AppState;
|
||||||
use crate::core::srs::{AppendMode, OrderMode};
|
use crate::core::srs::{AppendMode, OrderMode};
|
||||||
use crate::data::entities::{CardStatistics, DeckSettings};
|
|
||||||
use crate::data::Id;
|
use crate::data::Id;
|
||||||
|
use crate::data::entities::{CardStatistics, DeckSettings};
|
||||||
use crate::data_provider::card_sets::update_deck;
|
use crate::data_provider::card_sets::update_deck;
|
||||||
use crate::data_provider::card_stats::{add_stat_list, load_stats_of_deck};
|
use crate::data_provider::card_stats::{add_stat_list, load_stats_of_deck};
|
||||||
use crate::navigation::Page::{History, PreviousPage, Repetition, RepetitionSettings};
|
use crate::navigation::Page::{History, PreviousPage, Repetition, RepetitionSettings};
|
||||||
@@ -16,17 +16,17 @@ use crate::push_error_task;
|
|||||||
use crate::styling::*;
|
use crate::styling::*;
|
||||||
use chrono::{Days, Local, Utc};
|
use chrono::{Days, Local, Utc};
|
||||||
use hashbrown::{HashMap, HashSet};
|
use hashbrown::{HashMap, HashSet};
|
||||||
use iced::widget::button::{danger, Status};
|
|
||||||
pub use iced::widget::button::{Catalog, Style};
|
pub use iced::widget::button::{Catalog, Style};
|
||||||
|
use iced::widget::button::{Status, danger};
|
||||||
use iced::widget::tooltip::Position::Top;
|
use iced::widget::tooltip::Position::Top;
|
||||||
use iced::widget::{
|
use iced::widget::{
|
||||||
button, column, container, lazy, radio, row, scrollable, space, svg, text, text_input, tooltip,
|
Column, Row, button, column, container, lazy, radio, row, scrollable, space, svg, text,
|
||||||
Column, Row,
|
text_input, tooltip,
|
||||||
};
|
};
|
||||||
use iced::{Background, Border, Center, Color, Element, Fill, Length, Shadow, Task, Theme};
|
use iced::{Background, Border, Center, Color, Element, Fill, Length, Shadow, Task, Theme};
|
||||||
|
use iced_core::Padding;
|
||||||
use iced_core::border::Radius;
|
use iced_core::border::Radius;
|
||||||
use iced_core::svg::Handle;
|
use iced_core::svg::Handle;
|
||||||
use iced_core::Padding;
|
|
||||||
use parking_lot::Mutex;
|
use parking_lot::Mutex;
|
||||||
use std::ops::Deref;
|
use std::ops::Deref;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
@@ -53,7 +53,7 @@ impl NavigatedPage<RepetitionsMessage> for RepetitionsState {
|
|||||||
|
|
||||||
let selected_set = self.selected_deck_mut().unwrap();
|
let selected_set = self.selected_deck_mut().unwrap();
|
||||||
if selected_set.append_mode == AppendMode::Full {
|
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;
|
return None;
|
||||||
}
|
}
|
||||||
selected_set.existing_words_indices = selected_set.available_words_indices.clone();
|
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::Page::*;
|
||||||
use crate::navigation::{NavigatedPage, Page, RootMessage};
|
use crate::navigation::{NavigatedPage, Page, RootMessage};
|
||||||
|
use crate::pages::dictionary::DictionaryState;
|
||||||
|
use crate::pages::quiz::QuizState;
|
||||||
use crate::pages::randomizer::RandomizerState;
|
use crate::pages::randomizer::RandomizerState;
|
||||||
use crate::pages::repetitions::RepetitionsState;
|
use crate::pages::repetitions::RepetitionsState;
|
||||||
use crate::pages::selector::SelectorMessage::ChangeMode;
|
use crate::pages::selector::SelectorMessage::ChangeMode;
|
||||||
use crate::styling::*;
|
|
||||||
use crate::pages::sync::SyncState;
|
use crate::pages::sync::SyncState;
|
||||||
use crate::pages::writing::WritingState;
|
use crate::pages::writing::WritingState;
|
||||||
|
use crate::styling::*;
|
||||||
use iced::widget::button::{Status, Style};
|
use iced::widget::button::{Status, Style};
|
||||||
use iced::widget::*;
|
use iced::widget::*;
|
||||||
use iced::{Element, Task, alignment};
|
use iced::{Element, Task, alignment};
|
||||||
@@ -15,9 +18,6 @@ use iced_core::Background;
|
|||||||
use iced_core::Color;
|
use iced_core::Color;
|
||||||
use parking_lot::Mutex;
|
use parking_lot::Mutex;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use crate::app::AppState;
|
|
||||||
use crate::core::kana_set::{KanaSet, KanaType};
|
|
||||||
use crate::pages::quiz::QuizState;
|
|
||||||
|
|
||||||
pub struct SelectorState {
|
pub struct SelectorState {
|
||||||
pub set: KanaSet,
|
pub set: KanaSet,
|
||||||
|
|||||||
@@ -1,11 +1,10 @@
|
|||||||
|
use crate::core::kana_set::KanaSet;
|
||||||
use crate::navigation::Page::PreviousPage;
|
use crate::navigation::Page::PreviousPage;
|
||||||
use crate::navigation::{NavigatedPage, Page, RootMessage};
|
use crate::navigation::{NavigatedPage, Page, RootMessage};
|
||||||
use crate::styling::*;
|
use crate::styling::*;
|
||||||
use iced::widget::*;
|
use iced::widget::*;
|
||||||
use iced::{Element, Fill, Task, alignment};
|
use iced::{Element, Fill, Task, alignment};
|
||||||
use rand::seq::SliceRandom;
|
use rand::seq::SliceRandom;
|
||||||
use crate::core::kana_set::KanaSet;
|
|
||||||
|
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
pub struct WritingState {
|
pub struct WritingState {
|
||||||
|
|||||||
Reference in new issue
Block a user