~aleteoryx/muditaos

muditaos/module-apps/apps-common/windows/Dialog.hpp -rw-r--r-- 3.1 KiB
a405cad6Aleteoryx trim readme 6 days 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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
// Copyright (c) 2017-2024, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/blob/master/LICENSE.md

#pragma once

#include "AppWindow.hpp"
#include <Text.hpp>
#include <functional>
#include <DialogMetadata.hpp>
#include <module-gui/gui/widgets/Icon.hpp>

namespace gui::window::name
{
    inline constexpr auto dialog_confirm = "DialogConfirm";
    inline constexpr auto dialog_retry   = "DialogRetry";
}; // namespace gui::window::name

namespace gui
{
    namespace dialog
    {
        enum Option
        {
            YES,
            NO
        };

        namespace style
        {
            namespace option
            {
                inline constexpr auto w         = 150;
                inline constexpr auto h         = 75;
                inline constexpr auto margin    = 30;
                inline constexpr auto iconTextH = 99;
            } // namespace option

            namespace iconTextLabel
            {
                inline constexpr auto h = 188;
            } // namespace iconTextLabel

        } // namespace style
    }     // namespace dialog

    /// @brief base Dialog class
    ///
    /// Contain icon, text and Back action
    class Dialog : public AppWindow
    {
      protected:
        Icon *icon = nullptr;

      public:
        Dialog(app::ApplicationCommon *app, const std::string &name);

        void onBeforeShow(ShowMode mode, SwitchData *data) override;
    };

    /// @brief Confirm Dialog class
    ///
    /// Contain same items as Dialog but instead of Back there is OK action
    /// @Note it is also showing signal strength, battery on mode indicators
    class DialogConfirm : public Dialog
    {
      public:
        DialogConfirm(app::ApplicationCommon *app, const std::string &name);

        void onBeforeShow(ShowMode mode, SwitchData *data) override;
    };

    /// @brief Yes/No Dialog class
    ///
    /// Contain same items as Dialog and additionally Yes and No selectable options
    class DialogYesNo : public Dialog
    {
      protected:
        Label *yes = nullptr;
        Label *no  = nullptr;
        HBox *hBox = nullptr;

      public:
        DialogYesNo(app::ApplicationCommon *app, const std::string &name);

        void onBeforeShow(ShowMode mode, SwitchData *data) override;

      private:
        Label *createYesNoOption(Item *parent, const gui::dialog::Option &optionName);
    };

    /// @brief Yes/No Icon Text  Dialog class
    ///
    /// Contain same items as DialogYesNo and additionally puts text on icon
    class DialogYesNoIconTxt : public DialogYesNo
    {
      protected:
        Label *iconText = nullptr;

      public:
        DialogYesNoIconTxt(app::ApplicationCommon *app, const std::string &name);

        void onBeforeShow(ShowMode mode, SwitchData *data) override;
    };

    /// @brief Retry Dialog class
    ///
    /// Contain same items as Dialog but instead of OK there is a TRY AGAIN button
    class DialogRetry : public Dialog
    {
      public:
        DialogRetry(app::ApplicationCommon *app, const std::string &name);

        void onBeforeShow(ShowMode mode, SwitchData *data) override;
    };

}; // namespace gui