Optionally show all in writing test and update answers validation system
This commit is contained in:
+5
-2
@@ -69,6 +69,10 @@ impl QuizState {
|
|||||||
self.is_help = false;
|
self.is_help = false;
|
||||||
self.score.total += 1;
|
self.score.total += 1;
|
||||||
self.update_showed()
|
self.update_showed()
|
||||||
|
} else if self.current_roman.len() == self.correct_roman.len() {
|
||||||
|
self.score.total += 1;
|
||||||
|
self.score.fail += 1;
|
||||||
|
self.update_showed()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
QuizMessage::Back => todo!(),
|
QuizMessage::Back => todo!(),
|
||||||
@@ -96,8 +100,7 @@ impl QuizState {
|
|||||||
container(
|
container(
|
||||||
iced::widget::column![
|
iced::widget::column![
|
||||||
row![
|
row![
|
||||||
text!("{}", self.kana.to_uppercase())
|
text!("{}", self.kana.to_uppercase()).size(54),
|
||||||
.size(54),
|
|
||||||
text!(
|
text!(
|
||||||
"{}",
|
"{}",
|
||||||
if self.is_help {
|
if self.is_help {
|
||||||
|
|||||||
+23
-4
@@ -13,6 +13,7 @@ pub struct WritingState {
|
|||||||
kana_total: String,
|
kana_total: String,
|
||||||
roman_total: String,
|
roman_total: String,
|
||||||
next_text: String,
|
next_text: String,
|
||||||
|
show_all: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl NavigatedPage<WritingMessage> for WritingState {
|
impl NavigatedPage<WritingMessage> for WritingState {
|
||||||
@@ -36,6 +37,7 @@ impl WritingState {
|
|||||||
kana_total: "".to_string(),
|
kana_total: "".to_string(),
|
||||||
roman_total: "".to_string(),
|
roman_total: "".to_string(),
|
||||||
next_text: "Дальше".to_string(),
|
next_text: "Дальше".to_string(),
|
||||||
|
show_all: false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -45,6 +47,7 @@ impl WritingState {
|
|||||||
match message {
|
match message {
|
||||||
WritingMessage::Back => todo!(),
|
WritingMessage::Back => todo!(),
|
||||||
WritingMessage::Next => self.next(),
|
WritingMessage::Next => self.next(),
|
||||||
|
WritingMessage::SwitchShowMode(b) => self.show_all = b,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -59,16 +62,33 @@ impl WritingState {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if self.show_all {
|
||||||
|
|
||||||
|
if self.set.is_empty() == false && self.kana_total.is_empty() == false {
|
||||||
|
self.set.clear();
|
||||||
|
}
|
||||||
|
for pair in &self.set {
|
||||||
|
self.kana = "---".to_string();
|
||||||
|
self.roman_total += &*format!("{} ", &pair.1.clone()).to_string();
|
||||||
|
self.kana_total += &*format!("{} ", &pair.0).to_string();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
} else {
|
||||||
let current = self.set.pop().unwrap();
|
let current = self.set.pop().unwrap();
|
||||||
self.kana_total += &*format!("{} ", ¤t.0).to_string();
|
self.kana_total += &*format!("{} ", ¤t.0).to_string();
|
||||||
self.roman_total += &*format!("{} ", ¤t.1.clone()).to_string();
|
self.roman_total += &*format!("{} ", ¤t.1.clone()).to_string();
|
||||||
self.kana = current.1;
|
self.kana = current.1;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub fn view(&self) -> Element<'_, WritingMessage> {
|
pub fn view(&self) -> Element<'_, WritingMessage> {
|
||||||
container(
|
container(
|
||||||
iced::widget::column![
|
iced::widget::column![
|
||||||
text!("{}", self.roman_total).size(24),
|
checkbox(self.show_all)
|
||||||
|
.label("Показывать все сразу")
|
||||||
|
.on_toggle(WritingMessage::SwitchShowMode),
|
||||||
|
text!("{}", self.roman_total).size(34),
|
||||||
text!("{}", self.kana).size(48),
|
text!("{}", self.kana).size(48),
|
||||||
self.answers(),
|
self.answers(),
|
||||||
row![
|
row![
|
||||||
@@ -88,9 +108,7 @@ impl WritingState {
|
|||||||
|
|
||||||
fn answers(&self) -> Element<'_, WritingMessage> {
|
fn answers(&self) -> Element<'_, WritingMessage> {
|
||||||
if self.set.is_empty() {
|
if self.set.is_empty() {
|
||||||
text!("{}", self.kana_total)
|
text!("{}", self.kana_total).size(36).into()
|
||||||
.size(36)
|
|
||||||
.into()
|
|
||||||
} else {
|
} else {
|
||||||
space().height(36).into()
|
space().height(36).into()
|
||||||
}
|
}
|
||||||
@@ -100,4 +118,5 @@ impl WritingState {
|
|||||||
pub enum WritingMessage {
|
pub enum WritingMessage {
|
||||||
Next,
|
Next,
|
||||||
Back,
|
Back,
|
||||||
|
SwitchShowMode(bool),
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user