~aleteoryx/muditaos

ref: 2eca1d9b04a9da03fadb0192b0597942481e3fef muditaos/module-apps/apps-common/windows/NoEvents.cpp -rw-r--r-- 1.8 KiB
2eca1d9b — Piotr Tański [EGD-7047] Fixed navigation down through input texts 4 years ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md

#include "NoEvents.hpp"
#include "Dialog.hpp"
#include "DialogMetadataMessage.hpp"
#include <log.hpp>

#include <service-appmgr/Controller.hpp>
#include <header/AddElementAction.hpp>
#include <Image.hpp>

using namespace gui;

NoEvents::NoEvents(app::Application *app, const std::string &name) : gui::Dialog(app, name)
{
    header->navigationIndicatorAdd(new gui::header::AddElementAction(), gui::header::BoxSelection::Left);
}

void NoEvents::onBeforeShow(ShowMode mode, SwitchData *data)
{
    Dialog::onBeforeShow(mode, data);
    auto metadata = dynamic_cast<DialogMetadataMessage *>(data);
    if (metadata != nullptr) {
        auto foo      = metadata->get().action;
        inputCallback = [foo](Item &, const InputEvent &inputEvent) -> bool {
            if (foo && inputEvent.isShortRelease(KeyCode::KEY_LEFT)) {
                return foo();
            }
            return false;
        };
    }

    if (getTitle() == utils::translate("app_calendar_title_main")) {
        bottomBar->setActive(gui::BottomBar::Side::LEFT, true);
        bottomBar->setText(gui::BottomBar::Side::LEFT, utils::translate("app_calendar_bar_month"));
    }
}

bool NoEvents::onInput(const gui::InputEvent &inputEvent)
{
    if (inputEvent.isShortRelease(gui::KeyCode::KEY_RF) && getTitle() == utils::translate("app_calendar_title_main")) {
        app::manager::Controller::switchBack(application);
        return true;
    }

    if (AppWindow::onInput(inputEvent)) {
        return true;
    }

    if (inputEvent.isShortRelease(gui::KeyCode::KEY_LF) && getTitle() == utils::translate("app_calendar_title_main")) {
        application->switchWindow(gui::name::window::main_window);
        return true;
    }

    return false;
}