Add basic methods into NavigatedPage
This commit is contained in:
+41
-39
@@ -102,30 +102,8 @@ impl NavigatedPage<DictionaryMessage> for DictionaryState {
|
||||
|
||||
fn navigated(&mut self) {
|
||||
}
|
||||
}
|
||||
|
||||
impl DictionaryState {
|
||||
pub fn new(state: Arc<Mutex<AppState>>) -> Self {
|
||||
let len = state.lock().unwrap().dictionary.len();
|
||||
|
||||
let mut result = DictionaryState {
|
||||
include_map: vec![false; len],
|
||||
selected_group_index: 0,
|
||||
state,
|
||||
tag_map: HashMap::new(),
|
||||
reverse: false,
|
||||
search: "".to_string(),
|
||||
no_typing: true,
|
||||
reverse_list: true,
|
||||
auto_save_queue: HashMap::new(),
|
||||
};
|
||||
|
||||
result.update_tags();
|
||||
|
||||
result
|
||||
}
|
||||
|
||||
pub fn update(&mut self, message: DictionaryMessage) -> Task<RootMessage> {
|
||||
fn update(&mut self, message: DictionaryMessage) -> Task<RootMessage> {
|
||||
match message {
|
||||
NewWord => {
|
||||
let mut state = self.state.lock().unwrap();
|
||||
@@ -271,6 +249,45 @@ impl DictionaryState {
|
||||
|
||||
Task::none()
|
||||
}
|
||||
|
||||
fn view(&self) -> iced::Element<'_, DictionaryMessage> {
|
||||
back_overlay(
|
||||
row![
|
||||
iced::widget::column![
|
||||
self.groups_panel(),
|
||||
row![horizontal().width(8), self.words_list(),],
|
||||
button("Добавить слово").style(jl_button).on_press(NewWord),
|
||||
]
|
||||
.spacing(5),
|
||||
self.filters(),
|
||||
]
|
||||
.spacing(DEFAULT_SPACING)
|
||||
.into(),
|
||||
Back,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
impl DictionaryState {
|
||||
pub fn new(state: Arc<Mutex<AppState>>) -> Self {
|
||||
let len = state.lock().unwrap().dictionary.len();
|
||||
|
||||
let mut result = DictionaryState {
|
||||
include_map: vec![false; len],
|
||||
selected_group_index: 0,
|
||||
state,
|
||||
tag_map: HashMap::new(),
|
||||
reverse: false,
|
||||
search: "".to_string(),
|
||||
no_typing: true,
|
||||
reverse_list: true,
|
||||
auto_save_queue: HashMap::new(),
|
||||
};
|
||||
|
||||
result.update_tags();
|
||||
|
||||
result
|
||||
}
|
||||
|
||||
fn save_word(&mut self, i: usize) {
|
||||
let state = &mut self.state.lock().unwrap();
|
||||
@@ -291,22 +308,7 @@ impl DictionaryState {
|
||||
)
|
||||
}
|
||||
|
||||
pub fn view(&self) -> iced::Element<'_, DictionaryMessage> {
|
||||
back_overlay(
|
||||
row![
|
||||
iced::widget::column![
|
||||
self.groups_panel(),
|
||||
row![horizontal().width(8), self.words_list(),],
|
||||
button("Добавить слово").style(jl_button).on_press(NewWord),
|
||||
]
|
||||
.spacing(5),
|
||||
self.filters(),
|
||||
]
|
||||
.spacing(DEFAULT_SPACING)
|
||||
.into(),
|
||||
Back,
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
fn words_list(&self) -> iced::Element<'_, DictionaryMessage> {
|
||||
let time = Instant::now();
|
||||
|
||||
Reference in New Issue
Block a user