Skip to content
Repos

DevPlaceApp

C++ 1.1 KB39 lines Opens in site

Directory Raw Download

#pragma once
// Spec: INV-social 16 (Profile screen), PG-08. Own profile (username nullopt) and other users.
#include <memory>
#include <optional>

#include "screens/profile/ProfileModel.hpp"
#include "ui/Navigation.hpp"

namespace dp {

class ProfileScreen : public ui::Screen {
 public:
  explicit ProfileScreen(std::optional<std::string> username);
  ~ProfileScreen() override { *alive_ = false; }

  ui::ViewPtr body() override;
  std::string title() const override { return model_.navigationTitle(); }
  void onAppear() override;
  bool busy() const override { return model_.isBusy(); }

  ProfileModel& model() { return model_; }

  // Alert flows: block and mute need a confirmation, the other actions run directly.
  void tapFollow();
  void tapBlock();
  void tapMute();

 private:
  ui::ViewPtr buttonRow();
  ui::ViewPtr actionButton(const std::string& title, std::function<void()> action);
  ui::ViewPtr actionsMenu();
  void confirm(const std::string& verb, const std::string& message, std::function<void()> action);

  ProfileModel model_;
  bool started_ = false;
  std::shared_ptr<bool> alive_ = std::make_shared<bool>(true);
};

}  // namespace dp
40.6ms