Skip to content
Repos

DevPlaceApp

C++ 1.2 KB36 lines Opens in site

Directory Raw Download

#include "screens/comments/CommentEditorScreen.hpp"

#include "model/UserSearch.hpp"
#include "screens/AppContext.hpp"
#include "spec/PostsSpec.hpp"
#include "ui/Palette.hpp"

namespace dp {

using namespace ui;

CommentEditorScreen::CommentEditorScreen() = default;

ViewPtr CommentEditorScreen::body() {
  session_.beginFrame();
  CommentEditorProps props;
  props.text = Binding{[this] { return text_; }, [this](const std::string& v) { text_ = v; }};
  props.initialLineCount = spec::PostsLayout::kEditorInitialLines;
  props.focusOnAppear = true;
  props.attachments = session_.attachments();
  props.onAttachmentsChange = [this](const std::vector<UploadResponse>& list) { session_.setAttachments(list); };
  props.mentionParticipants = {{"u1", "retoor", std::nullopt}, {"u2", "devplace", std::nullopt}, {"u3", "mockuser", std::nullopt}};
  props.onCancel = [this] {
    text_.clear();
    cancelled_ = true;
  };
  props.onSubmit = [this](const std::string& content) {
    submitted_ = content;
    text_.clear();
  };
  ViewPtr editor = session_.editor("standalone").view(props);
  session_.endFrame();
  return editor->padding(spec::PostsLayout::kScreenPadding)->maxSize(Alignment::top())->background(Palette::bg1());
}

}  // namespace dp
35.5ms