Add basic methods into NavigatedPage
This commit is contained in:
+26
-24
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user