Add ScrollArea to notes container
This commit is contained in:
parent
b599f628de
commit
e839770c9a
1 changed files with 41 additions and 37 deletions
78
src/main.rs
78
src/main.rs
|
@ -122,19 +122,21 @@ impl eframe::App for App {
|
|||
});
|
||||
ui.separator();
|
||||
|
||||
for note in &mut self.notes {
|
||||
let render_result = note.render(ui, password, |id| {
|
||||
let _ = &self.saving.delete_note(&id).unwrap();
|
||||
info!("note with id {} was successfully deleted", id);
|
||||
egui::ScrollArea::vertical().show(ui, |ui| {
|
||||
for note in &mut self.notes {
|
||||
let render_result = note.render(ui, password, |id| {
|
||||
let _ = &self.saving.delete_note(&id).unwrap();
|
||||
info!("note with id {} was successfully deleted", id);
|
||||
|
||||
self.update_notes_next = true;
|
||||
});
|
||||
self.update_notes_next = true;
|
||||
});
|
||||
|
||||
if let Some(new_note) = render_result {
|
||||
*note = new_note;
|
||||
if let Some(new_note) = render_result {
|
||||
*note = new_note;
|
||||
}
|
||||
ui.add_space(10.0);
|
||||
}
|
||||
ui.add_space(10.0);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
CurrentMode::Compose => {
|
||||
|
@ -153,39 +155,41 @@ impl eframe::App for App {
|
|||
});
|
||||
ui.separator();
|
||||
|
||||
ui.label("title:");
|
||||
ui.text_edit_singleline(&mut self.title_buffer);
|
||||
egui::ScrollArea::vertical().show(ui, |ui| {
|
||||
ui.label("title:");
|
||||
ui.text_edit_singleline(&mut self.title_buffer);
|
||||
|
||||
ui.label("text:");
|
||||
ui.text_edit_multiline(&mut self.text_buffer);
|
||||
ui.label("text:");
|
||||
ui.text_edit_multiline(&mut self.text_buffer);
|
||||
|
||||
ui.add_space(10.0);
|
||||
if ui.button("add note").clicked() {
|
||||
let note = Note::Decrypted {
|
||||
id: SystemTime::now()
|
||||
.duration_since(SystemTime::UNIX_EPOCH)
|
||||
.unwrap()
|
||||
.as_millis()
|
||||
.to_string(),
|
||||
title: self.title_buffer.clone(),
|
||||
metadata: NoteMetadata {
|
||||
date: SystemTime::now(),
|
||||
arbitrary: None,
|
||||
},
|
||||
text: self.text_buffer.clone(),
|
||||
};
|
||||
ui.add_space(10.0);
|
||||
if ui.button("add note").clicked() {
|
||||
let note = Note::Decrypted {
|
||||
id: SystemTime::now()
|
||||
.duration_since(SystemTime::UNIX_EPOCH)
|
||||
.unwrap()
|
||||
.as_millis()
|
||||
.to_string(),
|
||||
title: self.title_buffer.clone(),
|
||||
metadata: NoteMetadata {
|
||||
date: SystemTime::now(),
|
||||
arbitrary: None,
|
||||
},
|
||||
text: self.text_buffer.clone(),
|
||||
};
|
||||
|
||||
self.saving.save_note(note.clone(), password.to_string()).unwrap();
|
||||
self.saving.save_note(note.clone(), password.to_string()).unwrap();
|
||||
|
||||
let mut vec_deque = VecDeque::from(self.notes.clone());
|
||||
vec_deque.push_front(note);
|
||||
let mut vec_deque = VecDeque::from(self.notes.clone());
|
||||
vec_deque.push_front(note);
|
||||
|
||||
self.notes = Vec::from(vec_deque);
|
||||
self.notes = Vec::from(vec_deque);
|
||||
|
||||
self.title_buffer = String::new();
|
||||
self.text_buffer = String::new();
|
||||
self.mode = CurrentMode::View;
|
||||
}
|
||||
self.title_buffer = String::new();
|
||||
self.text_buffer = String::new();
|
||||
self.mode = CurrentMode::View;
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
CurrentMode::PasswordInput => {
|
||||
|
|
Loading…
Reference in a new issue