Updated word display #19
No files matched your search
@@ -292,7 +292,11 @@ impl NavigatedPage<DictionaryMessage> for DictionaryState {
|
||||
GotoImport => {}
|
||||
SelectField(e, f, index) => {
|
||||
info!("Editing word {}", e.id);
|
||||
if self.word_editor.is_some() && let Some(selected) = &self.selected_cell && selected.0 != e {
|
||||
self.word_editor = Some(WordEditor::new(e, self.state.clone()));
|
||||
}
|
||||
self.selected_cell = Some((e, f, index));
|
||||
|
||||
return focus(iced::widget::Id::new("editor"));
|
||||
}
|
||||
EditField(value) => {
|
||||
|
||||
+64
-63
@@ -5,8 +5,10 @@ use crate::navigation::{NavigatedPage, Page, RootMessage};
|
||||
use crate::pages::word::WordMessage::*;
|
||||
use crate::styling::*;
|
||||
use iced::widget::button::danger;
|
||||
use iced::widget::{button, column, row, space, text, text_input};
|
||||
use iced::widget::{button, column, row, rule, scrollable, space, text, text_input};
|
||||
use iced::{Element, Fill, Task};
|
||||
use crate::data::repositories::Repository;
|
||||
use crate::jl_button;
|
||||
|
||||
pub struct WordEditor {
|
||||
state: AppState,
|
||||
@@ -54,68 +56,67 @@ impl WordEditor {
|
||||
}
|
||||
|
||||
pub(crate) fn view(&self) -> Element<'_, WordMessage> {
|
||||
// let mut fast_add = row![];
|
||||
// if !self.word.additional.contains_key("reading") {
|
||||
// fast_add = fast_add.push(
|
||||
// button("Чтение")
|
||||
// .style(button::text)
|
||||
// .on_press(AddAdditional("reading".to_string())),
|
||||
// );
|
||||
// }
|
||||
// if !self.word.additional.contains_key("description") {
|
||||
// fast_add = fast_add.push(
|
||||
// button("Описание")
|
||||
// .style(button::text)
|
||||
// .on_press(AddAdditional("description".to_string())),
|
||||
// );
|
||||
// }
|
||||
//
|
||||
// if !self.word.additional.contains_key("context") {
|
||||
// fast_add = fast_add.push(
|
||||
// button("В контексте")
|
||||
// .style(button::text)
|
||||
// .on_press(AddAdditional("context".to_string())),
|
||||
// );
|
||||
// }
|
||||
//
|
||||
// let mut col = iced::widget::column![
|
||||
// column![
|
||||
// text!("Ключ"),
|
||||
// text_input("key", &self.word.key).on_input(SetKey),
|
||||
// ]
|
||||
// .spacing(QUARTER_SPACING),
|
||||
// column![
|
||||
// text!("Значение"),
|
||||
// text_input("value", &self.word.value).on_input(SetValue),
|
||||
// ]
|
||||
// .spacing(QUARTER_SPACING),
|
||||
// column![
|
||||
// text!("Теги"),
|
||||
// text_input("tags", &self.word.tags).on_input(SetTags),
|
||||
// ]
|
||||
// .spacing(QUARTER_SPACING),
|
||||
// rule::horizontal(2),
|
||||
// scrollable(fast_add),
|
||||
// ];
|
||||
//
|
||||
// for more in &self.word.additional {
|
||||
// col = col.push(self.get_view_for_more(more));
|
||||
// }
|
||||
//
|
||||
// back_overlay(
|
||||
// column![
|
||||
// col.spacing(DEFAULT_SPACING / 2.0).width(Fill).height(Fill),
|
||||
// row![
|
||||
// button("Сохранить").style(jl_button).on_press(Save),
|
||||
// button("Удалить").style(danger).on_press(Delete),
|
||||
// ]
|
||||
// .spacing(DEFAULT_SPACING)
|
||||
// ]
|
||||
// .spacing(DEFAULT_SPACING)
|
||||
// .into(),
|
||||
// Back,
|
||||
// )
|
||||
space().into()
|
||||
let mut fast_add = row![];
|
||||
let word = self.state.dictionary.read().get_static(self.handle).unwrap();
|
||||
if !word.additional.contains_key("reading") {
|
||||
fast_add = fast_add.push(
|
||||
button("Чтение")
|
||||
.style(button::text)
|
||||
.on_press(AddAdditional("reading".to_string())),
|
||||
);
|
||||
}
|
||||
if !word.additional.contains_key("description") {
|
||||
fast_add = fast_add.push(
|
||||
button("Описание")
|
||||
.style(button::text)
|
||||
.on_press(AddAdditional("description".to_string())),
|
||||
);
|
||||
}
|
||||
|
||||
if !word.additional.contains_key("context") {
|
||||
fast_add = fast_add.push(
|
||||
button("В контексте")
|
||||
.style(button::text)
|
||||
.on_press(AddAdditional("context".to_string())),
|
||||
);
|
||||
}
|
||||
|
||||
let mut col = iced::widget::column![
|
||||
column![
|
||||
text!("Ключ"),
|
||||
text_input("key", &word.key).on_input(SetKey),
|
||||
]
|
||||
.spacing(QUARTER_SPACING),
|
||||
column![
|
||||
text!("Значение"),
|
||||
text_input("value", &word.value).on_input(SetValue),
|
||||
]
|
||||
.spacing(QUARTER_SPACING),
|
||||
column![
|
||||
text!("Теги"),
|
||||
text_input("tags", &word.tags).on_input(SetTags),
|
||||
]
|
||||
.spacing(QUARTER_SPACING),
|
||||
rule::horizontal(2),
|
||||
scrollable(fast_add),
|
||||
];
|
||||
|
||||
for more in &word.additional {
|
||||
col = col.push(self.get_view_for_more(more));
|
||||
}
|
||||
|
||||
column![
|
||||
col.spacing(DEFAULT_SPACING / 2.0).width(Fill).height(Fill),
|
||||
row![
|
||||
jl_button!("Сохранить").on_press(Save),
|
||||
button("Удалить").style(danger).on_press(Delete),
|
||||
]
|
||||
.spacing(DEFAULT_SPACING)
|
||||
]
|
||||
.spacing(DEFAULT_SPACING).into()
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user