ordenes_card.dart 6.1 KB

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