Files
MuditaOS/module-apps/application-settings-new/windows/KeypadLightWindow.cpp
Tomek Sobkowiak 4bc7df5f4a [EDG-4049] Add locked screen settings window with ON/OFF (#900)
* [EDG-4206] Add locked screen and integrate with ON/OFF widget
2020-11-02 18:24:00 +01:00

59 lines
2.0 KiB
C++

// Copyright (c) 2017-2020, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
#include "KeypadLightWindow.hpp"
#include "application-settings-new/ApplicationSettings.hpp"
#include "windows/OptionSetting.hpp"
#include <i18/i18.hpp>
namespace gui
{
KeypadLightWindow::KeypadLightWindow(app::Application *app) : BaseSettingsWindow(app, window::name::keypad_light)
{
setTitle(utils::localize.get("app_settings_display_keypad_light"));
}
void KeypadLightWindow::switchHandler(bool &toggleSwitch)
{
isActiveSwitchOn = false;
isOffSwitchOn = false;
isAlwaysOnSwitchOn = false;
toggleSwitch = !toggleSwitch;
rebuildOptionList();
}
auto KeypadLightWindow::buildOptionsList() -> std::list<gui::Option>
{
std::list<gui::Option> optionsList;
auto addCheckOption = [&](UTF8 text, bool &Switch) {
optionsList.emplace_back(std::make_unique<gui::OptionSettings>(
text,
[&](gui::Item &item) mutable {
switchHandler(Switch);
return true;
},
[=](gui::Item &item) {
if (item.focus) {
this->setBottomBarText(utils::translateI18(style::strings::common::Switch),
BottomBar::Side::CENTER);
}
return true;
},
this,
Switch ? RightItem::Checked : RightItem::Disabled));
};
addCheckOption(utils::translateI18("app_settings_display_keypad_light_on"), isAlwaysOnSwitchOn);
addCheckOption(utils::translateI18("app_settings_display_keypad_light_off"), isOffSwitchOn);
addCheckOption(utils::translateI18("app_settings_display_keypad_light_active"), isActiveSwitchOn);
return optionsList;
} // namespace gui
} // namespace gui