mirror of
https://github.com/Dasemu/Synapse.git
synced 2026-11-26 15:26:17 +00:00
Merge branch 'feat/tags-types-view' into feat/settings-theme-tree
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
commit
12c3cd463b
45 files changed
+3142
-248
No files matched your search
@@ -16,10 +16,10 @@ class SynapseApp extends StatefulWidget {
|
||||
}
|
||||
|
||||
class _SynapseAppState extends State<SynapseApp> {
|
||||
late final AppState _state = AppState(
|
||||
widget.backend,
|
||||
settings: widget.settings,
|
||||
)..loadRecent();
|
||||
late final AppState _state =
|
||||
AppState(widget.backend, settings: widget.settings)
|
||||
..loadRecent()
|
||||
..loadTypeIcons();
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
|
||||
@@ -70,9 +70,22 @@ abstract class GraphBackend {
|
||||
|
||||
Future<PageDto> setPageType(String pageId, String? type);
|
||||
|
||||
/// Types in use (most used first), then the seeded suggestions not used yet.
|
||||
/// Types in use (most used first), then types defined but unused, then the seeded
|
||||
/// suggestions not used yet; each with its emoji icon (`TagDto.icon`).
|
||||
Future<List<TagDto>> typeCatalog();
|
||||
|
||||
/// Adds a type to the vocabulary even with no pages; returns its spelling.
|
||||
Future<String> createType(String name);
|
||||
|
||||
/// Sets (or with `null` clears) the emoji of a type. Synced with the graph.
|
||||
Future<void> setTypeIcon(String name, String? icon);
|
||||
|
||||
/// Renames a type (and same-name tags), keeping its icon; returns the pages changed.
|
||||
Future<int> renameType(String old, String new_);
|
||||
|
||||
/// Deletes a type: its pages lose it and its icon goes; returns the pages changed.
|
||||
Future<int> removeType(String name);
|
||||
|
||||
/// Every tag in use (listed or implied by a type), most used first.
|
||||
Future<List<TagDto>> tagCatalog();
|
||||
|
||||
@@ -270,6 +283,16 @@ class FfiGraphBackend implements GraphBackend {
|
||||
Future<int> removeTag(String name) => _g.removeTag(name: name);
|
||||
@override
|
||||
Future<List<TagDto>> typeCatalog() => _g.typeCatalog();
|
||||
@override
|
||||
Future<String> createType(String name) => _g.createType(name: name);
|
||||
@override
|
||||
Future<void> setTypeIcon(String name, String? icon) =>
|
||||
_g.setTypeIcon(name: name, icon: icon);
|
||||
@override
|
||||
Future<int> renameType(String old, String new_) =>
|
||||
_g.renameType(old: old, new_: new_);
|
||||
@override
|
||||
Future<int> removeType(String name) => _g.removeType(name: name);
|
||||
|
||||
@override
|
||||
Future<List<TagDto>> tagCatalog() => _g.tagCatalog();
|
||||
|
||||
@@ -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,17 @@ class TreeCanvas extends StatefulWidget {
|
||||
required this.model,
|
||||
required this.onTap,
|
||||
this.name = 'Graph',
|
||||
this.typeIcon,
|
||||
this.iconsVersion = 0,
|
||||
});
|
||||
final GraphModel model;
|
||||
|
||||
/// Emoji of a page type, shown before page labels.
|
||||
final String? Function(String? type)? typeIcon;
|
||||
|
||||
/// Changes when the type icons change: labels re-resolve their emoji (no new layout).
|
||||
final int iconsVersion;
|
||||
|
||||
/// Label of the centre: the name of the notes store.
|
||||
final String name;
|
||||
final void Function(int global) onTap;
|
||||
@@ -294,9 +317,21 @@ class TreeCanvasState extends State<TreeCanvas> {
|
||||
if (!identical(oldWidget.model, widget.model) ||
|
||||
oldWidget.name != widget.name) {
|
||||
_build();
|
||||
} else if (oldWidget.iconsVersion != widget.iconsVersion) {
|
||||
_refreshIcons(_root);
|
||||
_repaint.value++;
|
||||
}
|
||||
}
|
||||
|
||||
/// Re-reads the type emoji of every page item (labels redraw with them).
|
||||
void _refreshIcons(TreeItem t) {
|
||||
final g = t.global;
|
||||
if (g != null) {
|
||||
t.icon = widget.typeIcon?.call(widget.model.node(g).pageType);
|
||||
}
|
||||
t.children.forEach(_refreshIcons);
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_generation++;
|
||||
@@ -306,7 +341,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;
|
||||
@@ -716,8 +755,8 @@ class _TreePainter extends CustomPainter {
|
||||
final Brightness brightness;
|
||||
final TextScaler textScaler;
|
||||
|
||||
/// Laid-out labels per item, invalidated when the text colours change.
|
||||
static final _cache = Expando<(Color, TextPainter)>();
|
||||
/// Laid-out labels per item, invalidated when the text colour or the icon changes.
|
||||
static final _cache = Expando<(Color, String?, TextPainter)>();
|
||||
|
||||
@override
|
||||
void paint(Canvas canvas, Size size) {
|
||||
@@ -845,12 +884,13 @@ class _TreePainter extends CustomPainter {
|
||||
final branch = t.children.isNotEmpty;
|
||||
final ink = branch || t.parent == null ? colors.ink : colors.muted;
|
||||
var entry = _cache[t];
|
||||
if (entry == null || entry.$1 != ink) {
|
||||
if (entry == null || entry.$1 != ink || entry.$2 != t.icon) {
|
||||
entry = _cache[t] = (
|
||||
ink,
|
||||
t.icon,
|
||||
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),
|
||||
@@ -867,7 +907,7 @@ class _TreePainter extends CustomPainter {
|
||||
)..layout(maxWidth: 170),
|
||||
);
|
||||
}
|
||||
final tp = entry.$2;
|
||||
final tp = entry.$3;
|
||||
final r = s._radius(t) * scale.clamp(0.6, 1.6);
|
||||
// Labels on the outer side of the node, away from its parent.
|
||||
final par = t.parent == null ? null : s._index[t.parent!];
|
||||
|
||||
@@ -8,7 +8,7 @@ import '../frb_generated.dart';
|
||||
import 'package:flutter_rust_bridge/flutter_rust_bridge_for_generated.dart';
|
||||
|
||||
// These functions are ignored because they are not marked as `pub`: `new`
|
||||
// These function are ignored because they are on traits that is not defined in current crate (put an empty `#[frb]` on it to unignore): `assert_fields_are_eq`, `assert_fields_are_eq`, `clone`, `clone`, `clone`, `clone`, `clone`, `clone`, `clone`, `clone`, `clone`, `clone`, `clone`, `clone`, `clone`, `clone`, `clone`, `clone`, `clone`, `clone`, `clone`, `clone`, `clone`, `clone`, `clone`, `clone`, `clone`, `eq`, `eq`, `eq`, `eq`, `eq`, `eq`, `eq`, `eq`, `eq`, `eq`, `eq`, `eq`, `eq`, `eq`, `eq`, `eq`, `eq`, `eq`, `eq`, `eq`, `eq`, `eq`, `eq`, `eq`, `eq`, `fmt`, `fmt`, `fmt`, `fmt`, `fmt`, `fmt`, `fmt`, `fmt`, `fmt`, `fmt`, `fmt`, `fmt`, `fmt`, `fmt`, `fmt`, `fmt`, `fmt`, `fmt`, `fmt`, `fmt`, `fmt`, `fmt`, `fmt`, `fmt`, `fmt`, `from`, `from`
|
||||
// These function are ignored because they are on traits that is not defined in current crate (put an empty `#[frb]` on it to unignore): `assert_fields_are_eq`, `assert_fields_are_eq`, `clone`, `clone`, `clone`, `clone`, `clone`, `clone`, `clone`, `clone`, `clone`, `clone`, `clone`, `clone`, `clone`, `clone`, `clone`, `clone`, `clone`, `clone`, `clone`, `clone`, `clone`, `clone`, `clone`, `clone`, `clone`, `eq`, `eq`, `eq`, `eq`, `eq`, `eq`, `eq`, `eq`, `eq`, `eq`, `eq`, `eq`, `eq`, `eq`, `eq`, `eq`, `eq`, `eq`, `eq`, `eq`, `eq`, `eq`, `eq`, `eq`, `eq`, `fmt`, `fmt`, `fmt`, `fmt`, `fmt`, `fmt`, `fmt`, `fmt`, `fmt`, `fmt`, `fmt`, `fmt`, `fmt`, `fmt`, `fmt`, `fmt`, `fmt`, `fmt`, `fmt`, `fmt`, `fmt`, `fmt`, `fmt`, `fmt`, `fmt`, `from`, `from`, `from`
|
||||
|
||||
class AssetDto {
|
||||
final String hash;
|
||||
@@ -43,12 +43,16 @@ class BacklinkGroup {
|
||||
final String pageId;
|
||||
final String pageTitle;
|
||||
final bool isJournal;
|
||||
|
||||
/// Type of the referencing page (for its icon).
|
||||
final String? pageType;
|
||||
final List<BlockDto> blocks;
|
||||
|
||||
const BacklinkGroup({
|
||||
required this.pageId,
|
||||
required this.pageTitle,
|
||||
required this.isJournal,
|
||||
this.pageType,
|
||||
required this.blocks,
|
||||
});
|
||||
|
||||
@@ -57,6 +61,7 @@ class BacklinkGroup {
|
||||
pageId.hashCode ^
|
||||
pageTitle.hashCode ^
|
||||
isJournal.hashCode ^
|
||||
pageType.hashCode ^
|
||||
blocks.hashCode;
|
||||
|
||||
@override
|
||||
@@ -67,6 +72,7 @@ class BacklinkGroup {
|
||||
pageId == other.pageId &&
|
||||
pageTitle == other.pageTitle &&
|
||||
isJournal == other.isJournal &&
|
||||
pageType == other.pageType &&
|
||||
blocks == other.blocks;
|
||||
}
|
||||
|
||||
@@ -266,6 +272,9 @@ class GraphNode {
|
||||
/// display name, `degree` the number of pages carrying the tag.
|
||||
final bool isTag;
|
||||
|
||||
/// The page's type (tree labels show its icon; the network view does not).
|
||||
final String? pageType;
|
||||
|
||||
const GraphNode({
|
||||
required this.id,
|
||||
required this.title,
|
||||
@@ -280,6 +289,7 @@ class GraphNode {
|
||||
this.homeHub,
|
||||
required this.tags,
|
||||
required this.isTag,
|
||||
this.pageType,
|
||||
});
|
||||
|
||||
@override
|
||||
@@ -296,7 +306,8 @@ class GraphNode {
|
||||
isHub.hashCode ^
|
||||
homeHub.hashCode ^
|
||||
tags.hashCode ^
|
||||
isTag.hashCode;
|
||||
isTag.hashCode ^
|
||||
pageType.hashCode;
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) =>
|
||||
@@ -315,7 +326,8 @@ class GraphNode {
|
||||
isHub == other.isHub &&
|
||||
homeHub == other.homeHub &&
|
||||
tags == other.tags &&
|
||||
isTag == other.isTag;
|
||||
isTag == other.isTag &&
|
||||
pageType == other.pageType;
|
||||
}
|
||||
|
||||
/// A hub (folder-like page) with its members.
|
||||
@@ -518,16 +530,24 @@ class PageBrief {
|
||||
final bool isJournal;
|
||||
final bool isHub;
|
||||
|
||||
/// The page's type (the UI shows its icon next to the title).
|
||||
final String? pageType;
|
||||
|
||||
const PageBrief({
|
||||
required this.id,
|
||||
required this.title,
|
||||
required this.isJournal,
|
||||
required this.isHub,
|
||||
this.pageType,
|
||||
});
|
||||
|
||||
@override
|
||||
int get hashCode =>
|
||||
id.hashCode ^ title.hashCode ^ isJournal.hashCode ^ isHub.hashCode;
|
||||
id.hashCode ^
|
||||
title.hashCode ^
|
||||
isJournal.hashCode ^
|
||||
isHub.hashCode ^
|
||||
pageType.hashCode;
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) =>
|
||||
@@ -537,7 +557,8 @@ class PageBrief {
|
||||
id == other.id &&
|
||||
title == other.title &&
|
||||
isJournal == other.isJournal &&
|
||||
isHub == other.isHub;
|
||||
isHub == other.isHub &&
|
||||
pageType == other.pageType;
|
||||
}
|
||||
|
||||
/// Everything the page view needs in one call.
|
||||
@@ -753,14 +774,37 @@ class TagDto {
|
||||
/// One of the seeded suggestions.
|
||||
final bool suggested;
|
||||
|
||||
/// Emoji of a type (types only).
|
||||
final String? icon;
|
||||
|
||||
/// Pages listing it as an explicit tag (tags only).
|
||||
final int explicit;
|
||||
|
||||
/// Pages having it as their type (tags only).
|
||||
final int typed;
|
||||
|
||||
/// Pages carrying it through their hub (tags only; hub tags cannot be renamed or removed).
|
||||
final int fromHub;
|
||||
|
||||
const TagDto({
|
||||
required this.name,
|
||||
required this.count,
|
||||
required this.suggested,
|
||||
this.icon,
|
||||
required this.explicit,
|
||||
required this.typed,
|
||||
required this.fromHub,
|
||||
});
|
||||
|
||||
@override
|
||||
int get hashCode => name.hashCode ^ count.hashCode ^ suggested.hashCode;
|
||||
int get hashCode =>
|
||||
name.hashCode ^
|
||||
count.hashCode ^
|
||||
suggested.hashCode ^
|
||||
icon.hashCode ^
|
||||
explicit.hashCode ^
|
||||
typed.hashCode ^
|
||||
fromHub.hashCode;
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) =>
|
||||
@@ -769,7 +813,11 @@ class TagDto {
|
||||
runtimeType == other.runtimeType &&
|
||||
name == other.name &&
|
||||
count == other.count &&
|
||||
suggested == other.suggested;
|
||||
suggested == other.suggested &&
|
||||
icon == other.icon &&
|
||||
explicit == other.explicit &&
|
||||
typed == other.typed &&
|
||||
fromHub == other.fromHub;
|
||||
}
|
||||
|
||||
class TimelineDayDto {
|
||||
@@ -831,14 +879,19 @@ class TitleHit {
|
||||
final String title;
|
||||
final bool isAlias;
|
||||
|
||||
/// Type of the page (for its icon).
|
||||
final String? pageType;
|
||||
|
||||
const TitleHit({
|
||||
required this.pageId,
|
||||
required this.title,
|
||||
required this.isAlias,
|
||||
this.pageType,
|
||||
});
|
||||
|
||||
@override
|
||||
int get hashCode => pageId.hashCode ^ title.hashCode ^ isAlias.hashCode;
|
||||
int get hashCode =>
|
||||
pageId.hashCode ^ title.hashCode ^ isAlias.hashCode ^ pageType.hashCode;
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) =>
|
||||
@@ -847,5 +900,6 @@ class TitleHit {
|
||||
runtimeType == other.runtimeType &&
|
||||
pageId == other.pageId &&
|
||||
title == other.title &&
|
||||
isAlias == other.isAlias;
|
||||
isAlias == other.isAlias &&
|
||||
pageType == other.pageType;
|
||||
}
|
||||
@@ -58,6 +58,9 @@ abstract class SynapseGraph implements RustOpaqueInterface {
|
||||
required String title,
|
||||
});
|
||||
|
||||
/// Adds a type to the vocabulary even if no page uses it; returns its spelling.
|
||||
Future<String> createType({required String name});
|
||||
|
||||
/// Deletes a block and its subtree.
|
||||
Future<List<BlockDto>> deleteBlock({required String id});
|
||||
|
||||
@@ -183,12 +186,18 @@ abstract class SynapseGraph implements RustOpaqueInterface {
|
||||
/// of pages changed.
|
||||
Future<int> removeTag({required String name});
|
||||
|
||||
/// Deletes a type: its pages lose it and its icon is dropped; returns the pages changed.
|
||||
Future<int> removeType({required String name});
|
||||
|
||||
Future<PageDto> renamePage({required String id, required String newTitle});
|
||||
|
||||
/// Renames a tag in the `tags` and `types` of every page carrying it; returns the number of
|
||||
/// pages changed.
|
||||
Future<int> renameTag({required String old, required String new_});
|
||||
|
||||
/// Renames a type (and same-name tags), keeping its icon; returns the pages changed.
|
||||
Future<int> renameType({required String old, required String new_});
|
||||
|
||||
/// Blocks whose text contains `query` (for `((` autocomplete), most recent first.
|
||||
Future<List<BlockHit>> searchBlocks({
|
||||
required String query,
|
||||
@@ -220,6 +229,9 @@ abstract class SynapseGraph implements RustOpaqueInterface {
|
||||
/// typed.
|
||||
Future<PageDto> setPageType({required String pageId, String? pageType});
|
||||
|
||||
/// Sets (or with `None` clears) the emoji of a type, defining the type if needed.
|
||||
Future<void> setTypeIcon({required String name, String? icon});
|
||||
|
||||
/// Every tag in use (listed or implied by a type) with its number of pages, most used first.
|
||||
Future<List<TagDto>> tagCatalog();
|
||||
|
||||
@@ -229,7 +241,8 @@ abstract class SynapseGraph implements RustOpaqueInterface {
|
||||
/// Today's date (graph clock) as `YYYY-MM-DD`.
|
||||
String today();
|
||||
|
||||
/// Types in use (most used first) followed by the seeded suggestions not used yet.
|
||||
/// Types in use (most used first), then defined unused types, then the seeded suggestions
|
||||
/// not used yet; each with its icon.
|
||||
Future<List<TagDto>> typeCatalog();
|
||||
|
||||
/// Replaces a block's Markdown (the debounced save while typing).
|
||||
|
||||
@@ -69,7 +69,7 @@ class RustLib extends BaseEntrypoint<RustLibApi, RustLibApiImpl, RustLibWire> {
|
||||
String get codegenVersion => '2.13.0';
|
||||
|
||||
@override
|
||||
int get rustContentHash => -1472342481;
|
||||
int get rustContentHash => 272705018;
|
||||
|
||||
static const kDefaultExternalLibraryLoaderConfig =
|
||||
ExternalLibraryLoaderConfig(
|
||||
@@ -175,6 +175,11 @@ abstract class RustLibApi extends BaseApi {
|
||||
required String title,
|
||||
});
|
||||
|
||||
Future<String> crateApiGraphSynapseGraphCreateType({
|
||||
required SynapseGraph that,
|
||||
required String name,
|
||||
});
|
||||
|
||||
Future<List<BlockDto>> crateApiGraphSynapseGraphDeleteBlock({
|
||||
required SynapseGraph that,
|
||||
required String id,
|
||||
@@ -344,6 +349,11 @@ abstract class RustLibApi extends BaseApi {
|
||||
required String name,
|
||||
});
|
||||
|
||||
Future<int> crateApiGraphSynapseGraphRemoveType({
|
||||
required SynapseGraph that,
|
||||
required String name,
|
||||
});
|
||||
|
||||
Future<PageDto> crateApiGraphSynapseGraphRenamePage({
|
||||
required SynapseGraph that,
|
||||
required String id,
|
||||
@@ -356,6 +366,12 @@ abstract class RustLibApi extends BaseApi {
|
||||
required String new_,
|
||||
});
|
||||
|
||||
Future<int> crateApiGraphSynapseGraphRenameType({
|
||||
required SynapseGraph that,
|
||||
required String old,
|
||||
required String new_,
|
||||
});
|
||||
|
||||
Future<List<BlockHit>> crateApiGraphSynapseGraphSearchBlocks({
|
||||
required SynapseGraph that,
|
||||
required String query,
|
||||
@@ -392,6 +408,12 @@ abstract class RustLibApi extends BaseApi {
|
||||
String? pageType,
|
||||
});
|
||||
|
||||
Future<void> crateApiGraphSynapseGraphSetTypeIcon({
|
||||
required SynapseGraph that,
|
||||
required String name,
|
||||
String? icon,
|
||||
});
|
||||
|
||||
Future<List<TagDto>> crateApiGraphSynapseGraphTagCatalog({
|
||||
required SynapseGraph that,
|
||||
});
|
||||
@@ -1070,6 +1092,44 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi {
|
||||
argNames: ["that", "hubId", "title"],
|
||||
);
|
||||
|
||||
@override
|
||||
Future<String> crateApiGraphSynapseGraphCreateType({
|
||||
required SynapseGraph that,
|
||||
required String name,
|
||||
}) {
|
||||
return handler.executeNormal(
|
||||
NormalTask(
|
||||
callFfi: (port_) {
|
||||
final serializer = SseSerializer(generalizedFrbRustBinding);
|
||||
sse_encode_Auto_Ref_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerSynapseGraph(
|
||||
that,
|
||||
serializer,
|
||||
);
|
||||
sse_encode_String(name, serializer);
|
||||
pdeCallFfi(
|
||||
generalizedFrbRustBinding,
|
||||
serializer,
|
||||
funcId: 17,
|
||||
port: port_,
|
||||
);
|
||||
},
|
||||
codec: SseCodec(
|
||||
decodeSuccessData: sse_decode_String,
|
||||
decodeErrorData: sse_decode_AnyhowException,
|
||||
),
|
||||
constMeta: kCrateApiGraphSynapseGraphCreateTypeConstMeta,
|
||||
argValues: [that, name],
|
||||
apiImpl: this,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
TaskConstMeta get kCrateApiGraphSynapseGraphCreateTypeConstMeta =>
|
||||
const TaskConstMeta(
|
||||
debugName: "SynapseGraph_create_type",
|
||||
argNames: ["that", "name"],
|
||||
);
|
||||
|
||||
@override
|
||||
Future<List<BlockDto>> crateApiGraphSynapseGraphDeleteBlock({
|
||||
required SynapseGraph that,
|
||||
@@ -1087,7 +1147,7 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi {
|
||||
pdeCallFfi(
|
||||
generalizedFrbRustBinding,
|
||||
serializer,
|
||||
funcId: 17,
|
||||
funcId: 18,
|
||||
port: port_,
|
||||
);
|
||||
},
|
||||
@@ -1125,7 +1185,7 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi {
|
||||
pdeCallFfi(
|
||||
generalizedFrbRustBinding,
|
||||
serializer,
|
||||
funcId: 18,
|
||||
funcId: 19,
|
||||
port: port_,
|
||||
);
|
||||
},
|
||||
@@ -1156,7 +1216,7 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi {
|
||||
that,
|
||||
serializer,
|
||||
);
|
||||
return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 19)!;
|
||||
return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 20)!;
|
||||
},
|
||||
codec: SseCodec(
|
||||
decodeSuccessData: sse_decode_String,
|
||||
@@ -1187,7 +1247,7 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi {
|
||||
pdeCallFfi(
|
||||
generalizedFrbRustBinding,
|
||||
serializer,
|
||||
funcId: 20,
|
||||
funcId: 21,
|
||||
port: port_,
|
||||
);
|
||||
},
|
||||
@@ -1225,7 +1285,7 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi {
|
||||
pdeCallFfi(
|
||||
generalizedFrbRustBinding,
|
||||
serializer,
|
||||
funcId: 21,
|
||||
funcId: 22,
|
||||
port: port_,
|
||||
);
|
||||
},
|
||||
@@ -1263,7 +1323,7 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi {
|
||||
pdeCallFfi(
|
||||
generalizedFrbRustBinding,
|
||||
serializer,
|
||||
funcId: 22,
|
||||
funcId: 23,
|
||||
port: port_,
|
||||
);
|
||||
},
|
||||
@@ -1297,7 +1357,7 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi {
|
||||
pdeCallFfi(
|
||||
generalizedFrbRustBinding,
|
||||
serializer,
|
||||
funcId: 23,
|
||||
funcId: 24,
|
||||
port: port_,
|
||||
);
|
||||
},
|
||||
@@ -1332,7 +1392,7 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi {
|
||||
pdeCallFfi(
|
||||
generalizedFrbRustBinding,
|
||||
serializer,
|
||||
funcId: 24,
|
||||
funcId: 25,
|
||||
port: port_,
|
||||
);
|
||||
},
|
||||
@@ -1374,7 +1434,7 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi {
|
||||
pdeCallFfi(
|
||||
generalizedFrbRustBinding,
|
||||
serializer,
|
||||
funcId: 25,
|
||||
funcId: 26,
|
||||
port: port_,
|
||||
);
|
||||
},
|
||||
@@ -1412,7 +1472,7 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi {
|
||||
pdeCallFfi(
|
||||
generalizedFrbRustBinding,
|
||||
serializer,
|
||||
funcId: 26,
|
||||
funcId: 27,
|
||||
port: port_,
|
||||
);
|
||||
},
|
||||
@@ -1450,7 +1510,7 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi {
|
||||
pdeCallFfi(
|
||||
generalizedFrbRustBinding,
|
||||
serializer,
|
||||
funcId: 27,
|
||||
funcId: 28,
|
||||
port: port_,
|
||||
);
|
||||
},
|
||||
@@ -1490,7 +1550,7 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi {
|
||||
pdeCallFfi(
|
||||
generalizedFrbRustBinding,
|
||||
serializer,
|
||||
funcId: 28,
|
||||
funcId: 29,
|
||||
port: port_,
|
||||
);
|
||||
},
|
||||
@@ -1526,7 +1586,7 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi {
|
||||
pdeCallFfi(
|
||||
generalizedFrbRustBinding,
|
||||
serializer,
|
||||
funcId: 29,
|
||||
funcId: 30,
|
||||
port: port_,
|
||||
);
|
||||
},
|
||||
@@ -1568,7 +1628,7 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi {
|
||||
pdeCallFfi(
|
||||
generalizedFrbRustBinding,
|
||||
serializer,
|
||||
funcId: 30,
|
||||
funcId: 31,
|
||||
port: port_,
|
||||
);
|
||||
},
|
||||
@@ -1608,7 +1668,7 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi {
|
||||
pdeCallFfi(
|
||||
generalizedFrbRustBinding,
|
||||
serializer,
|
||||
funcId: 31,
|
||||
funcId: 32,
|
||||
port: port_,
|
||||
);
|
||||
},
|
||||
@@ -1650,7 +1710,7 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi {
|
||||
pdeCallFfi(
|
||||
generalizedFrbRustBinding,
|
||||
serializer,
|
||||
funcId: 32,
|
||||
funcId: 33,
|
||||
port: port_,
|
||||
);
|
||||
},
|
||||
@@ -1681,7 +1741,7 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi {
|
||||
pdeCallFfi(
|
||||
generalizedFrbRustBinding,
|
||||
serializer,
|
||||
funcId: 33,
|
||||
funcId: 34,
|
||||
port: port_,
|
||||
);
|
||||
},
|
||||
@@ -1717,7 +1777,7 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi {
|
||||
pdeCallFfi(
|
||||
generalizedFrbRustBinding,
|
||||
serializer,
|
||||
funcId: 34,
|
||||
funcId: 35,
|
||||
port: port_,
|
||||
);
|
||||
},
|
||||
@@ -1755,7 +1815,7 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi {
|
||||
pdeCallFfi(
|
||||
generalizedFrbRustBinding,
|
||||
serializer,
|
||||
funcId: 35,
|
||||
funcId: 36,
|
||||
port: port_,
|
||||
);
|
||||
},
|
||||
@@ -1793,7 +1853,7 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi {
|
||||
pdeCallFfi(
|
||||
generalizedFrbRustBinding,
|
||||
serializer,
|
||||
funcId: 36,
|
||||
funcId: 37,
|
||||
port: port_,
|
||||
);
|
||||
},
|
||||
@@ -1831,7 +1891,7 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi {
|
||||
pdeCallFfi(
|
||||
generalizedFrbRustBinding,
|
||||
serializer,
|
||||
funcId: 37,
|
||||
funcId: 38,
|
||||
port: port_,
|
||||
);
|
||||
},
|
||||
@@ -1869,7 +1929,7 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi {
|
||||
pdeCallFfi(
|
||||
generalizedFrbRustBinding,
|
||||
serializer,
|
||||
funcId: 38,
|
||||
funcId: 39,
|
||||
port: port_,
|
||||
);
|
||||
},
|
||||
@@ -1907,7 +1967,7 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi {
|
||||
pdeCallFfi(
|
||||
generalizedFrbRustBinding,
|
||||
serializer,
|
||||
funcId: 39,
|
||||
funcId: 40,
|
||||
port: port_,
|
||||
);
|
||||
},
|
||||
@@ -1945,7 +2005,7 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi {
|
||||
pdeCallFfi(
|
||||
generalizedFrbRustBinding,
|
||||
serializer,
|
||||
funcId: 40,
|
||||
funcId: 41,
|
||||
port: port_,
|
||||
);
|
||||
},
|
||||
@@ -1983,7 +2043,7 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi {
|
||||
pdeCallFfi(
|
||||
generalizedFrbRustBinding,
|
||||
serializer,
|
||||
funcId: 41,
|
||||
funcId: 42,
|
||||
port: port_,
|
||||
);
|
||||
},
|
||||
@@ -2025,7 +2085,7 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi {
|
||||
pdeCallFfi(
|
||||
generalizedFrbRustBinding,
|
||||
serializer,
|
||||
funcId: 42,
|
||||
funcId: 43,
|
||||
port: port_,
|
||||
);
|
||||
},
|
||||
@@ -2065,7 +2125,7 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi {
|
||||
pdeCallFfi(
|
||||
generalizedFrbRustBinding,
|
||||
serializer,
|
||||
funcId: 43,
|
||||
funcId: 44,
|
||||
port: port_,
|
||||
);
|
||||
},
|
||||
@@ -2105,7 +2165,7 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi {
|
||||
pdeCallFfi(
|
||||
generalizedFrbRustBinding,
|
||||
serializer,
|
||||
funcId: 44,
|
||||
funcId: 45,
|
||||
port: port_,
|
||||
);
|
||||
},
|
||||
@@ -2145,7 +2205,7 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi {
|
||||
pdeCallFfi(
|
||||
generalizedFrbRustBinding,
|
||||
serializer,
|
||||
funcId: 45,
|
||||
funcId: 46,
|
||||
port: port_,
|
||||
);
|
||||
},
|
||||
@@ -2183,7 +2243,7 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi {
|
||||
pdeCallFfi(
|
||||
generalizedFrbRustBinding,
|
||||
serializer,
|
||||
funcId: 46,
|
||||
funcId: 47,
|
||||
port: port_,
|
||||
);
|
||||
},
|
||||
@@ -2223,7 +2283,7 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi {
|
||||
pdeCallFfi(
|
||||
generalizedFrbRustBinding,
|
||||
serializer,
|
||||
funcId: 47,
|
||||
funcId: 48,
|
||||
port: port_,
|
||||
);
|
||||
},
|
||||
@@ -2263,7 +2323,7 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi {
|
||||
pdeCallFfi(
|
||||
generalizedFrbRustBinding,
|
||||
serializer,
|
||||
funcId: 48,
|
||||
funcId: 49,
|
||||
port: port_,
|
||||
);
|
||||
},
|
||||
@@ -2301,7 +2361,7 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi {
|
||||
pdeCallFfi(
|
||||
generalizedFrbRustBinding,
|
||||
serializer,
|
||||
funcId: 49,
|
||||
funcId: 50,
|
||||
port: port_,
|
||||
);
|
||||
},
|
||||
@@ -2322,6 +2382,44 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi {
|
||||
argNames: ["that", "name"],
|
||||
);
|
||||
|
||||
@override
|
||||
Future<int> crateApiGraphSynapseGraphRemoveType({
|
||||
required SynapseGraph that,
|
||||
required String name,
|
||||
}) {
|
||||
return handler.executeNormal(
|
||||
NormalTask(
|
||||
callFfi: (port_) {
|
||||
final serializer = SseSerializer(generalizedFrbRustBinding);
|
||||
sse_encode_Auto_Ref_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerSynapseGraph(
|
||||
that,
|
||||
serializer,
|
||||
);
|
||||
sse_encode_String(name, serializer);
|
||||
pdeCallFfi(
|
||||
generalizedFrbRustBinding,
|
||||
serializer,
|
||||
funcId: 51,
|
||||
port: port_,
|
||||
);
|
||||
},
|
||||
codec: SseCodec(
|
||||
decodeSuccessData: sse_decode_u_32,
|
||||
decodeErrorData: sse_decode_AnyhowException,
|
||||
),
|
||||
constMeta: kCrateApiGraphSynapseGraphRemoveTypeConstMeta,
|
||||
argValues: [that, name],
|
||||
apiImpl: this,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
TaskConstMeta get kCrateApiGraphSynapseGraphRemoveTypeConstMeta =>
|
||||
const TaskConstMeta(
|
||||
debugName: "SynapseGraph_remove_type",
|
||||
argNames: ["that", "name"],
|
||||
);
|
||||
|
||||
@override
|
||||
Future<PageDto> crateApiGraphSynapseGraphRenamePage({
|
||||
required SynapseGraph that,
|
||||
@@ -2341,7 +2439,7 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi {
|
||||
pdeCallFfi(
|
||||
generalizedFrbRustBinding,
|
||||
serializer,
|
||||
funcId: 50,
|
||||
funcId: 52,
|
||||
port: port_,
|
||||
);
|
||||
},
|
||||
@@ -2381,7 +2479,7 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi {
|
||||
pdeCallFfi(
|
||||
generalizedFrbRustBinding,
|
||||
serializer,
|
||||
funcId: 51,
|
||||
funcId: 53,
|
||||
port: port_,
|
||||
);
|
||||
},
|
||||
@@ -2402,6 +2500,46 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi {
|
||||
argNames: ["that", "old", "new_"],
|
||||
);
|
||||
|
||||
@override
|
||||
Future<int> crateApiGraphSynapseGraphRenameType({
|
||||
required SynapseGraph that,
|
||||
required String old,
|
||||
required String new_,
|
||||
}) {
|
||||
return handler.executeNormal(
|
||||
NormalTask(
|
||||
callFfi: (port_) {
|
||||
final serializer = SseSerializer(generalizedFrbRustBinding);
|
||||
sse_encode_Auto_Ref_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerSynapseGraph(
|
||||
that,
|
||||
serializer,
|
||||
);
|
||||
sse_encode_String(old, serializer);
|
||||
sse_encode_String(new_, serializer);
|
||||
pdeCallFfi(
|
||||
generalizedFrbRustBinding,
|
||||
serializer,
|
||||
funcId: 54,
|
||||
port: port_,
|
||||
);
|
||||
},
|
||||
codec: SseCodec(
|
||||
decodeSuccessData: sse_decode_u_32,
|
||||
decodeErrorData: sse_decode_AnyhowException,
|
||||
),
|
||||
constMeta: kCrateApiGraphSynapseGraphRenameTypeConstMeta,
|
||||
argValues: [that, old, new_],
|
||||
apiImpl: this,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
TaskConstMeta get kCrateApiGraphSynapseGraphRenameTypeConstMeta =>
|
||||
const TaskConstMeta(
|
||||
debugName: "SynapseGraph_rename_type",
|
||||
argNames: ["that", "old", "new_"],
|
||||
);
|
||||
|
||||
@override
|
||||
Future<List<BlockHit>> crateApiGraphSynapseGraphSearchBlocks({
|
||||
required SynapseGraph that,
|
||||
@@ -2421,7 +2559,7 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi {
|
||||
pdeCallFfi(
|
||||
generalizedFrbRustBinding,
|
||||
serializer,
|
||||
funcId: 52,
|
||||
funcId: 55,
|
||||
port: port_,
|
||||
);
|
||||
},
|
||||
@@ -2461,7 +2599,7 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi {
|
||||
pdeCallFfi(
|
||||
generalizedFrbRustBinding,
|
||||
serializer,
|
||||
funcId: 53,
|
||||
funcId: 56,
|
||||
port: port_,
|
||||
);
|
||||
},
|
||||
@@ -2501,7 +2639,7 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi {
|
||||
pdeCallFfi(
|
||||
generalizedFrbRustBinding,
|
||||
serializer,
|
||||
funcId: 54,
|
||||
funcId: 57,
|
||||
port: port_,
|
||||
);
|
||||
},
|
||||
@@ -2541,7 +2679,7 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi {
|
||||
pdeCallFfi(
|
||||
generalizedFrbRustBinding,
|
||||
serializer,
|
||||
funcId: 55,
|
||||
funcId: 58,
|
||||
port: port_,
|
||||
);
|
||||
},
|
||||
@@ -2581,7 +2719,7 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi {
|
||||
pdeCallFfi(
|
||||
generalizedFrbRustBinding,
|
||||
serializer,
|
||||
funcId: 56,
|
||||
funcId: 59,
|
||||
port: port_,
|
||||
);
|
||||
},
|
||||
@@ -2621,7 +2759,7 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi {
|
||||
pdeCallFfi(
|
||||
generalizedFrbRustBinding,
|
||||
serializer,
|
||||
funcId: 57,
|
||||
funcId: 60,
|
||||
port: port_,
|
||||
);
|
||||
},
|
||||
@@ -2642,6 +2780,46 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi {
|
||||
argNames: ["that", "pageId", "pageType"],
|
||||
);
|
||||
|
||||
@override
|
||||
Future<void> crateApiGraphSynapseGraphSetTypeIcon({
|
||||
required SynapseGraph that,
|
||||
required String name,
|
||||
String? icon,
|
||||
}) {
|
||||
return handler.executeNormal(
|
||||
NormalTask(
|
||||
callFfi: (port_) {
|
||||
final serializer = SseSerializer(generalizedFrbRustBinding);
|
||||
sse_encode_Auto_Ref_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerSynapseGraph(
|
||||
that,
|
||||
serializer,
|
||||
);
|
||||
sse_encode_String(name, serializer);
|
||||
sse_encode_opt_String(icon, serializer);
|
||||
pdeCallFfi(
|
||||
generalizedFrbRustBinding,
|
||||
serializer,
|
||||
funcId: 61,
|
||||
port: port_,
|
||||
);
|
||||
},
|
||||
codec: SseCodec(
|
||||
decodeSuccessData: sse_decode_unit,
|
||||
decodeErrorData: sse_decode_AnyhowException,
|
||||
),
|
||||
constMeta: kCrateApiGraphSynapseGraphSetTypeIconConstMeta,
|
||||
argValues: [that, name, icon],
|
||||
apiImpl: this,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
TaskConstMeta get kCrateApiGraphSynapseGraphSetTypeIconConstMeta =>
|
||||
const TaskConstMeta(
|
||||
debugName: "SynapseGraph_set_type_icon",
|
||||
argNames: ["that", "name", "icon"],
|
||||
);
|
||||
|
||||
@override
|
||||
Future<List<TagDto>> crateApiGraphSynapseGraphTagCatalog({
|
||||
required SynapseGraph that,
|
||||
@@ -2657,7 +2835,7 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi {
|
||||
pdeCallFfi(
|
||||
generalizedFrbRustBinding,
|
||||
serializer,
|
||||
funcId: 58,
|
||||
funcId: 62,
|
||||
port: port_,
|
||||
);
|
||||
},
|
||||
@@ -2697,7 +2875,7 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi {
|
||||
pdeCallFfi(
|
||||
generalizedFrbRustBinding,
|
||||
serializer,
|
||||
funcId: 59,
|
||||
funcId: 63,
|
||||
port: port_,
|
||||
);
|
||||
},
|
||||
@@ -2728,7 +2906,7 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi {
|
||||
that,
|
||||
serializer,
|
||||
);
|
||||
return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 60)!;
|
||||
return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 64)!;
|
||||
},
|
||||
codec: SseCodec(
|
||||
decodeSuccessData: sse_decode_String,
|
||||
@@ -2759,7 +2937,7 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi {
|
||||
pdeCallFfi(
|
||||
generalizedFrbRustBinding,
|
||||
serializer,
|
||||
funcId: 61,
|
||||
funcId: 65,
|
||||
port: port_,
|
||||
);
|
||||
},
|
||||
@@ -2799,7 +2977,7 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi {
|
||||
pdeCallFfi(
|
||||
generalizedFrbRustBinding,
|
||||
serializer,
|
||||
funcId: 62,
|
||||
funcId: 66,
|
||||
port: port_,
|
||||
);
|
||||
},
|
||||
@@ -2920,13 +3098,14 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi {
|
||||
BacklinkGroup dco_decode_backlink_group(dynamic raw) {
|
||||
// Codec=Dco (DartCObject based), see doc to use other codecs
|
||||
final arr = raw as List<dynamic>;
|
||||
if (arr.length != 4)
|
||||
throw Exception('unexpected arr length: expect 4 but see ${arr.length}');
|
||||
if (arr.length != 5)
|
||||
throw Exception('unexpected arr length: expect 5 but see ${arr.length}');
|
||||
return BacklinkGroup(
|
||||
pageId: dco_decode_String(arr[0]),
|
||||
pageTitle: dco_decode_String(arr[1]),
|
||||
isJournal: dco_decode_bool(arr[2]),
|
||||
blocks: dco_decode_list_block_dto(arr[3]),
|
||||
pageType: dco_decode_opt_String(arr[3]),
|
||||
blocks: dco_decode_list_block_dto(arr[4]),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -3042,8 +3221,8 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi {
|
||||
GraphNode dco_decode_graph_node(dynamic raw) {
|
||||
// Codec=Dco (DartCObject based), see doc to use other codecs
|
||||
final arr = raw as List<dynamic>;
|
||||
if (arr.length != 13)
|
||||
throw Exception('unexpected arr length: expect 13 but see ${arr.length}');
|
||||
if (arr.length != 14)
|
||||
throw Exception('unexpected arr length: expect 14 but see ${arr.length}');
|
||||
return GraphNode(
|
||||
id: dco_decode_String(arr[0]),
|
||||
title: dco_decode_String(arr[1]),
|
||||
@@ -3058,6 +3237,7 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi {
|
||||
homeHub: dco_decode_opt_box_autoadd_u_32(arr[10]),
|
||||
tags: dco_decode_list_String(arr[11]),
|
||||
isTag: dco_decode_bool(arr[12]),
|
||||
pageType: dco_decode_opt_String(arr[13]),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -3322,13 +3502,14 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi {
|
||||
PageBrief dco_decode_page_brief(dynamic raw) {
|
||||
// Codec=Dco (DartCObject based), see doc to use other codecs
|
||||
final arr = raw as List<dynamic>;
|
||||
if (arr.length != 4)
|
||||
throw Exception('unexpected arr length: expect 4 but see ${arr.length}');
|
||||
if (arr.length != 5)
|
||||
throw Exception('unexpected arr length: expect 5 but see ${arr.length}');
|
||||
return PageBrief(
|
||||
id: dco_decode_String(arr[0]),
|
||||
title: dco_decode_String(arr[1]),
|
||||
isJournal: dco_decode_bool(arr[2]),
|
||||
isHub: dco_decode_bool(arr[3]),
|
||||
pageType: dco_decode_opt_String(arr[4]),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -3427,12 +3608,16 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi {
|
||||
TagDto dco_decode_tag_dto(dynamic raw) {
|
||||
// Codec=Dco (DartCObject based), see doc to use other codecs
|
||||
final arr = raw as List<dynamic>;
|
||||
if (arr.length != 3)
|
||||
throw Exception('unexpected arr length: expect 3 but see ${arr.length}');
|
||||
if (arr.length != 7)
|
||||
throw Exception('unexpected arr length: expect 7 but see ${arr.length}');
|
||||
return TagDto(
|
||||
name: dco_decode_String(arr[0]),
|
||||
count: dco_decode_u_32(arr[1]),
|
||||
suggested: dco_decode_bool(arr[2]),
|
||||
icon: dco_decode_opt_String(arr[3]),
|
||||
explicit: dco_decode_u_32(arr[4]),
|
||||
typed: dco_decode_u_32(arr[5]),
|
||||
fromHub: dco_decode_u_32(arr[6]),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -3466,12 +3651,13 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi {
|
||||
TitleHit dco_decode_title_hit(dynamic raw) {
|
||||
// Codec=Dco (DartCObject based), see doc to use other codecs
|
||||
final arr = raw as List<dynamic>;
|
||||
if (arr.length != 3)
|
||||
throw Exception('unexpected arr length: expect 3 but see ${arr.length}');
|
||||
if (arr.length != 4)
|
||||
throw Exception('unexpected arr length: expect 4 but see ${arr.length}');
|
||||
return TitleHit(
|
||||
pageId: dco_decode_String(arr[0]),
|
||||
title: dco_decode_String(arr[1]),
|
||||
isAlias: dco_decode_bool(arr[2]),
|
||||
pageType: dco_decode_opt_String(arr[3]),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -3612,11 +3798,13 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi {
|
||||
var var_pageId = sse_decode_String(deserializer);
|
||||
var var_pageTitle = sse_decode_String(deserializer);
|
||||
var var_isJournal = sse_decode_bool(deserializer);
|
||||
var var_pageType = sse_decode_opt_String(deserializer);
|
||||
var var_blocks = sse_decode_list_block_dto(deserializer);
|
||||
return BacklinkGroup(
|
||||
pageId: var_pageId,
|
||||
pageTitle: var_pageTitle,
|
||||
isJournal: var_isJournal,
|
||||
pageType: var_pageType,
|
||||
blocks: var_blocks,
|
||||
);
|
||||
}
|
||||
@@ -3751,6 +3939,7 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi {
|
||||
var var_homeHub = sse_decode_opt_box_autoadd_u_32(deserializer);
|
||||
var var_tags = sse_decode_list_String(deserializer);
|
||||
var var_isTag = sse_decode_bool(deserializer);
|
||||
var var_pageType = sse_decode_opt_String(deserializer);
|
||||
return GraphNode(
|
||||
id: var_id,
|
||||
title: var_title,
|
||||
@@ -3765,6 +3954,7 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi {
|
||||
homeHub: var_homeHub,
|
||||
tags: var_tags,
|
||||
isTag: var_isTag,
|
||||
pageType: var_pageType,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -4167,11 +4357,13 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi {
|
||||
var var_title = sse_decode_String(deserializer);
|
||||
var var_isJournal = sse_decode_bool(deserializer);
|
||||
var var_isHub = sse_decode_bool(deserializer);
|
||||
var var_pageType = sse_decode_opt_String(deserializer);
|
||||
return PageBrief(
|
||||
id: var_id,
|
||||
title: var_title,
|
||||
isJournal: var_isJournal,
|
||||
isHub: var_isHub,
|
||||
pageType: var_pageType,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -4277,7 +4469,19 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi {
|
||||
var var_name = sse_decode_String(deserializer);
|
||||
var var_count = sse_decode_u_32(deserializer);
|
||||
var var_suggested = sse_decode_bool(deserializer);
|
||||
return TagDto(name: var_name, count: var_count, suggested: var_suggested);
|
||||
var var_icon = sse_decode_opt_String(deserializer);
|
||||
var var_explicit = sse_decode_u_32(deserializer);
|
||||
var var_typed = sse_decode_u_32(deserializer);
|
||||
var var_fromHub = sse_decode_u_32(deserializer);
|
||||
return TagDto(
|
||||
name: var_name,
|
||||
count: var_count,
|
||||
suggested: var_suggested,
|
||||
icon: var_icon,
|
||||
explicit: var_explicit,
|
||||
typed: var_typed,
|
||||
fromHub: var_fromHub,
|
||||
);
|
||||
}
|
||||
|
||||
@protected
|
||||
@@ -4309,7 +4513,13 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi {
|
||||
var var_pageId = sse_decode_String(deserializer);
|
||||
var var_title = sse_decode_String(deserializer);
|
||||
var var_isAlias = sse_decode_bool(deserializer);
|
||||
return TitleHit(pageId: var_pageId, title: var_title, isAlias: var_isAlias);
|
||||
var var_pageType = sse_decode_opt_String(deserializer);
|
||||
return TitleHit(
|
||||
pageId: var_pageId,
|
||||
title: var_title,
|
||||
isAlias: var_isAlias,
|
||||
pageType: var_pageType,
|
||||
);
|
||||
}
|
||||
|
||||
@protected
|
||||
@@ -4449,6 +4659,7 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi {
|
||||
sse_encode_String(self.pageId, serializer);
|
||||
sse_encode_String(self.pageTitle, serializer);
|
||||
sse_encode_bool(self.isJournal, serializer);
|
||||
sse_encode_opt_String(self.pageType, serializer);
|
||||
sse_encode_list_block_dto(self.blocks, serializer);
|
||||
}
|
||||
|
||||
@@ -4557,6 +4768,7 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi {
|
||||
sse_encode_opt_box_autoadd_u_32(self.homeHub, serializer);
|
||||
sse_encode_list_String(self.tags, serializer);
|
||||
sse_encode_bool(self.isTag, serializer);
|
||||
sse_encode_opt_String(self.pageType, serializer);
|
||||
}
|
||||
|
||||
@protected
|
||||
@@ -4942,6 +5154,7 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi {
|
||||
sse_encode_String(self.title, serializer);
|
||||
sse_encode_bool(self.isJournal, serializer);
|
||||
sse_encode_bool(self.isHub, serializer);
|
||||
sse_encode_opt_String(self.pageType, serializer);
|
||||
}
|
||||
|
||||
@protected
|
||||
@@ -5016,6 +5229,10 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi {
|
||||
sse_encode_String(self.name, serializer);
|
||||
sse_encode_u_32(self.count, serializer);
|
||||
sse_encode_bool(self.suggested, serializer);
|
||||
sse_encode_opt_String(self.icon, serializer);
|
||||
sse_encode_u_32(self.explicit, serializer);
|
||||
sse_encode_u_32(self.typed, serializer);
|
||||
sse_encode_u_32(self.fromHub, serializer);
|
||||
}
|
||||
|
||||
@protected
|
||||
@@ -5043,6 +5260,7 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi {
|
||||
sse_encode_String(self.pageId, serializer);
|
||||
sse_encode_String(self.title, serializer);
|
||||
sse_encode_bool(self.isAlias, serializer);
|
||||
sse_encode_opt_String(self.pageType, serializer);
|
||||
}
|
||||
|
||||
@protected
|
||||
@@ -5222,6 +5440,10 @@ class SynapseGraphImpl extends RustOpaque implements SynapseGraph {
|
||||
title: title,
|
||||
);
|
||||
|
||||
/// Adds a type to the vocabulary even if no page uses it; returns its spelling.
|
||||
Future<String> createType({required String name}) => RustLib.instance.api
|
||||
.crateApiGraphSynapseGraphCreateType(that: this, name: name);
|
||||
|
||||
/// Deletes a block and its subtree.
|
||||
Future<List<BlockDto>> deleteBlock({required String id}) => RustLib
|
||||
.instance
|
||||
@@ -5436,6 +5658,10 @@ class SynapseGraphImpl extends RustOpaque implements SynapseGraph {
|
||||
Future<int> removeTag({required String name}) => RustLib.instance.api
|
||||
.crateApiGraphSynapseGraphRemoveTag(that: this, name: name);
|
||||
|
||||
/// Deletes a type: its pages lose it and its icon is dropped; returns the pages changed.
|
||||
Future<int> removeType({required String name}) => RustLib.instance.api
|
||||
.crateApiGraphSynapseGraphRemoveType(that: this, name: name);
|
||||
|
||||
Future<PageDto> renamePage({required String id, required String newTitle}) =>
|
||||
RustLib.instance.api.crateApiGraphSynapseGraphRenamePage(
|
||||
that: this,
|
||||
@@ -5450,6 +5676,12 @@ class SynapseGraphImpl extends RustOpaque implements SynapseGraph {
|
||||
.api
|
||||
.crateApiGraphSynapseGraphRenameTag(that: this, old: old, new_: new_);
|
||||
|
||||
/// Renames a type (and same-name tags), keeping its icon; returns the pages changed.
|
||||
Future<int> renameType({required String old, required String new_}) => RustLib
|
||||
.instance
|
||||
.api
|
||||
.crateApiGraphSynapseGraphRenameType(that: this, old: old, new_: new_);
|
||||
|
||||
/// Blocks whose text contains `query` (for `((` autocomplete), most recent first.
|
||||
Future<List<BlockHit>> searchBlocks({
|
||||
required String query,
|
||||
@@ -5507,6 +5739,12 @@ class SynapseGraphImpl extends RustOpaque implements SynapseGraph {
|
||||
pageType: pageType,
|
||||
);
|
||||
|
||||
/// Sets (or with `None` clears) the emoji of a type, defining the type if needed.
|
||||
Future<void> setTypeIcon({required String name, String? icon}) => RustLib
|
||||
.instance
|
||||
.api
|
||||
.crateApiGraphSynapseGraphSetTypeIcon(that: this, name: name, icon: icon);
|
||||
|
||||
/// Every tag in use (listed or implied by a type) with its number of pages, most used first.
|
||||
Future<List<TagDto>> tagCatalog() =>
|
||||
RustLib.instance.api.crateApiGraphSynapseGraphTagCatalog(that: this);
|
||||
@@ -5523,7 +5761,8 @@ class SynapseGraphImpl extends RustOpaque implements SynapseGraph {
|
||||
String today() =>
|
||||
RustLib.instance.api.crateApiGraphSynapseGraphToday(that: this);
|
||||
|
||||
/// Types in use (most used first) followed by the seeded suggestions not used yet.
|
||||
/// Types in use (most used first), then defined unused types, then the seeded suggestions
|
||||
/// not used yet; each with its icon.
|
||||
Future<List<TagDto>> typeCatalog() =>
|
||||
RustLib.instance.api.crateApiGraphSynapseGraphTypeCatalog(that: this);
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import 'dart:ui' show PlatformDispatcher;
|
||||
|
||||
import 'package:flutter/foundation.dart' show mapEquals;
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart' show HardwareKeyboard;
|
||||
|
||||
@@ -31,6 +32,11 @@ class SettingsRoute extends AppRoute {
|
||||
const SettingsRoute();
|
||||
}
|
||||
|
||||
/// Manage the vocabulary: types (with their emoji) and tags.
|
||||
class TagsTypesRoute extends AppRoute {
|
||||
const TagsTypesRoute();
|
||||
}
|
||||
|
||||
enum GraphMode {
|
||||
network('Network', Icons.hub_outlined),
|
||||
brain('Synapses', Icons.bolt_outlined),
|
||||
@@ -81,6 +87,9 @@ class AppTab {
|
||||
/// Title of a page route (the route only has an id); set once the page is shown.
|
||||
String? label;
|
||||
|
||||
/// Type of the page shown (for its emoji next to [title]); set with [label].
|
||||
String? pageType;
|
||||
|
||||
/// Stable identity for widget keys (reordering, closing).
|
||||
final int uid = _nextUid++;
|
||||
static int _nextUid = 0;
|
||||
@@ -90,6 +99,7 @@ class AppTab {
|
||||
TimelineRoute() => 'Timeline',
|
||||
AllPagesRoute() => 'All pages',
|
||||
SettingsRoute() => 'Settings',
|
||||
TagsTypesRoute() => 'Tags & types',
|
||||
TagRoute(:final name) => '#$name',
|
||||
GraphRoute() => 'Graph',
|
||||
PageTarget(:final title) => label ?? title ?? 'Page',
|
||||
@@ -100,6 +110,7 @@ class AppTab {
|
||||
TimelineRoute() => Icons.timeline_rounded,
|
||||
AllPagesRoute() => Icons.description_outlined,
|
||||
SettingsRoute() => Icons.settings_outlined,
|
||||
TagsTypesRoute() => Icons.style_outlined,
|
||||
TagRoute() => Icons.sell_outlined,
|
||||
GraphRoute() => Icons.hub_outlined,
|
||||
PageTarget() => Icons.article_outlined,
|
||||
@@ -116,6 +127,7 @@ Map<String, dynamic>? routeToJson(AppRoute r, {String? label}) => switch (r) {
|
||||
TimelineRoute() => {'t': 'timeline'},
|
||||
AllPagesRoute() => {'t': 'all'},
|
||||
SettingsRoute() => {'t': 'settings'},
|
||||
TagsTypesRoute() => {'t': 'tags-types'},
|
||||
TagRoute() => {'t': 'tag', 'name': r.name},
|
||||
GraphRoute() => {
|
||||
't': 'graph',
|
||||
@@ -142,6 +154,8 @@ AppRoute? routeFromJson(Object? j) {
|
||||
return const AllPagesRoute();
|
||||
case 'settings':
|
||||
return const SettingsRoute();
|
||||
case 'tags-types':
|
||||
return const TagsTypesRoute();
|
||||
case 'tag':
|
||||
final name = j['name'];
|
||||
return name is String && name.isNotEmpty ? TagRoute(name) : null;
|
||||
@@ -338,6 +352,48 @@ class AppState extends ChangeNotifier {
|
||||
/// Bumped to make the current view reload from the core (failed writes, renames).
|
||||
int generation = 0;
|
||||
|
||||
/// Emoji of each type, by lower-cased type name (types are names; see [typeIcon]).
|
||||
final Map<String, String> typeIcons = {};
|
||||
|
||||
/// The emoji of a page type, if it has one.
|
||||
String? typeIcon(String? type) =>
|
||||
type == null ? null : typeIcons[type.trim().toLowerCase()];
|
||||
|
||||
/// The type emoji of the page a tab shows (null for other routes).
|
||||
String? tabTypeIcon(AppTab t) =>
|
||||
t.route is PageTarget ? typeIcon(t.pageType) : null;
|
||||
|
||||
/// Bumped whenever [typeIcons] changes (lets painters such as the tree view redraw).
|
||||
int iconsVersion = 0;
|
||||
|
||||
/// Reloads [typeIcons] from the type catalogue (at start, after type edits and on every
|
||||
/// [reload]); listeners are only notified when something changed. Errors are logged.
|
||||
Future<void> loadTypeIcons() async {
|
||||
final List<TagDto> types;
|
||||
try {
|
||||
types = await backend.typeCatalog();
|
||||
} catch (e, st) {
|
||||
debugPrint('loading type icons failed: $e\n$st');
|
||||
return;
|
||||
}
|
||||
final next = {
|
||||
for (final t in types)
|
||||
if (t.icon != null) t.name.toLowerCase(): t.icon!,
|
||||
};
|
||||
if (mapEquals(next, typeIcons)) return;
|
||||
typeIcons
|
||||
..clear()
|
||||
..addAll(next);
|
||||
iconsVersion++;
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
/// Views reload from the core: so do the type icons (they may have changed elsewhere).
|
||||
void _bumpGeneration() {
|
||||
generation++;
|
||||
loadTypeIcons().ignore();
|
||||
}
|
||||
|
||||
/// Hubs expanded in the sidebar tree (kept here so it survives sidebar rebuilds).
|
||||
final expandedHubs = <String>{};
|
||||
|
||||
@@ -369,7 +425,7 @@ class AppState extends ChangeNotifier {
|
||||
|
||||
/// Rebuilds the current view from the core (after queued writes have run).
|
||||
void reload() {
|
||||
generation++;
|
||||
_bumpGeneration();
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
@@ -380,6 +436,7 @@ class AppState extends ChangeNotifier {
|
||||
t.forward.clear();
|
||||
t.route = r;
|
||||
t.label = null;
|
||||
t.pageType = null;
|
||||
_saveSettings();
|
||||
notifyListeners();
|
||||
}
|
||||
@@ -458,7 +515,7 @@ class AppState extends ChangeNotifier {
|
||||
}
|
||||
}
|
||||
}
|
||||
generation++;
|
||||
_bumpGeneration();
|
||||
_saveSettings();
|
||||
notifyListeners();
|
||||
}
|
||||
@@ -510,7 +567,7 @@ class AppState extends ChangeNotifier {
|
||||
t.label = null;
|
||||
}
|
||||
}
|
||||
generation++;
|
||||
_bumpGeneration();
|
||||
_saveSettings();
|
||||
notifyListeners();
|
||||
}
|
||||
@@ -520,7 +577,7 @@ class AppState extends ChangeNotifier {
|
||||
tab
|
||||
..route = r
|
||||
..label = null;
|
||||
generation++;
|
||||
_bumpGeneration();
|
||||
_saveSettings();
|
||||
notifyListeners();
|
||||
}
|
||||
@@ -548,6 +605,7 @@ class AppState extends ChangeNotifier {
|
||||
tab.label = label;
|
||||
_saveSettings();
|
||||
}
|
||||
tab.pageType = page.pageType;
|
||||
}
|
||||
recent.removeWhere((p) => p.id == page.id);
|
||||
// Hubs are folders, not pages: they never show up in recents.
|
||||
@@ -559,6 +617,7 @@ class AppState extends ChangeNotifier {
|
||||
title: page.title,
|
||||
isJournal: page.journalDate != null,
|
||||
isHub: false,
|
||||
pageType: page.pageType,
|
||||
),
|
||||
);
|
||||
if (recent.length > 12) recent.removeLast();
|
||||
@@ -572,7 +631,13 @@ class AppState extends ChangeNotifier {
|
||||
for (final p in pages) {
|
||||
if (!p.isHub && !recent.any((r) => r.id == p.id)) {
|
||||
recent.add(
|
||||
PageBrief(id: p.id, title: p.title, isJournal: false, isHub: p.isHub),
|
||||
PageBrief(
|
||||
id: p.id,
|
||||
title: p.title,
|
||||
isJournal: false,
|
||||
isHub: p.isHub,
|
||||
pageType: p.pageType,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -591,6 +656,7 @@ class AppState extends ChangeNotifier {
|
||||
title: title,
|
||||
isJournal: recent[i].isJournal,
|
||||
isHub: recent[i].isHub,
|
||||
pageType: recent[i].pageType,
|
||||
);
|
||||
}
|
||||
notifyListeners();
|
||||
|
||||
@@ -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;
|
||||
@@ -309,6 +310,7 @@ class _AllPagesViewState extends State<AllPagesView> {
|
||||
: colors.faint,
|
||||
),
|
||||
),
|
||||
TypeIcon(p.pageType, size: 14, gap: 6),
|
||||
Expanded(
|
||||
child: Text(
|
||||
p.title,
|
||||
|
||||
@@ -442,6 +442,9 @@ class _GraphViewState extends State<GraphView> {
|
||||
model: m,
|
||||
onTap: _open,
|
||||
name: AppScope.read(context).backend.graphName,
|
||||
typeIcon: AppScope.read(context).typeIcon,
|
||||
// Subscribes: icon edits (or icons loaded after a cold start) reach the labels.
|
||||
iconsVersion: AppScope.of(context).iconsVersion,
|
||||
);
|
||||
}
|
||||
final sub = _sub;
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -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),
|
||||
|
||||
@@ -16,6 +16,8 @@ import 'graph_view.dart';
|
||||
import 'settings_view.dart';
|
||||
import 'tab_strip.dart';
|
||||
import 'tag_view.dart';
|
||||
import 'tags_types_view.dart';
|
||||
import '../widgets/type_icon.dart';
|
||||
|
||||
/// App frame: sidebar (navigation, hubs, recents), top bar (history, search, theme,
|
||||
/// settings) and the current view.
|
||||
@@ -132,6 +134,7 @@ class _ShellState extends State<Shell> {
|
||||
),
|
||||
AllPagesRoute() => const AllPagesView(),
|
||||
SettingsRoute() => const SettingsView(),
|
||||
TagsTypesRoute() => const TagsTypesView(),
|
||||
TagRoute() => TagView(name: route.name),
|
||||
PageTarget() => PageScreen(target: route),
|
||||
},
|
||||
@@ -323,6 +326,13 @@ class _Sidebar extends StatelessWidget {
|
||||
onTap: () => go(const AllPagesRoute()),
|
||||
onMiddle: () => newTab(const AllPagesRoute()),
|
||||
),
|
||||
_NavItem(
|
||||
icon: Icons.style_outlined,
|
||||
label: 'Tags & types',
|
||||
selected: route is TagsTypesRoute,
|
||||
onTap: () => go(const TagsTypesRoute()),
|
||||
onMiddle: () => newTab(const TagsTypesRoute()),
|
||||
),
|
||||
const SizedBox(height: 22),
|
||||
Expanded(
|
||||
child: ListView(
|
||||
@@ -342,6 +352,7 @@ class _Sidebar extends StatelessWidget {
|
||||
for (final p in app.recent)
|
||||
_NavItem(
|
||||
label: p.isJournal ? longDate(p.title) : p.title,
|
||||
leading: TypeIcon(p.pageType),
|
||||
selected: route is PageTarget && route.id == p.id,
|
||||
dense: true,
|
||||
onTap: () => go(PageTarget(id: p.id)),
|
||||
@@ -360,6 +371,7 @@ class _Sidebar extends StatelessWidget {
|
||||
class _NavItem extends StatefulWidget {
|
||||
const _NavItem({
|
||||
this.icon,
|
||||
this.leading,
|
||||
required this.label,
|
||||
required this.selected,
|
||||
required this.onTap,
|
||||
@@ -367,6 +379,9 @@ class _NavItem extends StatefulWidget {
|
||||
this.dense = false,
|
||||
});
|
||||
final IconData? icon;
|
||||
|
||||
/// Shown before the label (a page's type emoji).
|
||||
final Widget? leading;
|
||||
final String label;
|
||||
final bool selected;
|
||||
final VoidCallback onTap;
|
||||
@@ -417,6 +432,7 @@ class _NavItemState extends State<_NavItem> {
|
||||
),
|
||||
const SizedBox(width: 10),
|
||||
],
|
||||
?widget.leading,
|
||||
Expanded(
|
||||
child: Text(
|
||||
widget.label,
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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';
|
||||
|
||||
@@ -25,6 +26,8 @@ class TagView extends StatelessWidget {
|
||||
() => app.backend.renameTag(name, next),
|
||||
report: false,
|
||||
);
|
||||
// A type of that name moves its emoji to the new name.
|
||||
await app.loadTypeIcons();
|
||||
app.replaceRoute(TagRoute(next));
|
||||
} catch (e) {
|
||||
messenger.showSnackBar(SnackBar(content: Text(errorText(e))));
|
||||
@@ -58,6 +61,7 @@ class TagView extends StatelessWidget {
|
||||
if (ok != true) return;
|
||||
try {
|
||||
await app.queue.run(() => app.backend.removeTag(name), report: false);
|
||||
await app.loadTypeIcons();
|
||||
app.reload();
|
||||
} catch (e) {
|
||||
messenger.showSnackBar(SnackBar(content: Text(errorText(e))));
|
||||
@@ -81,10 +85,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 +148,7 @@ class TagView extends StatelessWidget {
|
||||
color: colors.faint,
|
||||
),
|
||||
const SizedBox(width: 10),
|
||||
TypeIcon(p.pageType, size: 14, gap: 6),
|
||||
Expanded(
|
||||
child: Text(
|
||||
p.title,
|
||||
|
||||
@@ -0,0 +1,394 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../backend/graph_backend.dart';
|
||||
import '../state/app_state.dart';
|
||||
import '../theme/theme.dart';
|
||||
import '../widgets/common.dart';
|
||||
import '../widgets/emoji_picker.dart';
|
||||
import '../widgets/pickers.dart';
|
||||
|
||||
/// Manages the vocabulary. Types: emoji (shown before the names of their pages), name and
|
||||
/// page count; create, rename, delete. Tags: name, page count and where they come from
|
||||
/// (listed on pages, a type, a hub); explicit ones can be renamed or removed. Tapping a name
|
||||
/// opens its tag view.
|
||||
class TagsTypesView extends StatefulWidget {
|
||||
const TagsTypesView({super.key});
|
||||
|
||||
@override
|
||||
State<TagsTypesView> createState() => _TagsTypesViewState();
|
||||
}
|
||||
|
||||
class _TagsTypesViewState extends State<TagsTypesView> {
|
||||
bool _tags = false;
|
||||
late Future<(List<TagDto>, List<TagDto>)> _data = _load();
|
||||
|
||||
Future<(List<TagDto>, List<TagDto>)> _load() async {
|
||||
final backend = AppScope.read(context).backend;
|
||||
return (await backend.typeCatalog(), await backend.tagCatalog());
|
||||
}
|
||||
|
||||
void _reload() {
|
||||
AppScope.read(context).loadTypeIcons().ignore();
|
||||
setState(() {
|
||||
_data = _load();
|
||||
});
|
||||
}
|
||||
|
||||
/// Runs a write through the queue (errors become a snack bar), then reloads the lists.
|
||||
Future<void> _run(Future<void> Function(GraphBackend b) op) async {
|
||||
final app = AppScope.read(context);
|
||||
final messenger = ScaffoldMessenger.of(context);
|
||||
try {
|
||||
await app.queue.run(() => op(app.backend), report: false);
|
||||
} catch (e) {
|
||||
messenger.showSnackBar(SnackBar(content: Text(errorText(e))));
|
||||
} finally {
|
||||
if (mounted) _reload();
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> _newType() async {
|
||||
final app = AppScope.read(context);
|
||||
await showNameDialog<String>(
|
||||
context,
|
||||
heading: 'New type',
|
||||
confirm: 'Create',
|
||||
hint: 'Type name',
|
||||
submit: (name) =>
|
||||
app.queue.run(() => app.backend.createType(name), report: false),
|
||||
);
|
||||
if (mounted) _reload();
|
||||
}
|
||||
|
||||
Future<void> _pickIcon(TagDto t) async {
|
||||
final picked = await showEmojiPicker(
|
||||
context,
|
||||
title: 'Emoji for ${t.name}',
|
||||
current: t.icon,
|
||||
);
|
||||
if (picked == null || picked.emoji == t.icon) return;
|
||||
await _run((b) => b.setTypeIcon(t.name, picked.emoji));
|
||||
}
|
||||
|
||||
Future<void> _renameType(TagDto t) async {
|
||||
final app = AppScope.read(context);
|
||||
await showNameDialog<int>(
|
||||
context,
|
||||
heading: 'Rename type',
|
||||
confirm: 'Rename',
|
||||
hint: 'Type name',
|
||||
initial: t.name,
|
||||
submit: (name) => app.queue.run(
|
||||
() => app.backend.renameType(t.name, name),
|
||||
report: false,
|
||||
),
|
||||
);
|
||||
if (mounted) _reload();
|
||||
}
|
||||
|
||||
Future<void> _deleteType(TagDto t) async {
|
||||
final ok = await _confirm(
|
||||
title: 'Delete type “${t.name}”?',
|
||||
body: t.count == 0
|
||||
? 'No page has this type. Its emoji is removed too.'
|
||||
: '${_pages(t.count)} lose this type (their tags stay). '
|
||||
'Its emoji is removed too.',
|
||||
action: 'Delete',
|
||||
);
|
||||
if (ok) await _run((b) => b.removeType(t.name));
|
||||
}
|
||||
|
||||
Future<void> _renameTag(TagDto t) async {
|
||||
final app = AppScope.read(context);
|
||||
await showNameDialog<int>(
|
||||
context,
|
||||
heading: 'Rename tag',
|
||||
confirm: 'Rename',
|
||||
hint: 'Tag name',
|
||||
initial: t.name,
|
||||
submit: (name) => app.queue.run(
|
||||
() => app.backend.renameTag(t.name, name),
|
||||
report: false,
|
||||
),
|
||||
);
|
||||
if (mounted) _reload();
|
||||
}
|
||||
|
||||
Future<void> _deleteTag(TagDto t) async {
|
||||
final ok = await _confirm(
|
||||
title: 'Delete tag #${t.name}?',
|
||||
body:
|
||||
'It is removed from the ${_pages(t.explicit)} that list it.'
|
||||
'${t.typed > 0 ? ' Pages with the type “${t.name}” keep it.' : ''}'
|
||||
'${t.fromHub > 0 ? ' Members of the hub “${t.name}” keep it.' : ''}',
|
||||
action: 'Delete',
|
||||
);
|
||||
if (ok) await _run((b) => b.removeTag(t.name));
|
||||
}
|
||||
|
||||
Future<bool> _confirm({
|
||||
required String title,
|
||||
required String body,
|
||||
required String action,
|
||||
}) async =>
|
||||
await showDialog<bool>(
|
||||
context: context,
|
||||
builder: (ctx) => AlertDialog(
|
||||
title: Text(title),
|
||||
content: Text(body),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () => Navigator.pop(ctx, false),
|
||||
child: const Text('Cancel'),
|
||||
),
|
||||
TextButton(
|
||||
key: const ValueKey('tt-confirm'),
|
||||
onPressed: () => Navigator.pop(ctx, true),
|
||||
child: Text(action),
|
||||
),
|
||||
],
|
||||
),
|
||||
) ??
|
||||
false;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final colors = context.colors;
|
||||
return FutureBuilder<(List<TagDto>, List<TagDto>)>(
|
||||
future: _data,
|
||||
builder: (context, snap) {
|
||||
final data = snap.data;
|
||||
return LayoutBuilder(
|
||||
builder: (context, box) => ListView(
|
||||
padding: EdgeInsets.fromLTRB(
|
||||
sidePadding(box.maxWidth),
|
||||
36,
|
||||
sidePadding(box.maxWidth),
|
||||
80,
|
||||
),
|
||||
children: [
|
||||
Text(
|
||||
'Tags & types',
|
||||
style: Theme.of(context).textTheme.headlineLarge,
|
||||
),
|
||||
const SizedBox(height: 6),
|
||||
Text(
|
||||
'A type says what a page is (one per page) and shows its emoji '
|
||||
'before the page’s name. Tags file pages under topics.',
|
||||
style: TextStyle(fontSize: 12.5, color: colors.faint),
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
Row(
|
||||
children: [
|
||||
SegmentedButton<bool>(
|
||||
showSelectedIcon: false,
|
||||
segments: [
|
||||
ButtonSegment(
|
||||
value: false,
|
||||
label: Text(
|
||||
'Types',
|
||||
key: const ValueKey('tt-tab-types'),
|
||||
),
|
||||
),
|
||||
ButtonSegment(
|
||||
value: true,
|
||||
label: Text('Tags', key: const ValueKey('tt-tab-tags')),
|
||||
),
|
||||
],
|
||||
selected: {_tags},
|
||||
onSelectionChanged: (s) => setState(() => _tags = s.first),
|
||||
),
|
||||
const Spacer(),
|
||||
if (!_tags)
|
||||
TextButton.icon(
|
||||
key: const ValueKey('new-type'),
|
||||
onPressed: _newType,
|
||||
icon: const Icon(Icons.add_rounded, size: 18),
|
||||
label: const Text('New type'),
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
if (data == null)
|
||||
const SizedBox.shrink()
|
||||
else if (_tags)
|
||||
..._tagRows(data.$2)
|
||||
else
|
||||
..._typeRows(data.$1),
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
Iterable<Widget> _typeRows(List<TagDto> types) sync* {
|
||||
final colors = context.colors;
|
||||
final app = AppScope.read(context);
|
||||
if (types.isEmpty) {
|
||||
yield Text('No types yet.', style: TextStyle(color: colors.muted));
|
||||
}
|
||||
for (final t in types) {
|
||||
yield _Row(
|
||||
key: ValueKey('type-row-${t.name}'),
|
||||
leading: Tooltip(
|
||||
message: t.icon == null ? 'Choose an emoji' : 'Change the emoji',
|
||||
child: InkWell(
|
||||
key: ValueKey('type-icon-btn-${t.name}'),
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
onTap: () => _pickIcon(t),
|
||||
child: Container(
|
||||
width: 34,
|
||||
height: 34,
|
||||
alignment: Alignment.center,
|
||||
decoration: BoxDecoration(
|
||||
color: colors.surface,
|
||||
border: Border.all(color: colors.line),
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
child: t.icon == null
|
||||
? Icon(
|
||||
Icons.add_reaction_outlined,
|
||||
size: 17,
|
||||
color: colors.faint,
|
||||
)
|
||||
: Text(t.icon!, style: const TextStyle(fontSize: 18)),
|
||||
),
|
||||
),
|
||||
),
|
||||
name: t.name,
|
||||
detail: t.count == 0
|
||||
? (t.suggested ? 'suggested · no pages' : 'no pages')
|
||||
: _pages(t.count),
|
||||
onOpen: () => app.navigate(TagRoute(t.name)),
|
||||
menu: PopupMenuButton<String>(
|
||||
key: ValueKey('type-menu-${t.name}'),
|
||||
tooltip: 'Type actions',
|
||||
icon: Icon(Icons.more_horiz_rounded, color: colors.muted, size: 20),
|
||||
onSelected: (v) => switch (v) {
|
||||
'icon' => _pickIcon(t),
|
||||
'rename' => _renameType(t),
|
||||
_ => _deleteType(t),
|
||||
},
|
||||
itemBuilder: (_) => const [
|
||||
PopupMenuItem(value: 'icon', child: Text('Emoji…')),
|
||||
PopupMenuItem(value: 'rename', child: Text('Rename…')),
|
||||
PopupMenuItem(value: 'delete', child: Text('Delete…')),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Iterable<Widget> _tagRows(List<TagDto> tags) sync* {
|
||||
final colors = context.colors;
|
||||
final app = AppScope.read(context);
|
||||
if (tags.isEmpty) {
|
||||
yield Text('No tags yet.', style: TextStyle(color: colors.muted));
|
||||
}
|
||||
for (final t in tags) {
|
||||
final sources = [
|
||||
if (t.explicit > 0) 'listed on ${t.explicit}',
|
||||
if (t.typed > 0) 'type',
|
||||
if (t.fromHub > 0) 'hub',
|
||||
];
|
||||
final String? locked = t.explicit > 0
|
||||
? null
|
||||
: t.fromHub > 0
|
||||
? 'Comes from the hub “${t.name}”: rename or delete the hub instead.'
|
||||
: 'Comes from the type “${t.name}”: manage it under Types.';
|
||||
yield _Row(
|
||||
key: ValueKey('tag-row-${t.name}'),
|
||||
leading: Icon(Icons.sell_outlined, size: 17, color: colors.faint),
|
||||
name: '#${t.name}',
|
||||
detail: '${_pages(t.count)} · ${sources.join(', ')}',
|
||||
onOpen: () => app.navigate(TagRoute(t.name)),
|
||||
menu: locked != null
|
||||
? Tooltip(
|
||||
key: ValueKey('tag-locked-${t.name}'),
|
||||
message: locked,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(12),
|
||||
child: Icon(
|
||||
Icons.lock_outline_rounded,
|
||||
size: 17,
|
||||
color: colors.faint,
|
||||
),
|
||||
),
|
||||
)
|
||||
: PopupMenuButton<String>(
|
||||
key: ValueKey('tag-menu-${t.name}'),
|
||||
tooltip: 'Tag actions',
|
||||
icon: Icon(
|
||||
Icons.more_horiz_rounded,
|
||||
color: colors.muted,
|
||||
size: 20,
|
||||
),
|
||||
onSelected: (v) =>
|
||||
v == 'rename' ? _renameTag(t) : _deleteTag(t),
|
||||
itemBuilder: (_) => const [
|
||||
PopupMenuItem(value: 'rename', child: Text('Rename…')),
|
||||
PopupMenuItem(value: 'delete', child: Text('Delete…')),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
String _pages(int n) => '$n ${n == 1 ? 'page' : 'pages'}';
|
||||
|
||||
class _Row extends StatelessWidget {
|
||||
const _Row({
|
||||
super.key,
|
||||
required this.leading,
|
||||
required this.name,
|
||||
required this.detail,
|
||||
required this.onOpen,
|
||||
required this.menu,
|
||||
});
|
||||
final Widget leading;
|
||||
final String name;
|
||||
final String detail;
|
||||
final VoidCallback onOpen;
|
||||
final Widget menu;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final colors = context.colors;
|
||||
return Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 3),
|
||||
child: Row(
|
||||
children: [
|
||||
leading,
|
||||
const SizedBox(width: 12),
|
||||
Expanded(
|
||||
child: InkWell(
|
||||
borderRadius: BorderRadius.circular(6),
|
||||
onTap: onOpen,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 6),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
name,
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: TextStyle(fontSize: 14.5, color: colors.ink),
|
||||
),
|
||||
Text(
|
||||
detail,
|
||||
style: TextStyle(fontSize: 12, color: colors.faint),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
menu,
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,327 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../theme/theme.dart';
|
||||
|
||||
/// Curated emoji, grouped (no emoji package: a short list covers the usual types, and any
|
||||
/// other emoji can be pasted).
|
||||
const emojiGroups = <(String, List<String>)>[
|
||||
(
|
||||
'People',
|
||||
[
|
||||
'🧑',
|
||||
'👤',
|
||||
'👥',
|
||||
'👩',
|
||||
'👨',
|
||||
'🧒',
|
||||
'👪',
|
||||
'🧑💼',
|
||||
'🧑🔬',
|
||||
'🧑🎨',
|
||||
'🧑🏫',
|
||||
'🧑💻',
|
||||
'🧑⚕️',
|
||||
'🤝',
|
||||
'💬',
|
||||
'🫂',
|
||||
],
|
||||
),
|
||||
(
|
||||
'Places',
|
||||
[
|
||||
'📍',
|
||||
'🏠',
|
||||
'🏢',
|
||||
'🏛️',
|
||||
'🏙️',
|
||||
'🏞️',
|
||||
'🗺️',
|
||||
'🌍',
|
||||
'✈️',
|
||||
'🏫',
|
||||
'🏥',
|
||||
'🏪',
|
||||
'⛪',
|
||||
'🏰',
|
||||
'🏖️',
|
||||
'⛰️',
|
||||
],
|
||||
),
|
||||
(
|
||||
'Things',
|
||||
[
|
||||
'📕',
|
||||
'📚',
|
||||
'📄',
|
||||
'📝',
|
||||
'📎',
|
||||
'💻',
|
||||
'📱',
|
||||
'🖥️',
|
||||
'⚙️',
|
||||
'🔧',
|
||||
'🧰',
|
||||
'💡',
|
||||
'🔑',
|
||||
'📦',
|
||||
'🎁',
|
||||
'🗂️',
|
||||
],
|
||||
),
|
||||
(
|
||||
'Ideas',
|
||||
[
|
||||
'💭',
|
||||
'🧠',
|
||||
'💡',
|
||||
'❓',
|
||||
'❗',
|
||||
'🎯',
|
||||
'🧩',
|
||||
'🔬',
|
||||
'🧪',
|
||||
'📐',
|
||||
'📊',
|
||||
'📈',
|
||||
'🔍',
|
||||
'✨',
|
||||
'🌀',
|
||||
'♾️',
|
||||
],
|
||||
),
|
||||
(
|
||||
'Nature',
|
||||
[
|
||||
'🌱',
|
||||
'🌿',
|
||||
'🌳',
|
||||
'🌸',
|
||||
'🍄',
|
||||
'🌊',
|
||||
'🔥',
|
||||
'⭐',
|
||||
'🌙',
|
||||
'☀️',
|
||||
'⚡',
|
||||
'❄️',
|
||||
'🐱',
|
||||
'🐶',
|
||||
'🐦',
|
||||
'🦋',
|
||||
],
|
||||
),
|
||||
(
|
||||
'Food',
|
||||
[
|
||||
'🍳',
|
||||
'🥗',
|
||||
'🍝',
|
||||
'🍕',
|
||||
'🍰',
|
||||
'🍎',
|
||||
'🥖',
|
||||
'🧀',
|
||||
'☕',
|
||||
'🍵',
|
||||
'🍷',
|
||||
'🍺',
|
||||
'🥘',
|
||||
'🌮',
|
||||
'🍣',
|
||||
'🥕',
|
||||
],
|
||||
),
|
||||
(
|
||||
'Activities',
|
||||
[
|
||||
'📅',
|
||||
'🎉',
|
||||
'🎵',
|
||||
'🎬',
|
||||
'🎮',
|
||||
'🎨',
|
||||
'📷',
|
||||
'⚽',
|
||||
'🏃',
|
||||
'🧘',
|
||||
'✍️',
|
||||
'🎤',
|
||||
'🎓',
|
||||
'💼',
|
||||
'🛠️',
|
||||
'🧳',
|
||||
],
|
||||
),
|
||||
(
|
||||
'Symbols',
|
||||
[
|
||||
'❤️',
|
||||
'⭐',
|
||||
'✅',
|
||||
'⚠️',
|
||||
'🔖',
|
||||
'🏷️',
|
||||
'📌',
|
||||
'🔗',
|
||||
'💰',
|
||||
'⏳',
|
||||
'🔒',
|
||||
'🚩',
|
||||
'🔴',
|
||||
'🟢',
|
||||
'🔵',
|
||||
'🟣',
|
||||
],
|
||||
),
|
||||
];
|
||||
|
||||
/// True when [s] (trimmed) is one emoji: a single user-perceived character that is not plain
|
||||
/// ASCII (so letters, digits and punctuation are refused).
|
||||
bool isSingleEmoji(String s) {
|
||||
final t = s.trim();
|
||||
return t.isNotEmpty &&
|
||||
t.characters.length == 1 &&
|
||||
t.runes.any((r) => r > 0x7f) &&
|
||||
!t.contains(RegExp(r'\s'));
|
||||
}
|
||||
|
||||
/// What the picker returned: an emoji, or `null` to clear the icon.
|
||||
class EmojiChoice {
|
||||
const EmojiChoice(this.emoji);
|
||||
final String? emoji;
|
||||
}
|
||||
|
||||
/// Lets the user pick an emoji from [emojiGroups], paste any other one, or clear it.
|
||||
/// Returns `null` when cancelled.
|
||||
Future<EmojiChoice?> showEmojiPicker(
|
||||
BuildContext context, {
|
||||
required String title,
|
||||
String? current,
|
||||
}) => showDialog<EmojiChoice>(
|
||||
context: context,
|
||||
builder: (_) => _EmojiPicker(title: title, current: current),
|
||||
);
|
||||
|
||||
class _EmojiPicker extends StatefulWidget {
|
||||
const _EmojiPicker({required this.title, this.current});
|
||||
final String title;
|
||||
final String? current;
|
||||
|
||||
@override
|
||||
State<_EmojiPicker> createState() => _EmojiPickerState();
|
||||
}
|
||||
|
||||
class _EmojiPickerState extends State<_EmojiPicker> {
|
||||
final _text = TextEditingController();
|
||||
String? _error;
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_text.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
void _usePasted() {
|
||||
final t = _text.text.trim();
|
||||
if (t.isEmpty) return;
|
||||
if (!isSingleEmoji(t)) {
|
||||
setState(() => _error = 'Enter a single emoji');
|
||||
return;
|
||||
}
|
||||
Navigator.pop(context, EmojiChoice(t));
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final colors = context.colors;
|
||||
return AlertDialog(
|
||||
title: Text(widget.title),
|
||||
content: SizedBox(
|
||||
width: 420,
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
TextField(
|
||||
key: const ValueKey('emoji-input'),
|
||||
controller: _text,
|
||||
decoration: InputDecoration(
|
||||
hintText: 'Paste any emoji',
|
||||
errorText: _error,
|
||||
suffixIcon: IconButton(
|
||||
key: const ValueKey('emoji-use'),
|
||||
tooltip: 'Use this emoji',
|
||||
icon: const Icon(Icons.check_rounded),
|
||||
onPressed: _usePasted,
|
||||
),
|
||||
),
|
||||
onChanged: (_) {
|
||||
if (_error != null) setState(() => _error = null);
|
||||
},
|
||||
onSubmitted: (_) => _usePasted(),
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
Flexible(
|
||||
child: SingleChildScrollView(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
for (final (group, list) in emojiGroups) ...[
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(top: 8, bottom: 4),
|
||||
child: Text(
|
||||
group.toUpperCase(),
|
||||
style: Theme.of(context).textTheme.labelSmall,
|
||||
),
|
||||
),
|
||||
Wrap(
|
||||
spacing: 2,
|
||||
runSpacing: 2,
|
||||
children: [
|
||||
for (final e in list)
|
||||
InkWell(
|
||||
key: ValueKey('emoji-$group-$e'),
|
||||
borderRadius: BorderRadius.circular(6),
|
||||
onTap: () =>
|
||||
Navigator.pop(context, EmojiChoice(e)),
|
||||
child: Container(
|
||||
width: 38,
|
||||
height: 38,
|
||||
alignment: Alignment.center,
|
||||
decoration: BoxDecoration(
|
||||
color: e == widget.current
|
||||
? colors.accentSoft
|
||||
: null,
|
||||
borderRadius: BorderRadius.circular(6),
|
||||
),
|
||||
child: Text(
|
||||
e,
|
||||
style: const TextStyle(fontSize: 20),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
actions: [
|
||||
if (widget.current != null)
|
||||
TextButton(
|
||||
key: const ValueKey('emoji-clear'),
|
||||
onPressed: () => Navigator.pop(context, const EmojiChoice(null)),
|
||||
child: const Text('Remove emoji'),
|
||||
),
|
||||
TextButton(
|
||||
onPressed: () => Navigator.pop(context),
|
||||
child: const Text('Cancel'),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -161,6 +161,7 @@ Future<T?> showNameDialog<T>(
|
||||
required String confirm,
|
||||
required Future<T> Function(String name) submit,
|
||||
String hint = 'Title',
|
||||
String initial = '',
|
||||
}) => showDialog<T>(
|
||||
context: context,
|
||||
builder: (_) => _NameDialog<T>(
|
||||
@@ -168,6 +169,7 @@ Future<T?> showNameDialog<T>(
|
||||
confirm: confirm,
|
||||
submit: submit,
|
||||
hint: hint,
|
||||
initial: initial,
|
||||
),
|
||||
);
|
||||
|
||||
@@ -177,8 +179,10 @@ class _NameDialog<T> extends StatefulWidget {
|
||||
required this.confirm,
|
||||
required this.submit,
|
||||
required this.hint,
|
||||
this.initial = '',
|
||||
});
|
||||
final String heading;
|
||||
final String initial;
|
||||
final String confirm;
|
||||
final String hint;
|
||||
final Future<T> Function(String) submit;
|
||||
@@ -188,7 +192,7 @@ class _NameDialog<T> extends StatefulWidget {
|
||||
}
|
||||
|
||||
class _NameDialogState<T> extends State<_NameDialog<T>> {
|
||||
final _text = TextEditingController();
|
||||
late final _text = TextEditingController(text: widget.initial);
|
||||
String? _error;
|
||||
bool _busy = false;
|
||||
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../state/app_state.dart';
|
||||
|
||||
/// The emoji of a page's type, drawn just left of the page's name (titles, lists, tabs, the
|
||||
/// tree view; never in the network graph). Nothing when the type has no emoji. Icons come
|
||||
/// from [AppState.typeIcons], so lists only need the page's type.
|
||||
class TypeIcon extends StatelessWidget {
|
||||
const TypeIcon(this.pageType, {super.key, this.size = 13, this.gap = 5});
|
||||
|
||||
final String? pageType;
|
||||
final double size;
|
||||
|
||||
/// Space between the emoji and the name.
|
||||
final double gap;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final icon = AppScope.of(context).typeIcon(pageType);
|
||||
if (icon == null) return const SizedBox.shrink();
|
||||
return Padding(
|
||||
padding: EdgeInsets.only(right: gap),
|
||||
child: Text(
|
||||
icon,
|
||||
key: const ValueKey('type-icon'),
|
||||
style: TextStyle(fontSize: size, height: 1.15),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// [title] prefixed with [icon] (for places that only take a string: canvas labels).
|
||||
String withTypeIcon(String? icon, String title) =>
|
||||
icon == null ? title : '$icon $title';
|
||||
Reference in new issue
Block a user