The inbox as a page of the notebook

Whose mail it is, the folders as tabs with their counts, the search, the messages
as rows with picture, date, kind and a line of text, and a message itself as a note
on the dimmed book. The tablet frame of the old news screen is gone.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
MichaelandClaude Fable 5.2 committed 2026-11-15 19:49:46 +01:00
1 parent 6bbb50c574
commit f4d44364c7
5 files changed
+74 -163

No files matched your search

+14
View File
@@ -451,3 +451,17 @@ body .pg-btn.pg-go[disabled] {opacity:1;background-color:var(--p-a3);border-colo
.pg-dlg .pg-empty {flex:none;}
/* an empty note is a block: bare text inside a flex box would not be drawn */
.pg-empty {display:block;padding:72dp 54dp;}
/* --- the inbox --- */
.pg-root .nw-search {display:block;flex:1;height:68dp;padding:0 27dp;border:2dp var(--p-div);border-radius:36dp;background-color:var(--p-n1);font-family:Modern;font-size:30dp;color:var(--p-text);}
.nw-row {display:flex;flex:none;align-items:center;gap:27dp;padding:16dp 14dp;border-bottom:2dp var(--p-rule);}
.nw-row:hover {background-color:var(--p-row);}
.nw-dot {display:block;flex:none;width:22dp;height:22dp;border-radius:11dp;}
.nw-row.is-unread .nw-dot {background-color:var(--p-a6);}
.nw-art {display:block;flex:none;}
.pg-root .news-art,.pg-ov .news-art {border:0dp;border-radius:22dp;background-color:var(--p-n2);}
.nw-copy {display:block;flex:1;min-width:0;}
.pg-root .nw-title {font-size:34dp;font-weight:normal;margin-top:4dp;}
.nw-row.is-unread .nw-title {font-weight:bold;}
.nw-excerpt {display:block;font-size:28dp;line-height:36dp;}
.nw-body {display:block;font-size:36dp;line-height:54dp;}
+1 -1
View File
@@ -203,7 +203,7 @@ void App::engine_render() {
if(menu_=="settings")out+="<div class=\"fill menu-layer\" style=\"z-index:100;\">"+window("Einstellungen",render_settings())+"</div>";
if(menu_=="indoor")out+="<div class=\"fill menu-layer\" style=\"z-index:100;\">"+window("Hallentabellen",render_indoor())+"</div>";
if(menu_=="balance")out+="<div class=\"fill menu-layer\" style=\"z-index:100;\">"+window("Bilanz",render_balance())+"</div>";
if(menu_=="news")out+="<div class=\"fill\" style=\"z-index:100;\">"+render_news()+"</div>";
if(menu_=="news")out+="<div class=\"fill menu-layer\" style=\"z-index:100;\">"+render_news()+"</div>";
if(menu_=="achievements")out+="<div class=\"fill menu-layer\" style=\"z-index:100;\">"+window("Erfolge",render_achievements())+"</div>";
if(menu_=="transfer")out+="<div class=\"fill menu-layer\" style=\"z-index:100;\">"+window("Transfers",render_transfer())+"</div>";
if(menu_=="stadium")out+="<div class=\"fill menu-layer\" style=\"z-index:100;\">"+window("Stadion",render_stadium())+"</div>";
+57 -160
View File
@@ -30,92 +30,53 @@ std::string App::render_news_art(const Json &message, double size) {
"\" style=\"width:" + scalar(size) + "dp;height:" + scalar(size) +
"dp;\">" + art + "</div>";
}
// The messages of a folder as rows of the page: a dot while unread, the sender's picture, date
// and kind, the headline as a link, a line of the text, and the two things one does with a
// message. The controls replace this list alone while the player types a search.
std::string App::render_news_feed(const Json &data) {
const std::string ink = theme_ == "midnight" ? "#d2d6dc" : theme_ == "matchday" ? "#3a4830" : "#474238";
const auto icon = [&](const char *name, const char *path) {
return picture(renderer_.diagram(std::string("news-icon-") + name + "-" + theme_, "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 20 20\"><path d=\"" + std::string(path) + "\" fill=\"none\" stroke=\"" + ink +
"\" stroke-width=\"1.6\" stroke-linejoin=\"round\"/></svg>", 72), 36, 36);
};
std::string out;
for (const auto &m : data.at("items")) {
const auto id = m.at("id").get<std::string>(),
name = m.at("title").get<std::string>();
const bool unread = m.at("read").is_boolean() && !m.at("read").get<bool>(),
archived = m.at("folder") == "archive" || (engine_mode_&&m.at("folder")=="trash");
out += "<div id=\"news-row-" + id + "\" class=\"news-message" +
(unread ? " is-unread" : "") + "\">";
if (unread)
out += "<span class=\"news-unread-dot\"></span>";
out +=
render_news_art(m) +
"<div class=\"news-message-copy\"><div "
"class=\"news-message-meta\"><span>" +
esc(m.at("display_date").get<std::string>()) +
"</span><span class=\"news-category\">" +
esc(m.at("category").get<std::string>()) + "</span>" +
(unread ? "<span class=\"news-new\">Neu</span>" : "") +
(data.value("fictional", false) ? "<span class=\"news-new\">Demo</span>"
: "") +
"</div>";
out += btn("news-open", esc(name), "news-message-title",
"id=\"news-read-" + id + "\" data-id=\"" + id +
"\" aria-label=\"Nachricht lesen: " + esc(name) + "\"");
// a one-line message is its own headline; the excerpt would only repeat it
out += (m.at("body").get<std::string>() == name ? std::string() : "<p class=\"news-excerpt\">" + esc(m.at("body").get<std::string>()) + "</p>") +
"</div><div class=\"news-row-actions\">";
// Native CSS line-art has no private bitmap or SVG dependency.
out += btn(
"news-move",
"<span class=\"news-symbol archive" +
std::string(archived ? " restore" : "") +
"\"><span class=\"news-archive-lid\"></span><span "
"class=\"news-archive-handle\"></span></span>",
"news-icon-button",
"id=\"news-move-" + id + "\" data-id=\"" + id + "\" aria-label=\"" +
std::string(archived ? "Ins Postfach verschieben: "
: "Archivieren: ") +
esc(name) + "\" title=\"" +
std::string(archived ? "Ins Postfach verschieben" : "Archivieren") +
"\" " + std::string(engine_mode_&&m.value("mutable",false)==false?"disabled":""));
out += btn("news-delete", glyph("trash", 36), "news-icon-button",
"id=\"news-delete-" + id + "\" data-id=\"" + id +
"\" aria-label=\"Löschen: " + esc(name) +
"\" title=\"Löschen\" " + std::string(engine_mode_&&(m.value("mutable",false)==false||m.at("folder")=="trash")?"disabled":""));
out += "</div></div>";
const auto id = m.at("id").get<std::string>(), name = m.at("title").get<std::string>();
const bool unread = m.at("read").is_boolean() && !m.at("read").get<bool>(), archived = m.at("folder") == "archive" || (engine_mode_ && m.at("folder") == "trash");
const auto category = m.at("category").get<std::string>();
out += "<div id=\"news-row-" + id + "\" class=\"nw-row" + std::string(unread ? " is-unread" : "") + "\"><span class=\"nw-dot\"></span><span class=\"nw-art\">" + render_news_art(m, 86) + "</span><div class=\"nw-copy\"><div class=\"pg-row pg-mut\" style=\"" +
pg_css("gap:8px;font-size:12px;") + "\"><span>" + esc(m.at("display_date").get<std::string>()) + "</span><span class=\"pg-tag" + std::string(category == "Bericht" ? " sage" : "") + "\">" + esc(category) + "</span>" +
(unread ? "<span class=\"pg-tag accent\">Neu</span>" : "") + (data.value("fictional", false) ? "<span class=\"pg-tag\">Demo</span>" : "") + "</div>" +
btn("news-open", "<span>" + esc(name) + "</span>", "pg-link nw-title", "id=\"news-read-" + id + "\" data-id=\"" + id + "\" aria-label=\"Nachricht lesen: " + esc(name) + "\"") +
// a one-line message is its own headline; the excerpt would only repeat it
(m.at("body").get<std::string>() == name ? std::string() : "<span class=\"pg-mut pg-nowrap nw-excerpt\">" + esc(m.at("body").get<std::string>()) + "</span>") + "</div><div class=\"pg-row\" style=\"" + pg_css("gap:4px;") + "flex:none;\">" +
pg_button("news-move", icon(archived ? "restore" : "archive", archived ? "M3 10l4-4v3h10v2H7v3z" : "M3 4h14v4H3zM4 8v8h12V8M8 11h4"), "round",
"id=\"news-move-" + id + "\" data-id=\"" + id + "\" aria-label=\"" + std::string(archived ? "Ins Postfach verschieben: " : "Archivieren: ") + esc(name) + "\" title=\"" + std::string(archived ? "Ins Postfach verschieben" : "Archivieren") + "\" " +
std::string(engine_mode_ && m.value("mutable", false) == false ? "disabled" : "")) +
pg_button("news-delete", icon("trash", "M4 6h12M8 6V4h4v2M6 6l1 10h6l1-10"), "round",
"id=\"news-delete-" + id + "\" data-id=\"" + id + "\" aria-label=\"Löschen: " + esc(name) + "\" title=\"Löschen\" " + std::string(engine_mode_ && (m.value("mutable", false) == false || m.at("folder") == "trash") ? "disabled" : "")) +
"</div></div>";
}
if (out.empty()) {
const bool query = !news_view_.value("query", "").empty(),
archive = news_view_.value("folder", "inbox") == "archive";
out = "<div class=\"news-empty\"><div "
"class=\"news-empty-art\"><span></span></div><h3>" +
std::string(query ? "Keine Nachrichten gefunden"
: archive ? "Dein Archiv ist noch leer"
: "Alles auf dem neuesten Stand") +
"</h3><p>" +
std::string(query ? "Versuche einen anderen Suchbegriff."
: archive
? "Archivierte Meldungen bleiben hier zum Nachlesen."
: "Hier erscheinen neue Meldungen für dein Team.") +
"</p></div>";
const bool query = !news_view_.value("query", "").empty(), archive = news_view_.value("folder", "inbox") == "archive";
out = "<div class=\"pg-empty\"><strong class=\"pg-h\" style=\"font-size:" + pg(20) + ";\">" + std::string(query ? "Keine Nachrichten gefunden" : archive ? "Dein Archiv ist noch leer" : "Alles auf dem neuesten Stand") + "</strong><span style=\"display:block;\">" +
std::string(query ? "Versuche einen anderen Suchbegriff." : archive ? "Archivierte Meldungen bleiben hier zum Nachlesen." : "Hier erscheinen neue Meldungen für dein Team.") + "</span></div>";
}
return out;
}
std::string App::render_news_detail(const Json &message) {
const auto name = message.at("title").get<std::string>();
return "<div id=\"news-detail-layer\" class=\"news-detail-layer\"><div "
"class=\"news-detail-shade\"></div><div class=\"news-detail-box\" "
"role=\"dialog\" aria-modal=\"true\" "
"aria-labelledby=\"news-detail-title\"><h2 id=\"news-detail-title\">" +
esc(name) +
"</h2><div class=\"news-detail\"><div class=\"news-detail-meta\">" +
render_news_art(message) + "<div><p>" +
esc(message.at("category").get<std::string>()) + "</p><p>" +
esc(message.at("display_date").get<std::string>()) +
"</p></div></div><p class=\"news-detail-body\">" +
(engine_mode_?news_body_markup(message.at("body").get<std::string>()):esc(message.at("body").get<std::string>())) +
"</p><small>" + std::string(engine_mode_?(message.value("source",std::string())=="mail"?"Aus dem Spielpostfach":"Bericht aus dem Almanach"):"Fiktive Meldung für den Oberflächen-Prototyp.") + "</small></div><div "
"class=\"news-detail-actions\">" +
btn("news-detail-close", "Schließen", {}, "id=\"news-detail-close\"") +
btn("news-detail-move",
(message.at("folder") == "archive" || (engine_mode_&&message.at("folder")=="trash")) ? "Ins Postfach" : "Archivieren",
{}, "id=\"news-detail-move\" " + std::string(engine_mode_&&message.value("mutable",false)==false?"disabled":"")) +
"</div></div></div>";
const auto name = message.at("title").get<std::string>(), category = message.at("category").get<std::string>();
const bool archived = message.at("folder") == "archive" || (engine_mode_ && message.at("folder") == "trash");
return "<div id=\"news-detail-layer\" class=\"pg-ov\"><div class=\"pg-dlg\" role=\"dialog\" aria-modal=\"true\" aria-labelledby=\"news-detail-title\" style=\"width:" + pg(640) + ";\"><div><h2 id=\"news-detail-title\">" + esc(name) +
"</h2></div><div class=\"pg-row\" style=\"" + pg_css("gap:14px;") + "\"><span class=\"nw-art large\">" + render_news_art(message, 144) + "</span><div><span class=\"pg-tag" + std::string(category == "Bericht" ? " sage" : "") + "\" style=\"display:inline-block;\">" +
esc(category) + "</span><span class=\"pg-mut\" style=\"display:block;margin-top:" + pg(4) + ";\">" + esc(message.at("display_date").get<std::string>()) + "</span></div></div><p class=\"nw-body\">" +
(engine_mode_ ? news_body_markup(message.at("body").get<std::string>()) : esc(message.at("body").get<std::string>())) + "</p><span class=\"pg-mut\" style=\"display:block;font-size:" + pg(12.5) + ";\">" +
std::string(engine_mode_ ? (message.value("source", std::string()) == "mail" ? "Aus dem Spielpostfach" : "Bericht aus dem Almanach") : "Fiktive Meldung für den Oberflächen-Prototyp.") + "</span><div class=\"pg-dlg-act\">" +
pg_button("news-detail-move", archived ? "Ins Postfach" : "Archivieren", "", "id=\"news-detail-move\" " + std::string(engine_mode_ && message.value("mutable", false) == false ? "disabled" : "")) +
pg_button("news-detail-close", "Schließen", "primary", "id=\"news-detail-close\"") + "</div></div></div>";
}
// The inbox as a page of the notebook: whose it is, the folders as tabs, the search, the
// messages, and at the foot what there is and the way back from the last move.
std::string App::render_news() {
const auto s = engine_mode_?Snapshot{}:snap();
if (!engine_mode_ && (news_world_ != s.world || news_source_ != source_.get())) {
@@ -124,98 +85,34 @@ std::string App::render_news() {
news_source_ = source_.get();
}
const auto data = news_data(news_view_.value("folder","inbox"),news_view_.value("query",""));
if (!data.value("ok", false))
return window("Nachrichten",
"<p>Das Nachrichtenpostfach ist nicht verfügbar.</p>");
if (!data.value("ok", false)) return window("Nachrichten", "<div class=\"pg-page\"><div class=\"pg-empty\">Das Nachrichtenpostfach ist nicht verfügbar.</div></div>");
const auto folder = news_view_.value("folder", "inbox");
std::string content =
"<div id=\"news-underlay\" class=\"news-layout\"><div "
"class=\"news-masthead\"><div class=\"news-brand\"><span "
"class=\"news-wordmark\">Dreierpack</span><div><p>" + std::string(engine_mode_ ? "" : "DEIN SPIELJOURNAL") + "</p><h2>Nachrichten</h2></div></div><div "
"class=\"news-owner\"><div><strong>" +
esc(data.at("club_name").get<std::string>()) + "</strong><p>" +
esc(data.at("date").get<std::string>()) + "</p></div>" +
(data.value("scope", Json::object()).value("kind", std::string()) ==
"national"
? picture(renderer_.diagram("news-header-national",
ui_nation_flag_svg("de"), 176),
88, 59)
: crest(world_->find("clubs", data.value("club", std::string())),
88)) +
"</div></div>";
content += "<div class=\"news-navigation\"><div class=\"news-tabs\" "
"role=\"tablist\" aria-label=\"Postfach und Archiv\">";
for (const auto &f : (engine_mode_?std::vector<std::string>{"inbox","archive","trash"}:std::vector<std::string>{"inbox","archive"}))
content +=
btn("news-folder",
"<span>" + std::string(f == "inbox" ? "Postfach" : f=="archive"?"Archiv":"Papierkorb") +
"</span><span class=\"news-tab-count\">" +
std::to_string(data.at("counts").at(f).get<int>()) + "</span>",
std::string("news-tab ") + (folder == f ? "active" : ""),
"id=\"news-tab-" + f + "\" data-id=\"" + f +
"\" role=\"tab\" aria-controls=\"news-feed\" aria-selected=\"" +
(folder == f ? "true" : "false") + "\" tabindex=\"" +
(folder == f ? "0" : "-1") + "\"");
content += "</div><div class=\"news-search\"><span "
"class=\"news-search-symbol\"><span></span></span><input "
"id=\"news-search\" maxlength=\"120\" type=\"text\" "
"aria-label=\"Nachrichten durchsuchen\" placeholder=\"Nachrichten "
"durchsuchen\" value=\"" +
esc(news_view_.value("query", "")) + "\"/></div>";
content +=
btn("news-read-all", glyph("check", 36) + "<span>Alle gelesen</span>",
"news-read-all",
"id=\"news-read-all\" " +
std::string(data.at("can_read").get<bool>() ? "" : "disabled"));
content += "</div><div id=\"news-feed\" class=\"news-feed\" "
"role=\"tabpanel\" aria-labelledby=\"news-tab-" +
folder + "\">" + render_news_feed(data) +
"</div><div class=\"news-bottom\"><p id=\"news-feedback\" "
"role=\"status\">";
std::string content = "<div id=\"news-underlay\" class=\"pg-page\"><div class=\"pg-row\" style=\"" + pg_css("gap:12px;") + "\">" +
(data.value("scope", Json::object()).value("kind", std::string()) == "national" ? picture(renderer_.diagram("news-header-national", ui_nation_flag_svg("de"), 176), 104, 70)
: crest(world_->find("clubs", data.value("club", std::string())), 104)) +
"<div class=\"pg-grow\"><strong class=\"pg-h\" style=\"font-size:" + pg(20) + ";\">" + esc(data.at("club_name").get<std::string>()) + "</strong><span class=\"pg-mut\" style=\"display:block;\">" + esc(data.at("date").get<std::string>()) +
"</span></div><div class=\"pg-tabs\" role=\"tablist\" aria-label=\"Postfach und Archiv\">";
for (const auto &f : (engine_mode_ ? std::vector<std::string>{"inbox", "archive", "trash"} : std::vector<std::string>{"inbox", "archive"}))
content += btn("news-folder", "<span>" + std::string(f == "inbox" ? "Postfach" : f == "archive" ? "Archiv" : "Papierkorb") + " · " + std::to_string(data.at("counts").at(f).get<int>()) + "</span>", folder == f ? "on" : "",
"id=\"news-tab-" + f + "\" data-id=\"" + f + "\" role=\"tab\" aria-controls=\"news-feed\" aria-selected=\"" + (folder == f ? "true" : "false") + "\" tabindex=\"" + (folder == f ? "0" : "-1") + "\"");
content += "</div></div><div class=\"pg-row\"><input id=\"news-search\" class=\"nw-search\" maxlength=\"120\" type=\"text\" aria-label=\"Nachrichten durchsuchen\" placeholder=\"Nachrichten durchsuchen\" value=\"" + esc(news_view_.value("query", "")) + "\"/>" +
pg_button("news-read-all", "<span>Alle gelesen</span>", "", "id=\"news-read-all\" " + std::string(data.at("can_read").get<bool>() ? "" : "disabled")) +
"</div><div class=\"pg-panel pg-col pg-grow\" style=\"" + pg_css("gap:0px;padding:4px 10px;") + "\"><div id=\"news-feed\" class=\"pg-tbody\" role=\"tabpanel\" aria-labelledby=\"news-tab-" + folder + "\">" + render_news_feed(data) +
"</div></div><nav class=\"pg-foot\"><span class=\"pg-status\" id=\"news-feedback\" role=\"status\">";
const auto feedback = news_view_.value("feedback", "");
content += esc(
feedback.empty()
? std::to_string(data.at("items").size()) +
(data.at("items").size() == 1 ? " Nachricht" : " Nachrichten") +
" · " + std::to_string(data.at("shown_unread").get<int>()) +
" ungelesen"
: feedback);
content += esc(feedback.empty() ? std::to_string(data.at("items").size()) + (data.at("items").size() == 1 ? " Nachricht" : " Nachrichten") + " · " + std::to_string(data.at("shown_unread").get<int>()) + " ungelesen" : feedback);
if (data.value("unbound_count", size_t(0)))
content +=
esc(" · " + std::to_string(data.at("unbound_count").get<size_t>()) +
(data.at("unbound_count").get<size_t>() == 1
? " Altbestand ohne Besitzerbeleg unverändert erhalten"
: " Altbestände ohne Besitzerbeleg unverändert erhalten"));
content += "</p>" +
btn("news-undo", glyph("undo", 32) + "<span>Rückgängig</span>",
"news-undo",
"id=\"news-undo\" style=\"display:" +
std::string((engine_mode_?engine_news_undo_.is_object():news_undo_.is_array() && !news_undo_.empty())
? "flex"
: "none") +
";\"") +
"</div></div>";
content += esc(" · " + std::to_string(data.at("unbound_count").get<size_t>()) + (data.at("unbound_count").get<size_t>() == 1 ? " Altbestand ohne Besitzerbeleg unverändert erhalten" : " Altbestände ohne Besitzerbeleg unverändert erhalten"));
content += "</span>" + pg_button("news-undo", "<span>Rückgängig</span>", "", "id=\"news-undo\" style=\"display:" + std::string((engine_mode_ ? engine_news_undo_.is_object() : news_undo_.is_array() && !news_undo_.empty()) ? "flex" : "none") + ";\"") + "</nav></div>";
if (!news_dialog_.empty()) {
const auto all = news_data(folder,"");
const auto &items = all.at("items");
const auto found =
std::find_if(items.begin(), items.end(),
[&](const auto &m) { return m.at("id") == news_dialog_; });
if (found != items.end())
content += render_news_detail(*found);
else
news_dialog_.clear();
const auto found = std::find_if(items.begin(), items.end(), [&](const auto &m) { return m.at("id") == news_dialog_; });
if (found != items.end()) content += render_news_detail(*found);
else news_dialog_.clear();
}
return "<div class=\"window news-tablet\"><div "
"class=\"news-camera\"></div><div class=\"titlebar\">" +
btn("close", "<span>×</span>", "close",
"id=\"window-close\" aria-label=\"Fenster schließen\"") +
"<h1>Nachrichten</h1></div><div class=\"content\">" + content +
"</div><div class=\"news-screen-footer\"><span>" + std::string(engine_mode_?"":"Fiktive Meldungen · Modern UI Demo") + "</span><span>Dreierpack Manager</span></div><div "
"class=\"news-homebar\"></div></div>";
return window("Nachrichten", content);
}
std::string App::render_news_widget(const Json &object) {
const auto data = news_data("inbox", "");
const auto raw_items = engine_mode_ ? engine_news_value_.at("items")
+1 -1
View File
@@ -5,7 +5,7 @@
// The menus that are laid out as a page of the notebook. Every other career menu is still a
// sheet of the old format, shown scaled inside the book.
bool App::page_native() const {
static const std::set<std::string> native{"transfer", "training", "almanac", "tactics", "achievements", "highscore", "balance", "contracts", "environment", "tables", "league", "other", "strengths", "fairplay", "indoor", "scorers"};
static const std::set<std::string> native{"news", "transfer", "training", "almanac", "tactics", "achievements", "highscore", "balance", "contracts", "environment", "tables", "league", "other", "strengths", "fairplay", "indoor", "scorers"};
if (menu_ == "calendar" || menu_ == "postpone" || menu_ == "lineup") return notebook_page() && engine_mode_;
// a national coach arranges friendlies on the older sheet
if (menu_ == "friendlies") return notebook_page() && engine_mode_ && engine_data_.contains("desktop") && engine_data_.at("desktop").at("meta").at("scope").at("role") == "club";
+1 -1
View File
@@ -173,7 +173,7 @@ std::string App::render_menu(const std::string &key) {
if(key=="view-save"||key=="view-load")return render_files(true,key=="view-save");
if (key == "widgets" || key == "background" || key == "warning" || key == "quit") return render_widget_dialog(key);
if (key == "news")
return "<div class=\"fill\" style=\"z-index:100;\">" + render_news() + "</div>";
return "<div class=\"fill menu-layer\" style=\"z-index:100;\">" + render_news() + "</div>";
std::string body;
if(source_ && snap().state.at("career").value("role","club")=="national" && std::set<std::string>{"achievements","friendlies","scorers"}.contains(key))
body=render_national(key);