~aleteoryx/muditaos

ref: 2a53becd2524fc0dba7260632d3ec409eb3a61fd muditaos/module-apps/application-notes/presenter/NoteEditWindowPresenter.hpp -rw-r--r-- 1.6 KiB
2a53becd — Maciej Janicki [BH-1136] Fix bootloop after low power 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
// 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 <apps-common/BasePresenter.hpp>

#include <module-apps/application-notes/model/NotesRepository.hpp>

namespace app::notes
{
    class NoteEditWindowContract
    {
      public:
        class View
        {
          public:
            virtual ~View() noexcept = default;

            virtual bool isNoteEmpty() const noexcept = 0;
        };
        class Presenter : public BasePresenter<NoteEditWindowContract::View>
        {
          public:
            virtual ~Presenter() noexcept = default;

            virtual void onNoteChanged()                          = 0;
            virtual bool isAutoSaveApproved() const noexcept      = 0;
            virtual void save(std::shared_ptr<NotesRecord> &note) = 0;
        };
    };

    class NoteEditWindowPresenter : public NoteEditWindowContract::Presenter
    {
      public:
        explicit NoteEditWindowPresenter(std::unique_ptr<AbstractNotesRepository> &&notesRepository);

        void onNoteChanged() override;
        bool isAutoSaveApproved() const noexcept override;
        void save(std::shared_ptr<NotesRecord> &note) override;

      private:
        std::unique_ptr<AbstractNotesRepository> notesRepository;
        bool noteChanged = false;
    };

    class NoteCreateWindowPresenter : public NoteEditWindowPresenter
    {
      public:
        using NoteEditWindowPresenter::NoteEditWindowPresenter;

        bool isAutoSaveApproved() const noexcept override;
    };
} // namespace app::notes