and genlist item for ContactDateField.
Change-Id: I04a96a1905835aa21bda120bd545a63faaf06e21
Signed-off-by: Eugene Kurzberg <i.kurtsberg@samsung.com>
ContactDateFieldControl(Model::ContactDateField &field);
/**
+ * @brief Show date picker popup.
+ */
+ void showPicker();
+
+ /**
* @brief Update the control using field's value.
*/
void update();
private:
virtual void onCreated() override;
void onCreatePressed();
+ void onDonePressed(Evas_Object *entry, void *eventInfo);
static void onEntryChanged(Evas_Object *button, Evas_Object *entry, void *eventInfo);
ResultCallback m_OnResult;
{
}
+void ContactDateFieldControl::showPicker()
+{
+ Ui::DatePopup *popup = new Ui::DatePopup(m_Field.getValue());
+ popup->setResultCallback([this](const tm &date) {
+ m_Field.setValue(date);
+ update();
+ });
+ popup->create(getEvasObject());
+}
+
void ContactDateFieldControl::update()
{
tm date = m_Field.getValue();
void ContactDateFieldControl::onButtonPressed(Evas_Object *button, void *eventInfo)
{
- Ui::DatePopup *popup = new Ui::DatePopup(m_Field.getValue());
- popup->setResultCallback([this](const tm &date) {
- m_Field.setValue(date);
- update();
- });
- popup->create(getEvasObject());
+ showPicker();
}
if (m_Field.getType() == TypeText) {
Evas_Object *entry = static_cast<Ui::Editfield *>(control)->getEntry();
elm_object_focus_set(entry, EINA_TRUE);
+ } else if (m_Field.getType() == TypeDate) {
+ static_cast<ContactDateFieldControl *>(control)->showPicker();
}
}
}
#include "Contacts/Input/ContactObjectCustomTypePopup.h"
#include "Ui/Editfield.h"
+#include "Utils/Callback.h"
using namespace Contacts::Input;
elm_entry_input_panel_return_key_type_set(entry, ELM_INPUT_PANEL_RETURN_KEY_TYPE_DONE);
evas_object_smart_callback_add(entry, "changed",
(Evas_Smart_Cb) &ContactObjectCustomTypePopup::onEntryChanged, button);
+ evas_object_smart_callback_add(entry, "activated",
+ makeCallback(&ContactObjectCustomTypePopup::onDonePressed), this);
elm_object_focus_set(entry, EINA_TRUE);
}
}
}
+void ContactObjectCustomTypePopup::onDonePressed(Evas_Object *entry, void *eventInfo)
+{
+ onCreatePressed();
+ delete this;
+}
+
void ContactObjectCustomTypePopup::onEntryChanged(Evas_Object *button, Evas_Object *entry, void *eventInfo)
{
elm_object_disabled_set(button, elm_entry_is_empty(entry));