~aleteoryx/muditaos

ref: d5c3d41ca469c8498d66a34077a19e59ec8e56d2 muditaos/module-apps/application-desktop/windows/LockWindow.hpp -rw-r--r-- 1.8 KiB
d5c3d41c — Piotr Tański [EGD-5204] Secure USB communication 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
58
59
60
61
62
63
64
65
66
// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md

#pragma once

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

namespace gui
{
    class PinLock;
}

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

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

        LockWindow(app::Application *app, std::string name) : AppWindow(app, std::move(name))
        {}
        void build();
        void buildInfoTexts();
        void buildPinLabels(std::function<Rect *()> itemBuilder,
                            unsigned int pinSize,
                            unsigned int offsetX,
                            unsigned int offsetY,
                            unsigned int boxWidth);
        virtual void restore() noexcept;
        void setBottomBarWidgetsActive(bool left, bool center, bool right);
        void setText(const std::string &value,
                     TextType type,
                     bool isReach                          = false,
                     text::RichTextParser::TokenMap tokens = text::RichTextParser::TokenMap{});
        void setTitleBar(bool isVisible);

        std::unique_ptr<PinLock> lock = nullptr;
        gui::HBox *pinLabelsBox       = nullptr;
        gui::Text *primaryText        = nullptr;
        gui::Text *secondaryText      = nullptr;
        gui::Text *title              = nullptr;

      protected:
        virtual void buildBottomBar();
        virtual void buildTitleBar() = 0;

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