Fix random tags order and add local randomizer for sequences
This commit is contained in:
+63
-26
@@ -18,7 +18,9 @@ pub struct DictionaryState {
|
|||||||
dict: Vec<DictionaryElement>,
|
dict: Vec<DictionaryElement>,
|
||||||
include_map: Vec<bool>,
|
include_map: Vec<bool>,
|
||||||
tag_map: HashMap<String, bool>,
|
tag_map: HashMap<String, bool>,
|
||||||
reverse: bool
|
reverse: bool,
|
||||||
|
search: String,
|
||||||
|
no_typing: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug, Serialize, Deserialize)]
|
#[derive(Clone, Debug, Serialize, Deserialize)]
|
||||||
@@ -52,6 +54,8 @@ pub enum DictionaryMessage {
|
|||||||
Test,
|
Test,
|
||||||
ResetTags,
|
ResetTags,
|
||||||
SetReverse(bool),
|
SetReverse(bool),
|
||||||
|
Search(String),
|
||||||
|
SetTyping(bool),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl NavigatedPage<DictionaryMessage> for DictionaryState {
|
impl NavigatedPage<DictionaryMessage> for DictionaryState {
|
||||||
@@ -62,12 +66,16 @@ impl NavigatedPage<DictionaryMessage> for DictionaryState {
|
|||||||
if let Test = message {
|
if let Test = message {
|
||||||
if self.include_map.iter().any(|x| *x) {
|
if self.include_map.iter().any(|x| *x) {
|
||||||
let mut words = vec![];
|
let mut words = vec![];
|
||||||
for i in 0..self.include_map.len(){
|
for i in 0..self.include_map.len() {
|
||||||
if self.include_map[i] {
|
if self.include_map[i] {
|
||||||
words.push(self.dict[i].clone());
|
words.push(self.dict[i].clone());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return Some(Page::DictionaryQuiz(DictionaryQuizState::new(words, self.reverse)))
|
return Some(Page::DictionaryQuiz(DictionaryQuizState::new(
|
||||||
|
words,
|
||||||
|
self.reverse,
|
||||||
|
self.no_typing,
|
||||||
|
)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
None
|
None
|
||||||
@@ -95,9 +103,12 @@ impl DictionaryState {
|
|||||||
dict: list,
|
dict: list,
|
||||||
tag_map: HashMap::new(),
|
tag_map: HashMap::new(),
|
||||||
reverse: false,
|
reverse: false,
|
||||||
|
search: "".to_string(),
|
||||||
|
no_typing: false,
|
||||||
};
|
};
|
||||||
|
|
||||||
result.update_tags();
|
result.update_tags();
|
||||||
|
|
||||||
result
|
result
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -118,7 +129,6 @@ impl DictionaryState {
|
|||||||
}
|
}
|
||||||
DictionaryMessage::Include(i, b) => self.include_map[i] = b,
|
DictionaryMessage::Include(i, b) => self.include_map[i] = b,
|
||||||
DictionaryMessage::IncludeTag(t, v) => {
|
DictionaryMessage::IncludeTag(t, v) => {
|
||||||
println!("Including tag {}", t);
|
|
||||||
self.tag_map.insert(t, v);
|
self.tag_map.insert(t, v);
|
||||||
self.update_words_include()
|
self.update_words_include()
|
||||||
}
|
}
|
||||||
@@ -131,9 +141,12 @@ impl DictionaryState {
|
|||||||
let content = serde_json::to_string_pretty(&self.dict.clone()).unwrap();
|
let content = serde_json::to_string_pretty(&self.dict.clone()).unwrap();
|
||||||
fs::write(dir, content.clone())
|
fs::write(dir, content.clone())
|
||||||
.unwrap_or_else(|e| println!("Can't write file: {}", e));
|
.unwrap_or_else(|e| println!("Can't write file: {}", e));
|
||||||
println!("{}", content);
|
}
|
||||||
},
|
|
||||||
DictionaryMessage::SetReverse(v) => self.reverse = v,
|
DictionaryMessage::SetReverse(v) => self.reverse = v,
|
||||||
|
DictionaryMessage::Search(s) => {
|
||||||
|
self.search = s;
|
||||||
|
}
|
||||||
|
DictionaryMessage::SetTyping(b) => self.no_typing = b,
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -141,20 +154,22 @@ impl DictionaryState {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn view(&self) -> iced::Element<'_, DictionaryMessage> {
|
pub fn view(&self) -> iced::Element<'_, DictionaryMessage> {
|
||||||
container(row![
|
container(
|
||||||
iced::widget::column![
|
row![
|
||||||
button("Назад").on_press(Back),
|
iced::widget::column![
|
||||||
self.words_list(),
|
button("Назад").on_press(Back),
|
||||||
row![
|
self.words_list(),
|
||||||
button("Добавить слово").on_press(DictionaryMessage::NewWord),
|
row![
|
||||||
button("Сохранить словарь").on_press(DictionaryMessage::Save),
|
button("Добавить слово").on_press(DictionaryMessage::NewWord),
|
||||||
|
button("Сохранить словарь").on_press(DictionaryMessage::Save),
|
||||||
|
]
|
||||||
|
.spacing(10)
|
||||||
]
|
]
|
||||||
.spacing(10)
|
.spacing(5),
|
||||||
|
self.filters()
|
||||||
]
|
]
|
||||||
.spacing(5)
|
.spacing(10),
|
||||||
.padding(10),
|
)
|
||||||
self.filters()
|
|
||||||
])
|
|
||||||
.padding(10)
|
.padding(10)
|
||||||
.into()
|
.into()
|
||||||
}
|
}
|
||||||
@@ -164,6 +179,15 @@ impl DictionaryState {
|
|||||||
|
|
||||||
let mut i = 0;
|
let mut i = 0;
|
||||||
for word in &self.dict {
|
for word in &self.dict {
|
||||||
|
if !self.search.is_empty() {
|
||||||
|
if word.key.contains(&self.search) == false
|
||||||
|
&& word.value.contains(&self.search) == false
|
||||||
|
{
|
||||||
|
i += 1;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
let mut line = Row::new().width(Length::Fill).align_y(Center);
|
let mut line = Row::new().width(Length::Fill).align_y(Center);
|
||||||
line = line
|
line = line
|
||||||
.push(
|
.push(
|
||||||
@@ -173,17 +197,20 @@ impl DictionaryState {
|
|||||||
.push(space().width(10));
|
.push(space().width(10));
|
||||||
|
|
||||||
line = line.push(
|
line = line.push(
|
||||||
text_input("Ключ", &word.key).size(20)
|
text_input("Ключ", &word.key)
|
||||||
|
.size(20)
|
||||||
.width(Length::Fill)
|
.width(Length::Fill)
|
||||||
.on_input(move |string| DictionaryMessage::SetKey(i, string)),
|
.on_input(move |string| DictionaryMessage::SetKey(i, string)),
|
||||||
);
|
);
|
||||||
line = line.push(
|
line = line.push(
|
||||||
text_input("Значение", &word.value).size(20)
|
text_input("Значение", &word.value)
|
||||||
|
.size(20)
|
||||||
.width(Length::Fill)
|
.width(Length::Fill)
|
||||||
.on_input(move |string| DictionaryMessage::SetValue(i, string)),
|
.on_input(move |string| DictionaryMessage::SetValue(i, string)),
|
||||||
);
|
);
|
||||||
line = line.push(
|
line = line.push(
|
||||||
text_input("Тэги", &word.tags).size(20)
|
text_input("Тэги", &word.tags)
|
||||||
|
.size(20)
|
||||||
.width(Length::Fill)
|
.width(Length::Fill)
|
||||||
.on_input(move |string| DictionaryMessage::SetTags(i, string)),
|
.on_input(move |string| DictionaryMessage::SetTags(i, string)),
|
||||||
);
|
);
|
||||||
@@ -211,13 +238,21 @@ impl DictionaryState {
|
|||||||
|
|
||||||
fn filters(&self) -> iced::Element<'_, DictionaryMessage> {
|
fn filters(&self) -> iced::Element<'_, DictionaryMessage> {
|
||||||
iced::widget::column![
|
iced::widget::column![
|
||||||
|
text_input("Поиск", &self.search)
|
||||||
|
.on_input(DictionaryMessage::Search)
|
||||||
|
.width(Length::Fill),
|
||||||
text!("Всего слов: {}", self.dict.len()),
|
text!("Всего слов: {}", self.dict.len()),
|
||||||
text!(
|
text!(
|
||||||
"Выбрано слов: {}",
|
"Выбрано слов: {}",
|
||||||
self.include_map.iter().filter(|i| **i).count()
|
self.include_map.iter().filter(|i| **i).count()
|
||||||
),
|
),
|
||||||
self.tags_selector(),
|
self.tags_selector(),
|
||||||
toggler(self.reverse).label("Обратный тест").on_toggle(DictionaryMessage::SetReverse),
|
toggler(self.no_typing)
|
||||||
|
.label("Без набора")
|
||||||
|
.on_toggle(DictionaryMessage::SetTyping),
|
||||||
|
toggler(self.reverse)
|
||||||
|
.label("Обратный тест")
|
||||||
|
.on_toggle(DictionaryMessage::SetReverse),
|
||||||
button(text!("Тест").center().width(Length::Fill))
|
button(text!("Тест").center().width(Length::Fill))
|
||||||
.on_press(Test)
|
.on_press(Test)
|
||||||
.width(Length::Fill),
|
.width(Length::Fill),
|
||||||
@@ -240,7 +275,9 @@ impl DictionaryState {
|
|||||||
snap: false,
|
snap: false,
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
for tag in &self.tag_map {
|
let mut sorted_tags = self.tag_map.iter().collect::<Vec<_>>();
|
||||||
|
sorted_tags.sort();
|
||||||
|
for tag in sorted_tags {
|
||||||
col = col.push(
|
col = col.push(
|
||||||
checkbox(*tag.1)
|
checkbox(*tag.1)
|
||||||
.label(tag.0)
|
.label(tag.0)
|
||||||
@@ -283,8 +320,6 @@ impl DictionaryState {
|
|||||||
.map(|(t, _)| t.clone())
|
.map(|(t, _)| t.clone())
|
||||||
.collect::<Vec<String>>();
|
.collect::<Vec<String>>();
|
||||||
|
|
||||||
println!("Including include tags: {:?}", include_tags);
|
|
||||||
|
|
||||||
if include_tags.is_empty() {
|
if include_tags.is_empty() {
|
||||||
self.include_map.iter_mut().for_each(|x| *x = false);
|
self.include_map.iter_mut().for_each(|x| *x = false);
|
||||||
return;
|
return;
|
||||||
@@ -292,8 +327,10 @@ impl DictionaryState {
|
|||||||
|
|
||||||
for i in 0..self.include_map.len() {
|
for i in 0..self.include_map.len() {
|
||||||
let tags = split_with_coma(self.dict[i].tags.clone());
|
let tags = split_with_coma(self.dict[i].tags.clone());
|
||||||
if tags.iter().any(|t| include_tags.contains(t)) {
|
if tags.iter().all(|t| include_tags.contains(t)) {
|
||||||
self.include_map[i] = true;
|
self.include_map[i] = true;
|
||||||
|
} else {
|
||||||
|
self.include_map[i] = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+30
-13
@@ -20,10 +20,10 @@ pub struct DictionaryQuizState {
|
|||||||
is_help: bool,
|
is_help: bool,
|
||||||
reverse: bool,
|
reverse: bool,
|
||||||
laps: u32,
|
laps: u32,
|
||||||
|
no_typing: bool,
|
||||||
}
|
}
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
pub enum DictionaryQuizMessage {
|
pub enum DictionaryQuizMessage {
|
||||||
Next,
|
|
||||||
Back,
|
Back,
|
||||||
AnswerChanged(String),
|
AnswerChanged(String),
|
||||||
SubmitAnswer,
|
SubmitAnswer,
|
||||||
@@ -40,7 +40,11 @@ impl NavigatedPage<DictionaryQuizMessage> for DictionaryQuizState {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl DictionaryQuizState {
|
impl DictionaryQuizState {
|
||||||
pub fn new(words: Vec<DictionaryElement>, reverse: bool) -> DictionaryQuizState {
|
pub fn new(
|
||||||
|
words: Vec<DictionaryElement>,
|
||||||
|
reverse: bool,
|
||||||
|
no_typing: bool,
|
||||||
|
) -> DictionaryQuizState {
|
||||||
DictionaryQuizState {
|
DictionaryQuizState {
|
||||||
words,
|
words,
|
||||||
current_set: Vec::new(),
|
current_set: Vec::new(),
|
||||||
@@ -51,14 +55,12 @@ impl DictionaryQuizState {
|
|||||||
is_help: false,
|
is_help: false,
|
||||||
reverse,
|
reverse,
|
||||||
laps: 0,
|
laps: 0,
|
||||||
|
no_typing,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn update(&mut self, message: DictionaryQuizMessage) -> Task<RootMessage> {
|
pub fn update(&mut self, message: DictionaryQuizMessage) -> Task<RootMessage> {
|
||||||
match message {
|
match message {
|
||||||
DictionaryQuizMessage::Next => {
|
|
||||||
self.next();
|
|
||||||
}
|
|
||||||
DictionaryQuizMessage::Back => {}
|
DictionaryQuizMessage::Back => {}
|
||||||
DictionaryQuizMessage::AnswerChanged(c) => self.answer = c.clone(),
|
DictionaryQuizMessage::AnswerChanged(c) => self.answer = c.clone(),
|
||||||
DictionaryQuizMessage::SubmitAnswer => self.submit(),
|
DictionaryQuizMessage::SubmitAnswer => self.submit(),
|
||||||
@@ -71,7 +73,7 @@ impl DictionaryQuizState {
|
|||||||
container(
|
container(
|
||||||
iced::widget::column![
|
iced::widget::column![
|
||||||
self.laps(),
|
self.laps(),
|
||||||
row![
|
iced::widget::column![
|
||||||
text!("{}", self.view).size(54),
|
text!("{}", self.view).size(54),
|
||||||
text!(
|
text!(
|
||||||
"{}",
|
"{}",
|
||||||
@@ -80,10 +82,10 @@ impl DictionaryQuizState {
|
|||||||
} else {
|
} else {
|
||||||
String::new()
|
String::new()
|
||||||
}
|
}
|
||||||
),
|
).size(20).align_y(alignment::Vertical::Center),
|
||||||
]
|
]
|
||||||
.align_y(alignment::Vertical::Center)
|
.align_x(alignment::Horizontal::Center)
|
||||||
.spacing(20),
|
.spacing(5),
|
||||||
text_input("Перевод", &self.answer)
|
text_input("Перевод", &self.answer)
|
||||||
.size(28)
|
.size(28)
|
||||||
.width(250)
|
.width(250)
|
||||||
@@ -112,14 +114,29 @@ impl DictionaryQuizState {
|
|||||||
.center_x(Fill)
|
.center_x(Fill)
|
||||||
.into()
|
.into()
|
||||||
}
|
}
|
||||||
fn next(&mut self) {}
|
|
||||||
|
|
||||||
fn submit(&mut self) {
|
fn submit(&mut self) {
|
||||||
if self.view == "---" {
|
if self.view == "---" {
|
||||||
self.show_next();
|
self.show_next();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if self.no_typing {
|
||||||
|
self.no_type_submit();
|
||||||
|
} else {
|
||||||
|
self.default_submit();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn no_type_submit(&mut self) {
|
||||||
|
if self.is_help {
|
||||||
|
self.is_help = false;
|
||||||
|
self.show_next()
|
||||||
|
}else {
|
||||||
|
self.is_help = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn default_submit(&mut self) {
|
||||||
if !self.is_help {
|
if !self.is_help {
|
||||||
self.score.total += 1;
|
self.score.total += 1;
|
||||||
}
|
}
|
||||||
@@ -182,8 +199,8 @@ impl DictionaryQuizState {
|
|||||||
col.spacing(10).into()
|
col.spacing(10).into()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn appeal_button(&self) -> iced::Element<'_, DictionaryQuizMessage> {
|
fn appeal_button(&self) -> Element<'_, DictionaryQuizMessage> {
|
||||||
if self.is_help {
|
if self.is_help && self.no_typing == false {
|
||||||
return button("Апелляция")
|
return button("Апелляция")
|
||||||
.on_press(DictionaryQuizMessage::Appeal)
|
.on_press(DictionaryQuizMessage::Appeal)
|
||||||
.into();
|
.into();
|
||||||
|
|||||||
+7
-3
@@ -5,16 +5,18 @@ mod selector;
|
|||||||
mod writing;
|
mod writing;
|
||||||
mod dictionary;
|
mod dictionary;
|
||||||
mod dictionary_test;
|
mod dictionary_test;
|
||||||
|
mod randomizer;
|
||||||
|
|
||||||
use crate::quiz::*;
|
use crate::quiz::*;
|
||||||
use crate::selector::*;
|
use crate::selector::*;
|
||||||
use crate::writing::{WritingMessage, WritingState};
|
use crate::writing::{WritingMessage, WritingState};
|
||||||
use crate::Page::{Dictionary, DictionaryQuiz, Quiz, Selector, Writing};
|
use crate::Page::{Dictionary, DictionaryQuiz, Quiz, Randomizer, Selector, Writing};
|
||||||
use iced::widget::text;
|
use iced::widget::text;
|
||||||
use iced::{Font, Task};
|
use iced::{Font, Task};
|
||||||
use iced::Element;
|
use iced::Element;
|
||||||
use crate::dictionary::{DictionaryMessage, DictionaryState};
|
use crate::dictionary::{DictionaryMessage, DictionaryState};
|
||||||
use crate::dictionary_test::{DictionaryQuizMessage, DictionaryQuizState};
|
use crate::dictionary_test::{DictionaryQuizMessage, DictionaryQuizState};
|
||||||
|
use crate::randomizer::randomizer::{ RandomizerMessage, RandomizerState};
|
||||||
|
|
||||||
fn main() -> iced::Result {
|
fn main() -> iced::Result {
|
||||||
iced::application(ScreenState::boot, ScreenState::update, ScreenState::view)
|
iced::application(ScreenState::boot, ScreenState::update, ScreenState::view)
|
||||||
@@ -28,6 +30,7 @@ pub enum RootMessage {
|
|||||||
Writing(WritingMessage),
|
Writing(WritingMessage),
|
||||||
Dictionary(DictionaryMessage),
|
Dictionary(DictionaryMessage),
|
||||||
DictionaryQuiz(DictionaryQuizMessage),
|
DictionaryQuiz(DictionaryQuizMessage),
|
||||||
|
Randomizer(RandomizerMessage)
|
||||||
}
|
}
|
||||||
|
|
||||||
enum Page {
|
enum Page {
|
||||||
@@ -36,6 +39,7 @@ enum Page {
|
|||||||
Writing(WritingState),
|
Writing(WritingState),
|
||||||
Dictionary(DictionaryState),
|
Dictionary(DictionaryState),
|
||||||
DictionaryQuiz(DictionaryQuizState),
|
DictionaryQuiz(DictionaryQuizState),
|
||||||
|
Randomizer(RandomizerState),
|
||||||
PreviousPage,
|
PreviousPage,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -62,12 +66,12 @@ impl ScreenState {
|
|||||||
(ScreenState::default(), Task::none())
|
(ScreenState::default(), Task::none())
|
||||||
}
|
}
|
||||||
pub fn update(&mut self, message: RootMessage) -> Task<RootMessage> {
|
pub fn update(&mut self, message: RootMessage) -> Task<RootMessage> {
|
||||||
state_update!(message, self.stack, Selector, Quiz, Writing, Dictionary, DictionaryQuiz);
|
state_update!(message, self.stack, Selector, Quiz, Writing, Dictionary, DictionaryQuiz, Randomizer);
|
||||||
Task::none()
|
Task::none()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn view(&self) -> Element<'_, RootMessage> {
|
pub fn view(&self) -> Element<'_, RootMessage> {
|
||||||
view_navigation!(self.stack, Quiz, Selector, Writing, Dictionary, DictionaryQuiz)
|
view_navigation!(self.stack, Quiz, Selector, Writing, Dictionary, DictionaryQuiz, Randomizer)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,71 @@
|
|||||||
|
|
||||||
|
pub mod randomizer {
|
||||||
|
use crate::randomizer::randomizer::RandomizerMessage::{Back, Start};
|
||||||
|
use crate::{NavigatedPage, Page, RootMessage};
|
||||||
|
use iced::widget::{button, container, text_editor};
|
||||||
|
use iced::Task;
|
||||||
|
use rand::prelude::SliceRandom;
|
||||||
|
|
||||||
|
#[derive(Clone, Debug)]
|
||||||
|
pub struct RandomizerState {
|
||||||
|
text: text_editor::Content,
|
||||||
|
list: Vec<String>
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Clone)]
|
||||||
|
pub enum RandomizerMessage {
|
||||||
|
Back,
|
||||||
|
Start,
|
||||||
|
Edit(text_editor::Action),
|
||||||
|
}
|
||||||
|
|
||||||
|
impl NavigatedPage<RandomizerMessage> for RandomizerState {
|
||||||
|
fn navigate(&self, message: &RandomizerMessage) -> Option<Page> {
|
||||||
|
if let RandomizerMessage::Back = message {
|
||||||
|
return Some(Page::PreviousPage);
|
||||||
|
}
|
||||||
|
None
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Default for RandomizerState {
|
||||||
|
fn default() -> Self {
|
||||||
|
Self::new()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl RandomizerState {
|
||||||
|
pub fn new() -> RandomizerState {
|
||||||
|
RandomizerState { text: Default::default(), list: vec![] }
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn update(&mut self, message: RandomizerMessage) -> Task<RootMessage> {
|
||||||
|
match message {
|
||||||
|
RandomizerMessage::Edit(action) => {
|
||||||
|
self.text.perform(action);
|
||||||
|
self.list = self.text.text().split("\n").map(|s| s.to_string()).collect();
|
||||||
|
},
|
||||||
|
RandomizerMessage::Start => {
|
||||||
|
self.list.shuffle(&mut rand::rng());
|
||||||
|
self.text = text_editor::Content::with_text(self.list.join("\n").as_str());
|
||||||
|
}
|
||||||
|
_ => {}
|
||||||
|
}
|
||||||
|
Task::none()
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn view(&self) -> iced::Element<'_, RandomizerMessage> {
|
||||||
|
container(
|
||||||
|
iced::widget::column![
|
||||||
|
button("Назад").on_press(Back),
|
||||||
|
text_editor(&self.text).on_action(RandomizerMessage::Edit
|
||||||
|
).width(400).height(400).placeholder("Каждый элемент с новой строки"),
|
||||||
|
button("Начать").on_press(Start),
|
||||||
|
]
|
||||||
|
.spacing(5),
|
||||||
|
)
|
||||||
|
.padding(10)
|
||||||
|
.into()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
+7
-1
@@ -6,6 +6,7 @@ use crate::{NavigatedPage, Page, QuizState, RootMessage};
|
|||||||
use iced::widget::*;
|
use iced::widget::*;
|
||||||
use iced::{alignment, Element, Task};
|
use iced::{alignment, Element, Task};
|
||||||
use crate::dictionary::DictionaryState;
|
use crate::dictionary::DictionaryState;
|
||||||
|
use crate::randomizer::randomizer::RandomizerState;
|
||||||
|
|
||||||
pub struct SelectorState {
|
pub struct SelectorState {
|
||||||
pub set: KanaSet,
|
pub set: KanaSet,
|
||||||
@@ -28,6 +29,7 @@ pub enum SelectorMessage {
|
|||||||
Check(usize, bool),
|
Check(usize, bool),
|
||||||
ChangeMode(bool),
|
ChangeMode(bool),
|
||||||
ToDictionary,
|
ToDictionary,
|
||||||
|
ToRandomize,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl NavigatedPage<SelectorMessage> for SelectorState {
|
impl NavigatedPage<SelectorMessage> for SelectorState {
|
||||||
@@ -45,6 +47,9 @@ impl NavigatedPage<SelectorMessage> for SelectorState {
|
|||||||
if let SelectorMessage::ToDictionary = message {
|
if let SelectorMessage::ToDictionary = message {
|
||||||
return Some(Page::Dictionary(DictionaryState::default()))
|
return Some(Page::Dictionary(DictionaryState::default()))
|
||||||
}
|
}
|
||||||
|
if let SelectorMessage::ToRandomize = message {
|
||||||
|
return Some(Page::Randomizer(RandomizerState::default()))
|
||||||
|
}
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -67,7 +72,8 @@ impl SelectorState {
|
|||||||
container(
|
container(
|
||||||
iced::widget::column![
|
iced::widget::column![
|
||||||
row![button("Переключить азбуки").on_press(SelectorMessage::Change),
|
row![button("Переключить азбуки").on_press(SelectorMessage::Change),
|
||||||
button("Словарь").on_press(SelectorMessage::ToDictionary),].spacing(10),
|
button("Словарь").on_press(SelectorMessage::ToDictionary),
|
||||||
|
button("Рандомайзер").on_press(SelectorMessage::ToRandomize)].spacing(10),
|
||||||
self.rows_selector(),
|
self.rows_selector(),
|
||||||
toggler(self.is_writing)
|
toggler(self.is_writing)
|
||||||
.label("Режим письма")
|
.label("Режим письма")
|
||||||
|
|||||||
Reference in New Issue
Block a user