summaryrefslogtreecommitdiff
path: root/src/ui/ui_contacts.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/ui/ui_contacts.cpp')
-rw-r--r--src/ui/ui_contacts.cpp31
1 files changed, 25 insertions, 6 deletions
diff --git a/src/ui/ui_contacts.cpp b/src/ui/ui_contacts.cpp
index c381db5..d57776e 100644
--- a/src/ui/ui_contacts.cpp
+++ b/src/ui/ui_contacts.cpp
@@ -18,9 +18,8 @@ void ui_setup_contacts()
memset(&selected_for_removal, 0, sizeof(contact));
}
-void draw_contact_form(contact* buffer, bool viewing_only = false)
+void draw_contact_form_ex(contact* buffer, bool viewing_only = false, bool with_autocomplete = false, bool* on_autocomplete = 0)
{
- bool with_autocomplete = false;
const char* selected_country = NULL;
ImGui::Spacing();
@@ -37,12 +36,26 @@ void draw_contact_form(contact* buffer, bool viewing_only = false)
// 2. Full name
ImGui::SetNextItemWidth(widthAvailable*0.5f);
if (with_autocomplete) {
- contact autocomplete_list[5];
- int autocomplete_count = 5;
- char* autocomplete_strings[5] = { "1", "2", "3", "4", "5" };
+ contact autocomplete_list[5];
+ int autocomplete_count = administration_get_contact_recommendations(autocomplete_list, 5, buffer->name);
+ char* autocomplete_strings[5];
+
+ for (int i = 0; i < autocomplete_count; i++)
+ {
+ autocomplete_strings[i] = autocomplete_list[i].name;
+ }
- ui_helper_TextInputWithAutocomplete(localize("contact.form.fullname"), localize("contact.form.fullname"),
+ int autocomplete_index = ui_helper_TextInputWithAutocomplete(localize("contact.form.fullname"), localize("contact.form.fullname"),
buffer->name, IM_ARRAYSIZE(buffer->name), (char**)autocomplete_strings, autocomplete_count);
+
+ if (on_autocomplete) {
+ *on_autocomplete = autocomplete_index != -1;
+ }
+
+ if (autocomplete_index != -1)
+ {
+ memcpy(buffer, &autocomplete_list[autocomplete_index], sizeof(contact));
+ }
}
else ImGui::InputTextWithHint(localize("contact.form.fullname"), localize("contact.form.fullname"), buffer->name, IM_ARRAYSIZE(buffer->name));
ImGui::SameLine();ui_helper_draw_required_tag();
@@ -131,6 +144,12 @@ void draw_contact_form(contact* buffer, bool viewing_only = false)
if (viewing_only) ImGui::EndDisabled();
}
+void draw_contact_form(contact* buffer, bool viewing_only = false)
+{
+ draw_contact_form_ex(buffer, viewing_only, false, 0);
+}
+
+
static void draw_contact_list()
{
const u32 items_per_page = 50;