Browse Source

Add Contact create

embed
Manos Pitsidianakis 3 years ago
parent
commit
bac75b96dd
Signed by untrusted user: epilys GPG Key ID: 73627C2F690DF710
  1. 23
      ui/src/components/contacts/contact_list.rs

23
ui/src/components/contacts/contact_list.rs

@ -54,8 +54,8 @@ impl ContactList {
fn initialize(&mut self, context: &mut Context) {
let account = &mut context.accounts[self.account_pos];
let book = &mut account.address_book;
self.length = book.len();
self.content.resize(MAX_COLS, book.len(), Cell::with_char(' '));
eprintln!("initialize {:?}", book);
self.id_positions.clear();
if self.id_positions.capacity() < book.len() {
@ -127,6 +127,27 @@ impl Component for ContactList {
return true;
},
UIEventType::Input(Key::Char('n')) => {
let card = Card::new();
let mut manager = ContactManager::default();
manager.card = card;
manager.account_pos = self.account_pos;
let entity = Entity::from(Box::new(manager));
self.mode = ViewMode::View(*entity.id());
self.view = Some(entity);
return true;
},
UIEventType::Input(Key::Up) => {
self.set_dirty();
self.new_cursor_pos = self.cursor_pos.saturating_sub(1);
return true;
},
UIEventType::Input(Key::Down) if self.cursor_pos < self.length.saturating_sub(1) => {
self.set_dirty();
self.new_cursor_pos += 1;
return true;
},
UIEventType::EntityKill(ref kill_id) if self.mode == ViewMode::View(*kill_id) => {
self.mode = ViewMode::List;
self.view.take();

Loading…
Cancel
Save