Adding words by parts
This commit is contained in:
+32
-24
@@ -2,22 +2,23 @@
|
||||
mod data_provider;
|
||||
mod dictionary;
|
||||
mod dictionary_test;
|
||||
pub mod helpers;
|
||||
mod history;
|
||||
pub mod import;
|
||||
mod lang;
|
||||
pub mod navigation;
|
||||
mod quiz;
|
||||
mod randomizer;
|
||||
mod repetition;
|
||||
mod repetition_settings;
|
||||
mod repetitions;
|
||||
mod selector;
|
||||
pub mod styling;
|
||||
mod sync;
|
||||
mod word;
|
||||
mod writing;
|
||||
mod repetition_settings;
|
||||
pub mod import;
|
||||
pub mod helpers;
|
||||
|
||||
use crate::RootMessage::Keyboard;
|
||||
use crate::data_provider::card_sets::load_sets;
|
||||
use crate::data_provider::settings::get_setting;
|
||||
use crate::data_provider::sqlite::default_connection;
|
||||
@@ -25,16 +26,15 @@ use crate::data_provider::words::{load_word_groups, load_words};
|
||||
use crate::lang::{CardSetSettings, WordData, WordGroup};
|
||||
use crate::navigation::{AppSettings, RootMessage, ScreenState};
|
||||
use crate::quiz::*;
|
||||
use crate::RootMessage::Keyboard;
|
||||
use chrono::NaiveDate;
|
||||
use iced::{keyboard, Subscription, Theme};
|
||||
use iced::{window, Font};
|
||||
use iced_core::window::Position;
|
||||
use iced::{Font, window};
|
||||
use iced::{Subscription, Theme, keyboard};
|
||||
use iced_core::Size;
|
||||
use rusqlite::Connection;
|
||||
use std::collections::HashMap;
|
||||
use iced_core::window::Position;
|
||||
use iced_core::window::settings::PlatformSpecific;
|
||||
use mimalloc::MiMalloc;
|
||||
use rusqlite::Connection;
|
||||
use std::collections::HashMap;
|
||||
|
||||
#[global_allocator]
|
||||
static GLOBAL: MiMalloc = MiMalloc;
|
||||
@@ -43,7 +43,8 @@ const USER_FONT: Font = Font::with_name("Noto Sans JP");
|
||||
|
||||
fn main() -> iced::Result {
|
||||
println!("Welcome to JapLearn");
|
||||
iced::application(ScreenState::boot, ScreenState::update, ScreenState::view).window(window_settings())
|
||||
iced::application(ScreenState::boot, ScreenState::update, ScreenState::view)
|
||||
.window(window_settings())
|
||||
.subscription(subscription)
|
||||
.title("JapLearn")
|
||||
.settings(iced::Settings {
|
||||
@@ -52,23 +53,23 @@ fn main() -> iced::Result {
|
||||
})
|
||||
.font(include_bytes!("../noto.ttf"))
|
||||
.default_font(USER_FONT)
|
||||
.theme(Theme::GruvboxDark).run()
|
||||
.theme(Theme::GruvboxDark)
|
||||
.run()
|
||||
}
|
||||
|
||||
fn window_settings() -> window::Settings {
|
||||
let mut settings = window::Settings{
|
||||
let mut settings = window::Settings {
|
||||
position: Position::Centered,
|
||||
min_size: Some(Size::new(700.0_f32, 700.0_f32)),
|
||||
.. Default::default()
|
||||
..Default::default()
|
||||
};
|
||||
|
||||
#[cfg(target_os = "linux")]
|
||||
{
|
||||
settings.platform_specific =
|
||||
PlatformSpecific {
|
||||
application_id: "JapLearn".to_string(),
|
||||
override_redirect: false
|
||||
};
|
||||
settings.platform_specific = PlatformSpecific {
|
||||
application_id: "JapLearn".to_string(),
|
||||
override_redirect: false,
|
||||
};
|
||||
}
|
||||
|
||||
settings
|
||||
@@ -84,7 +85,7 @@ pub struct AppState {
|
||||
pub word_groups: Vec<WordGroup>,
|
||||
pub connection: Connection,
|
||||
pub sync_data: AppSettings,
|
||||
pub activity: HashMap<u32, Vec<(NaiveDate, u32)>>
|
||||
pub activity: HashMap<u32, Vec<(NaiveDate, u32)>>,
|
||||
}
|
||||
|
||||
impl Default for AppState {
|
||||
@@ -95,14 +96,15 @@ impl Default for AppState {
|
||||
|
||||
impl AppState {
|
||||
pub fn new() -> Self {
|
||||
|
||||
|
||||
Self {
|
||||
dictionary: vec![],
|
||||
card_sets: vec![],
|
||||
word_groups: vec![],
|
||||
connection: default_connection(),
|
||||
sync_data: AppSettings { key: None, auto_web_fetch: false },
|
||||
sync_data: AppSettings {
|
||||
key: None,
|
||||
auto_web_fetch: false,
|
||||
},
|
||||
activity: Default::default(),
|
||||
}
|
||||
}
|
||||
@@ -122,6 +124,12 @@ fn fill_state(state: &mut AppState) {
|
||||
|
||||
fn load_settings(connection: &Connection) -> AppSettings {
|
||||
let key = get_setting("SYNC_KEY".to_string(), connection);
|
||||
let fetch = get_setting("AUTO_WEB_FETCH".to_string(), connection).unwrap_or("false".to_string()).parse::<bool>().unwrap();
|
||||
AppSettings { key, auto_web_fetch: fetch }
|
||||
let fetch = get_setting("AUTO_WEB_FETCH".to_string(), connection)
|
||||
.unwrap_or("false".to_string())
|
||||
.parse::<bool>()
|
||||
.unwrap();
|
||||
AppSettings {
|
||||
key,
|
||||
auto_web_fetch: fetch,
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user