Skip to content
Repos

DevPlaceApp

C++ 1.3 KB42 lines Opens in site

Directory Raw Download

#pragma once
// Spec: INV-social 15 (Notifications screen), PG-07. Grouped notification cards, open and route, mark all read,
// infinite scroll footer, refresh on pull, reselect at top and window focus.
#include <memory>

#include "screens/conversation/WindowFocusWatcher.hpp"
#include "screens/notifications/NotificationsModel.hpp"
#include "ui/Navigation.hpp"

namespace dp {

class NotificationsScreen : public ui::Screen {
 public:
  NotificationsScreen();
  ~NotificationsScreen() override;

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

  NotificationsModel& model() { return model_; }
  bool isAtTop() const { return isAtTop_; }
  // Performs the route returned by open(): Router calls for post, conversation, own profile and web.
  static void perform(const NotificationRoute& route);

 private:
  ui::ViewPtr groupSection(const NotificationGroup& group);
  ui::ViewPtr emptyState();
  ui::ViewPtr content();

  NotificationsModel model_;
  std::unique_ptr<WindowFocusWatcher> focus_;
  int observerId_ = 0;
  bool wasLoggedIn_ = false;
  bool isAtTop_ = true;
  std::shared_ptr<bool> alive_ = std::make_shared<bool>(true);
};

}  // namespace dp
47.8ms