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