~aleteoryx/muditaos

ref: 57b5eb3da5975d37f74437eea9eb50b9adee6bac muditaos/module-apps/application-alarm-clock/widgets/AlarmSnoozeOptionsItem.cpp -rw-r--r-- 1.2 KiB
57b5eb3d — Adam Wulkiewicz [BH-1557] Change Harmony home screen font to bigger one 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
// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md

#include "AlarmSnoozeOptionsItem.hpp"
#include <i18n/i18n.hpp>

namespace gui
{
    AlarmSnoozeOptionsItem::AlarmSnoozeOptionsItem(const std::string &description) : AlarmOptionsItem(description)
    {
        std::vector<UTF8> printOptions;

        for (auto const &option : snoozeOptions) {
            printOptions.push_back(option.second);
        }

        optionSpinner->setData({printOptions});

        onSaveCallback = [&](std::shared_ptr<AlarmEventRecord> alarm) {
            for (auto const &option : snoozeOptions) {
                if (option.second == optionSpinner->getCurrentValue().c_str()) {
                    alarm->snoozeDuration = option.first.count();
                }
            }
        };

        onLoadCallback = [&](std::shared_ptr<AlarmEventRecord> alarm) {
            auto valueToLoad = alarm->snoozeDuration;
            for (auto const &option : snoozeOptions) {
                if (option.first.count() == valueToLoad) {
                    optionSpinner->setCurrentValue(option.second);
                }
            }
        };
    }
} /* namespace gui */