lateral_menu_cliente.dart 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259
  1. import 'package:flutter/material.dart';
  2. import 'package:google_fonts/google_fonts.dart';
  3. import 'package:localstore/localstore.dart';
  4. import 'package:quiosco_soler_2/clientes/models/cuentas_bancarias.dart';
  5. import '../pages/avisos.dart';
  6. import '../pages/comentarios.dart';
  7. class LateralMenuCliente extends StatefulWidget {
  8. final CuentasBancarias cuentasBancarias;
  9. final void Function(bool) shouldRefresh;
  10. const LateralMenuCliente({Key? key, required this.cuentasBancarias, required this.shouldRefresh}) : super(key: key);
  11. @override
  12. State<LateralMenuCliente> createState() => _LateralMenuClienteState();
  13. }
  14. class _LateralMenuClienteState extends State<LateralMenuCliente> {
  15. final db = Localstore.instance;
  16. Map<String, dynamic> _info = {};
  17. bool _isLoading = true;
  18. @override
  19. void initState() {
  20. super.initState();
  21. init();
  22. }
  23. void init() async{
  24. final items = await db.collection('clientes').get();
  25. final key = items!.keys.last;
  26. _info = items[key];
  27. setState(() => _isLoading = false);
  28. }
  29. @override
  30. Widget build(BuildContext context) {
  31. return Drawer(
  32. child: ListView(
  33. padding: EdgeInsets.zero,
  34. children: [
  35. DrawerHeader(
  36. child: Column(
  37. mainAxisAlignment: MainAxisAlignment.center,
  38. crossAxisAlignment: CrossAxisAlignment.center,
  39. children: [
  40. Container(
  41. decoration: BoxDecoration(
  42. color: Colors.white,
  43. borderRadius: BorderRadius.circular(50.0),
  44. ),
  45. width: 64.0,
  46. height: 64.0,
  47. child: const Icon(
  48. Icons.account_circle,
  49. color: Color(0xFFFF0000),
  50. size: 64.0,
  51. ),
  52. ),
  53. const SizedBox(height: 8.0),
  54. const Text(
  55. 'CLIENTE',
  56. textAlign: TextAlign.center,
  57. style: TextStyle(
  58. fontFamily: 'Helvetica Neue Black Cond',
  59. fontSize: 18.0,
  60. color: Colors.white,
  61. ),
  62. ),
  63. const SizedBox(height: 16.0),
  64. ],
  65. ),
  66. decoration: const BoxDecoration(color: Color(0xFFFF0000)),
  67. ),
  68. if(_isLoading)
  69. const Center(
  70. child: CircularProgressIndicator(),
  71. ),
  72. if(!_isLoading)
  73. Column(
  74. children: [
  75. Container(
  76. child: Text(
  77. '${_info['dinum']}\n\n${_info['user']}',
  78. textAlign: TextAlign.center,
  79. style: GoogleFonts.roboto(
  80. fontWeight: FontWeight.w500,
  81. color: Colors.black,
  82. fontSize: 18.0,
  83. ),
  84. ),
  85. margin: const EdgeInsets.all(10.0),
  86. padding: const EdgeInsets.only(bottom: 10.0),
  87. decoration: const BoxDecoration(
  88. border: Border(
  89. bottom: BorderSide(
  90. color: Color.fromRGBO(255, 0, 0, 1),
  91. width: 2.0
  92. )
  93. )
  94. ),
  95. ),
  96. ListTile(
  97. leading: const Icon(
  98. Icons.account_balance_wallet,
  99. color: Color.fromRGBO(255, 0, 0, 1),
  100. size: 32.0,
  101. ),
  102. title: Text(
  103. 'CUENTAS BANCARIAS S&P',
  104. style: GoogleFonts.roboto(
  105. color: Colors.black,
  106. fontSize: 16.0
  107. ),
  108. ),
  109. onTap: (){
  110. showDialog(
  111. context: context,
  112. barrierDismissible: true,
  113. builder: (_) {
  114. List<String> infoElements = widget.cuentasBancarias.result!.info!.split('##');
  115. List<Widget> children = [];
  116. for(int i = 0; i < infoElements.length; i++){
  117. List<String> infoDetails = infoElements[i].split('|');
  118. for(int j = 0; j < infoDetails.length; j++){
  119. children.add(Container(
  120. child: Text(
  121. infoDetails[j],
  122. textAlign: TextAlign.start,
  123. style: GoogleFonts.roboto(
  124. fontSize: 16,
  125. fontWeight: j == 0 ? FontWeight.bold : FontWeight.normal
  126. ),
  127. ),
  128. margin: EdgeInsets.fromLTRB(
  129. 4.0,
  130. j == 0 ? 8.0 : 0.0,
  131. 4.0,
  132. j == 0 ? 12.0 : 0.0
  133. ),
  134. ));
  135. }
  136. children.add(const SizedBox(height: 8.0));
  137. }
  138. return AlertDialog(
  139. title: Text(
  140. 'Cuentas Bancarias S&P',
  141. textAlign: TextAlign.center,
  142. style: GoogleFonts.robotoSlab(
  143. fontWeight: FontWeight.bold,
  144. fontSize: 18.0
  145. ),
  146. ),
  147. content: Column(
  148. mainAxisSize: MainAxisSize.min,
  149. children: children,
  150. ),
  151. );
  152. },
  153. );
  154. },
  155. ),
  156. Container(
  157. margin: const EdgeInsets.symmetric(horizontal: 20.0),
  158. color: Colors.black12,
  159. height: 2.0,
  160. width: double.infinity,
  161. ),
  162. Container(
  163. margin: const EdgeInsets.symmetric(vertical: 8.0),
  164. padding: const EdgeInsets.symmetric(horizontal: 8.0, vertical: 8.0),
  165. child: Text(
  166. _buildDate(),
  167. style: GoogleFonts.roboto(
  168. color: Colors.black,
  169. fontSize: 16.0,
  170. fontWeight: FontWeight.w500
  171. ),
  172. textAlign: TextAlign.center,
  173. ),
  174. ),
  175. ListTile(
  176. leading: const Icon(
  177. Icons.help_outline,
  178. color: Color.fromRGBO(255, 0, 0, 1),
  179. size: 32.0,
  180. ),
  181. title: Text(
  182. 'DUDAS Y/O COMENTARIOS',
  183. style: GoogleFonts.roboto(
  184. color: Colors.black,
  185. fontSize: 16.0,
  186. fontWeight: FontWeight.w500
  187. ),
  188. ),
  189. onTap: () => Navigator.push(context, MaterialPageRoute(
  190. builder: (context) => ComentariosPage()
  191. )),
  192. ),
  193. ListTile(
  194. leading: const Icon(
  195. Icons.markunread,
  196. color: Color.fromRGBO(255, 0, 0, 1),
  197. size: 32.0,
  198. ),
  199. title: Text(
  200. 'AVISOS',
  201. style: GoogleFonts.roboto(
  202. color: Colors.black,
  203. fontSize: 16.0,
  204. fontWeight: FontWeight.w500
  205. ),
  206. ),
  207. onTap: () => Navigator.of(context).push(MaterialPageRoute(
  208. builder: (context) => AvisosPage()
  209. )),
  210. ),
  211. ListTile(
  212. leading: const Icon(
  213. Icons.refresh,
  214. color: Color.fromRGBO(255, 0, 0, 1),
  215. size: 32.0,
  216. ),
  217. title: Text(
  218. 'ACTUALIZAR DATOS',
  219. style: GoogleFonts.roboto(
  220. color: Colors.black,
  221. fontSize: 16.0,
  222. fontWeight: FontWeight.w500
  223. ),
  224. ),
  225. onTap: (){
  226. widget.shouldRefresh(true);
  227. Navigator.pop(context);
  228. },
  229. )
  230. ],
  231. )
  232. ],
  233. ),
  234. );
  235. }
  236. String _buildDate(){
  237. int dayInt = DateTime.now().day;
  238. int monthInt = DateTime.now().month;
  239. int year = DateTime.now().year;
  240. String day = dayInt < 10 ? "0$dayInt" : "$dayInt";
  241. String month = monthInt < 10 ? "0$monthInt" : "$monthInt";
  242. return "FECHA - $day/$month/$year";
  243. }
  244. }