mirror of
https://github.com/Dasemu/Synapse.git
synced 2026-11-26 23:36:20 +00:00
feat(app): hubs, types and tags UI, themes, key bindings and slash commands
Settings screen (themes incl. Sweet, rebindable shortcuts), rich text escapes, page sidebar with the local graph, sortable All pages, tree view changes and the Type/Tags rows in the page header. Docs updated. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
e18fd2c27e
commit
88ef4a97a5
32 files changed
+5431
-375
No files matched your search
@@ -0,0 +1,42 @@
|
||||
import 'dart:convert';
|
||||
import 'dart:io';
|
||||
|
||||
/// Where user preferences (theme, key bindings) are kept between runs.
|
||||
abstract class SettingsStore {
|
||||
Map<String, dynamic> load();
|
||||
void save(Map<String, dynamic> data);
|
||||
}
|
||||
|
||||
/// Keeps nothing (tests, previews).
|
||||
class MemorySettings implements SettingsStore {
|
||||
Map<String, dynamic> data = {};
|
||||
|
||||
@override
|
||||
Map<String, dynamic> load() => data;
|
||||
|
||||
@override
|
||||
void save(Map<String, dynamic> d) => data = d;
|
||||
}
|
||||
|
||||
/// A small JSON file; unreadable or corrupt files just mean defaults.
|
||||
class FileSettings implements SettingsStore {
|
||||
FileSettings(this.path);
|
||||
final String path;
|
||||
|
||||
@override
|
||||
Map<String, dynamic> load() {
|
||||
try {
|
||||
final v = jsonDecode(File(path).readAsStringSync());
|
||||
return v is Map<String, dynamic> ? v : {};
|
||||
} catch (_) {
|
||||
return {};
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
void save(Map<String, dynamic> data) {
|
||||
try {
|
||||
File(path).writeAsStringSync(jsonEncode(data));
|
||||
} catch (_) {}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user