back_overlay first
This commit is contained in:
+21
-27
@@ -4,8 +4,12 @@ use crate::dictionary::DictionaryMessage::{
|
|||||||
};
|
};
|
||||||
use crate::dictionary_test::DictionaryQuizState;
|
use crate::dictionary_test::DictionaryQuizState;
|
||||||
use crate::lang::{WordData, WordGroup};
|
use crate::lang::{WordData, WordGroup};
|
||||||
|
use crate::navigation::Page::Word;
|
||||||
|
use crate::navigation::{NavigatedPage, Page};
|
||||||
|
use crate::styling::*;
|
||||||
use crate::word::WordState;
|
use crate::word::WordState;
|
||||||
use crate::{AppState, RootMessage };
|
use crate::{AppState, RootMessage};
|
||||||
|
use DictionaryMessage::Back;
|
||||||
use chrono::{DateTime, TimeDelta, Utc};
|
use chrono::{DateTime, TimeDelta, Utc};
|
||||||
use iced::alignment::Vertical::Center;
|
use iced::alignment::Vertical::Center;
|
||||||
use iced::widget::button::Style;
|
use iced::widget::button::Style;
|
||||||
@@ -20,10 +24,6 @@ use std::ops::Add;
|
|||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
use std::sync::{Arc, Mutex};
|
use std::sync::{Arc, Mutex};
|
||||||
use std::time::{Duration, Instant};
|
use std::time::{Duration, Instant};
|
||||||
use DictionaryMessage::Back;
|
|
||||||
use crate::navigation::{NavigatedPage, Page};
|
|
||||||
use crate::navigation::Page::Word;
|
|
||||||
use crate::styling::*;
|
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub struct DictionaryState {
|
pub struct DictionaryState {
|
||||||
@@ -160,7 +160,6 @@ impl DictionaryState {
|
|||||||
v = v[..v.len() - 2].to_string()
|
v = v[..v.len() - 2].to_string()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
while v.contains(",,") {
|
while v.contains(",,") {
|
||||||
let index = v.find(",,").unwrap();
|
let index = v.find(",,").unwrap();
|
||||||
v.remove(index);
|
v.remove(index);
|
||||||
@@ -292,21 +291,17 @@ impl DictionaryState {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn view(&self) -> iced::Element<'_, DictionaryMessage> {
|
pub fn view(&self) -> iced::Element<'_, DictionaryMessage> {
|
||||||
container(
|
back_overlay(
|
||||||
row![
|
iced::widget::column![
|
||||||
iced::widget::column![
|
self.groups_panel(),
|
||||||
button("Назад").style(jl_button).on_press(Back),
|
self.words_list(),
|
||||||
self.groups_panel(),
|
button("Добавить слово")
|
||||||
self.words_list(),
|
.style(jl_button)
|
||||||
button("Добавить слово").style(jl_button).on_press(DictionaryMessage::NewWord),
|
.on_press(DictionaryMessage::NewWord),
|
||||||
]
|
|
||||||
.spacing(5),
|
|
||||||
self.filters()
|
|
||||||
]
|
]
|
||||||
.spacing(DEFAULT_SPACING),
|
.into(),
|
||||||
|
Back,
|
||||||
)
|
)
|
||||||
.padding(10)
|
|
||||||
.into()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn words_list(&self) -> iced::Element<'_, DictionaryMessage> {
|
fn words_list(&self) -> iced::Element<'_, DictionaryMessage> {
|
||||||
@@ -415,13 +410,14 @@ impl DictionaryState {
|
|||||||
toggler(self.reverse)
|
toggler(self.reverse)
|
||||||
.label("Обратный тест")
|
.label("Обратный тест")
|
||||||
.on_toggle(DictionaryMessage::SetReverse),
|
.on_toggle(DictionaryMessage::SetReverse),
|
||||||
button(text!("Тест").center().width(Length::Fill)).style(jl_button)
|
button(text!("Тест").center().width(Length::Fill))
|
||||||
|
.style(jl_button)
|
||||||
.on_press(Test)
|
.on_press(Test)
|
||||||
.width(Length::Fill),
|
.width(Length::Fill),
|
||||||
]
|
]
|
||||||
.width(250)
|
.width(250)
|
||||||
.spacing(DEFAULT_SPACING)
|
.spacing(DEFAULT_SPACING)
|
||||||
.into()
|
.into()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn tags_selector(&self) -> iced::Element<'_, DictionaryMessage> {
|
fn tags_selector(&self) -> iced::Element<'_, DictionaryMessage> {
|
||||||
@@ -462,7 +458,6 @@ impl DictionaryState {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
let current_tags = self
|
let current_tags = self
|
||||||
.tag_map
|
.tag_map
|
||||||
.keys()
|
.keys()
|
||||||
@@ -544,7 +539,7 @@ impl DictionaryState {
|
|||||||
]
|
]
|
||||||
.spacing(DEFAULT_SPACING)
|
.spacing(DEFAULT_SPACING)
|
||||||
]
|
]
|
||||||
.into()
|
.into()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -555,7 +550,6 @@ pub fn split_with_coma(ts: &str) -> Vec<String> {
|
|||||||
.collect::<Vec<String>>()
|
.collect::<Vec<String>>()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
pub fn app_data_dir() -> PathBuf {
|
pub fn app_data_dir() -> PathBuf {
|
||||||
let mut dir = dirs::data_dir().unwrap();
|
let mut dir = dirs::data_dir().unwrap();
|
||||||
dir.push("jap_learn");
|
dir.push("jap_learn");
|
||||||
@@ -574,4 +568,4 @@ pub fn app_cache_dir() -> PathBuf {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dir
|
dir
|
||||||
}
|
}
|
||||||
|
|||||||
+19
-1
@@ -1,8 +1,11 @@
|
|||||||
use iced::border::Radius;
|
use iced::border::Radius;
|
||||||
|
use iced::Element;
|
||||||
use iced::widget::button::{primary, Status};
|
use iced::widget::button::{primary, Status};
|
||||||
|
use iced::widget::{button, container};
|
||||||
use crate::repetitions::Style;
|
use crate::repetitions::Style;
|
||||||
use iced_core::{Border, Theme};
|
use iced_core::{Border, Theme};
|
||||||
|
use iced_core::alignment::Horizontal::Left;
|
||||||
|
use iced_core::Length::Fill;
|
||||||
|
|
||||||
pub const DEFAULT_SPACING: f32 = 16.0;
|
pub const DEFAULT_SPACING: f32 = 16.0;
|
||||||
pub const ACCENT_FONT_SIZE: f32 = 22.0;
|
pub const ACCENT_FONT_SIZE: f32 = 22.0;
|
||||||
@@ -19,3 +22,18 @@ pub fn jl_button(theme: &Theme, status: Status) -> Style {
|
|||||||
style
|
style
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn back_overlay<'a, T: Clone + 'a>(content: Element<'a, T>, back_message: T) -> Element<'a, T> {
|
||||||
|
container(
|
||||||
|
iced::widget::column![
|
||||||
|
button("Назад")
|
||||||
|
.style(jl_button)
|
||||||
|
.on_press(back_message),
|
||||||
|
content
|
||||||
|
]
|
||||||
|
.align_x(Left)
|
||||||
|
.width(Fill),
|
||||||
|
)
|
||||||
|
.center_x(Fill)
|
||||||
|
.padding(10)
|
||||||
|
.into()
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user