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