feat(inventory): implement swipeable inventory tile and product picker field

This commit is contained in:
Nils-Johan Gynther
2026-04-22 21:19:36 +02:00
parent b04a82aaf8
commit 14d782aeec
6 changed files with 632 additions and 170 deletions
@@ -3,6 +3,7 @@ import 'package:flutter_riverpod/flutter_riverpod.dart';
import '../../../core/api/api_error_mapper.dart';
import '../../../core/forms/form_options.dart';
import '../../../core/ui/product_picker_field.dart';
import '../../../features/inventory/data/inventory_providers.dart';
import '../../auth/data/auth_providers.dart';
import '../../../core/ui/async_state_views.dart';
@@ -264,6 +265,9 @@ class _PantryScreenState extends ConsumerState<PantryScreen> {
(a, b) =>
a.displayName.toLowerCase().compareTo(b.displayName.toLowerCase()),
);
final availableOptions = availableProducts
.map((p) => (id: p.id, name: p.displayName))
.toList();
final grouped = <String, List<PantryItem>>{};
for (final item in pantryItems) {
@@ -289,27 +293,12 @@ class _PantryScreenState extends ConsumerState<PantryScreen> {
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Expanded(
child: DropdownButtonFormField<int>(
child: ProductPickerField(
products: availableOptions,
value: _selectedProductId,
isExpanded: true,
decoration: const InputDecoration(
labelText: 'Produkt',
border: OutlineInputBorder(),
),
items: availableProducts
.map(
(product) => DropdownMenuItem<int>(
value: product.id,
child: Text(
product.displayName,
overflow: TextOverflow.ellipsis,
),
),
)
.toList(),
onChanged: _isSubmitting
? null
: (value) => setState(() => _selectedProductId = value),
enabled: !_isSubmitting && availableProducts.isNotEmpty,
label: 'Produkt',
onChanged: (value) => setState(() => _selectedProductId = value),
),
),
const SizedBox(width: 8),