feat: add gallery feature with database integration and rendering capabilities
Build Android App / build (push) Failing after 2m19s

This commit is contained in:
ImBenji
2026-08-25 11:46:33 +01:00
parent b66b73a3c6
commit 8c2212b563
17 changed files with 2902 additions and 885 deletions
+39
View File
@@ -0,0 +1,39 @@
import "package:hive_flutter/hive_flutter.dart";
import "package:quotegen_client/models/gallery_item.dart";
class GalleryDB {
static const String _boxName = "gallery";
static LazyBox<String> get _box => Hive.lazyBox<String>(_boxName);
static Future<void> saveItem(GalleryItem item) async {
await _box.put(item.id, item.toJsonString());
}
static Future<void> deleteItem(String id) async {
await _box.delete(id);
}
static Future<List<GalleryItem>> getAllItems() async {
final keys = _box.keys.toList();
final items = <GalleryItem>[];
for (final key in keys) {
final raw = await _box.get(key);
if (raw != null) {
try {
items.add(GalleryItem.fromJsonString(raw));
} catch (e) {
// skip corrupted entries
print("GalleryDB: failed to parse item $key: $e");
}
}
}
items.sort((a, b) => b.createdAt.compareTo(a.createdAt));
return items;
}
}