Files
notas/lib/models/note.dart
T
Marcos efe602a5da 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.
2026-05-18 16:11:19 +02:00

72 lines
1.8 KiB
Dart

import 'package:uuid/uuid.dart';
// Model: Note
// - Representa una nota guardada en la app.
// - `id` es el identificador local de SQLite (autoincrement).
// - `uuid` es el identificador global sincronizado con el servidor.
// - `index` representa el orden visual dentro de la lista.
// - `serverVersion` se usa para resolver conflictos en sync.
// - `isDeleted` marca eliminaciones blandas.
class Note {
Note({
this.id,
String? uuid,
required this.title,
required this.body,
required this.createdAt,
required this.updatedAt,
required this.index,
this.serverVersion = 0,
this.isDeleted = false,
this.categoryId,
}) : uuid = uuid ?? Uuid().v4();
final int? id;
final String uuid;
final String title;
final String body;
final DateTime createdAt;
final DateTime updatedAt;
final int index;
final int serverVersion;
final bool isDeleted;
final String? categoryId;
Note copyWith({
int? id,
String? uuid,
String? title,
String? body,
DateTime? createdAt,
DateTime? updatedAt,
int? index,
int? serverVersion,
bool? isDeleted,
String? categoryId,
}) {
return Note(
id: id ?? this.id,
uuid: uuid ?? this.uuid,
title: title ?? this.title,
body: body ?? this.body,
createdAt: createdAt ?? this.createdAt,
updatedAt: updatedAt ?? this.updatedAt,
index: index ?? this.index,
serverVersion: serverVersion ?? this.serverVersion,
isDeleted: isDeleted ?? this.isDeleted,
categoryId: categoryId ?? this.categoryId,
);
}
@override
bool operator ==(Object other) {
if (identical(this, other)) {
return true;
}
return other is Note && uuid == other.uuid;
}
@override
int get hashCode => uuid.hashCode;
}