feat: Implement note encryption and synchronization features

- Added NoteEncryption class for encrypting and decrypting note content using AES-GCM.
- Updated NoteRepository to handle synchronization of notes and categories with the server, including encryption of note data before sending.
- Introduced SyncRequest and SyncResponse models for managing synchronization data.
- Enhanced LocalVaultService to store and retrieve the encryption key.
- Modified HomeScreen and SettingsScreen to trigger synchronization after note operations and manage API endpoint settings.
- Added SyncStatusIndicator to provide visual feedback on synchronization status in the app title bar.
- Created Category model to manage note categories with encryption support.
- Updated note model to include UUID, server version, deletion status, and category ID.
- Added necessary UI elements for displaying and managing the encryption key in SettingsScreen.
- Updated dependencies in pubspec.yaml for cryptography and HTTP handling.
This commit is contained in:
2026-05-18 16:11:19 +02:00
parent 516b3b9aa3
commit efe602a5da
18 changed files with 2531 additions and 71 deletions
+29 -4
View File
@@ -75,6 +75,12 @@ class _HomeScreenState extends State<HomeScreen> {
setState(() {
_notes = updatedNotes;
});
// Trigger sync after creating a note and refresh local list
try {
await widget.repository.performSync();
await _loadNotes();
} catch (_) {}
}
}
@@ -92,6 +98,12 @@ class _HomeScreenState extends State<HomeScreen> {
setState(() {
_notes = updatedNotes;
});
// Trigger sync after deleting a note and refresh local list
try {
await widget.repository.performSync();
await _loadNotes();
} catch (_) {}
}
Future<void> _reorderNote(int oldIndex, int newIndex) async {
@@ -140,6 +152,11 @@ class _HomeScreenState extends State<HomeScreen> {
setState(() {
_notes = _normalizeNotes(updatedNotes);
});
// Trigger sync after editing a note and refresh local list
try {
await widget.repository.performSync();
await _loadNotes();
} catch (_) {}
}
}
}
@@ -172,9 +189,16 @@ class _HomeScreenState extends State<HomeScreen> {
? const Center(child: CircularProgressIndicator())
: _notes.isEmpty
? const _EmptyState()
: MouseRegion(
cursor: _isDragging ? SystemMouseCursors.grabbing : SystemMouseCursors.basic,
child: MasonryGridView.count(
: RefreshIndicator(
onRefresh: () async {
try {
await widget.repository.performSync();
} catch (_) {}
await _loadNotes();
},
child: MouseRegion(
cursor: _isDragging ? SystemMouseCursors.grabbing : SystemMouseCursors.basic,
child: MasonryGridView.count(
crossAxisCount: crossAxisCount,
mainAxisSpacing: 10,
crossAxisSpacing: 10,
@@ -296,7 +320,8 @@ class _HomeScreenState extends State<HomeScreen> {
);
},
),
);
),
);
return Scaffold(
body: Container(