initial vibecoded release

This commit is contained in:
cyberbread-ru
2026-05-15 16:35:12 +04:00
commit 993478e6e3
78 changed files with 3044 additions and 0 deletions
+53
View File
@@ -0,0 +1,53 @@
import 'package:uuid/uuid.dart';
import '../models/note.dart';
import '../repositories/local_note_repository.dart';
import 'sync_service.dart';
class NoteService {
final LocalNoteRepository _local;
final SyncService? _sync;
final _uuid = const Uuid();
NoteService({
required LocalNoteRepository local,
SyncService? sync,
}) : _local = local,
_sync = sync;
Future<List<Note>> getAllNotes() => _local.getAll();
Future<Note> createNote({String title = '', String content = ''}) async {
final note = Note(
id: _uuid.v4(),
title: title,
content: content,
createdAt: DateTime.now(),
updatedAt: DateTime.now(),
);
await _local.save(note);
return note;
}
Future<Note> updateNote(Note note) async {
final updated = note.copyWith(updatedAt: DateTime.now());
await _local.save(updated);
return updated;
}
Future<void> deleteNote(String id) async {
await _local.delete(id);
}
/// Manual backup — push everything to the server.
Future<void> triggerBackup() async {
if (_sync == null) throw Exception('Backup not configured');
await _sync!.pushAll();
}
/// Restore — pull everything from the server.
Future<void> triggerRestore() async {
if (_sync == null) throw Exception('Backup not configured');
await _sync!.pullAll();
}
}