pedido_detalle_screen.dart 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. import 'dart:io';
  2. import 'package:flutter/material.dart';
  3. import 'package:pdf/pdf.dart';
  4. import 'package:printing/printing.dart';
  5. import 'package:provider/provider.dart';
  6. import 'package:yoshi_papas_app/themes/themes.dart';
  7. import 'package:yoshi_papas_app/views/pedido/pedido_ticket.dart';
  8. import '../../models/models.dart';
  9. class PedidoDetalleScreen extends StatelessWidget {
  10. final Pedido pedido;
  11. const PedidoDetalleScreen({Key? key, required this.pedido}) : super(key: key);
  12. String obtenerEstadoPedido(String? estado) {
  13. switch (estado) {
  14. case '1':
  15. return "NUEVO";
  16. case '2':
  17. return "EN PROCESO";
  18. case '3':
  19. return "TERMINADO";
  20. case '4':
  21. return "CANCELADO";
  22. default:
  23. return "ESTADO DESCONOCIDO"; // En caso de que se reciba un valor no esperado
  24. }
  25. }
  26. @override
  27. Widget build(BuildContext context) {
  28. print("Productos en el pedido: ${pedido.productos.length}");
  29. return Scaffold(
  30. appBar: AppBar(
  31. title: Text('Detalle del Pedido ${pedido.folio}'),
  32. ),
  33. body: SingleChildScrollView(
  34. padding: const EdgeInsets.all(
  35. 12.0), // Agrega padding al contenedor general
  36. child: Column(
  37. children: [
  38. Card(
  39. elevation: 4, // Sombra de la tarjeta
  40. color: Colors.white, // Fondo blanco de la tarjeta
  41. child: Column(
  42. children: [
  43. ListTile(
  44. title: Text(
  45. 'Cliente: ${pedido.nombreCliente}',
  46. style: TextStyle(
  47. fontWeight:
  48. FontWeight.bold), // Negritas para el título
  49. ),
  50. subtitle: Text('Comentarios: ${pedido.comentarios}'),
  51. ),
  52. // ListTile(
  53. // title: Text(
  54. // 'Estado del Pedido: ${obtenerEstadoPedido(pedido.estatus)}',
  55. // style: TextStyle(
  56. // fontSize: 16,
  57. // fontWeight: FontWeight.bold,
  58. // color: Colors
  59. // .deepOrange), // Estilo para el estado del pedido
  60. // ),
  61. // )
  62. ],
  63. )),
  64. SizedBox(height: 10), // Espacio entre componentes
  65. Card(
  66. elevation: 4,
  67. color: Colors.white,
  68. child: Padding(
  69. padding: const EdgeInsets.all(8.0),
  70. child: Column(
  71. crossAxisAlignment: CrossAxisAlignment.start,
  72. children: [
  73. Text('Productos',
  74. style: TextStyle(
  75. fontSize: 18, fontWeight: FontWeight.bold)),
  76. ListView.builder(
  77. shrinkWrap: true,
  78. physics: NeverScrollableScrollPhysics(),
  79. itemCount: pedido.productos.length,
  80. itemBuilder: (context, index) {
  81. final pedidoProducto = pedido.productos[index];
  82. return ListTile(
  83. title: Text(
  84. pedidoProducto.producto?.nombre ??
  85. "Producto no especificado",
  86. style: TextStyle(
  87. fontWeight: FontWeight
  88. .bold), // Negritas para el nombre del producto
  89. ),
  90. subtitle:
  91. Text('Cantidad: ${pedidoProducto.cantidad}'),
  92. );
  93. },
  94. ),
  95. SizedBox(height: 20), // Espacio antes del botón
  96. ElevatedButton(
  97. onPressed: () => printTickets(pedido),
  98. child: Text('Imprimir Ticket'),
  99. style: ElevatedButton.styleFrom(
  100. primary: AppTheme.primary,
  101. onPrimary: Colors.white,
  102. ),
  103. ),
  104. ],
  105. ),
  106. ),
  107. ),
  108. ],
  109. )),
  110. );
  111. }
  112. }