widgets_components.dart 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763
  1. // ignore_for_file: use_build_context_synchronously, prefer_if_null_operators, prefer_conditional_assignment
  2. import 'dart:io';
  3. import 'dart:typed_data';
  4. import 'package:camera/camera.dart';
  5. import 'package:flutter/material.dart';
  6. import 'package:intl/intl.dart';
  7. import 'package:omni_datetime_picker/omni_datetime_picker.dart';
  8. import 'package:flutter/material.dart' as d;
  9. import 'package:datetime_picker_formfield/datetime_picker_formfield.dart' as d2;
  10. import 'package:provider/provider.dart';
  11. import 'package:url_launcher/url_launcher.dart';
  12. import 'package:flutter/foundation.dart' show kIsWeb;
  13. import 'package:path_provider/path_provider.dart';
  14. import '../data/session/session_storage.dart';
  15. import '../models/media_model.dart';
  16. import '../themes/themes.dart';
  17. import 'package:timezone/timezone.dart' as tz;
  18. import 'package:http/http.dart' as http;
  19. import "package:universal_html/html.dart" as html;
  20. //import 'dart:html';
  21. //import 'dart:html' as html;
  22. encabezado(
  23. {double elevacion = 1,
  24. List<Widget>? acciones,
  25. PreferredSize? bottom,
  26. Color? backgroundColor,
  27. String? nombre,
  28. Widget? leading = null,
  29. String? titulo,
  30. bool centerTitle = true}) {
  31. TextStyle estilo = const TextStyle(fontWeight: FontWeight.bold);
  32. if (acciones == null) {
  33. acciones = [];
  34. }
  35. return AppBar(
  36. leading: leading,
  37. elevation: elevacion,
  38. backgroundColor: backgroundColor,
  39. centerTitle: centerTitle,
  40. title: titulo == null
  41. ? Image.asset("assets/icono-BN.png", width: 100)
  42. : Text(titulo.toString(), style: estilo),
  43. actions: [
  44. ...acciones,
  45. Image.asset("assets/icono-BN.png", width: 100),
  46. ],
  47. bottom: bottom);
  48. }
  49. tarjeta(Widget item, {Color color = Colors.white, double padding = 0}) {
  50. if (padding > 0) {
  51. return Padding(
  52. padding: const EdgeInsets.all(0),
  53. child: Card(
  54. color: color,
  55. shape:
  56. RoundedRectangleBorder(borderRadius: BorderRadius.circular(10)),
  57. margin: const EdgeInsets.only(bottom: 16),
  58. elevation: 0,
  59. borderOnForeground: true,
  60. child: Padding(padding: EdgeInsets.all(padding), child: item)));
  61. }
  62. return Card(
  63. color: color,
  64. shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(10)),
  65. margin: const EdgeInsets.only(bottom: 8),
  66. elevation: 0,
  67. borderOnForeground: true,
  68. child: Padding(
  69. padding: const EdgeInsets.all(8),
  70. child: item,
  71. ));
  72. }
  73. class Cargando extends StatelessWidget {
  74. const Cargando({super.key});
  75. @override
  76. Widget build(BuildContext context) {
  77. return Scaffold(
  78. backgroundColor: const Color(0xFFE0E0E0),
  79. body: Center(
  80. child: Column(mainAxisAlignment: MainAxisAlignment.center, children: [
  81. Padding(
  82. padding: const EdgeInsets.fromLTRB(16, 0, 16, 10),
  83. child: Image.asset("assets/icono-BN.png", height: 200)),
  84. const CircularProgressIndicator(backgroundColor: Colors.grey),
  85. Container(margin: const EdgeInsets.only(bottom: 8.0)),
  86. const Text("Cargando contenido...",
  87. style: TextStyle(
  88. fontWeight: FontWeight.bold,
  89. fontSize: 16,
  90. color: Colors.black)),
  91. const Text("Por favor espere.",
  92. style: TextStyle(
  93. fontWeight: FontWeight.bold,
  94. fontSize: 16,
  95. color: Colors.black),
  96. textAlign: TextAlign.center)
  97. ]),
  98. ));
  99. }
  100. }
  101. boton(String etiqueta, Function()? accion,
  102. {double height = 75, double width = 380}) {
  103. return Align(
  104. alignment: Alignment.topLeft,
  105. child: SizedBox(
  106. height: height,
  107. width: 380,
  108. child: ElevatedButton(
  109. style: ButtonStyle(
  110. shape: MaterialStatePropertyAll(
  111. RoundedRectangleBorder(
  112. borderRadius: BorderRadius.circular(10),
  113. ),
  114. ),
  115. backgroundColor: MaterialStatePropertyAll(AppTheme.primary),
  116. ),
  117. onPressed: accion,
  118. child: Row(
  119. mainAxisAlignment: MainAxisAlignment.center,
  120. children: [
  121. Text(etiqueta,
  122. style: TextStyle(fontSize: 18, color: AppTheme.secondary)),
  123. ],
  124. ),
  125. ),
  126. ),
  127. );
  128. }
  129. Future<DateTime?> showHora(BuildContext context, DateTime? fecha) async {
  130. if (fecha == null) {
  131. return fecha;
  132. }
  133. final tiempo = await showTimePicker(
  134. useRootNavigator: false,
  135. helpText: "CAPTURAR HORA",
  136. confirmText: "ACEPTAR",
  137. cancelText: "CANCELAR",
  138. hourLabelText: "HORA",
  139. minuteLabelText: "MINUTO",
  140. initialEntryMode: TimePickerEntryMode.input,
  141. context: context,
  142. initialTime: TimeOfDay.fromDateTime(fecha),
  143. builder: (context, childs) {
  144. return MediaQuery(
  145. data: MediaQuery.of(context).copyWith(
  146. alwaysUse24HourFormat: true,
  147. padding: const EdgeInsets.all(1),
  148. size: const Size.square(1),
  149. textScaler: const TextScaler.linear(.8)),
  150. child: childs!);
  151. },
  152. );
  153. return d2.DateTimeField.combine(fecha!, tiempo);
  154. }
  155. Future<DateTime?> showDatetimePicker(BuildContext context, DateTime? fecha,
  156. {DateTime? inicia,
  157. DateTime? termina,
  158. OmniDateTimePickerType tipo = OmniDateTimePickerType.dateAndTime,
  159. bool solofecha = false}) async {
  160. if (termina == null) {
  161. termina = DateTime(2030);
  162. }
  163. final f = await showDatePicker(
  164. context: context,
  165. initialDate: fecha ?? DateTime.now(),
  166. firstDate: inicia ?? DateTime(2023),
  167. lastDate: termina,
  168. cancelText: "CANCELAR",
  169. confirmText: "ACEPTAR",
  170. builder: (context, child) {
  171. return Theme(
  172. data: Theme.of(context).copyWith(
  173. colorScheme: ColorScheme.light(
  174. primary: AppTheme.primary,
  175. onSurface: AppTheme.secondary,
  176. ),
  177. textButtonTheme: TextButtonThemeData(
  178. style: TextButton.styleFrom(
  179. backgroundColor: AppTheme.secondary,
  180. ),
  181. ),
  182. ),
  183. child: child!,
  184. );
  185. },
  186. );
  187. if (f == null || solofecha) {
  188. return f;
  189. }
  190. final tiempo = await showTimePicker(
  191. context: context,
  192. initialTime: TimeOfDay.fromDateTime(f),
  193. helpText: "CAPTURAR HORA",
  194. confirmText: "ACEPTAR",
  195. cancelText: "CANCELAR",
  196. hourLabelText: "HORA",
  197. minuteLabelText: "MINUTO",
  198. initialEntryMode: TimePickerEntryMode.input,
  199. builder: (context, child) {
  200. return Theme(
  201. data: Theme.of(context).copyWith(
  202. colorScheme: ColorScheme.light(
  203. primary: AppTheme.primary,
  204. onSurface: AppTheme.secondary,
  205. ),
  206. textButtonTheme: TextButtonThemeData(
  207. style: TextButton.styleFrom(
  208. backgroundColor: AppTheme.secondary,
  209. ),
  210. ),
  211. ),
  212. child: child!,
  213. );
  214. },
  215. );
  216. return d2.DateTimeField.combine(f, tiempo);
  217. }
  218. class FechaSelectWidget extends StatelessWidget {
  219. final DateTime? fecha;
  220. final Function(DateTime) onFechaChanged;
  221. final String etiqueta;
  222. final BuildContext context;
  223. const FechaSelectWidget({
  224. Key? key,
  225. required this.fecha,
  226. required this.onFechaChanged,
  227. required this.etiqueta,
  228. required this.context,
  229. }) : super(key: key);
  230. @override
  231. Widget build(BuildContext context) {
  232. return Column(
  233. crossAxisAlignment: CrossAxisAlignment.start,
  234. children: [
  235. Text(
  236. etiqueta,
  237. style: const TextStyle(
  238. fontWeight: FontWeight.bold,
  239. fontSize: 16,
  240. ),
  241. ),
  242. const SizedBox(height: 5),
  243. InkWell(
  244. onTap: () async {
  245. DateTime? d = await showDatetimePicker(
  246. context,
  247. fecha,
  248. tipo: OmniDateTimePickerType.date,
  249. solofecha: true,
  250. );
  251. if (d == null) return;
  252. onFechaChanged(d);
  253. },
  254. child: Container(
  255. decoration: BoxDecoration(
  256. border: Border.all(color: Colors.grey[400]!),
  257. borderRadius: BorderRadius.circular(10),
  258. ),
  259. padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 15),
  260. child: Row(
  261. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  262. children: [
  263. Text(
  264. fecha == null
  265. ? "Seleccionar"
  266. : DateFormat("dd/MM/yyyy").format(fecha!),
  267. style: TextStyle(
  268. color: fecha == null ? Colors.grey : Colors.black,
  269. ),
  270. ),
  271. const Icon(Icons.calendar_month),
  272. ],
  273. ),
  274. ),
  275. ),
  276. ],
  277. );
  278. }
  279. }
  280. Widget circulo(Widget item, {Function()? accion, Color? color}) {
  281. color ??= Colors.black;
  282. return InkWell(
  283. onTap: accion,
  284. child: Container(
  285. decoration: BoxDecoration(
  286. border: Border.all(
  287. color: color, // <--- border color
  288. width: 2.0,
  289. ),
  290. borderRadius: const BorderRadius.all(
  291. Radius.circular(50) // <--- border radius here
  292. ),
  293. ),
  294. child: item));
  295. }
  296. alerta(BuildContext context, {String? etiqueta = "Capturar búsqueda"}) {
  297. return showDialog(
  298. context: context,
  299. builder: (context) {
  300. return AlertDialog(
  301. title: Text(etiqueta.toString()),
  302. actions: [
  303. Row(children: [
  304. Expanded(
  305. child: TextButton(
  306. style: ButtonStyle(
  307. backgroundColor: MaterialStatePropertyAll(Colors.black)),
  308. onPressed: () async {
  309. Navigator.pop(context);
  310. },
  311. child: const Text(
  312. 'Continuar',
  313. style: TextStyle(color: Colors.white),
  314. ),
  315. ))
  316. ])
  317. ],
  318. );
  319. });
  320. }
  321. botonElevated(
  322. {Function()? accion,
  323. String? titulo = "Buscar",
  324. Color color = Colors.black}) {
  325. return ElevatedButton(
  326. style: ElevatedButton.styleFrom(
  327. backgroundColor: color,
  328. shape: RoundedRectangleBorder(
  329. borderRadius: BorderRadius.circular(12), // <-- Radius
  330. )),
  331. onPressed: accion,
  332. child: Text(
  333. titulo.toString(),
  334. style: const TextStyle(color: Colors.white),
  335. ),
  336. );
  337. }
  338. Widget xMedia(XFile m) {
  339. bool archivo = false;
  340. Widget icono = const Icon(Icons.file_copy, size: 50);
  341. int lastIndex = m.name.lastIndexOf('.');
  342. String extension = "";
  343. if (lastIndex != -1 && lastIndex < m.name.length - 1) {
  344. extension = m.name.substring(lastIndex + 1);
  345. }
  346. switch (extension) {
  347. case "mp4":
  348. archivo = true;
  349. icono = const Icon(Icons.video_file, size: 50);
  350. break;
  351. case "wav":
  352. archivo = true;
  353. icono = Image.asset("assets/audio-file.png");
  354. archivo = true;
  355. break;
  356. case "jpeg":
  357. case "jpg":
  358. case "png":
  359. break;
  360. case "pdf":
  361. icono = Image.asset("assets/pdf-file.png");
  362. archivo = true;
  363. break;
  364. case "csv":
  365. case "docx":
  366. icono = Image.asset("assets/word.png");
  367. archivo = true;
  368. break;
  369. case "xlsx":
  370. icono = Image.asset("assets/excel.png");
  371. archivo = true;
  372. break;
  373. }
  374. String nombre = m.name.toString();
  375. if (nombre.length > 25) {
  376. nombre = "${m.name.toString().substring(0, 24)}...";
  377. }
  378. return InkWell(
  379. onTap: () async {
  380. String url = m.path.toString();
  381. await canLaunch(url)
  382. ? await launch(url, forceSafariVC: false, forceWebView: false)
  383. : print('Could not launch '); //aqui
  384. },
  385. child: Stack(alignment: Alignment.center, children: [
  386. Container(
  387. height: 100.0,
  388. width: 100.0,
  389. clipBehavior: Clip.antiAlias,
  390. decoration: BoxDecoration(
  391. border: Border.all(color: Colors.black, width: 1.0),
  392. borderRadius: const BorderRadius.all(Radius.circular(15.0)),
  393. ),
  394. child: archivo
  395. ? icono
  396. : Image.network(m.path.toString(),
  397. scale:
  398. 1) // _firma == null?const Icon(Icons.pages, size: 30, color: Colors.black): contenedorFirma,
  399. ),
  400. Positioned(
  401. bottom: 0,
  402. child: Container(
  403. width: 200,
  404. height: 40,
  405. color: Colors.grey.shade800,
  406. child: Column(
  407. mainAxisAlignment: MainAxisAlignment.center,
  408. children: [
  409. Text(
  410. nombre,
  411. textAlign: TextAlign.center,
  412. textScaler: const TextScaler.linear(.8),
  413. style: const TextStyle(color: Colors.white),
  414. ),
  415. ]),
  416. )),
  417. ]));
  418. }
  419. Widget wMedia(Media m, {Function()? eliminar}) {
  420. bool archivo = false;
  421. Widget icono = const Icon(Icons.file_copy, size: 50);
  422. switch (m.extension) {
  423. case "mp4":
  424. archivo = true;
  425. icono = const Icon(Icons.video_file, size: 50);
  426. break;
  427. case "wav":
  428. archivo = true;
  429. icono = Image.asset("assets/audio-file.png");
  430. archivo = true;
  431. break;
  432. case "jpeg":
  433. case "jpg":
  434. case "png":
  435. break;
  436. case "pdf":
  437. icono = Image.asset("assets/pdf-file.png");
  438. archivo = true;
  439. break;
  440. case "csv":
  441. case "docx":
  442. icono = Image.asset("assets/word.png");
  443. archivo = true;
  444. break;
  445. case "xlsx":
  446. icono = Image.asset("assets/excel.png");
  447. archivo = true;
  448. break;
  449. }
  450. String fecha = "";
  451. if (m.creado != null) {
  452. String timeZone = 'America/Hermosillo';
  453. fecha = formatFechaConZonaHoraria(m.creado!, timeZone);
  454. }
  455. String nombre = m.nombre.toString();
  456. if (nombre.length > 25) {
  457. nombre = "${m.nombre.toString().substring(0, 24)}...";
  458. }
  459. return InkWell(
  460. onTap: () async {
  461. String url = m.ruta.toString();
  462. await canLaunch(url)
  463. ? await launch(url, forceSafariVC: false, forceWebView: false)
  464. : print('Could not launch '); //aqui
  465. },
  466. child: Stack(alignment: Alignment.center, children: [
  467. Container(
  468. height: 160.0,
  469. width: 160.0,
  470. clipBehavior: Clip.antiAlias,
  471. decoration: BoxDecoration(
  472. border: Border.all(color: Colors.black, width: 1.0),
  473. borderRadius: const BorderRadius.all(Radius.circular(15.0)),
  474. ),
  475. child: archivo
  476. ? icono
  477. : Image.network(m.ruta.toString(),
  478. scale:
  479. 1) // _firma == null?const Icon(Icons.pages, size: 30, color: Colors.black): contenedorFirma,
  480. ),
  481. Positioned(
  482. bottom: 0,
  483. child: Container(
  484. width: 500,
  485. height: 40,
  486. color: Colors.grey.shade800,
  487. child: Column(
  488. mainAxisAlignment: MainAxisAlignment.center,
  489. children: [
  490. Text(
  491. nombre,
  492. textAlign: TextAlign.center,
  493. textScaler: const TextScaler.linear(.8),
  494. style: const TextStyle(color: Colors.white),
  495. ),
  496. Text(
  497. fecha,
  498. textAlign: TextAlign.center,
  499. textScaler: const TextScaler.linear(.8),
  500. style: const TextStyle(color: Colors.white),
  501. ),
  502. ]),
  503. )),
  504. Positioned(
  505. left: 0,
  506. top: 0,
  507. child: ElevatedButton(
  508. onPressed: eliminar,
  509. style: ElevatedButton.styleFrom(
  510. shape: CircleBorder(),
  511. padding: EdgeInsets.all(16),
  512. ),
  513. child: Icon(
  514. Icons.delete,
  515. color: Colors.red.shade800,
  516. ),
  517. ),
  518. ),
  519. ]));
  520. }
  521. Widget agregarMedia(
  522. {Color color = Colors.green,
  523. Function()? accion,
  524. String titulo = "Agregar Media",
  525. Icon? icono,
  526. double tamano = 160}) {
  527. if (icono == null) {
  528. icono = Icon(
  529. Icons.add,
  530. size: tamano < 100 ? 60 : 100,
  531. color: Colors.white,
  532. );
  533. }
  534. return InkWell(
  535. onTap: accion,
  536. child: Stack(alignment: Alignment.center, children: [
  537. // Contenedor con un color de fondo y dimensiones específicas
  538. Container(
  539. width: tamano,
  540. height: tamano,
  541. color: color,
  542. ),
  543. // Texto flotante
  544. Positioned(
  545. child:
  546. Column(mainAxisAlignment: MainAxisAlignment.center, children: [
  547. icono,
  548. titulo.isEmpty
  549. ? Container()
  550. : Text(
  551. titulo,
  552. style: const TextStyle(
  553. color: Colors.white,
  554. fontSize: 16,
  555. ),
  556. ),
  557. ])),
  558. ]));
  559. }
  560. String formatFechaConZonaHoraria(DateTime dateTime, String timeZone) {
  561. // Obtiene la ubicación de la zona horaria
  562. tz.Location location = tz.getLocation(timeZone);
  563. // Convierte la fecha a la zona horaria deseada
  564. tz.TZDateTime fechaConZona = tz.TZDateTime.from(dateTime, location);
  565. // Formatea la fecha con la zona horaria
  566. //String formattedFecha = DateFormat("dd/MM/yyyy HH:mm '($timeZone)'").format(fechaConZona);
  567. String formattedFecha = DateFormat("dd/MM/yyyy HH:mm").format(fechaConZona);
  568. return formattedFecha;
  569. }
  570. html.Location getLocation(String timeZone) {
  571. // Obtiene la ubicación de la zona horaria
  572. return getLocation(timeZone);
  573. }
  574. int obtenerAxiscount(Size s) {
  575. int axiscount = 8;
  576. if (s.width > 1300) {
  577. axiscount = 8;
  578. }
  579. if (s.width > 900 && s.width < 1300) {
  580. axiscount = 5;
  581. }
  582. if (s.width > 700 && s.width < 900) {
  583. axiscount = 4;
  584. }
  585. if (s.width > 600 && s.width < 700) {
  586. axiscount = 3;
  587. }
  588. if (s.width < 600) {
  589. axiscount = 2;
  590. }
  591. return axiscount;
  592. }
  593. imprimirExcel(String url, String nombre) async {
  594. var t = await SessionStorage().getToken();
  595. Map<String, String> headers = {
  596. 'Authorization': 'Bearer $t',
  597. 'Content-Type': 'application/json', // Puedes ajustar según sea necesario
  598. };
  599. http.Response response = await http.get(
  600. Uri.parse(url),
  601. headers: headers,
  602. );
  603. if (response.statusCode == 200) {
  604. // Obtener el contenido del archivo como Uint8List
  605. Uint8List fileBytes = response.bodyBytes;
  606. if (!kIsWeb) {
  607. // Lógica para dispositivos móviles y escritorio
  608. final directory = await getApplicationDocumentsDirectory();
  609. final path = '${directory.path}/$nombre.xlsx';
  610. final file = File(path);
  611. await file.writeAsBytes(fileBytes);
  612. final Uri fileUri = Uri.file(path);
  613. if (await canLaunchUrl(fileUri)) {
  614. await launchUrl(fileUri);
  615. } else {
  616. throw 'No se pudo abrir el archivo';
  617. }
  618. return; // Retorna después de manejar la lógica de dispositivos móviles
  619. }
  620. // Lógica específica para la web sigue aquí
  621. // Asegúrate de que este código solo se ejecute en la web
  622. if (kIsWeb) {
  623. // Crea y descarga el archivo para la web
  624. final blob = html.Blob([fileBytes]);
  625. final url = html.Url.createObjectUrlFromBlob(blob);
  626. final anchor = html.AnchorElement(href: url)
  627. ..setAttribute('download', '$nombre.xlsx')
  628. ..click();
  629. html.Url.revokeObjectUrl(url);
  630. }
  631. } else {
  632. print(
  633. 'Error al descargar el archivo. Código de estado: ${response.statusCode}');
  634. }
  635. }
  636. imprimirPdf(String url, String nombre) async {
  637. var t = await SessionStorage().getToken();
  638. Map<String, String> headers = {
  639. 'Authorization': 'Bearer $t',
  640. 'Content-Type': 'application/json', // Puedes ajustar según sea necesario
  641. };
  642. http.Response response = await http.get(
  643. Uri.parse(url),
  644. headers: headers,
  645. );
  646. if (response.statusCode == 200) {
  647. // Obtener el contenido del archivo como Uint8List
  648. Uint8List fileBytes = response.bodyBytes;
  649. // Crear un blob con los bytes del archivo
  650. final blob = html.Blob([fileBytes]);
  651. // Crear un objeto URL para el blob
  652. final url = html.Url.createObjectUrlFromBlob(blob);
  653. // Crear un enlace de descarga y hacer clic en él para descargar el archivo
  654. final anchor = html.AnchorElement(href: url)
  655. ..target = 'blank'
  656. ..download =
  657. '$nombre.pdf'; // Ajustar el nombre y la extensión del archivo
  658. anchor.click();
  659. // Liberar el objeto URL
  660. html.Url.revokeObjectUrl(url);
  661. } else {
  662. print(
  663. 'Error al descargar el archivo. Código de estado: ${response.statusCode}');
  664. }
  665. }
  666. Widget usuarioHeader(String nombre, String correo) {
  667. return Row(
  668. mainAxisAlignment: MainAxisAlignment.center,
  669. crossAxisAlignment: CrossAxisAlignment.center,
  670. children: [
  671. Column(
  672. mainAxisAlignment: MainAxisAlignment.center,
  673. crossAxisAlignment: CrossAxisAlignment.end,
  674. children: [
  675. Text(nombre,
  676. style: TextStyle(
  677. color: Colors.black, fontWeight: FontWeight.bold),
  678. textAlign: TextAlign.right),
  679. Text(correo,
  680. style: TextStyle(color: Colors.grey.shade900),
  681. textAlign: TextAlign.right),
  682. ]),
  683. Text(" "),
  684. CircleAvatar(
  685. child: Icon(Icons.verified_user, color: Colors.white),
  686. backgroundColor: Colors.black),
  687. Text(" "),
  688. ]);
  689. }
  690. Future eliminarMedia(
  691. BuildContext context, Media m, Function()? confirmacion) async {
  692. return await showDialog(
  693. context: context,
  694. builder: (context) {
  695. return AlertDialog(
  696. surfaceTintColor: AppTheme.secondary,
  697. title: const Text('¿Desea eliminar esta archivo?'),
  698. actions: [
  699. TextButton(
  700. onPressed: () {
  701. Navigator.pop(context);
  702. },
  703. child: const Text('Cancelar'),
  704. ),
  705. TextButton(
  706. onPressed: confirmacion,
  707. child: const Text(
  708. 'Sí, estoy seguro',
  709. style: TextStyle(color: Colors.red),
  710. ),
  711. ),
  712. ],
  713. );
  714. },
  715. );
  716. }