~aleteoryx/muditaos

ref: ca9579a252e7ea6186b2dedb4dd6f66309eb0d93 muditaos/module-apps/apps-common/locks/windows/LockInputWindow.hpp -rw-r--r-- 2.2 KiB
ca9579a2 — Dawid Wojtas [BH-1590] Light press ends the Power Nap 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
78
79
// 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 <locks/widgets/LockBox.hpp>

#include <AppWindow.hpp>
#include <Text.hpp>
#include <ImageBox.hpp>

namespace locks
{
    class Lock;
}

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

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

        void buildPinLabels(const std::function<Rect *()> &itemBuilder, unsigned int pinSize);
        void setText(const std::string &value,
                     TextType type,
                     text::RichTextParser::TokenMap tokens = text::RichTextParser::TokenMap{});
        void setTitleBar(bool titleVisible, bool iceVisible);
        void setImage(const UTF8 &imageName);
        void setNavBarWidgetsActive(bool left, bool center, bool right);

        [[nodiscard]] auto getToken(Token token) const -> std::string;
        status_bar::Configuration configureStatusBar(status_bar::Configuration appConfiguration) override;

        std::unique_ptr<locks::Lock> lock = nullptr;
        gui::HBox *pinLabelsBox           = nullptr;

      protected:
        LockInputWindow(app::ApplicationCommon *app, std::string name) : AppWindow(app, std::move(name))
        {}

        void build();
        void restore() noexcept;

        virtual void setVisibleState();
        std::unique_ptr<LockBox> lockBox = nullptr;

        [[nodiscard]] auto isInInputState() const noexcept -> bool;
        [[nodiscard]] auto isInInvalidInputState() const noexcept -> bool;
        [[nodiscard]] auto isIceVisible() const noexcept -> bool;

      private:
        gui::VBox *body          = nullptr;
        gui::ImageBox *infoImage = nullptr;
        gui::Text *primaryText   = nullptr;
        gui::Text *secondaryText = nullptr;

        void buildBody();
        void buildImage();
        void buildInfoTexts();
        void buildPinBody();
        void buildNavBar();
        void buildIceBox();
    };
} // namespace gui