From 32126d88125f60786678af97fcf163318c144e91 Mon Sep 17 00:00:00 2001 From: Eugene Kurzberg Date: Fri, 10 Feb 2017 14:43:46 +0200 Subject: Implement "Alarm deleted" popup. Refactor InputView button behavior. Change-Id: Ib72e13bb5702f1df2b9f508bfce604d659e74991 Signed-off-by: Eugene Kurzberg --- alarm-app/inc/Input/InputView.h | 3 + alarm-app/src/Input/InputView.cpp | 55 ++++++++---- lib-common/.cproject | 97 ++-------------------- lib-common/edje/common/images/check_18.png | Bin 0 -> 3386 bytes lib-common/inc/Common/AlarmDeletedPopup.h | 34 ++++++++ lib-common/res/common/edje/CommonPath.h | 3 + lib-common/res/common/edje/toast-check-layout.edc | 61 ++++++++++++++ lib-common/src/Common/AlarmDeletedPopup.cpp | 34 ++++++++ 8 files changed, 178 insertions(+), 109 deletions(-) create mode 100644 lib-common/edje/common/images/check_18.png create mode 100644 lib-common/inc/Common/AlarmDeletedPopup.h create mode 100644 lib-common/res/common/edje/toast-check-layout.edc create mode 100644 lib-common/src/Common/AlarmDeletedPopup.cpp diff --git a/alarm-app/inc/Input/InputView.h b/alarm-app/inc/Input/InputView.h index 7f7f8e8..19b4139 100644 --- a/alarm-app/inc/Input/InputView.h +++ b/alarm-app/inc/Input/InputView.h @@ -48,6 +48,9 @@ namespace Input Evas_Object *createScroller(Evas_Object *parent); void updateButton(); + void saveAlarm(); + void deleteAlarm(); + bool isFirstPage() const; void onTimeChanged(Evas_Object *datetime, void *eventInfo); void onPageChanged(Evas_Object *scroller, void *eventInfo); diff --git a/alarm-app/src/Input/InputView.cpp b/alarm-app/src/Input/InputView.cpp index f5b561e..752036f 100644 --- a/alarm-app/src/Input/InputView.cpp +++ b/alarm-app/src/Input/InputView.cpp @@ -17,6 +17,7 @@ #include "Input/InputView.h" #include "Input/SetRepeatView.h" #include "Input/SetTimeView.h" +#include "Common/AlarmDeletedPopup.h" #include "Common/Model/AlarmConsumer.h" #include "Ui/PageIndex.h" @@ -104,6 +105,41 @@ void InputView::updateButton() elm_object_translatable_text_set(m_Button, text); } +void InputView::saveAlarm() +{ + tm time = m_TimeView->getTimePicker()->getTime(); + m_Alarm.setTime(time.tm_hour, time.tm_min); + m_Alarm.setRepeat(m_RepeatView->getDaySelector()->getSelectedDays()); + + elm_object_disabled_set(m_Button, EINA_TRUE); + AlarmConsumer::getInstance().saveAlarm(m_Alarm, [this](bool isSuccess) { + if (!isSuccess) { + /* TODO: Show error message */ + elm_object_disabled_set(m_Button, EINA_FALSE); + return; + } + + getPage()->close(); + }); +} + +void InputView::deleteAlarm() +{ + elm_object_disabled_set(m_Button, EINA_TRUE); + AlarmConsumer::getInstance().deleteAlarm(m_Alarm.getId(), [this](bool isSuccess) { + if (!isSuccess) { + /* TODO: Show error message */ + elm_object_disabled_set(m_Button, EINA_FALSE); + return; + } + + auto popup = new Common::AlarmDeletedPopup(); + popup->create(getEvasObject()); + popup->show(); + getPage()->close(); + }); +} + bool InputView::isFirstPage() const { int index = 0; @@ -124,29 +160,14 @@ void InputView::onPageChanged(Evas_Object *scroller, void *eventInfo) void InputView::onButtonPressed(Evas_Object *button, void *eventInfo) { - auto resultCallback = [this](bool isSuccess) { - if (isSuccess) { - getPage()->close(); - } else { - /* TODO: Show error message */ - elm_object_disabled_set(m_Button, EINA_FALSE); - } - }; - if (isFirstPage()) { if (!m_HasDeleteButton) { elm_scroller_page_bring_in(m_Scroller, 1, 0); return; } - elm_object_disabled_set(button, EINA_FALSE); - AlarmConsumer::getInstance().deleteAlarm(m_Alarm.getId(), resultCallback); + deleteAlarm(); } else { - tm time = m_TimeView->getTimePicker()->getTime(); - m_Alarm.setTime(time.tm_hour, time.tm_min); - m_Alarm.setRepeat(m_RepeatView->getDaySelector()->getSelectedDays()); - - elm_object_disabled_set(button, EINA_FALSE); - AlarmConsumer::getInstance().saveAlarm(m_Alarm, resultCallback); + saveAlarm(); } } diff --git a/lib-common/.cproject b/lib-common/.cproject index 7f4056a..07dc980 100644 --- a/lib-common/.cproject +++ b/lib-common/.cproject @@ -28,95 +28,7 @@ - +