feat: enhance inventory management with category and location filters
Test Suite / test (24.15.0) (push) Has been cancelled
Test Suite / test (24.15.0) (push) Has been cancelled
This commit is contained in:
@@ -17,6 +17,7 @@ class InventoryScreen extends ConsumerWidget {
|
||||
(value: 'nameAsc', label: context.l10n.inventorySortNameAsc),
|
||||
(value: 'bestBeforeAsc', label: context.l10n.inventorySortBestBeforeAsc),
|
||||
(value: 'bestBeforeDesc', label: context.l10n.inventorySortBestBeforeDesc),
|
||||
(value: 'l1CategoryAsc', label: 'L1-kategori (A-O)'),
|
||||
];
|
||||
|
||||
@override
|
||||
@@ -32,6 +33,17 @@ class InventoryScreen extends ConsumerWidget {
|
||||
onRetry: () => ref.invalidate(inventoryProvider),
|
||||
),
|
||||
data: (items) {
|
||||
final visibleItems = [...items];
|
||||
if (sort == 'l1CategoryAsc') {
|
||||
visibleItems.sort((a, b) {
|
||||
final byCategory = a.l1Category.toLowerCase().compareTo(
|
||||
b.l1Category.toLowerCase(),
|
||||
);
|
||||
if (byCategory != 0) return byCategory;
|
||||
return a.displayName.toLowerCase().compareTo(b.displayName.toLowerCase());
|
||||
});
|
||||
}
|
||||
|
||||
final filterSection = Padding(
|
||||
padding: const EdgeInsets.fromLTRB(12, 12, 12, 4),
|
||||
child: Column(
|
||||
@@ -83,7 +95,7 @@ class InventoryScreen extends ConsumerWidget {
|
||||
),
|
||||
);
|
||||
|
||||
if (items.isEmpty) {
|
||||
if (visibleItems.isEmpty) {
|
||||
return Stack(
|
||||
children: [
|
||||
ListView(
|
||||
@@ -109,11 +121,11 @@ class InventoryScreen extends ConsumerWidget {
|
||||
children: [
|
||||
ListView.separated(
|
||||
padding: const EdgeInsets.only(bottom: 88),
|
||||
itemCount: items.length + 1,
|
||||
itemCount: visibleItems.length + 1,
|
||||
separatorBuilder: (_, __) => const Divider(height: 1),
|
||||
itemBuilder: (context, index) {
|
||||
if (index == 0) return filterSection;
|
||||
final item = items[index - 1];
|
||||
final item = visibleItems[index - 1];
|
||||
return SwipeableInventoryTile(item: item);
|
||||
},
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user