## Summary **What is the goal of this PR?** This change avoids the pattern of creating a `std::string` using `.substr` in order to compare against a file extension literal. ```c++ std::string path; if (path.length() >= 4 && path.substr(path.length() - 4) == ".ext") ``` The `checkFileExtension` utility has moved from StringUtils to FsHelpers, to be available to code in lib/. The signature now accepts a `std::string_view` instead of `std::string`, which makes the single implementation reusable for Arduino `String`. Added utility functions for commonly repeated extensions. These changes **save about 2 KB of flash (5,999,427 to 5,997,343)**. --- ### AI Usage While CrossPoint doesn't have restrictions on AI tools in contributing, please be transparent about their usage as it helps set the right context for reviewers. Did you use AI tools to help write this code? _**NO**_
35 lines
1.0 KiB
C++
35 lines
1.0 KiB
C++
#pragma once
|
|
|
|
#include <functional>
|
|
#include <memory>
|
|
|
|
#include "CrossPointSettings.h"
|
|
#include "components/themes/BaseTheme.h"
|
|
|
|
class UITheme {
|
|
// Static instance
|
|
static UITheme instance;
|
|
|
|
public:
|
|
UITheme();
|
|
static UITheme& getInstance() { return instance; }
|
|
|
|
const ThemeMetrics& getMetrics() const { return *currentMetrics; }
|
|
const BaseTheme& getTheme() const { return *currentTheme; }
|
|
void reload();
|
|
void setTheme(CrossPointSettings::UI_THEME type);
|
|
static int getNumberOfItemsPerPage(const GfxRenderer& renderer, bool hasHeader, bool hasTabBar, bool hasButtonHints,
|
|
bool hasSubtitle);
|
|
static std::string getCoverThumbPath(std::string coverBmpPath, int coverHeight);
|
|
static UIIcon getFileIcon(const std::string& filename);
|
|
static int getStatusBarHeight();
|
|
static int getProgressBarHeight();
|
|
|
|
private:
|
|
const ThemeMetrics* currentMetrics;
|
|
std::unique_ptr<BaseTheme> currentTheme;
|
|
};
|
|
|
|
// Helper macro to access current theme
|
|
#define GUI UITheme::getInstance().getTheme()
|