Implement local vault service with encryption key management and integrate it into the app. Add settings screen for data management and enhance home screen with new features. Update database connection for encryption support and modify repository to use the new database structure. Improve UI elements across the application for better user experience.

This commit is contained in:
2026-05-13 22:57:23 +02:00
parent 96f8f95924
commit 94fdfe51eb
16 changed files with 875 additions and 87 deletions
+13 -3
View File
@@ -19,7 +19,7 @@ class Notes extends Table {
@DriftDatabase(tables: [Notes])
class AppDatabase extends _$AppDatabase {
AppDatabase() : super(_openConnection());
AppDatabase({required String encryptionKey}) : super(_openConnection(encryptionKey));
@override
int get schemaVersion => 1;
@@ -94,11 +94,21 @@ class AppDatabase extends _$AppDatabase {
}
}
LazyDatabase _openConnection() {
LazyDatabase _openConnection(String encryptionKey) {
return LazyDatabase(() async {
final Directory supportDir = await getApplicationSupportDirectory();
final File file = File(p.join(supportDir.path, 'notes.sqlite'));
return NativeDatabase(file);
return NativeDatabase(
file,
setup: (database) {
final String escapedKey = encryptionKey.replaceAll("'", "''");
// sqlite3mc can emulate SQLCipher file format for compatibility.
database.execute("PRAGMA cipher = 'sqlcipher'");
database.execute('PRAGMA legacy = 4');
database.execute("PRAGMA key = '$escapedKey'");
},
);
});
}