~aleteoryx/muditaos

ref: 2e8815bb383fd70f080ae004867de066987a0da0 muditaos/module-apps/application-settings/windows/network/SimPINSettingsWindow.cpp -rw-r--r-- 2.6 KiB
2e8815bb — Lefucjusz [MOS-657] Fix contacts list order 3 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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
// Copyright (c) 2017-2022, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md

#include "SimPINSettingsWindow.hpp"

#include <application-settings/windows/WindowNames.hpp>
#include <OptionSetting.hpp>
#include <service-appmgr/Controller.hpp>

namespace gui
{
    SimPINSettingsWindow::SimPINSettingsWindow(app::ApplicationCommon *app,
                                               std::unique_ptr<SimPINSettingsWindowContract::Presenter> simPINPresenter)
        : BaseSettingsWindow(app, window::name::sim_pin_settings), presenter(std::move(simPINPresenter))
    {
        presenter->attach(this);
        presenter->requestLockState();
    }

    void SimPINSettingsWindow::onBeforeShow(ShowMode mode, SwitchData *data)
    {
        presenter->onBeforeShow(mode, data);
    }

    auto SimPINSettingsWindow::buildOptionsList() -> std::list<Option>
    {
        std::list<Option> optionList;

        optionList.emplace_back(std::make_unique<option::OptionSettings>(
            utils::translate("app_settings_network_pin"),
            [=](Item &) {
                presenter->togglePinState();
                return true;
            },
            [=](Item &item) {
                if (item.focus) {
                    this->setNavBarText(utils::translate(style::strings::common::Switch), nav_bar::Side::Center);
                }
                else {
                    this->setNavBarText(utils::translate(style::strings::common::select), nav_bar::Side::Center);
                }
                return true;
            },
            nullptr,
            presenter->isPinEnabled() ? option::SettingRightItem::On : option::SettingRightItem::Off));

        if (presenter->isPinEnabled()) {
            optionList.emplace_back(std::make_unique<option::OptionSettings>(
                utils::translate("app_settings_network_pin_change_code"),
                [=](Item &) {
                    application->getSimLockSubject().changeSimPin();
                    return true;
                },
                nullptr,
                nullptr,
                option::SettingRightItem::ArrowWhite));
        }

        return optionList;
    }

    void SimPINSettingsWindow::setNavbarCenterActive(bool state)
    {
        setNavBarActive(nav_bar::Side::Center, state);
    }

    void SimPINSettingsWindow::setTitle(const UTF8 &text)
    {
        const auto currentWindow = application->getCurrentWindow();
        currentWindow->setTitle(text);
    }

    void SimPINSettingsWindow::refreshOptionsList()
    {
        BaseSettingsWindow::refreshOptionsList();
    }
} // namespace gui