Skip to content
Repos

DevPlaceApp

C++ 980 B32 lines Opens in site

Directory Raw Download

#pragma once
// Spec: INV-shell 11 (cross-tab routing). Screens call the router for navigation that leaves their own stack.
#include <string>

#include "model/User.hpp"
#include "screens/PostDestination.hpp"

namespace dp {

class Router {
 public:
  virtual ~Router() = default;
  // Select the Posts tab and open the post there.
  virtual void openPost(const PostDestination& destination) = 0;
  // Select the Messages tab and open the conversation (stack = [user]).
  virtual void openConversation(const User& user) = 0;
  // Select the Settings tab and open the own profile.
  virtual void openOwnProfile() = 0;
  // Present the sign in screen (full screen cover).
  virtual void presentLogin() = 0;
  // Open an http(s) URL in the system browser.
  virtual void openUrl(const std::string& url) = 0;

  static Router& instance();
  static void install(Router* router);

 private:
  static inline Router* current_ = nullptr;
  friend class RouterAccess;
};

}  // namespace dp
35.0ms