ordenes_card.dart 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221
  1. import 'package:flutter/material.dart';
  2. class OrdenMesaCard extends StatelessWidget {
  3. final String mesaNumero;
  4. final String ordenNumero;
  5. final List<OrdenItem> items;
  6. final bool tieneItemsListos;
  7. final VoidCallback onLiberarOrden;
  8. const OrdenMesaCard({
  9. Key? key,
  10. required this.mesaNumero,
  11. required this.ordenNumero,
  12. required this.items,
  13. this.tieneItemsListos = false,
  14. required this.onLiberarOrden,
  15. }) : super(key: key);
  16. @override
  17. Widget build(BuildContext context) {
  18. return Card(
  19. margin: const EdgeInsets.all(8.0),
  20. child: Column(
  21. crossAxisAlignment: CrossAxisAlignment.stretch,
  22. mainAxisSize: MainAxisSize.min,
  23. children: [
  24. // Encabezado de la mesa
  25. Padding(
  26. padding: const EdgeInsets.all(16.0),
  27. child: Row(
  28. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  29. children: [
  30. Text(
  31. 'Mesa $mesaNumero',
  32. style: const TextStyle(
  33. fontSize: 18,
  34. fontWeight: FontWeight.bold,
  35. ),
  36. ),
  37. Row(
  38. children: [
  39. const Icon(Icons.access_time, size: 16),
  40. const SizedBox(width: 4),
  41. Text('15:03'),
  42. ],
  43. ),
  44. ],
  45. ),
  46. ),
  47. const Divider(height: 1),
  48. // Número de orden
  49. Padding(
  50. padding:
  51. const EdgeInsets.symmetric(horizontal: 16.0, vertical: 8.0),
  52. child: Text(
  53. 'Orden #$ordenNumero',
  54. style: TextStyle(
  55. color: Colors.grey[600],
  56. fontSize: 14,
  57. ),
  58. ),
  59. ),
  60. // Lista de items
  61. ListView.builder(
  62. shrinkWrap: true,
  63. physics: const NeverScrollableScrollPhysics(),
  64. itemCount: items.length,
  65. itemBuilder: (context, index) {
  66. final item = items[index];
  67. return ListTile(
  68. contentPadding: const EdgeInsets.symmetric(horizontal: 16.0),
  69. leading: Text(
  70. '${item.cantidad}x',
  71. style: const TextStyle(
  72. fontSize: 16,
  73. fontWeight: FontWeight.bold,
  74. ),
  75. ),
  76. title: Text(
  77. item.nombre,
  78. style: const TextStyle(
  79. fontSize: 16,
  80. fontWeight: FontWeight.w500,
  81. ),
  82. ),
  83. subtitle: Column(
  84. crossAxisAlignment: CrossAxisAlignment.start,
  85. children: [
  86. Text(
  87. item.descripcion,
  88. style: TextStyle(
  89. color: Colors.grey[600],
  90. fontSize: 14,
  91. ),
  92. ),
  93. if (item.notas != null)
  94. Text(
  95. item.notas!,
  96. style: TextStyle(
  97. color: Colors.red[400],
  98. fontSize: 14,
  99. ),
  100. ),
  101. ],
  102. ),
  103. trailing: item.isListo
  104. ? Container(
  105. padding: const EdgeInsets.symmetric(
  106. horizontal: 12, vertical: 6),
  107. decoration: BoxDecoration(
  108. color: Colors.black,
  109. borderRadius: BorderRadius.circular(20),
  110. ),
  111. child: const Text(
  112. 'Listo',
  113. style: TextStyle(
  114. color: Colors.white,
  115. fontSize: 12,
  116. ),
  117. ),
  118. )
  119. : const Icon(Icons.chevron_right),
  120. );
  121. },
  122. ),
  123. Padding(
  124. padding: const EdgeInsets.all(16.0),
  125. child: ElevatedButton(
  126. onPressed: onLiberarOrden,
  127. style: ElevatedButton.styleFrom(
  128. backgroundColor: const Color(0xFF4CAF50),
  129. padding: const EdgeInsets.symmetric(vertical: 16),
  130. shape: RoundedRectangleBorder(
  131. borderRadius: BorderRadius.circular(8),
  132. ),
  133. ),
  134. child: const Text(
  135. 'Liberar Orden Completa',
  136. style: TextStyle(
  137. color: Colors.white,
  138. fontSize: 16,
  139. fontWeight: FontWeight.w500,
  140. ),
  141. ),
  142. ),
  143. ),
  144. ],
  145. ),
  146. );
  147. }
  148. }
  149. class OrdenItem {
  150. final int cantidad;
  151. final String nombre;
  152. final String descripcion;
  153. final String? notas;
  154. final bool isListo;
  155. OrdenItem({
  156. required this.cantidad,
  157. required this.nombre,
  158. required this.descripcion,
  159. this.notas,
  160. this.isListo = false,
  161. });
  162. }
  163. class OrdenesScreen extends StatelessWidget {
  164. const OrdenesScreen({Key? key}) : super(key: key);
  165. @override
  166. Widget build(BuildContext context) {
  167. final items = [
  168. OrdenItem(
  169. cantidad: 1,
  170. nombre: 'Chilaquiles Verdes',
  171. descripcion: 'Tortillas fritas en salsa verde con pollo',
  172. notas: 'Sin cebolla ni tomate',
  173. ),
  174. OrdenItem(
  175. cantidad: 2,
  176. nombre: 'Huevos Rancheros',
  177. descripcion: 'Huevos fritos sobre tortilla con salsa roja',
  178. ),
  179. ];
  180. final items2 = [
  181. OrdenItem(
  182. cantidad: 1,
  183. nombre: 'Club Sandwich',
  184. descripcion: 'Sándwich triple con pollo, jamón y tocino',
  185. isListo: true,
  186. ),
  187. ];
  188. return ListView(
  189. children: [
  190. OrdenMesaCard(
  191. mesaNumero: '5',
  192. ordenNumero: 'A-123',
  193. items: items,
  194. onLiberarOrden: () {
  195. // Implementar lógica para liberar orden
  196. },
  197. ),
  198. OrdenMesaCard(
  199. mesaNumero: '3',
  200. ordenNumero: 'A-124',
  201. items: items2,
  202. tieneItemsListos: true,
  203. onLiberarOrden: () {
  204. // Implementar lógica para liberar orden
  205. },
  206. ),
  207. ],
  208. );
  209. }
  210. }