model_.addSwitch({switchId_, userName_, activityType});
break;
case ChangeType::UPDATE:
- model_.addSwitch({switchId_, userName_, activityType});
+ model_.updateSwitch({switchId_, userName_, activityType});
break;
default:
ASSERT(0, "Unhandled change type");
#include "AddSwitchPagePresenter.hpp"
#include "AppContext.hpp"
#include "RemoveSwitchesPagePresenter.hpp"
+#include "SelectActionPagePresenter.hpp"
#include "UniversalSwitchConstants.hpp"
SwitchesPagePresenter::SwitchesPagePresenter()
{
auto &items = groups_.back().items_;
auto switches = model_.getAllSwitchConfigurationItems();
- for (auto oneSwitch : switches) {
+ for (auto &oneSwitch : switches) {
items.push_back(std::make_unique<ListItem>(
oneSwitch.userName,
model_.getActivityName(oneSwitch.activityType),
- [this](auto item) {
- //UpdateSwitchPage should be added here
+ [this, oneSwitch](auto item) {
+ this->createUpdatePage(oneSwitch.switchId);
}));
}
items.push_back(std::make_unique<ListItem>(
true,
ACCESSIBILITY_UNIVERSAL_SWITCH_PLUS_ICON));
}
+
+void SwitchesPagePresenter::createUpdatePage(const std::string &switchId)
+{
+ auto providerName = utils::stringSplitByDelimiter(switchId, '_')[0];
+ if (providerName == ACCESSIBILITY_UNIVERSAL_SWITCH_SCREEN_SWITCH_PROVIDER) {
+ Singleton<AppContext>::instance().push(std::make_unique<SelectActionPagePresenter>(switchId, ACCESSIBILITY_UNIVERSAL_SWITCH_SCREEN, ChangeType::UPDATE, 0));
+ return;
+ }
+ if (providerName == ACCESSIBILITY_UNIVERSAL_SWITCH_ACCESSORIES_SWITCH_PROVIDER) {
+ return;
+ }
+ if (providerName == ACCESSIBILITY_UNIVERSAL_SWITCH_CAMERA_SWITCH_PROVIDER) {
+ Singleton<AppContext>::instance().push(std::make_unique<SelectActionPagePresenter>(switchId, ACCESSIBILITY_UNIVERSAL_SWITCH_CAMERA_SWITCH_PROVIDER, ChangeType::UPDATE, 0));
+ return;
+ }
+}
\ No newline at end of file
#include "Elementary.h"
#include <sstream>
+#include <vector>
using SettingCallback = void (*)(void *, Evas_Object *, void *);
return out.str();
}
+
+ inline std::vector<std::string> stringSplitByDelimiter(const std::string &s, char delimiter)
+ {
+ std::vector<std::string> tokens;
+ std::string token;
+ std::istringstream tokenStream(s);
+ while (std::getline(tokenStream, token, delimiter)) {
+ tokens.push_back(token);
+ }
+ return tokens;
+ }
} // namespace utils
#endif