From 150df09b9ce2f40aa83a707cdd0e79927d4d4d6a Mon Sep 17 00:00:00 2001 From: Lukasz Wlazly Date: Tue, 25 Jun 2019 11:16:37 +0200 Subject: [PATCH] Add NoSwitchesModalPresenter Change-Id: I43d94f3525fbdf758dc52dad253e1e6421dc01c2 --- src/presenter/NoSwitchesModalPresenter.cpp | 19 +++++++++++++++++++ src/presenter/NoSwitchesModalPresenter.hpp | 12 ++++++++++++ src/presenter/UniversalSwitchPagePresenter.cpp | 3 ++- src/view/ModalView.cpp | 2 +- 4 files changed, 34 insertions(+), 2 deletions(-) create mode 100644 src/presenter/NoSwitchesModalPresenter.cpp create mode 100644 src/presenter/NoSwitchesModalPresenter.hpp diff --git a/src/presenter/NoSwitchesModalPresenter.cpp b/src/presenter/NoSwitchesModalPresenter.cpp new file mode 100644 index 0000000..20799e5 --- /dev/null +++ b/src/presenter/NoSwitchesModalPresenter.cpp @@ -0,0 +1,19 @@ +#include "NoSwitchesModalPresenter.hpp" + +#include "AddSwitchPagePresenter.hpp" +#include "AppContext.hpp" + +NoSwitchesModalPresenter::NoSwitchesModalPresenter() +{ + setTitle("Add switch?"); + text_ = "To turn on Universal switch, tap ADD SWITCH and add at least one switch"; + + doneText_ = "IDS_ACCS_UNIVERSAL_SWITCH_POPUP_ADD"; + doneCb_ = [this]() { + Singleton::instance().push(std::make_unique()); + }; + + cancelCb_ = [this]() { + DEBUG("cancel cb"); + }; +} \ No newline at end of file diff --git a/src/presenter/NoSwitchesModalPresenter.hpp b/src/presenter/NoSwitchesModalPresenter.hpp new file mode 100644 index 0000000..3d380c1 --- /dev/null +++ b/src/presenter/NoSwitchesModalPresenter.hpp @@ -0,0 +1,12 @@ +#ifndef NO_SWITCHES_MODAL_PRESENTER_HPP +#define NO_SWITCHES_MODAL_PRESENTER_HPP + +#include "ModalPresenter.hpp" + +class NoSwitchesModalPresenter : public ModalPresenter +{ + public: + NoSwitchesModalPresenter(); +}; + +#endif \ No newline at end of file diff --git a/src/presenter/UniversalSwitchPagePresenter.cpp b/src/presenter/UniversalSwitchPagePresenter.cpp index 5c7884c..41e8257 100644 --- a/src/presenter/UniversalSwitchPagePresenter.cpp +++ b/src/presenter/UniversalSwitchPagePresenter.cpp @@ -1,5 +1,6 @@ #include "UniversalSwitchPagePresenter.hpp" +#include "NoSwitchesModalPresenter.hpp" #include "UniversalSwitchSettingsPagePresenter.hpp" UniversalSwitchPagePresenter::UniversalSwitchPagePresenter() @@ -18,7 +19,7 @@ UniversalSwitchPagePresenter::UniversalSwitchPagePresenter() else { item->widgetState_ = false; DEBUG("No switch configured"); - //There should be created popup which inform that user should configure at least one switch + Singleton::instance().pushModal(std::make_unique()); } }, ListItem::WidgetType::toggle, diff --git a/src/view/ModalView.cpp b/src/view/ModalView.cpp index 3a435a8..fadda64 100644 --- a/src/view/ModalView.cpp +++ b/src/view/ModalView.cpp @@ -32,7 +32,7 @@ ModalView::ModalView(const NavigationContext &context, ModalPresenter *presenter c(); nf->removeChild(p); }, - "IDS_ACCS_DELETE", + presenter->getDoneText(), "bottom"); popup->setPartContent("button2", doneBtn); } \ No newline at end of file -- 2.7.4