feat(app): show the type emoji before page names

Page header, All pages, quick switcher, recents, tabs, hub members, tag view,
linked references, related pages, type pill and the tree view; not the network
graph.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
dasemuandClaude Opus 5.5 committed 2026-10-26 06:44:35 +01:00
1 parent a5bee50190
commit 00a64401e0
10 files changed
+430 -46

No files matched your search

+30 -7
View File
@@ -8,13 +8,17 @@ import 'package:flutter/scheduler.dart';
import '../state/app_state.dart';
import '../theme/theme.dart';
import '../widgets/type_icon.dart';
import 'graph_model.dart';
/// A node of the hub / namespace / tag tree.
class TreeItem {
TreeItem(this.label, {this.global, this.isHub = false});
TreeItem(this.label, {this.global, this.isHub = false, this.icon});
final String label;
/// Emoji of the page's type, drawn before [label] (the network view never shows it).
String? icon;
/// Drawn with the folder look.
final bool isHub;
@@ -51,8 +55,13 @@ class TreeItem {
/// split on `/`, straight off the centre) for pages in no hub, then the remaining notes
/// (orphans included) straight off the centre. Journals and tags are left out. Nothing is
/// capped: large branches are collapsed in the canvas instead.
TreeItem buildNamespaceTree(GraphModel g, {String name = 'Graph'}) {
TreeItem buildNamespaceTree(
GraphModel g, {
String name = 'Graph',
String? Function(String? type)? typeIcon,
}) {
final root = TreeItem(name);
String? icon(int i) => typeIcon?.call(g.node(i).pageType);
final placed = <int>{};
bool page(int i) => !g.isJournal(i) && !g.isTag(i);
@@ -61,14 +70,19 @@ TreeItem buildNamespaceTree(GraphModel g, {String name = 'Graph'}) {
final nested = {for (final m in members.values) ...m};
TreeItem? build(int hub) {
if (!placed.add(hub)) return null;
final item = TreeItem(g.node(hub).title, global: hub, isHub: true);
final item = TreeItem(
g.node(hub).title,
global: hub,
isHub: true,
icon: icon(hub),
);
for (final m in members[hub] ?? const <int>{}) {
if (!page(m)) continue;
if (g.isHub(m)) {
final sub = build(m);
if (sub != null) item.children.add(sub);
} else if (placed.add(m)) {
item.children.add(TreeItem(g.node(m).title, global: m));
item.children.add(TreeItem(g.node(m).title, global: m, icon: icon(m)));
}
}
return item;
@@ -101,6 +115,7 @@ TreeItem buildNamespaceTree(GraphModel g, {String name = 'Graph'}) {
final p = byTitle[parts.sublist(0, k + 1).join('/').toLowerCase()];
if (p != null && !placed.contains(p)) {
at.global = p;
at.icon = icon(p);
placed.add(p);
}
}
@@ -110,7 +125,7 @@ TreeItem buildNamespaceTree(GraphModel g, {String name = 'Graph'}) {
// Everything else hangs straight off the centre.
for (var i = 0; i < g.nodeCount; i++) {
if (page(i) && !g.isHub(i) && placed.add(i)) {
root.children.add(TreeItem(g.node(i).title, global: i));
root.children.add(TreeItem(g.node(i).title, global: i, icon: icon(i)));
}
}
_measure(root, 0, null);
@@ -241,9 +256,13 @@ class TreeCanvas extends StatefulWidget {
required this.model,
required this.onTap,
this.name = 'Graph',
this.typeIcon,
});
final GraphModel model;
/// Emoji of a page type, shown before page labels.
final String? Function(String? type)? typeIcon;
/// Label of the centre: the name of the notes store.
final String name;
final void Function(int global) onTap;
@@ -306,7 +325,11 @@ class TreeCanvasState extends State<TreeCanvas> {
}
void _build() {
_root = buildNamespaceTree(widget.model, name: widget.name);
_root = buildNamespaceTree(
widget.model,
name: widget.name,
typeIcon: widget.typeIcon,
);
expandInitial(_root);
_items = const [];
_userMoved = false;
@@ -850,7 +873,7 @@ class _TreePainter extends CustomPainter {
ink,
TextPainter(
text: TextSpan(
text: t.label,
text: withTypeIcon(t.icon, t.label),
style: TextStyle(
fontFamily: uiFont,
fontSize: t.parent == null ? 14 : (branch ? 12.5 : 11.5),
+2
View File
@@ -3,6 +3,7 @@ import 'package:flutter/material.dart';
import '../backend/graph_backend.dart';
import '../state/app_state.dart';
import '../theme/theme.dart';
import '../widgets/type_icon.dart';
import '../widgets/common.dart';
import '../widgets/dates.dart';
import '../widgets/pickers.dart' show errorText;
@@ -303,6 +304,7 @@ class _AllPagesViewState extends State<AllPagesView> {
: colors.faint,
),
),
TypeIcon(p.pageType, size: 14, gap: 6),
Expanded(
child: Text(
p.title,
+1
View File
@@ -442,6 +442,7 @@ class _GraphViewState extends State<GraphView> {
model: m,
onTap: _open,
name: AppScope.read(context).backend.graphName,
typeIcon: AppScope.read(context).typeIcon,
);
}
final sub = _sub;
+2
View File
@@ -3,6 +3,7 @@ import 'package:flutter/material.dart';
import '../backend/graph_backend.dart';
import '../state/app_state.dart';
import '../theme/theme.dart';
import '../widgets/type_icon.dart';
import '../widgets/common.dart';
import '../widgets/dates.dart';
import '../widgets/pickers.dart';
@@ -296,6 +297,7 @@ class _MemberRowState extends State<_MemberRow> {
color: colors.accent.withAlpha(0xCC),
),
const SizedBox(width: 10),
TypeIcon(m.pageType, size: 14, gap: 6),
Expanded(
child: Text(
m.title,
+42 -17
View File
@@ -5,6 +5,7 @@ import '../editor/outline_view.dart';
import '../state/app_state.dart';
import '../state/outline_controller.dart';
import '../theme/theme.dart';
import '../widgets/type_icon.dart';
import '../widgets/common.dart';
import '../widgets/dates.dart';
import '../widgets/pickers.dart';
@@ -239,6 +240,10 @@ class _Header extends StatelessWidget {
Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Padding(
padding: const EdgeInsets.only(top: 4),
child: TypeIcon(page.pageType, size: 26, gap: 10),
),
Expanded(child: TitleField(page: page)),
IconButton(
key: const ValueKey('page-sidebar-toggle'),
@@ -471,16 +476,24 @@ class _LinkedReferences extends StatelessWidget {
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
TextLink(
group.isJournal
? longDate(group.pageTitle)
: group.pageTitle,
onTap: () => app.openId(group.pageId),
style: TextStyle(
fontSize: 13,
fontWeight: FontWeight.w600,
color: colors.ink,
),
Row(
mainAxisSize: MainAxisSize.min,
children: [
TypeIcon(group.pageType),
Flexible(
child: TextLink(
group.isJournal
? longDate(group.pageTitle)
: group.pageTitle,
onTap: () => app.openId(group.pageId),
style: TextStyle(
fontSize: 13,
fontWeight: FontWeight.w600,
color: colors.ink,
),
),
),
],
),
const SizedBox(height: 4),
for (final b in group.blocks)
@@ -544,13 +557,25 @@ class RelatedPanel extends StatelessWidget {
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
TextLink(
x.page.isJournal ? longDate(x.page.title) : x.page.title,
icon: x.page.isJournal
? Icons.calendar_today_outlined
: Icons.description_outlined,
onTap: () => app.openId(x.page.id),
style: TextStyle(fontSize: 13.5, color: colors.ink),
Row(
mainAxisSize: MainAxisSize.min,
children: [
TypeIcon(x.page.pageType),
Flexible(
child: TextLink(
x.page.isJournal
? longDate(x.page.title)
: x.page.title,
icon: app.typeIcon(x.page.pageType) != null
? null
: x.page.isJournal
? Icons.calendar_today_outlined
: Icons.description_outlined,
onTap: () => app.openId(x.page.id),
style: TextStyle(fontSize: 13.5, color: colors.ink),
),
),
],
),
const SizedBox(height: 4),
ClipRRect(
+18 -5
View File
@@ -4,6 +4,7 @@ import 'package:flutter/services.dart';
import '../backend/graph_backend.dart';
import '../state/app_state.dart';
import '../theme/theme.dart';
import '../widgets/type_icon.dart';
/// Ctrl+K: jump to a page by title or alias, to a page whose blocks contain the text, or
/// create it.
@@ -168,6 +169,7 @@ class _QuickSwitcherState extends State<QuickSwitcher> {
onMiddle: () => _open(i, newTab: true),
icon: Icons.description_outlined,
title: _hits[i].title,
pageType: _hits[i].pageType,
detail: _hits[i].isAlias ? 'alias' : null,
),
if (_blocks.isNotEmpty)
@@ -217,6 +219,7 @@ class _Item extends StatelessWidget {
required this.onMiddle,
this.detail,
this.snippet,
this.pageType,
});
final bool selected;
final VoidCallback onTap;
@@ -225,6 +228,9 @@ class _Item extends StatelessWidget {
final String title;
final String? detail;
/// Type of the page hit (its emoji goes before the title).
final String? pageType;
/// Matching text shown under the title (content results).
final Widget? snippet;
@@ -254,11 +260,18 @@ class _Item extends StatelessWidget {
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
title,
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: TextStyle(fontSize: 14, color: colors.ink),
Row(
children: [
TypeIcon(pageType),
Expanded(
child: Text(
title,
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: TextStyle(fontSize: 14, color: colors.ink),
),
),
],
),
if (snippet != null) ...[
const SizedBox(height: 2),
+19 -6
View File
@@ -115,11 +115,18 @@ class _TabItemState extends State<_TabItem> {
),
child: Row(
children: [
Icon(
widget.tab.icon,
size: 13,
color: active ? colors.accent : colors.faint,
),
if (app.tabTypeIcon(widget.tab) case final emoji?)
Text(
emoji,
key: const ValueKey('type-icon'),
style: const TextStyle(fontSize: 12.5, height: 1.15),
)
else
Icon(
widget.tab.icon,
size: 13,
color: active ? colors.accent : colors.faint,
),
const SizedBox(width: 7),
Expanded(
child: Text(
@@ -215,7 +222,13 @@ Future<void> showTabsSheet(BuildContext context) {
dense: true,
selected: i == app.activeTab,
selectedColor: colors.accent,
leading: Icon(tabs[i].icon, size: 18),
leading: switch (app.tabTypeIcon(tabs[i])) {
final String emoji => Text(
emoji,
style: const TextStyle(fontSize: 16),
),
null => Icon(tabs[i].icon, size: 18),
},
title: Text(
tabs[i].title,
maxLines: 1,
+13 -4
View File
@@ -3,6 +3,7 @@ import 'package:flutter/material.dart';
import '../backend/graph_backend.dart';
import '../state/app_state.dart';
import '../theme/theme.dart';
import '../widgets/type_icon.dart';
import '../widgets/common.dart';
import '../widgets/pickers.dart';
@@ -81,10 +82,17 @@ class TagView extends StatelessWidget {
80,
),
children: [
Text(
'#$name',
key: const ValueKey('tag-title'),
style: Theme.of(context).textTheme.headlineLarge,
Row(
children: [
TypeIcon(name, size: 26, gap: 10),
Expanded(
child: Text(
'#$name',
key: const ValueKey('tag-title'),
style: Theme.of(context).textTheme.headlineLarge,
),
),
],
),
const SizedBox(height: 6),
Wrap(
@@ -137,6 +145,7 @@ class TagView extends StatelessWidget {
color: colors.faint,
),
const SizedBox(width: 10),
TypeIcon(p.pageType, size: 14, gap: 6),
Expanded(
child: Text(
p.title,
+15 -7
View File
@@ -5,6 +5,7 @@ import '../state/app_state.dart';
import '../theme/theme.dart';
import 'common.dart';
import 'pickers.dart';
import 'type_icon.dart';
/// The page's metadata as one compact wrapping line: the type pill, the tag chips (sorted;
/// tapping one opens its [TagRoute]) and a "+ tag" link. A page has at most one type; tags
@@ -107,13 +108,19 @@ class _TypePill extends StatelessWidget {
color: colors.accentSoft,
borderRadius: BorderRadius.circular(6),
),
child: Text(
name,
style: TextStyle(
fontSize: 12.5,
fontWeight: FontWeight.w600,
color: colors.accent,
),
child: Row(
mainAxisSize: MainAxisSize.min,
children: [
TypeIcon(name, size: 12, gap: 4),
Text(
name,
style: TextStyle(
fontSize: 12.5,
fontWeight: FontWeight.w600,
color: colors.accent,
),
),
],
),
),
),
@@ -295,6 +302,7 @@ class _TypePickerState extends State<_TypePicker> {
for (final t in options)
ActionChip(
key: ValueKey('type-opt-${t.name}'),
avatar: t.icon == null ? null : Text(t.icon!),
label: Text(
t.count > 0 ? '${t.name} · ${t.count}' : t.name,
style: TextStyle(