add close action in Contacts List

embed
Manos Pitsidianakis 2019-03-02 08:39:59 +02:00
parent f748f1e692
commit 12cc9950c7
Signed by: Manos Pitsidianakis
GPG Key ID: 73627C2F690DF710
1 changed files with 13 additions and 0 deletions

View File

@ -8,6 +8,7 @@ const MAX_COLS: usize = 500;
enum ViewMode {
List,
View(CardId),
Close(Uuid),
}
#[derive(Debug)]
@ -88,6 +89,14 @@ impl ContactList {
impl Component for ContactList {
fn draw(&mut self, grid: &mut CellBuffer, area: Area, context: &mut Context) {
if let ViewMode::Close(u) = self.mode {
context.replies.push_back(UIEvent {
id: 0,
event_type: UIEventType::Action(Tab(Kill(u))),
});
return;
}
if let Some(mgr) = self.view.as_mut() {
mgr.draw(grid, area, context);
return;
@ -189,4 +198,8 @@ impl Component for ContactList {
};
self.dirty = true;
}
fn kill(&mut self, uuid: Uuid) {
self.mode = ViewMode::Close(uuid);
}
}