123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290 |
- import 'package:computo_lite/main.dart';
- import 'package:computo_lite/views/package/package_store.dart';
- import 'package:computo_lite/viewmodels/viewmodels.dart';
- import 'package:flutter/material.dart';
- import 'package:provider/provider.dart';
- const Map<int, dynamic> showButtonsConsejos = {
- 1: [1],
- 2: [1, 2, 3],
- 3: [1, 3]
- };
- class PackagePage extends StatefulWidget {
- final Map<String, dynamic> _package;
- final List<Map<String, dynamic>> _binnacle;
- final String _entradaSalida;
- final bool _scanner;
- final int _idConsejoElectoralBitacora;
- final int _idTipoEleccion;
- PackagePage(this._package, this._binnacle, this._entradaSalida, this._scanner,
- this._idConsejoElectoralBitacora, this._idTipoEleccion)
- : super();
- @override
- _PackagePageState createState() => _PackagePageState();
- }
- class _PackagePageState extends State<PackagePage> {
- final StoreViewModel _storeViewModel = StoreViewModel();
- String numeros = ""; // Inicializar como vacío
- String nombre = ""; // Inicializar como vacío
- String primeraLetraNombre = "";
- bool _verifying = false;
- @override
- void initState() {
- super.initState();
- _initializePackageData(); // Llamar a este método en initState
- }
- void _initializePackageData() {
- String textoCompleto = widget._package["nombreCompletoActa"].toString();
- int indiceEspacio = textoCompleto.indexOf(' ');
- if (indiceEspacio != -1) {
- // Asegurarse de que se encontró un espacio
- numeros = textoCompleto.substring(0, indiceEspacio);
- nombre = textoCompleto.substring(indiceEspacio + 1);
- if (nombre.isNotEmpty) {
- primeraLetraNombre = nombre[0]; // Extraer la primera letra del nombre
- }
- }
- }
- Future<void> _verifySotre(String sacarAlmacenar) async {
- try {
- if (mounted) setState(() => _verifying = true);
- final bool openStore = await _storeViewModel.openStore();
- if (!openStore) {
- HelpersViewModel.dialog(
- 2,
- const Row(
- children: [
- Icon(Icons.error),
- SizedBox(width: 5),
- Text("Error"),
- ],
- ),
- "La bodega esta cerrada.",
- context,
- "Cerrar",
- "Ir a bodega",
- () {}, () {
- //Navigator.push(context, MaterialPageRoute(builder: (context) => MyApp(pageSelected: 3)));
- });
- return;
- }
- // Navigator.push(
- // context,
- // MaterialPageRoute(
- // builder: (context) =>
- // PackageStore(sacarAlmacenar, widget._package, widget._scanner)),
- // );
- } catch (e) {
- print(e);
- } finally {
- if (mounted) setState(() => _verifying = false);
- }
- }
- @override
- Widget build(BuildContext context) {
- // final Map<String, dynamic> user =
- // Provider.of<LoginViewModel>(context, listen: true).userData;
- return Scaffold(
- // floatingActionButton: _verifying
- // ? const CircularProgressIndicator()
- // : widget._entradaSalida == "E"
- // ? widget._idTipoEleccion ==
- // user["consejoElectoral"]["idTipoConsejoElectoral"] &&
- // widget._idConsejoElectoralBitacora ==
- // user["consejoElectoral"]["idConsejoElectoral"]
- // ? Padding(
- // padding: const EdgeInsets.only(left: 30.0),
- // child: SizedBox(
- // width: double.infinity,
- // child: TextButton(
- // onPressed: () async => await _verifySotre("S"),
- // style: ButtonStyle(
- // backgroundColor:
- // MaterialStateProperty.all<Color>(
- // const Color(0xffdb6500))),
- // child: const Text(
- // "Sacar",
- // style: TextStyle(color: Colors.white),
- // )),
- // ),
- // )
- // : widget._idConsejoElectoralBitacora !=
- // user["consejoElectoral"]["idConsejoElectoral"]
- // ? Padding(
- // padding: const EdgeInsets.only(left: 30.0),
- // child: SizedBox(
- // width: double.infinity,
- // child: TextButton(
- // onPressed: () async => await _verifySotre("E"),
- // style: ButtonStyle(
- // backgroundColor:
- // MaterialStateProperty.all<Color>(
- // const Color(0xffdb6500))),
- // child: const Text(
- // "Almacenar",
- // style: TextStyle(color: Colors.white),
- // )),
- // ),
- // )
- // : const SizedBox()
- // : List.from(showButtonsConsejos[user["consejoElectoral"]
- // ["idTipoConsejoElectoral"]])
- // .contains(widget._package["idTipoEleccion"])
- // ? Padding(
- // padding: const EdgeInsets.only(left: 30.0),
- // child: SizedBox(
- // width: double.infinity,
- // child: TextButton(
- // onPressed: () async => await _verifySotre("E"),
- // style: ButtonStyle(
- // backgroundColor:
- // MaterialStateProperty.all<Color>(
- // const Color(0xffdb6500))),
- // child: const Text(
- // "Almacenar",
- // style: TextStyle(color: Colors.white),
- // )),
- // ),
- // )
- // : const SizedBox(),
- appBar: AppBar(
- centerTitle: true,
- iconTheme: const IconThemeData(color: Colors.white),
- title: Image.asset("assets/logo_iee.png", height: 50),
- ),
- body: _packageInfo(),
- );
- }
- Widget _packageInfo() {
- return Padding(
- padding: const EdgeInsets.all(20.0),
- child: SingleChildScrollView(
- child: Column(
- crossAxisAlignment: CrossAxisAlignment.start,
- children: [
- const SizedBox(height: 10),
- const Center(
- child: Text("Acta / Paquete",
- style:
- TextStyle(fontSize: 18, fontWeight: FontWeight.bold))),
- const SizedBox(height: 20),
- Row(children: [
- const Icon(
- Icons.description_outlined,
- size: 150,
- ),
- RichText(
- text: TextSpan(
- children: [
- const TextSpan(
- text:
- /*"$primeraLetraNombre\n"*/ "C\n", // Aquí se usa la variable primeraLetraNombre
- style: TextStyle(
- fontWeight: FontWeight.bold,
- color: Color(0xFF0000FF),
- fontSize: 50),
- ),
- TextSpan(
- text:
- "$numeros\n", // Agrega un salto de línea después de los números
- style: const TextStyle(
- fontWeight:
- FontWeight.bold, // Estilo para los números
- color: Color(0xFF980000),
- fontSize: 30 // Por ejemplo, números en azul
- ),
- ),
- TextSpan(
- text: nombre, // El nombre en la siguiente línea
- style: const TextStyle(
- fontWeight:
- FontWeight.normal, // Estilo para el nombre
- color: Colors.black,
- fontSize: 30 // Por ejemplo, nombre en negro
- ),
- ),
- ],
- ),
- ),
- ]),
- const SizedBox(height: 20),
- RichText(
- text: TextSpan(
- text: 'Elección: ',
- style: const TextStyle(
- fontWeight: FontWeight.bold,
- color: Colors.black,
- fontSize: 16),
- children: <TextSpan>[
- TextSpan(
- text:
- widget._package["tipoEleccion"]["nombre"].toString(),
- style: const TextStyle(fontWeight: FontWeight.normal)),
- ],
- ),
- ),
- const SizedBox(height: 20),
- RichText(
- text: TextSpan(
- text: 'Ubicación: ',
- style: const TextStyle(
- fontWeight: FontWeight.bold,
- color: Colors.black,
- fontSize: 16),
- children: <TextSpan>[
- TextSpan(
- text: widget._package["casilla"]["ubicacion"].toString(),
- style: const TextStyle(fontWeight: FontWeight.normal)),
- ],
- ),
- ),
- const SizedBox(height: 10),
- const Divider(indent: 2, color: Colors.black),
- const SizedBox(height: 10),
- const Center(
- child: Text("Recibo Capturado",
- style:
- TextStyle(fontSize: 18, fontWeight: FontWeight.bold))),
- const SizedBox(height: 20),
- widget._package["ultimaRecepcion"]["fecha"] != null
- ? const Padding(
- padding: EdgeInsets.all(8.0),
- child: Center(
- child: Row(
- children: [
- Icon(Icons.description_outlined, size: 80),
- Text("Recibo de Captura")
- ],
- )))
- : const Padding(
- padding: EdgeInsets.all(8.0),
- child: Center(
- child: Row(
- children: [
- Icon(Icons.watch_later_outlined, size: 80),
- Text("Sin Recibo")
- ],
- )))
- ],
- ),
- ),
- );
- }
- }
|