ordenes_card.dart 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211
  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. child: Column(
  79. mainAxisSize: MainAxisSize.min,
  80. children: [
  81. Padding(
  82. padding: const EdgeInsets.all(16.0),
  83. child: Row(
  84. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  85. children: [
  86. Text(
  87. 'Mesa $mesaNumero',
  88. style: const TextStyle(
  89. fontSize: 18,
  90. fontWeight: FontWeight.bold,
  91. ),
  92. ),
  93. Row(
  94. children: [
  95. const Icon(Icons.access_time, size: 16),
  96. const SizedBox(width: 4),
  97. const Text('15:03'),
  98. ],
  99. ),
  100. ],
  101. ),
  102. ),
  103. const Divider(height: 1),
  104. Padding(
  105. padding:
  106. const EdgeInsets.symmetric(horizontal: 16.0, vertical: 8.0),
  107. child: Align(
  108. alignment: Alignment.centerLeft,
  109. child: Text(
  110. 'Orden #$ordenNumero',
  111. style: TextStyle(
  112. color: Colors.grey[600],
  113. fontSize: 14,
  114. ),
  115. ),
  116. ),
  117. ),
  118. ...items.map((item) => ListTile(
  119. contentPadding: const EdgeInsets.symmetric(horizontal: 16.0),
  120. leading: Text(
  121. '${item.cantidad}x',
  122. style: const TextStyle(
  123. fontSize: 16,
  124. fontWeight: FontWeight.bold,
  125. ),
  126. ),
  127. title: Text(
  128. item.nombre,
  129. style: const TextStyle(
  130. fontSize: 16,
  131. fontWeight: FontWeight.w500,
  132. ),
  133. ),
  134. subtitle: Column(
  135. crossAxisAlignment: CrossAxisAlignment.start,
  136. children: [
  137. Text(
  138. item.descripcion,
  139. style: TextStyle(
  140. color: Colors.grey[600],
  141. fontSize: 14,
  142. ),
  143. ),
  144. if (item.notas != null)
  145. Text(
  146. item.notas!,
  147. style: TextStyle(
  148. color: Colors.red[400],
  149. fontSize: 14,
  150. ),
  151. ),
  152. ],
  153. ),
  154. trailing: item.isListo
  155. ? Container(
  156. padding: const EdgeInsets.symmetric(
  157. horizontal: 12, vertical: 6),
  158. decoration: BoxDecoration(
  159. color: Colors.black,
  160. borderRadius: BorderRadius.circular(20),
  161. ),
  162. child: const Text(
  163. 'Listo',
  164. style: TextStyle(
  165. color: Colors.white,
  166. fontSize: 12,
  167. ),
  168. ),
  169. )
  170. : const Icon(Icons.chevron_right),
  171. )),
  172. Padding(
  173. padding: const EdgeInsets.all(16.0),
  174. child: ElevatedButton(
  175. onPressed: onLiberarOrden,
  176. style: ElevatedButton.styleFrom(
  177. backgroundColor: const Color(0xFF4CAF50),
  178. padding: const EdgeInsets.symmetric(vertical: 16),
  179. shape: RoundedRectangleBorder(
  180. borderRadius: BorderRadius.circular(8),
  181. ),
  182. ),
  183. child: const SizedBox(
  184. width: double.infinity,
  185. child: Text(
  186. 'Liberar Orden Completa',
  187. textAlign: TextAlign.center,
  188. style: TextStyle(
  189. color: Colors.white,
  190. fontSize: 16,
  191. fontWeight: FontWeight.w500,
  192. ),
  193. ),
  194. ),
  195. ),
  196. ),
  197. ],
  198. ),
  199. );
  200. }
  201. }