feat(inventory): implement swipeable inventory tile and product picker field
This commit is contained in:
@@ -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),
|
||||
|
||||
Reference in New Issue
Block a user