Partial dictionary rewrite
This commit is contained in:
1 parent
1509947cb0
commit
f2035ca749
12 files changed
+304
-363
No files matched your search
@@ -1,4 +1,4 @@
|
||||
use crate::data::entities::WordData;
|
||||
use crate::data::entities::{EntityHandle, WordData};
|
||||
use crate::navigation::Page::PreviousPage;
|
||||
use crate::navigation::RootMessage;
|
||||
use crate::navigation::*;
|
||||
@@ -13,10 +13,9 @@ use iced::widget::{Row, button, container, row, space, text, text_input};
|
||||
use iced::{Border, Element, Fill, Task, Theme, alignment};
|
||||
use rand::prelude::SliceRandom;
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct DictionaryQuizState {
|
||||
words: Vec<WordData>,
|
||||
current_set: Vec<WordData>,
|
||||
words: Vec<EntityHandle<WordData>>,
|
||||
current_set: Vec<EntityHandle<WordData>>,
|
||||
answer: String,
|
||||
view: String,
|
||||
correct: String,
|
||||
@@ -104,8 +103,8 @@ impl NavigatedPage<DictionaryQuizMessage> for DictionaryQuizState {
|
||||
}
|
||||
|
||||
impl DictionaryQuizState {
|
||||
pub fn new(words: Vec<WordData>, reverse: bool, no_typing: bool) -> DictionaryQuizState {
|
||||
DictionaryQuizState {
|
||||
pub fn new(words: Vec<EntityHandle<WordData>>, reverse: bool, no_typing: bool) -> DictionaryQuizState {
|
||||
let state = DictionaryQuizState {
|
||||
words,
|
||||
current_set: Vec::new(),
|
||||
answer: "".to_string(),
|
||||
@@ -116,7 +115,9 @@ impl DictionaryQuizState {
|
||||
reverse,
|
||||
laps: 0,
|
||||
no_typing,
|
||||
}
|
||||
};
|
||||
|
||||
state
|
||||
}
|
||||
|
||||
fn submit(&mut self) {
|
||||
@@ -172,7 +173,7 @@ impl DictionaryQuizState {
|
||||
self.is_help = false;
|
||||
self.answer = String::new();
|
||||
|
||||
let next: WordData = match self.current_set.pop() {
|
||||
let next: EntityHandle<WordData> = match self.current_set.pop() {
|
||||
Some(word) => word,
|
||||
None => {
|
||||
self.update_set();
|
||||
|
||||
Reference in new issue
Block a user