Dictionary partial rewritten and dictionary quiz rewritten
This commit is contained in:
1 parent
f2035ca749
commit
f19a6f64c3
2 files changed
+114
-99
No files matched your search
@@ -12,8 +12,11 @@ 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::app::AppState;
|
||||
use crate::data::repositories::Repository;
|
||||
|
||||
pub struct DictionaryQuizState {
|
||||
state: AppState,
|
||||
words: Vec<EntityHandle<WordData>>,
|
||||
current_set: Vec<EntityHandle<WordData>>,
|
||||
answer: String,
|
||||
@@ -103,8 +106,9 @@ impl NavigatedPage<DictionaryQuizMessage> for DictionaryQuizState {
|
||||
}
|
||||
|
||||
impl DictionaryQuizState {
|
||||
pub fn new(words: Vec<EntityHandle<WordData>>, reverse: bool, no_typing: bool) -> DictionaryQuizState {
|
||||
pub fn new(words: Vec<EntityHandle<WordData>>, reverse: bool, no_typing: bool, state: AppState) -> DictionaryQuizState {
|
||||
let state = DictionaryQuizState {
|
||||
state,
|
||||
words,
|
||||
current_set: Vec::new(),
|
||||
answer: "".to_string(),
|
||||
@@ -181,12 +185,14 @@ impl DictionaryQuizState {
|
||||
}
|
||||
};
|
||||
|
||||
let repo = self.state.dictionary.read();
|
||||
let next = repo.get_static(next).unwrap();
|
||||
if self.reverse {
|
||||
self.view = next.value.clone();
|
||||
self.correct = next.key.clone();
|
||||
self.view = next.value;
|
||||
self.correct = next.key;
|
||||
} else {
|
||||
self.view = next.key.clone();
|
||||
self.correct = next.value.clone();
|
||||
self.view = next.key;
|
||||
self.correct = next.value;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user