|
@@ -755,6 +755,7 @@ class _PedidoFormState extends State<PedidoForm> {
|
|
item.selectedToppings.forEach((categoryId, selectedToppingIds) {
|
|
item.selectedToppings.forEach((categoryId, selectedToppingIds) {
|
|
for (int toppingId in selectedToppingIds) {
|
|
for (int toppingId in selectedToppingIds) {
|
|
selectedToppings.add(PedidoProductoTopping(
|
|
selectedToppings.add(PedidoProductoTopping(
|
|
|
|
+ idCategoria: categoryId,
|
|
idTopping: toppingId,
|
|
idTopping: toppingId,
|
|
));
|
|
));
|
|
}
|
|
}
|
|
@@ -1103,99 +1104,87 @@ class _PedidoFormState extends State<PedidoForm> {
|
|
],
|
|
],
|
|
),
|
|
),
|
|
),
|
|
),
|
|
|
|
+ // ExpansionTile para todos los toppings
|
|
if (item.selectableToppings.isNotEmpty)
|
|
if (item.selectableToppings.isNotEmpty)
|
|
ExpansionTile(
|
|
ExpansionTile(
|
|
- title: Text('Toppings',
|
|
|
|
- style: const TextStyle(
|
|
|
|
- fontWeight: FontWeight.bold, fontSize: 16)),
|
|
|
|
|
|
+ title: const Text(
|
|
|
|
+ 'Toppings',
|
|
|
|
+ style: TextStyle(
|
|
|
|
+ fontWeight: FontWeight.bold, fontSize: 16),
|
|
|
|
+ ),
|
|
children: item.selectableToppings.entries.map((entry) {
|
|
children: item.selectableToppings.entries.map((entry) {
|
|
final categoryId = entry.key;
|
|
final categoryId = entry.key;
|
|
final availableToppings = entry.value;
|
|
final availableToppings = entry.value;
|
|
final categoria =
|
|
final categoria =
|
|
categorias.firstWhere((c) => c.id == categoryId);
|
|
categorias.firstWhere((c) => c.id == categoryId);
|
|
|
|
|
|
- return Column(
|
|
|
|
- crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
- children: [
|
|
|
|
- Padding(
|
|
|
|
- padding: const EdgeInsets.only(left: 16.0),
|
|
|
|
- child: Text(
|
|
|
|
- categoria.descripcion!,
|
|
|
|
- style: const TextStyle(
|
|
|
|
- fontWeight: FontWeight.bold,
|
|
|
|
- fontSize: 16),
|
|
|
|
- ),
|
|
|
|
- ),
|
|
|
|
- ...availableToppings.map((topping) {
|
|
|
|
- ValueNotifier<bool> isSelectedNotifier =
|
|
|
|
- ValueNotifier<bool>(
|
|
|
|
- item.selectedToppings[categoryId]
|
|
|
|
- ?.contains(topping.id) ??
|
|
|
|
- false,
|
|
|
|
- );
|
|
|
|
-
|
|
|
|
- return ValueListenableBuilder<bool>(
|
|
|
|
- valueListenable: isSelectedNotifier,
|
|
|
|
- builder: (context, isSelected, _) {
|
|
|
|
- return CheckboxListTile(
|
|
|
|
- activeColor: AppTheme.primary,
|
|
|
|
- title: Row(
|
|
|
|
- mainAxisAlignment:
|
|
|
|
- MainAxisAlignment.spaceBetween,
|
|
|
|
- children: [
|
|
|
|
- Text(topping.nombre!),
|
|
|
|
- if (topping.precio != 0.0)
|
|
|
|
- Text(
|
|
|
|
- '+\$${topping.precio}',
|
|
|
|
- style: TextStyle(
|
|
|
|
- color: Colors.black,
|
|
|
|
- fontSize: 13,
|
|
|
|
- ),
|
|
|
|
- ),
|
|
|
|
- ],
|
|
|
|
|
|
+ return ExpansionTile(
|
|
|
|
+ initiallyExpanded: true,
|
|
|
|
+ title: Text(
|
|
|
|
+ categoria.nombre!,
|
|
|
|
+ style: const TextStyle(
|
|
|
|
+ fontWeight: FontWeight.bold, fontSize: 16),
|
|
|
|
+ ),
|
|
|
|
+ children: availableToppings.map((topping) {
|
|
|
|
+ bool isSelected = item
|
|
|
|
+ .selectedToppings[categoryId]
|
|
|
|
+ ?.contains(topping.id) ??
|
|
|
|
+ false;
|
|
|
|
+ return CheckboxListTile(
|
|
|
|
+ activeColor: AppTheme.primary,
|
|
|
|
+ title: Row(
|
|
|
|
+ mainAxisAlignment:
|
|
|
|
+ MainAxisAlignment.spaceBetween,
|
|
|
|
+ children: [
|
|
|
|
+ Text(topping.nombre!),
|
|
|
|
+ if (topping.precio != 0.0)
|
|
|
|
+ Text(
|
|
|
|
+ '+\$${topping.precio}',
|
|
|
|
+ style: const TextStyle(
|
|
|
|
+ color: Colors.black,
|
|
|
|
+ fontSize: 13,
|
|
|
|
+ ),
|
|
),
|
|
),
|
|
- value: isSelected,
|
|
|
|
- onChanged: (bool? value) {
|
|
|
|
- final maximoToppings =
|
|
|
|
- categoria.maximo ?? 0;
|
|
|
|
-
|
|
|
|
- if (value == true) {
|
|
|
|
- if ((item.selectedToppings[categoryId]
|
|
|
|
- ?.length ??
|
|
|
|
- 0) >=
|
|
|
|
- maximoToppings) {
|
|
|
|
- item.selectedToppings[categoryId]!
|
|
|
|
- .remove(item
|
|
|
|
- .selectedToppings[
|
|
|
|
- categoryId]!
|
|
|
|
- .first);
|
|
|
|
- }
|
|
|
|
- item.selectedToppings[categoryId] ??=
|
|
|
|
- <int>{};
|
|
|
|
- item.selectedToppings[categoryId]!
|
|
|
|
- .add(topping.id!);
|
|
|
|
- } else {
|
|
|
|
- item.selectedToppings[categoryId]
|
|
|
|
- ?.remove(topping.id!);
|
|
|
|
- if (item.selectedToppings[categoryId]
|
|
|
|
- ?.isEmpty ??
|
|
|
|
- false) {
|
|
|
|
- item.selectedToppings
|
|
|
|
- .remove(categoryId);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- setState(() {});
|
|
|
|
- _recalcularTotal();
|
|
|
|
- },
|
|
|
|
- );
|
|
|
|
- },
|
|
|
|
- );
|
|
|
|
- }).toList(),
|
|
|
|
- ],
|
|
|
|
|
|
+ ],
|
|
|
|
+ ),
|
|
|
|
+ value: isSelected,
|
|
|
|
+ onChanged: (bool? value) {
|
|
|
|
+ final maximoToppings = categoria.maximo ?? 0;
|
|
|
|
+
|
|
|
|
+ setState(() {
|
|
|
|
+ if (value == true) {
|
|
|
|
+ if ((item.selectedToppings[categoryId]
|
|
|
|
+ ?.length ??
|
|
|
|
+ 0) >=
|
|
|
|
+ maximoToppings) {
|
|
|
|
+ item.selectedToppings[categoryId]!
|
|
|
|
+ .remove(item
|
|
|
|
+ .selectedToppings[categoryId]!
|
|
|
|
+ .first);
|
|
|
|
+ }
|
|
|
|
+ item.selectedToppings[categoryId] ??=
|
|
|
|
+ <int>{};
|
|
|
|
+ item.selectedToppings[categoryId]!
|
|
|
|
+ .add(topping.id!);
|
|
|
|
+ } else {
|
|
|
|
+ item.selectedToppings[categoryId]
|
|
|
|
+ ?.remove(topping.id!);
|
|
|
|
+ if (item.selectedToppings[categoryId]
|
|
|
|
+ ?.isEmpty ??
|
|
|
|
+ false) {
|
|
|
|
+ item.selectedToppings
|
|
|
|
+ .remove(categoryId);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ _recalcularTotal();
|
|
|
|
+ });
|
|
|
|
+ },
|
|
|
|
+ );
|
|
|
|
+ }).toList(),
|
|
);
|
|
);
|
|
}).toList(),
|
|
}).toList(),
|
|
),
|
|
),
|
|
- Divider(),
|
|
|
|
|
|
+ const Divider(),
|
|
],
|
|
],
|
|
);
|
|
);
|
|
},
|
|
},
|
|
@@ -1210,7 +1199,7 @@ class _PedidoFormState extends State<PedidoForm> {
|
|
child: ElevatedButton(
|
|
child: ElevatedButton(
|
|
onPressed: _finalizeOrder,
|
|
onPressed: _finalizeOrder,
|
|
style: ElevatedButton.styleFrom(
|
|
style: ElevatedButton.styleFrom(
|
|
- primary: AppTheme.tertiary,
|
|
|
|
|
|
+ backgroundColor: AppTheme.tertiary,
|
|
textStyle: const TextStyle(fontSize: 22),
|
|
textStyle: const TextStyle(fontSize: 22),
|
|
fixedSize: const Size(250, 50),
|
|
fixedSize: const Size(250, 50),
|
|
),
|
|
),
|
|
@@ -1352,10 +1341,9 @@ class _PedidoFormState extends State<PedidoForm> {
|
|
});
|
|
});
|
|
},
|
|
},
|
|
style: ElevatedButton.styleFrom(
|
|
style: ElevatedButton.styleFrom(
|
|
- primary: isSelected ? AppTheme.tertiary : Colors.grey,
|
|
|
|
|
|
+ backgroundColor: isSelected ? AppTheme.tertiary : Colors.grey,
|
|
foregroundColor:
|
|
foregroundColor:
|
|
isSelected ? AppTheme.quaternary : AppTheme.secondary,
|
|
isSelected ? AppTheme.quaternary : AppTheme.secondary,
|
|
- onPrimary: AppTheme.secondary,
|
|
|
|
),
|
|
),
|
|
child: Text(categoria.nombre!),
|
|
child: Text(categoria.nombre!),
|
|
),
|
|
),
|