diff --git a/src/displayapp/DisplayApp.cpp b/src/displayapp/DisplayApp.cpp index add00650..f5b2efde 100644 --- a/src/displayapp/DisplayApp.cpp +++ b/src/displayapp/DisplayApp.cpp @@ -54,6 +54,8 @@ #include "libs/lv_conf.h" #include "UserApps.h" +#include + using namespace Pinetime::Applications; using namespace Pinetime::Applications::Display; @@ -516,10 +518,9 @@ void DisplayApp::LoadScreen(Apps app, DisplayApp::FullRefreshDirections directio switch (app) { case Apps::Launcher: { std::array apps; - int i = 0; - for (const auto& userApp : userApps) { - apps[i++] = Screens::Tile::Applications {userApp.icon, userApp.app, true}; - } + std::ranges::transform(userApps, apps.begin(), [](const auto& userApp) { + return Screens::Tile::Applications {userApp.icon, userApp.app, true}; + }); currentScreen = std::make_unique(this, settingsController, batteryController, @@ -530,13 +531,12 @@ void DisplayApp::LoadScreen(Apps app, DisplayApp::FullRefreshDirections directio std::move(apps)); } break; case Apps::Clock: { - const auto* watchFace = - std::find_if(userWatchFaces.begin(), userWatchFaces.end(), [this](const WatchFaceDescription& watchfaceDescription) { - return watchfaceDescription.watchFace == settingsController.GetWatchFace(); - }); - if (watchFace != userWatchFaces.end()) + const auto* watchFace = std::ranges::find_if(userWatchFaces, [this](const WatchFaceDescription& watchfaceDescription) { + return watchfaceDescription.watchFace == settingsController.GetWatchFace(); + }); + if (watchFace != userWatchFaces.end()) { currentScreen.reset(watchFace->create(controllers)); - else { + } else { currentScreen.reset(userWatchFaces[0].create(controllers)); } settingsController.SetAppMenu(0); @@ -587,11 +587,11 @@ void DisplayApp::LoadScreen(Apps app, DisplayApp::FullRefreshDirections directio break; case Apps::SettingWatchFace: { std::array items; - int i = 0; - for (const auto& userWatchFace : userWatchFaces) { - items[i++] = - Screens::SettingWatchFace::Item {userWatchFace.name, userWatchFace.watchFace, userWatchFace.isAvailable(controllers.filesystem)}; - } + std::ranges::transform(userWatchFaces, items.begin(), [this](const WatchFaceDescription& userWatchFace) { + return Screens::SettingWatchFace::Item {userWatchFace.name, + userWatchFace.watchFace, + userWatchFace.isAvailable(controllers.filesystem)}; + }); currentScreen = std::make_unique(this, std::move(items), settingsController, filesystem); } break; case Apps::SettingTimeFormat: @@ -639,7 +639,7 @@ void DisplayApp::LoadScreen(Apps app, DisplayApp::FullRefreshDirections directio currentScreen = std::make_unique(*systemTask, brightnessController); break; default: { - const auto* d = std::find_if(userApps.begin(), userApps.end(), [app](const AppDescription& appDescription) { + const auto* d = std::ranges::find_if(userApps, [app](const AppDescription& appDescription) { return appDescription.app == app; }); if (d != userApps.end()) {