Repos
C++
1.2 KB26 lines Opens in site
Directory
Raw
Download
#include "screens/components/NotificationRow.hpp"
#include "screens/components/RelativeTime.hpp"
#include "screens/components/UserViews.hpp"
#include "spec/SocialSpec.hpp"
#include "ui/Palette.hpp"
namespace dp {
using namespace ui;
ViewPtr NotificationRow(const Notification& n, std::function<void()> onSelect) {
using M = spec::SocialMetrics;
std::vector<ViewPtr> row;
if (n.actor) row.push_back(UserImage(*n.actor));
ViewPtr text = Text(n.data.message)->font(FontSpec::subheadline())->foreground(Palette::fg1())
->multilineAlign(TextAlign::Leading)->maxWidth(Alignment::leading());
row.push_back(VStack({text, RelativeTimeLabel(n.data.createdAt)}, M::kRowTextSpacing, HAlign::Leading)
->maxWidth(Alignment::leading()));
if (!n.data.read) row.push_back(CircleShape(Palette::accent())->frame(M::kUnreadDot, M::kUnreadDot)->paddingTop(M::kUnreadDotTop));
ViewPtr content = HStack(row, M::kRowSpacing, VAlign::Top)->padding(M::kRowPadding)
->background(n.data.read ? Color::clear() : Palette::accent().opacity(M::kUnreadTint));
return Button(content, std::move(onSelect), ButtonStyles::plain())->id(n.id());
}
} // namespace dp