~aleteoryx/muditaos

ref: 8f801262510042a71c5c2ef8b2ed1391995d8f7d muditaos/module-apps/application-meditation/windows/MeditationListViewWindows.cpp -rw-r--r-- 2.6 KiB
8f801262 — Przemyslaw Brudny [EGD-3434] ListView Scroll bar refactor 5 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
80
81
82
83
84
85
86
// Copyright (c) 2017-2020, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md

#include "MeditationListViewWindows.hpp"

#include "application-meditation/widgets/MeditationModel.hpp"
#include "application-meditation/data/Style.hpp"
#include "Names.hpp"

#include "ListView.hpp"
#include "Label.hpp"
#include <i18n/i18n.hpp>

using namespace gui;
namespace listViewWindow = style::meditation::listView::window;

MeditationListViewWindow::MeditationListViewWindow(app::Application *app, std::string windowName)
    : AppWindow(app, std::move(windowName))
{}

void MeditationListViewWindow::buildInterface()
{
    AppWindow::buildInterface();
    model->createData();
    list = new gui::ListView(this,
                             listViewWindow::X,
                             listViewWindow::Y,
                             listViewWindow::Width,
                             listViewWindow::Height,
                             model,
                             style::listview::ScrollBarType::Fixed);
    setFocusItem(list);
    bottomBar->setText(BottomBar::Side::RIGHT, utils::localize.get(style::strings::common::back));
}

void MeditationListViewWindow::destroyInterface()
{
    model->clearData();
    erase();
    invalidate();
}

void MeditationListViewWindow::rebuild()
{
    destroyInterface();
    buildInterface();
}

void MeditationListViewWindow::invalidate() noexcept
{
    list = nullptr;
}

void MeditationListViewWindow::onBeforeShow(ShowMode mode, SwitchData *data)
{
    list->rebuildList(style::listview::RebuildType::InPlace);
    list->setVisible(true);
}

MeditationOptionsWindow::MeditationOptionsWindow(app::Application *app)
    : MeditationListViewWindow(app, app::window::name::meditation_options)
{
    model = std::make_shared<MeditationOptionsModel>(app);
    buildInterface();
}

void MeditationOptionsWindow::buildInterface()
{
    MeditationListViewWindow::buildInterface();
    setTitle(utils::localize.get("common_options"));
    bottomBar->setText(BottomBar::Side::CENTER, utils::localize.get(style::strings::common::Switch));
}

PreparationTimeWindow::PreparationTimeWindow(app::Application *app)
    : MeditationListViewWindow(app, app::window::name::meditation_preparation)
{
    model = std::make_shared<PreparationTimeModel>(app);
    buildInterface();
}

void PreparationTimeWindow::buildInterface()
{
    MeditationListViewWindow::buildInterface();
    setTitle(utils::localize.get("app_meditation_preparation_time"));
    bottomBar->setText(BottomBar::Side::CENTER, utils::localize.get(style::strings::common::select));
}