Files
MuditaOS/module-apps/application-messages/windows/SearchStart.cpp
T
jimmorrisson 14918dc4f9 [EGD-4925] Change new filesystem handling implementation in module-gui. (#1193)
Due to vfs deprecation there is need to remove all vfs calls from code. This PR covers module gui. There are some modifications in other modules included which are necessary because of build system issues.
2020-12-16 15:23:11 +01:00

50 lines
1.9 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 "SearchStart.hpp"
#include "../ApplicationMessages.hpp"
#include <i18n/i18n.hpp>
#include <widgets/InputBox.hpp>
#include <cassert>
namespace gui
{
SMSSearch::SMSSearch(app::Application *app) : AppWindow(app, name::window::thread_sms_search)
{
buildInterface();
setTitle(utils::localize.get("app_messages_title_main"));
bottomBar->setActive(BottomBar::Side::CENTER, true);
bottomBar->setActive(BottomBar::Side::RIGHT, true);
bottomBar->setText(BottomBar::Side::CENTER, utils::localize.get(style::strings::common::search));
bottomBar->setText(BottomBar::Side::RIGHT, utils::localize.get(style::strings::common::back));
body = new gui::Item();
body->setBoundingBox(bodySize());
addWidget(body);
auto text = inputBox(this, utils::localize.get("common_search_uc"), "search");
inputCallback = [=](Item &, const InputEvent &inputEvent) -> bool {
auto app = dynamic_cast<app::ApplicationMessages *>(application);
assert(app);
if (inputEvent.state != InputEvent::State::keyReleasedShort) {
return false;
}
if (inputEvent.keyCode == KeyCode::KEY_ENTER) {
auto search_text = text->getText();
app->showSearchResults(utils::localize.get("common_search_results") + ": " + std::string(search_text),
search_text);
return true;
}
return false;
};
setFocusItem(text);
}
bool SMSSearch::onInput(const InputEvent &inputEvent)
{
return AppWindow::onInput(inputEvent) || (inputCallback && inputCallback(*this, inputEvent));
}
} // namespace gui