|
@@ -3,6 +3,7 @@ import 'package:provider/provider.dart';
|
|
|
import 'package:turquessa_mesas_hoster/core/models/mesa_model.dart';
|
|
|
import 'package:turquessa_mesas_hoster/utils/widgets/custom_appbar.dart';
|
|
|
import 'package:turquessa_mesas_hoster/utils/widgets/custom_card.dart';
|
|
|
+import 'package:turquessa_mesas_hoster/utils/widgets/get_status_style.dart';
|
|
|
import 'package:turquessa_mesas_hoster/utils/widgets/navigation_rail.dart';
|
|
|
|
|
|
import '../../../utils/widgets/ordenes_card.dart';
|
|
@@ -134,6 +135,8 @@ class TablaDetalles extends StatelessWidget {
|
|
|
|
|
|
@override
|
|
|
Widget build(BuildContext context) {
|
|
|
+ final mesaViewModel = Provider.of<MesaViewModel>(context, listen: true);
|
|
|
+ final style = getStatusStyle(status);
|
|
|
return Container(
|
|
|
decoration: BoxDecoration(
|
|
|
color: Color.fromARGB(255, 247, 249, 250),
|
|
@@ -151,7 +154,7 @@ class TablaDetalles extends StatelessWidget {
|
|
|
Container(
|
|
|
padding: const EdgeInsets.all(16),
|
|
|
decoration: BoxDecoration(
|
|
|
- color: table.activa! ? Colors.blue : Colors.grey,
|
|
|
+ color: style.iconColor,
|
|
|
),
|
|
|
child: Row(
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
@@ -205,11 +208,16 @@ class TablaDetalles extends StatelessWidget {
|
|
|
color: Colors.white.withOpacity(0.2),
|
|
|
borderRadius: BorderRadius.circular(20),
|
|
|
),
|
|
|
- child: Text(table.activa! ? 'Activa' : 'Inactiva',
|
|
|
- style: const TextStyle(
|
|
|
- color: Colors.white,
|
|
|
- fontWeight: FontWeight.bold,
|
|
|
- )),
|
|
|
+ child: GestureDetector(
|
|
|
+ onTap: () {
|
|
|
+ mesaViewModel.cambiarEstadoPedidoMesa(style.nextStatus);
|
|
|
+ },
|
|
|
+ child: Text(table.activa! ? 'Activa' : 'Inactiva',
|
|
|
+ style: const TextStyle(
|
|
|
+ color: Colors.white,
|
|
|
+ fontWeight: FontWeight.bold,
|
|
|
+ )),
|
|
|
+ ),
|
|
|
),
|
|
|
],
|
|
|
),
|
|
@@ -324,66 +332,26 @@ class TableCard extends StatelessWidget {
|
|
|
@override
|
|
|
Widget build(BuildContext context) {
|
|
|
final status = mesa.estado ?? EstadoPedido.disponible;
|
|
|
+ final mesaViewModel = Provider.of<MesaViewModel>(context, listen: true);
|
|
|
|
|
|
- Color backgroundColor;
|
|
|
- Color iconColor;
|
|
|
- IconData icon;
|
|
|
- Color cardColor;
|
|
|
-
|
|
|
- switch (status) {
|
|
|
- case EstadoPedido.disponible:
|
|
|
- backgroundColor = const Color.fromARGB(255, 220, 252, 232);
|
|
|
- iconColor = Colors.green;
|
|
|
- icon = Icons.table_restaurant_rounded;
|
|
|
- cardColor = const Color.fromARGB(255, 220, 252, 232);
|
|
|
- break;
|
|
|
- case EstadoPedido.surtida:
|
|
|
- backgroundColor = const Color.fromARGB(255, 220, 234, 254);
|
|
|
- iconColor = Colors.blue;
|
|
|
- icon = Icons.coffee_rounded;
|
|
|
- cardColor = const Color.fromARGB(255, 220, 234, 254);
|
|
|
- break;
|
|
|
- case EstadoPedido.preparacion:
|
|
|
- backgroundColor = const Color.fromARGB(255, 243, 232, 255);
|
|
|
- iconColor = Colors.deepPurple;
|
|
|
- icon = Icons.restaurant_rounded;
|
|
|
- cardColor = Colors.white;
|
|
|
- // cardColor = const Color.fromARGB(255, 243, 232, 255);
|
|
|
- break;
|
|
|
- case EstadoPedido.cobrado:
|
|
|
- backgroundColor = const Color.fromARGB(255, 255, 238, 213);
|
|
|
- iconColor = Colors.amber;
|
|
|
- icon = Icons.attach_money_rounded;
|
|
|
- cardColor = Colors.white;
|
|
|
- // cardColor = const Color.fromARGB(255, 255, 238, 213);
|
|
|
- break;
|
|
|
- default:
|
|
|
- backgroundColor = Colors.grey.shade200;
|
|
|
- iconColor = Colors.grey;
|
|
|
- icon = Icons.settings;
|
|
|
- cardColor = Colors.white;
|
|
|
- break;
|
|
|
- }
|
|
|
+ final style = getStatusStyle(status);
|
|
|
|
|
|
return Card(
|
|
|
borderOnForeground: false,
|
|
|
- color: cardColor,
|
|
|
+ color: style.cardColor,
|
|
|
child: Column(
|
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
|
children: [
|
|
|
IconButton(
|
|
|
onPressed: () {
|
|
|
- if (status == EstadoPedido.disponible) {
|
|
|
- final mesaViewModel =
|
|
|
- Provider.of<MesaViewModel>(context, listen: false);
|
|
|
- mesaViewModel.CambiarEstadoPedidoMesa(EstadoPedido.preparacion);
|
|
|
- }
|
|
|
+ mesaViewModel.cambiarEstadoPedidoMesa(style.nextStatus);
|
|
|
+ print('Cambiando estado de la mesa ${style.nextStatus}');
|
|
|
},
|
|
|
iconSize: 48,
|
|
|
style: ButtonStyle(
|
|
|
- backgroundColor: MaterialStateProperty.all(backgroundColor),
|
|
|
+ backgroundColor: MaterialStateProperty.all(style.backgroundColor),
|
|
|
),
|
|
|
- icon: Icon(icon, color: iconColor),
|
|
|
+ icon: Icon(style.icon, color: style.iconColor),
|
|
|
),
|
|
|
const SizedBox(height: 8),
|
|
|
Text(
|
|
@@ -399,14 +367,16 @@ class TableCard extends StatelessWidget {
|
|
|
Container(
|
|
|
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 6),
|
|
|
decoration: BoxDecoration(
|
|
|
- color: backgroundColor,
|
|
|
+ color: style.backgroundColor,
|
|
|
borderRadius: BorderRadius.circular(20),
|
|
|
),
|
|
|
- child: Text(status.toString().split('.').last,
|
|
|
- style: TextStyle(
|
|
|
- color: iconColor,
|
|
|
- fontWeight: FontWeight.bold,
|
|
|
- )),
|
|
|
+ child: Text(
|
|
|
+ status.toString().split('.').last,
|
|
|
+ style: TextStyle(
|
|
|
+ color: style.iconColor,
|
|
|
+ fontWeight: FontWeight.bold,
|
|
|
+ ),
|
|
|
+ ),
|
|
|
)
|
|
|
],
|
|
|
),
|