Initial commit: Sage Kitchen Management App v1.0.0
✨ Features implemented: - Smart inventory tracking with Hive database - Barcode scanning with auto-populated product info - Multiple API fallbacks (Open Food Facts, UPCItemDB) - Smart expiration date predictions by category - Discord webhook notifications (persisted) - Custom sage leaf vector icon - Material Design 3 UI with sage green theme - Privacy Policy & Terms of Service - Local-first, privacy-focused architecture 🎨 UI/UX: - Home dashboard with inventory stats - Add Item screen with barcode integration - Inventory list with expiration indicators - Settings with persistent preferences - About section with legal docs 🔧 Technical: - Flutter 3.35.5 with Riverpod state management - Hive 2.2.3 for local database - Mobile scanner for barcode detection - Feature-first architecture 🤖 Generated with Claude Code (https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
61
lib/data/local/hive_database.dart
Normal file
61
lib/data/local/hive_database.dart
Normal file
@@ -0,0 +1,61 @@
|
||||
import 'package:hive_flutter/hive_flutter.dart';
|
||||
import '../../features/inventory/models/food_item.dart';
|
||||
import '../../features/settings/models/app_settings.dart';
|
||||
|
||||
/// Singleton class to manage Hive database
|
||||
class HiveDatabase {
|
||||
static bool _initialized = false;
|
||||
|
||||
/// Initialize Hive
|
||||
static Future<void> init() async {
|
||||
if (_initialized) return;
|
||||
|
||||
await Hive.initFlutter();
|
||||
|
||||
// Register adapters
|
||||
Hive.registerAdapter(FoodItemAdapter());
|
||||
Hive.registerAdapter(LocationAdapter());
|
||||
Hive.registerAdapter(ExpirationStatusAdapter());
|
||||
Hive.registerAdapter(AppSettingsAdapter());
|
||||
|
||||
_initialized = true;
|
||||
}
|
||||
|
||||
/// Get the food items box
|
||||
static Future<Box<FoodItem>> getFoodBox() async {
|
||||
if (!Hive.isBoxOpen('foodItems')) {
|
||||
return await Hive.openBox<FoodItem>('foodItems');
|
||||
}
|
||||
return Hive.box<FoodItem>('foodItems');
|
||||
}
|
||||
|
||||
/// Get the settings box
|
||||
static Future<Box<AppSettings>> getSettingsBox() async {
|
||||
if (!Hive.isBoxOpen('appSettings')) {
|
||||
return await Hive.openBox<AppSettings>('appSettings');
|
||||
}
|
||||
return Hive.box<AppSettings>('appSettings');
|
||||
}
|
||||
|
||||
/// Get or create app settings
|
||||
static Future<AppSettings> getSettings() async {
|
||||
final box = await getSettingsBox();
|
||||
if (box.isEmpty) {
|
||||
final settings = AppSettings();
|
||||
await box.add(settings);
|
||||
return settings;
|
||||
}
|
||||
return box.getAt(0)!;
|
||||
}
|
||||
|
||||
/// Clear all data
|
||||
static Future<void> clearAll() async {
|
||||
final box = await getFoodBox();
|
||||
await box.clear();
|
||||
}
|
||||
|
||||
/// Close all boxes
|
||||
static Future<void> closeAll() async {
|
||||
await Hive.close();
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user