package_page.dart 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290
  1. import 'package:computo_lite/main.dart';
  2. import 'package:computo_lite/views/package/package_store.dart';
  3. import 'package:computo_lite/viewmodels/viewmodels.dart';
  4. import 'package:flutter/material.dart';
  5. import 'package:provider/provider.dart';
  6. const Map<int, dynamic> showButtonsConsejos = {
  7. 1: [1],
  8. 2: [1, 2, 3],
  9. 3: [1, 3]
  10. };
  11. class PackagePage extends StatefulWidget {
  12. final Map<String, dynamic> _package;
  13. final List<Map<String, dynamic>> _binnacle;
  14. final String _entradaSalida;
  15. final bool _scanner;
  16. final int _idConsejoElectoralBitacora;
  17. final int _idTipoEleccion;
  18. PackagePage(this._package, this._binnacle, this._entradaSalida, this._scanner,
  19. this._idConsejoElectoralBitacora, this._idTipoEleccion)
  20. : super();
  21. @override
  22. _PackagePageState createState() => _PackagePageState();
  23. }
  24. class _PackagePageState extends State<PackagePage> {
  25. final StoreViewModel _storeViewModel = StoreViewModel();
  26. String numeros = ""; // Inicializar como vacío
  27. String nombre = ""; // Inicializar como vacío
  28. String primeraLetraNombre = "";
  29. bool _verifying = false;
  30. @override
  31. void initState() {
  32. super.initState();
  33. _initializePackageData(); // Llamar a este método en initState
  34. }
  35. void _initializePackageData() {
  36. String textoCompleto = widget._package["nombreCompletoActa"].toString();
  37. int indiceEspacio = textoCompleto.indexOf(' ');
  38. if (indiceEspacio != -1) {
  39. // Asegurarse de que se encontró un espacio
  40. numeros = textoCompleto.substring(0, indiceEspacio);
  41. nombre = textoCompleto.substring(indiceEspacio + 1);
  42. if (nombre.isNotEmpty) {
  43. primeraLetraNombre = nombre[0]; // Extraer la primera letra del nombre
  44. }
  45. }
  46. }
  47. Future<void> _verifySotre(String sacarAlmacenar) async {
  48. try {
  49. if (mounted) setState(() => _verifying = true);
  50. final bool openStore = await _storeViewModel.openStore();
  51. if (!openStore) {
  52. HelpersViewModel.dialog(
  53. 2,
  54. const Row(
  55. children: [
  56. Icon(Icons.error),
  57. SizedBox(width: 5),
  58. Text("Error"),
  59. ],
  60. ),
  61. "La bodega esta cerrada.",
  62. context,
  63. "Cerrar",
  64. "Ir a bodega",
  65. () {}, () {
  66. //Navigator.push(context, MaterialPageRoute(builder: (context) => MyApp(pageSelected: 3)));
  67. });
  68. return;
  69. }
  70. // Navigator.push(
  71. // context,
  72. // MaterialPageRoute(
  73. // builder: (context) =>
  74. // PackageStore(sacarAlmacenar, widget._package, widget._scanner)),
  75. // );
  76. } catch (e) {
  77. print(e);
  78. } finally {
  79. if (mounted) setState(() => _verifying = false);
  80. }
  81. }
  82. @override
  83. Widget build(BuildContext context) {
  84. // final Map<String, dynamic> user =
  85. // Provider.of<LoginViewModel>(context, listen: true).userData;
  86. return Scaffold(
  87. // floatingActionButton: _verifying
  88. // ? const CircularProgressIndicator()
  89. // : widget._entradaSalida == "E"
  90. // ? widget._idTipoEleccion ==
  91. // user["consejoElectoral"]["idTipoConsejoElectoral"] &&
  92. // widget._idConsejoElectoralBitacora ==
  93. // user["consejoElectoral"]["idConsejoElectoral"]
  94. // ? Padding(
  95. // padding: const EdgeInsets.only(left: 30.0),
  96. // child: SizedBox(
  97. // width: double.infinity,
  98. // child: TextButton(
  99. // onPressed: () async => await _verifySotre("S"),
  100. // style: ButtonStyle(
  101. // backgroundColor:
  102. // MaterialStateProperty.all<Color>(
  103. // const Color(0xffdb6500))),
  104. // child: const Text(
  105. // "Sacar",
  106. // style: TextStyle(color: Colors.white),
  107. // )),
  108. // ),
  109. // )
  110. // : widget._idConsejoElectoralBitacora !=
  111. // user["consejoElectoral"]["idConsejoElectoral"]
  112. // ? Padding(
  113. // padding: const EdgeInsets.only(left: 30.0),
  114. // child: SizedBox(
  115. // width: double.infinity,
  116. // child: TextButton(
  117. // onPressed: () async => await _verifySotre("E"),
  118. // style: ButtonStyle(
  119. // backgroundColor:
  120. // MaterialStateProperty.all<Color>(
  121. // const Color(0xffdb6500))),
  122. // child: const Text(
  123. // "Almacenar",
  124. // style: TextStyle(color: Colors.white),
  125. // )),
  126. // ),
  127. // )
  128. // : const SizedBox()
  129. // : List.from(showButtonsConsejos[user["consejoElectoral"]
  130. // ["idTipoConsejoElectoral"]])
  131. // .contains(widget._package["idTipoEleccion"])
  132. // ? Padding(
  133. // padding: const EdgeInsets.only(left: 30.0),
  134. // child: SizedBox(
  135. // width: double.infinity,
  136. // child: TextButton(
  137. // onPressed: () async => await _verifySotre("E"),
  138. // style: ButtonStyle(
  139. // backgroundColor:
  140. // MaterialStateProperty.all<Color>(
  141. // const Color(0xffdb6500))),
  142. // child: const Text(
  143. // "Almacenar",
  144. // style: TextStyle(color: Colors.white),
  145. // )),
  146. // ),
  147. // )
  148. // : const SizedBox(),
  149. appBar: AppBar(
  150. centerTitle: true,
  151. iconTheme: const IconThemeData(color: Colors.white),
  152. title: Image.asset("assets/logo_iee.png", height: 50),
  153. ),
  154. body: _packageInfo(),
  155. );
  156. }
  157. Widget _packageInfo() {
  158. return Padding(
  159. padding: const EdgeInsets.all(20.0),
  160. child: SingleChildScrollView(
  161. child: Column(
  162. crossAxisAlignment: CrossAxisAlignment.start,
  163. children: [
  164. const SizedBox(height: 10),
  165. const Center(
  166. child: Text("Acta / Paquete",
  167. style:
  168. TextStyle(fontSize: 18, fontWeight: FontWeight.bold))),
  169. const SizedBox(height: 20),
  170. Row(children: [
  171. const Icon(
  172. Icons.description_outlined,
  173. size: 150,
  174. ),
  175. RichText(
  176. text: TextSpan(
  177. children: [
  178. const TextSpan(
  179. text:
  180. /*"$primeraLetraNombre\n"*/ "C\n", // Aquí se usa la variable primeraLetraNombre
  181. style: TextStyle(
  182. fontWeight: FontWeight.bold,
  183. color: Color(0xFF0000FF),
  184. fontSize: 50),
  185. ),
  186. TextSpan(
  187. text:
  188. "$numeros\n", // Agrega un salto de línea después de los números
  189. style: const TextStyle(
  190. fontWeight:
  191. FontWeight.bold, // Estilo para los números
  192. color: Color(0xFF980000),
  193. fontSize: 30 // Por ejemplo, números en azul
  194. ),
  195. ),
  196. TextSpan(
  197. text: nombre, // El nombre en la siguiente línea
  198. style: const TextStyle(
  199. fontWeight:
  200. FontWeight.normal, // Estilo para el nombre
  201. color: Colors.black,
  202. fontSize: 30 // Por ejemplo, nombre en negro
  203. ),
  204. ),
  205. ],
  206. ),
  207. ),
  208. ]),
  209. const SizedBox(height: 20),
  210. RichText(
  211. text: TextSpan(
  212. text: 'Elección: ',
  213. style: const TextStyle(
  214. fontWeight: FontWeight.bold,
  215. color: Colors.black,
  216. fontSize: 16),
  217. children: <TextSpan>[
  218. TextSpan(
  219. text:
  220. widget._package["tipoEleccion"]["nombre"].toString(),
  221. style: const TextStyle(fontWeight: FontWeight.normal)),
  222. ],
  223. ),
  224. ),
  225. const SizedBox(height: 20),
  226. RichText(
  227. text: TextSpan(
  228. text: 'Ubicación: ',
  229. style: const TextStyle(
  230. fontWeight: FontWeight.bold,
  231. color: Colors.black,
  232. fontSize: 16),
  233. children: <TextSpan>[
  234. TextSpan(
  235. text: widget._package["casilla"]["ubicacion"].toString(),
  236. style: const TextStyle(fontWeight: FontWeight.normal)),
  237. ],
  238. ),
  239. ),
  240. const SizedBox(height: 10),
  241. const Divider(indent: 2, color: Colors.black),
  242. const SizedBox(height: 10),
  243. const Center(
  244. child: Text("Recibo Capturado",
  245. style:
  246. TextStyle(fontSize: 18, fontWeight: FontWeight.bold))),
  247. const SizedBox(height: 20),
  248. widget._package["ultimaRecepcion"]["fecha"] != null
  249. ? const Padding(
  250. padding: EdgeInsets.all(8.0),
  251. child: Center(
  252. child: Row(
  253. children: [
  254. Icon(Icons.description_outlined, size: 80),
  255. Text("Recibo de Captura")
  256. ],
  257. )))
  258. : const Padding(
  259. padding: EdgeInsets.all(8.0),
  260. child: Center(
  261. child: Row(
  262. children: [
  263. Icon(Icons.watch_later_outlined, size: 80),
  264. Text("Sin Recibo")
  265. ],
  266. )))
  267. ],
  268. ),
  269. ),
  270. );
  271. }
  272. }