Add basic methods into NavigatedPage

This commit is contained in:
2026-08-13 22:03:47 +03:00
parent d8e7cbbc36
commit 4ca7aa7044
17 changed files with 590 additions and 324 deletions
+26 -24
View File
@@ -44,25 +44,8 @@ impl NavigatedPage<DictionaryQuizMessage> for DictionaryQuizState {
fn navigated(&mut self) {
}
}
impl DictionaryQuizState {
pub fn new(words: Vec<WordData>, reverse: bool, no_typing: bool) -> DictionaryQuizState {
DictionaryQuizState {
words,
current_set: Vec::new(),
answer: "".to_string(),
view: "---".to_string(),
correct: "".to_string(),
score: Default::default(),
is_help: false,
reverse,
laps: 0,
no_typing,
}
}
pub fn update(&mut self, message: DictionaryQuizMessage) -> Task<RootMessage> {
fn update(&mut self, message: DictionaryQuizMessage) -> Task<RootMessage> {
match message {
Back => {}
AnswerChanged(c) => self.answer = c.clone(),
@@ -72,7 +55,7 @@ impl DictionaryQuizState {
Task::none()
}
pub fn view(&self) -> Element<'_, DictionaryQuizMessage> {
fn view(&self) -> Element<'_, DictionaryQuizMessage> {
container(
iced::widget::column![
self.laps(),
@@ -112,13 +95,32 @@ impl DictionaryQuizState {
]
.spacing(DEFAULT_SPACING),
]
.spacing(DEFAULT_SPACING)
.align_x(alignment::Horizontal::Center),
.spacing(DEFAULT_SPACING)
.align_x(alignment::Horizontal::Center),
)
.center_y(Fill)
.center_x(Fill)
.into()
.center_y(Fill)
.center_x(Fill)
.into()
}
}
impl DictionaryQuizState {
pub fn new(words: Vec<WordData>, reverse: bool, no_typing: bool) -> DictionaryQuizState {
DictionaryQuizState {
words,
current_set: Vec::new(),
answer: "".to_string(),
view: "---".to_string(),
correct: "".to_string(),
score: Default::default(),
is_help: false,
reverse,
laps: 0,
no_typing,
}
}
fn submit(&mut self) {
if self.view == "---" {
self.show_next();