efe602a5da
- 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.
46 lines
998 B
Dart
46 lines
998 B
Dart
import 'package:uuid/uuid.dart';
|
|
|
|
class Category {
|
|
Category({
|
|
String? uuid,
|
|
required this.encryptedName,
|
|
this.serverVersion = 0,
|
|
this.isDeleted = false,
|
|
required this.updatedAt,
|
|
}) : uuid = uuid ?? Uuid().v4();
|
|
|
|
final String uuid;
|
|
final String encryptedName;
|
|
final int serverVersion;
|
|
final bool isDeleted;
|
|
final DateTime updatedAt;
|
|
|
|
Category copyWith({
|
|
String? uuid,
|
|
String? encryptedName,
|
|
int? serverVersion,
|
|
bool? isDeleted,
|
|
DateTime? updatedAt,
|
|
}) {
|
|
return Category(
|
|
uuid: uuid ?? this.uuid,
|
|
encryptedName: encryptedName ?? this.encryptedName,
|
|
serverVersion: serverVersion ?? this.serverVersion,
|
|
isDeleted: isDeleted ?? this.isDeleted,
|
|
updatedAt: updatedAt ?? this.updatedAt,
|
|
);
|
|
}
|
|
|
|
@override
|
|
bool operator ==(Object other) {
|
|
if (identical(this, other)) {
|
|
return true;
|
|
}
|
|
|
|
return other is Category && uuid == other.uuid;
|
|
}
|
|
|
|
@override
|
|
int get hashCode => uuid.hashCode;
|
|
}
|