~aleteoryx/muditaos

8f9c64e4e166763f5097295f8d3a9546ef489d8f — rrandomsky 2 years ago 5045fbe
[BH-1845] Fixed time format in Settings and Onboarding

Now the time format in Settings and Onboarding is currently set
and changes dynamically during the user changing the time parameters.
M harmony_changelog.md => harmony_changelog.md +1 -0
@@ 6,6 6,7 @@
* Fixed eink crash while refreshing
* Fixed problem with occasional background playback after song has finished
* Increase clock font in Relaxation, Meditation, Power nap mode
* Fixed time format in Settings and Onboarding

### Added
* Added brightness fade in functionality

M products/BellHybrid/apps/application-bell-settings/models/DateTimeUnitsModel.cpp => products/BellHybrid/apps/application-bell-settings/models/DateTimeUnitsModel.cpp +6 -4
@@ 62,6 62,7 @@ namespace app::bell_settings
        timeSetListItem =
            new gui::TimeSetListItem(0U, 0U, 0, 0, utils::translate("app_bell_settings_time_units_time_message"));
        internalData.push_back(timeSetListItem);
        timeSetListItem->getTimeFormat = [this](void) { return timeFmtSetListItem->getTimeFmt(); };

        timeFmtSetListItem = new gui::TimeFormatSetListItem(
            0, 0, 0, 0, utils::translate("app_bell_settings_time_units_time_fmt_top_message"));


@@ 103,9 104,9 @@ namespace app::bell_settings
    void DateTimeUnitsModel::saveData()
    {
        const auto date       = daySetListItem->dateSetSpinner->getDate();
        const auto year   = date.year().operator int();
        const auto month  = static_cast<int>(date.month().operator unsigned int());
        const auto day    = static_cast<int>(date.day().operator unsigned int());
        const auto year       = date.year().operator int();
        const auto month      = static_cast<int>(date.month().operator unsigned int());
        const auto day        = static_cast<int>(date.day().operator unsigned int());
        const auto hour       = timeSetListItem->timeSetSpinner->getHour();
        const auto minute     = timeSetListItem->timeSetSpinner->getMinute();
        const auto timeFormat = timeFmtSetListItem->getTimeFmt();


@@ 133,6 134,7 @@ namespace app::bell_settings
        const auto timeFormat = stm::api::timeFormat();
        const auto dateFormat = stm::api::dateFormat();
        timeSetListItem->timeSetSpinner->setTime(now);
        timeSetListItem->timeSetSpinner->setTimeFormat(timeFormat);
        yearSetListItem->dateSetSpinner->setDate(
            date::year_month_day{date::floor<date::days>(std::chrono::system_clock::now())});



@@ 190,7 192,7 @@ namespace app::bell_settings
        using namespace date::literals;

        /// Default date/time after factory reset: 2023/01/01 12:00PM
        const auto factoryResetDate   = 2023_y / jan / 1_d;
        const auto factoryResetDate    = 2023_y / jan / 1_d;
        const auto factoryResetTimeFmt = utils::time::Locale::TimeFormat::FormatTime24H;
        const auto factoryResetDateFmt = utils::time::Locale::DateFormat::DD_MM_YYYY;


M products/BellHybrid/apps/application-bell-settings/widgets/TimeSetListItem.cpp => products/BellHybrid/apps/application-bell-settings/widgets/TimeSetListItem.cpp +4 -1
@@ 20,7 20,7 @@ namespace gui
    {
        setupTopTextBox(description);
        setMinimumSize(style::sidelistview::list_item::w, style::sidelistview::list_item::h);
        timeSetSpinner = new TimeSetSpinner(body->getCenterBox());
        timeSetSpinner = new TimeSetFmtSpinner(body->getCenterBox());
        timeSetSpinner->setMaximumSize(style::bell_base_layout::w, style::bell_base_layout::h);
        timeSetSpinner->setFont(focusFontName, noFocusFontName);
        timeSetSpinner->setAlignment(Alignment(Alignment::Horizontal::Center, Alignment::Vertical::Center));


@@ 33,6 33,9 @@ namespace gui
        };

        focusChangedCallback = [&](Item &item) {
            if (getTimeFormat != nullptr) {
                timeSetSpinner->setTimeFormat(getTimeFormat());
            }
            setFocusItem(focus ? body : nullptr);
            return true;
        };

M products/BellHybrid/apps/application-bell-settings/widgets/TimeSetListItem.hpp => products/BellHybrid/apps/application-bell-settings/widgets/TimeSetListItem.hpp +3 -1
@@ 6,6 6,7 @@
#include <widgets/BellSideListItem.hpp>

#include <string>
#include "widgets/TimeSetFmtSpinner.hpp"

namespace gui
{


@@ 14,7 15,8 @@ namespace gui
    class TimeSetListItem : public BellSideListItem
    {
      public:
        TimeSetSpinner *timeSetSpinner = nullptr;
        TimeSetFmtSpinner *timeSetSpinner                                  = nullptr;
        std::function<utils::time::Locale::TimeFormat(void)> getTimeFormat = nullptr;

        TimeSetListItem(gui::Length x, gui::Length y, gui::Length w, gui::Length h, std::string description);
    };