123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118 |
- import 'dart:io';
- import 'package:flutter/material.dart';
- import 'package:pdf/pdf.dart';
- import 'package:printing/printing.dart';
- import 'package:provider/provider.dart';
- import 'package:yoshi_papas_app/themes/themes.dart';
- import 'package:yoshi_papas_app/views/pedido/pedido_ticket.dart';
- import '../../models/models.dart';
- class PedidoDetalleScreen extends StatelessWidget {
- final Pedido pedido;
- const PedidoDetalleScreen({Key? key, required this.pedido}) : super(key: key);
- String obtenerEstadoPedido(String? estado) {
- switch (estado) {
- case '1':
- return "NUEVO";
- case '2':
- return "EN PROCESO";
- case '3':
- return "TERMINADO";
- case '4':
- return "CANCELADO";
- default:
- return "ESTADO DESCONOCIDO"; // En caso de que se reciba un valor no esperado
- }
- }
- @override
- Widget build(BuildContext context) {
- print("Productos en el pedido: ${pedido.productos.length}");
- return Scaffold(
- appBar: AppBar(
- title: Text('Detalle del Pedido ${pedido.folio}'),
- ),
- body: SingleChildScrollView(
- padding: const EdgeInsets.all(
- 12.0), // Agrega padding al contenedor general
- child: Column(
- children: [
- Card(
- elevation: 4, // Sombra de la tarjeta
- color: Colors.white, // Fondo blanco de la tarjeta
- child: Column(
- children: [
- ListTile(
- title: Text(
- 'Cliente: ${pedido.nombreCliente}',
- style: TextStyle(
- fontWeight:
- FontWeight.bold), // Negritas para el título
- ),
- subtitle: Text('Comentarios: ${pedido.comentarios}'),
- ),
- // ListTile(
- // title: Text(
- // 'Estado del Pedido: ${obtenerEstadoPedido(pedido.estatus)}',
- // style: TextStyle(
- // fontSize: 16,
- // fontWeight: FontWeight.bold,
- // color: Colors
- // .deepOrange), // Estilo para el estado del pedido
- // ),
- // )
- ],
- )),
- SizedBox(height: 10), // Espacio entre componentes
- Card(
- elevation: 4,
- color: Colors.white,
- child: Padding(
- padding: const EdgeInsets.all(8.0),
- child: Column(
- crossAxisAlignment: CrossAxisAlignment.start,
- children: [
- Text('Productos',
- style: TextStyle(
- fontSize: 18, fontWeight: FontWeight.bold)),
- ListView.builder(
- shrinkWrap: true,
- physics: NeverScrollableScrollPhysics(),
- itemCount: pedido.productos.length,
- itemBuilder: (context, index) {
- final pedidoProducto = pedido.productos[index];
- return ListTile(
- title: Text(
- pedidoProducto.producto?.nombre ??
- "Producto no especificado",
- style: TextStyle(
- fontWeight: FontWeight
- .bold), // Negritas para el nombre del producto
- ),
- subtitle:
- Text('Cantidad: ${pedidoProducto.cantidad}'),
- );
- },
- ),
- SizedBox(height: 20), // Espacio antes del botón
- ElevatedButton(
- onPressed: () => printTickets(pedido),
- child: Text('Imprimir Ticket'),
- style: ElevatedButton.styleFrom(
- primary: AppTheme.primary,
- onPrimary: Colors.white,
- ),
- ),
- ],
- ),
- ),
- ),
- ],
- )),
- );
- }
- }
|