~aleteoryx/muditaos

ref: d84671140f8915ab221eed4462dee5be84be6b49 muditaos/module-apps/application-phonebook/windows/PhonebookNewContact.hpp -rw-r--r-- 1.9 KiB
d8467114 — rrandomsky [MOS-1007] Fix for no popup when contact cannot be saved because of same nubers 2 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
// Copyright (c) 2017-2023, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md

#pragma once

#include "application-phonebook/data/PhonebookItemData.hpp"
#include "application-phonebook/models/NewContactModel.hpp"

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

namespace gui
{
    class PhonebookNewContact : public AppWindow, public InfoAboutPreviousAppWhereWeComeFrom
    {
      public:
        explicit PhonebookNewContact(app::ApplicationCommon *app);

        auto onInput(const InputEvent &inputEvent) -> bool override;
        void onBeforeShow(ShowMode mode, SwitchData *data) override;
        auto handleSwitchData(SwitchData *data) -> bool override;
        void onClose(CloseReason reason) override;
        void rebuild() override;
        void buildInterface() override;
        void destroyInterface() override;

      private:
        enum class ContactAction
        {
            None,
            Add,
            Edit,
            EditTemporary
        };

        auto verifyAndSave() -> bool;
        void showDialogDuplicatedNumber(const utils::PhoneNumber::View &duplicatedNumber,
                                        const std::uint32_t duplicatedNumberContactID = 0u);
        void showDialogDuplicatedSpeedDialNumber();
        void showDialogPrimaryAndSecondaryNumberAreTheSame();
        void showDialogUnsavedChanges(std::function<bool()> whereToGoOnYes = nullptr);
        void setSaveButtonVisible(bool visible);
        void showContactDeletedNotification();
        bool checkIfContactWasDeletedDuringEditProcess() const;
        bool areUnsavedChanges() const;

        std::shared_ptr<ContactRecord> contact           = nullptr;
        std::shared_ptr<NewContactModel> newContactModel = nullptr;
        gui::ListView *list                              = nullptr;
        ContactAction contactAction                      = ContactAction::None;
    };

} /* namespace gui */