Repos
C++
2.0 KB51 lines Opens in site
Directory
Raw
Download
#pragma once
// Spec: INV-social 20 (EmojiPicker). Browse mode: optional Recent section plus 9 categories in a scroll view, a
// category bar at the bottom that scrolls to a section; search mode: Unicode name substring match.
//
// void presentEmojiPicker(ui::Rect anchor, std::function<void(const std::string&)> onPick); // sheet, closes on pick
// ViewPtr EmojiPickerView(std::shared_ptr<EmojiPickerModel>, onPick, onDismiss) // the body only
//
// Every pick is reported to onPick and recorded with SettingsStore::recordEmojiPick (max 30 recents).
// DIFF: category bar scrolling jumps (no animation); the search field sits under the navigation bar.
#include <functional>
#include <memory>
#include <string>
#include <vector>
#include "ui/Navigation.hpp"
namespace dp {
// State that must survive the per-frame rebuild.
struct EmojiPickerModel {
std::string search;
std::vector<float> sectionOffsets; // y of each section in the scroll content, filled while building
std::vector<std::string> sectionIds;
bool dismissOnPick = true;
};
// Pure layout helpers (unit tested).
struct EmojiPickerMetrics {
static int columnCount(float width); // max(1, Int((width - 16 + 4) / 48))
static float sectionHeight(std::size_t emojiCount, int columns);
};
ui::ViewPtr EmojiPickerView(std::shared_ptr<EmojiPickerModel> model, std::function<void(const std::string&)> onPick,
std::function<void()> onDismiss);
class EmojiPickerScreen : public ui::Screen {
public:
explicit EmojiPickerScreen(std::function<void(const std::string&)> onPick, bool dismissOnPick = true);
ui::ViewPtr body() override;
std::string title() const override { return ""; }
TitleMode titleMode() const override { return TitleMode::Inline; }
ui::ViewPtr toolbarLeading() override;
private:
std::function<void(const std::string&)> onPick_;
std::shared_ptr<EmojiPickerModel> model_;
};
void presentEmojiPicker(ui::Rect anchor, std::function<void(const std::string&)> onPick);
} // namespace dp