Skip to content
Repos

DevPlaceApp

C++ 1.2 KB37 lines Opens in site

Directory Raw Download

#pragma once
// Spec: INV-posts 11.3. The report sheet: cancel, confirm, reasons form, details field, failure state.
#include <memory>

#include "screens/components/ReportViewModel.hpp"
#include "ui/Navigation.hpp"

namespace dp {

class ReportScreen : public ui::Screen {
 public:
  explicit ReportScreen(std::shared_ptr<ReportViewModel> model);
  ~ReportScreen() override;

  ui::ViewPtr body() override;
  std::string title() const override { return model_->sheetTitle(); }
  TitleMode titleMode() const override { return TitleMode::Inline; }
  ui::ViewPtr toolbarLeading() override;
  ui::ViewPtr toolbarTrailing() override;
  void onAppear() override;
  bool busy() const override { return model_->isSubmitting(); }

  // Tap on "Report": submit, close the sheet and show the thank-you alert on success.
  void confirm();
  // Shows the "Thank you" alert for the noun.
  static void showThankYou(const std::string& noun);

 private:
  ui::ViewPtr reasonsForm();
  ui::ViewPtr failedState();
  ui::ViewPtr reasonRow(const ReportReason& reason);

  std::shared_ptr<ReportViewModel> model_;
  std::shared_ptr<bool> alive_ = std::make_shared<bool>(true);
};

}  // namespace dp
38.3ms