47387bb395
including the ability to add item into the shopping cart and remove them. The click events have been implemented, however the routes do not exist yet. NOTE: The shopping list item info sheet is still missing the unit type and value and some more advanced options, like deleting the item
51 lines
1.3 KiB
Dart
51 lines
1.3 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:outbag_app/backend/room.dart';
|
|
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
|
|
|
|
class ProductPicker extends StatelessWidget {
|
|
List<RoomProduct> products = [];
|
|
int? selected;
|
|
bool enabled = true;
|
|
Function(int?)? onSelect;
|
|
|
|
// hint and label may differ depending on the screen
|
|
String? hint;
|
|
String? label;
|
|
|
|
ProductPicker(
|
|
{required this.products,
|
|
this.selected,
|
|
this.onSelect,
|
|
this.hint,
|
|
this.label,
|
|
this.enabled = true});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Padding(
|
|
padding: const EdgeInsets.all(8),
|
|
child: DropdownMenu<int?>(
|
|
initialSelection: selected,
|
|
label: (label!=null)?Text(label!):null,
|
|
hintText: hint,
|
|
enabled: enabled,
|
|
onSelected: ((id) {
|
|
if (onSelect != null) {
|
|
onSelect!(id);
|
|
}
|
|
}),
|
|
dropdownMenuEntries: [
|
|
// entry for no product
|
|
DropdownMenuEntry(
|
|
value: null,
|
|
label: AppLocalizations.of(context)!.productNameNone,
|
|
),
|
|
// entry for every product
|
|
...products.map((product) => DropdownMenuEntry(
|
|
value: product.id,
|
|
label: product.name,
|
|
)),
|
|
],
|
|
));
|
|
}
|
|
}
|