~aleteoryx/muditaos

ref: 4a826142c01ad09b152591f991ff1d0e95f09c86 muditaos/module-apps/application-desktop/windows/PinLockBaseWindow.hpp -rw-r--r-- 2.1 KiB
4a826142 — alek [EGD-4429] Enable DEBUG_MODEM_OUTPUT_RESPONSE to true 5 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
// Copyright (c) 2017-2020, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md

#pragma once

#include "AppWindow.hpp"
#include "Text.hpp"

#include "RichTextParser.hpp"

namespace gui
{
    class PinLock;
}

namespace gui
{
    class PinLockBaseWindow : public AppWindow
    {
      public:
        enum class TextType
        {
            Title,
            Primary,
            Secondary
        };

        enum class Token
        {
            Sim,
            Attempts,
            Mins,
            CmeCode
        };

        PinLockBaseWindow(app::Application *app, std::string name) : AppWindow(app, name)
        {}
        void build();
        void buildInfoTexts();
        void buildPinLabels(std::function<Rect *()> itemBuilder,
                            unsigned int pinSize,
                            unsigned int offsetX,
                            unsigned int offsetY,
                            unsigned int boxWidth);
        void buildImages(const std::string &lockImg, const std::string &infoImg);
        void setBottomBarWidgetsActive(bool left, bool center, bool right);
        void setImagesVisible(bool lockImg, bool infoImg);
        void setTitleBar(bool isVisible, bool isIceActive);
        void setText(const std::string &value,
                     TextType type,
                     bool isReach                          = false,
                     text::RichTextParser::TokenMap tokens = text::RichTextParser::TokenMap{});
        void restore() noexcept;
        [[nodiscard]] auto getToken(Token token) const -> std::string;

        gui::HBox *iceBox        = nullptr;
        gui::Text *title         = nullptr;
        gui::Text *primaryText   = nullptr;
        gui::Text *secondaryText = nullptr;
        gui::Image *lockImage = nullptr;
        gui::Image *infoImage = nullptr;
        gui::HBox *pinLabelsBox = nullptr;

        std::unique_ptr<PinLock> lock = nullptr;

      private:
        void buildBottomBar();
        void buildTopBar();
        void buildTitleBar();
        [[nodiscard]] auto getText(TextType type) noexcept -> gui::Text *;
    };
} // namespace gui