Skip to content
Snippets Groups Projects
Commit 1ecd421e authored by Stephen D's avatar Stephen D
Browse files

wire up add new contact button

parent 863acd46
No related branches found
No related tags found
No related merge requests found
......@@ -11,6 +11,16 @@ pub struct Contact {
pub name: String<MAX_CONTACT_NAME_LENGTH>,
}
impl Default for Contact {
fn default() -> Self {
Contact {
callsign: String::new(),
ssid: 0,
name: String::new(),
}
}
}
#[derive(Debug)]
pub struct ContactGroup {
pub contacts: Vec<Contact, MAX_CONTACTS>,
......
......@@ -2,7 +2,7 @@ use embedded_graphics::{pixelcolor::Rgb565, prelude::DrawTarget};
use heapless::{String, Vec};
use crate::{
contact::{ContactGroup, MAX_CONTACTS, MAX_CONTACT_NAME_LENGTH},
contact::{Contact, ContactGroup, MAX_CONTACTS, MAX_CONTACT_NAME_LENGTH},
gui::{chat::Chat, contact_view::ContactView, selector::Selector, status::StatusBar, Element},
keyboard::KeyCode,
voltage::VoltMeter,
......@@ -169,8 +169,15 @@ impl Element for Controller {
}
(View::Contacts(c), KeyCode::Touchpad) => {
// TODO need to handle "Add New" button
self.cur_view = View::new_contact_options(c.selected());
if c.selected() == self.contacts.contacts.len() {
self.contacts.contacts.push(Contact::default()).unwrap();
// Go direct to edit page
self.cur_view =
View::from_contact_options_id(1, c.selected(), &self.contacts).unwrap();
} else {
self.cur_view = View::new_contact_options(c.selected());
}
}
(View::ContactOptions(c, contact_id), KeyCode::Touchpad) => {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment