From 697f72742976dae1d4e5301bb4a06c935a4151a9 Mon Sep 17 00:00:00 2001 From: Hugo Saint-Vignes Date: Fri, 9 Oct 2020 16:02:43 +0200 Subject: [PATCH] [apps/shared] Add discard confirmation on range parameters Change-Id: I609acbd136cb0bc84899777810f4c1497832952f --- apps/shared/range_parameter_controller.cpp | 12 +++++++++++- apps/shared/range_parameter_controller.h | 2 ++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/apps/shared/range_parameter_controller.cpp b/apps/shared/range_parameter_controller.cpp index 042253466..6256ce6aa 100644 --- a/apps/shared/range_parameter_controller.cpp +++ b/apps/shared/range_parameter_controller.cpp @@ -11,7 +11,12 @@ RangeParameterController::RangeParameterController(Responder * parentResponder, m_tempInteractiveRange(*interactiveRange), m_xRangeCells{}, m_yRangeCells{}, - m_yAutoCell(I18n::Message::YAuto) + m_yAutoCell(I18n::Message::YAuto), + m_confirmPopUpController(Invocation([](void * context, void * sender) { + Container::activeApp()->dismissModalViewController(); + ((RangeParameterController *)context)->stackController()->pop(); + return true; + }, this)) { for (int i = 0; i < k_numberOfEditableTextCell; i++) { m_xRangeCells[i].setParentResponder(&m_selectableTableView); @@ -82,6 +87,11 @@ bool RangeParameterController::handleEvent(Ion::Events::Event event) { m_selectableTableView.reloadData(); return true; } + if (event == Ion::Events::Back && m_interactiveRange->rangeChecksum() != m_tempInteractiveRange.rangeChecksum()) { + // Open pop-up to confirm discarding values + Container::activeApp()->displayModalViewController(&m_confirmPopUpController, 0.f, 0.f, Metric::ExamPopUpTopMargin, Metric::PopUpRightMargin, Metric::ExamPopUpBottomMargin, Metric::PopUpLeftMargin); + return true; + } return FloatParameterController::handleEvent(event); } diff --git a/apps/shared/range_parameter_controller.h b/apps/shared/range_parameter_controller.h index a2006f284..6de99e912 100644 --- a/apps/shared/range_parameter_controller.h +++ b/apps/shared/range_parameter_controller.h @@ -4,6 +4,7 @@ #include #include "interactive_curve_view_range.h" #include "float_parameter_controller.h" +#include "discard_pop_up_controller.h" namespace Shared { @@ -45,6 +46,7 @@ private: MessageTableCellWithEditableText m_xRangeCells[k_numberOfEditableTextCell]; MessageTableCellWithConvertibleEditableText m_yRangeCells[k_numberOfConvertibleTextCell]; MessageTableCellWithSwitch m_yAutoCell; + DiscardPopUpController m_confirmPopUpController; }; }