Add household sharing feature

 Features:
- Create household with 6-character shareable code
- Join existing household with code
- View household members and owner
- Leave household functionality
- Automatic inventory filtering by household
- Persistent household settings across app updates

🔧 Technical changes:
- Added Household model with Hive adapter (typeId: 4)
- Updated AppSettings with userName and currentHouseholdId fields
- Modified InventoryRepository to filter items by household
- Updated Add Item screen to set householdId on new items
- Added HouseholdScreen with full CRUD operations
- Integrated household sharing into Settings navigation

🎯 Behavior:
- Users not in a household see only their personal items
- Users in a household see shared household items
- New items automatically tagged with current household

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2025-10-04 14:46:10 -04:00
parent f4be460c3e
commit a360fadc17
9 changed files with 707 additions and 12 deletions

View File

@@ -2,6 +2,7 @@ import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:intl/intl.dart';
import '../../../core/constants/colors.dart';
import '../../../data/local/hive_database.dart';
import '../models/food_item.dart';
import '../controllers/inventory_controller.dart';
import '../services/barcode_service.dart';
@@ -118,6 +119,9 @@ class _AddItemScreenState extends ConsumerState<AddItemScreen> {
Future<void> _saveItem() async {
if (_formKey.currentState!.validate()) {
// Get current household ID from settings
final settings = await HiveDatabase.getSettings();
final item = FoodItem()
..name = _nameController.text.trim()
..barcode = _barcode
@@ -132,6 +136,7 @@ class _AddItemScreenState extends ConsumerState<AddItemScreen> {
..notes = _notesController.text.trim().isEmpty
? null
: _notesController.text.trim()
..householdId = settings.currentHouseholdId
..lastModified = DateTime.now();
try {