Add NoSwitchesModalPresenter 07/208507/4
authorLukasz Wlazly <l.wlazly@partner.samsung.com>
Tue, 25 Jun 2019 09:16:37 +0000 (11:16 +0200)
committerLukasz Wlazly <l.wlazly@partner.samsung.com>
Thu, 27 Jun 2019 06:57:41 +0000 (08:57 +0200)
Change-Id: I43d94f3525fbdf758dc52dad253e1e6421dc01c2

src/presenter/NoSwitchesModalPresenter.cpp [new file with mode: 0644]
src/presenter/NoSwitchesModalPresenter.hpp [new file with mode: 0644]
src/presenter/UniversalSwitchPagePresenter.cpp
src/view/ModalView.cpp

diff --git a/src/presenter/NoSwitchesModalPresenter.cpp b/src/presenter/NoSwitchesModalPresenter.cpp
new file mode 100644 (file)
index 0000000..20799e5
--- /dev/null
@@ -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<AppContext>::instance().push(std::make_unique<AddSwitchPagePresenter>());
+       };
+
+       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 (file)
index 0000000..3d380c1
--- /dev/null
@@ -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
index 5c7884c..41e8257 100644 (file)
@@ -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<AppContext>::instance().pushModal(std::make_unique<NoSwitchesModalPresenter>());
                        }
                },
                ListItem::WidgetType::toggle,
index 3a435a8..fadda64 100644 (file)
@@ -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