Repos
C++
1.0 KB36 lines Opens in site
Directory
Raw
Download
#pragma once
// Spec: FR-CLI-02. Screen ids reachable with --screen. Each area registers its screens.
#include <functional>
#include <map>
#include <string>
#include <vector>
#include "ui/Navigation.hpp"
namespace dp {
class ScreenRegistry {
public:
using Factory = std::function<ui::ScreenPtr()>;
// `needsLogin`: the harness signs in with the mock user first.
void add(const std::string& id, Factory factory, bool needsLogin = false);
ui::ScreenPtr make(const std::string& id) const;
bool needsLogin(const std::string& id) const;
std::vector<std::string> ids() const;
static ScreenRegistry& instance();
private:
struct Entry {
Factory factory;
bool needsLogin = false;
};
std::map<std::string, Entry> entries_;
};
// Implemented by the owners of each area (see src/screens/*/Register.cpp).
void registerFeedScreens(ScreenRegistry& registry);
void registerComposeScreens(ScreenRegistry& registry);
void registerSocialScreens(ScreenRegistry& registry);
void registerAppScreens(ScreenRegistry& registry);
} // namespace dp