Use common activity pattern
This commit is contained in:
@@ -1,35 +1,18 @@
|
||||
#pragma once
|
||||
#include <I18n.h>
|
||||
|
||||
#include <functional>
|
||||
#include <vector>
|
||||
|
||||
#include "activities/Activity.h"
|
||||
#include "util/ButtonNavigator.h"
|
||||
|
||||
class ClockSettingsActivity final : public Activity {
|
||||
enum class Action { USE_CLOCK, CLOCK_FORMAT, TIMEZONE, SYNC_TIME, DETECT_TIMEZONE, NONE };
|
||||
|
||||
struct MenuItem {
|
||||
Action action;
|
||||
StrId labelId;
|
||||
bool isSeparator = false;
|
||||
static MenuItem separator(StrId label) { return {Action::NONE, label, true}; }
|
||||
[[nodiscard]] std::string getTitle() const;
|
||||
};
|
||||
|
||||
ButtonNavigator buttonNavigator;
|
||||
int selectedIndex = 0;
|
||||
const std::vector<MenuItem> menuItems;
|
||||
|
||||
static std::vector<MenuItem> buildMenuItems();
|
||||
void handleSelection();
|
||||
#include "../MenuListActivity.h"
|
||||
|
||||
class ClockSettingsActivity final : public MenuListActivity {
|
||||
public:
|
||||
explicit ClockSettingsActivity(GfxRenderer& renderer, MappedInputManager& mappedInput)
|
||||
: Activity("ClockSettings", renderer, mappedInput), menuItems(buildMenuItems()) {}
|
||||
void onEnter() override;
|
||||
void onExit() override;
|
||||
void loop() override;
|
||||
: MenuListActivity("ClockSettings", renderer, mappedInput) {
|
||||
buildMenuItems();
|
||||
}
|
||||
|
||||
void render(RenderLock&&) override;
|
||||
|
||||
private:
|
||||
void buildMenuItems();
|
||||
void onActionSelected(int index) override;
|
||||
void onSettingToggled(int index) override;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user