From: Eugene Kurzberg Date: Fri, 24 Jun 2016 08:38:37 +0000 (+0300) Subject: Added possibility to append View to Navigator without navigating to it. X-Git-Tag: submit/tizen/20160826.132643~1^2~90 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=04ee5fa70d0828fb46d68a9bf52b1ebe5aaac254;p=profile%2Fmobile%2Fapps%2Fnative%2Fphone-contacts.git Added possibility to append View to Navigator without navigating to it. Change-Id: I76fbe5e46840a7e8f4e45f6e89f3685b2f532c02 Signed-off-by: Eugene Kurzberg --- diff --git a/contacts-app/src/OperationDefaultController.cpp b/contacts-app/src/OperationDefaultController.cpp index cc305f1..f600cb6 100644 --- a/contacts-app/src/OperationDefaultController.cpp +++ b/contacts-app/src/OperationDefaultController.cpp @@ -52,7 +52,7 @@ void OperationDefaultController::onCreate() m_Tabs[TabContacts] = new Contacts::List::ListView(); for (auto &&tab : m_Tabs) { - m_Navigator->navigateTo(tab); + m_Navigator->appendView(tab); } } diff --git a/lib-apps-common/inc/Ui/Navigator.h b/lib-apps-common/inc/Ui/Navigator.h index b0c9f22..4e14818 100644 --- a/lib-apps-common/inc/Ui/Navigator.h +++ b/lib-apps-common/inc/Ui/Navigator.h @@ -49,6 +49,14 @@ namespace Ui size_t getPageCount() const; /** + * @brief Add view to navigator. + * @details Adding a view may also result in navigating to it + * if it's a first view or this is a #StackNavigator. + * @param[in] view View to add + */ + void appendView(View *view); + + /** * @brief Navigate to existing or new View. * @param[in] view View to navigate to */ diff --git a/lib-apps-common/src/Ui/Navigator.cpp b/lib-apps-common/src/Ui/Navigator.cpp index b6443f5..ab3ea48 100644 --- a/lib-apps-common/src/Ui/Navigator.cpp +++ b/lib-apps-common/src/Ui/Navigator.cpp @@ -39,6 +39,27 @@ size_t Navigator::getPageCount() const return m_PageCount; } +void Navigator::appendView(View *view) +{ + if (!view) { + return; + } + + Navigator *stackNavi = m_StackNavi; + Navigator *tabNavi = m_TabNavi; + if (getType() == StackNavigator) { + stackNavi = this; + } else { + tabNavi = this; + } + + NavigatorPage *page = attachView(view); + page->onNavigatorAttached(this, view); + view->onNavigatorAttached(stackNavi, tabNavi, page); + + ++m_PageCount; +} + void Navigator::navigateTo(View *view) { if (!view) { @@ -50,21 +71,9 @@ void Navigator::navigateTo(View *view) return; } - NavigatorType navigatorType = NavigatorType(getType()); - if (view->getNavigator(navigatorType) != this) { - Navigator *stackNavi = m_StackNavi; - Navigator *tabNavi = m_TabNavi; - if (navigatorType == StackNavigator) { - stackNavi = this; - } else { - tabNavi = this; - } - - page = attachView(view); - page->onNavigatorAttached(this, view); - view->onNavigatorAttached(stackNavi, tabNavi, page); - - ++m_PageCount; + if (view->getNavigator(NavigatorType(getType())) != this) { + appendView(view); + page = view->getPage(); } navigateToPage(page);