widgets_components.dart 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758
  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. primary: 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. primary: 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. onPressed: () async {
  307. Navigator.pop(context);
  308. },
  309. child: const Text('Continuar'),
  310. ))
  311. ])
  312. ],
  313. );
  314. });
  315. }
  316. botonElevated(
  317. {Function()? accion,
  318. String? titulo = "Buscar",
  319. Color color = Colors.black}) {
  320. return ElevatedButton(
  321. style: ElevatedButton.styleFrom(
  322. backgroundColor: color,
  323. shape: RoundedRectangleBorder(
  324. borderRadius: BorderRadius.circular(12), // <-- Radius
  325. )),
  326. onPressed: accion,
  327. child: Text(
  328. titulo.toString(),
  329. style: const TextStyle(color: Colors.white),
  330. ),
  331. );
  332. }
  333. Widget xMedia(XFile m) {
  334. bool archivo = false;
  335. Widget icono = const Icon(Icons.file_copy, size: 50);
  336. int lastIndex = m.name.lastIndexOf('.');
  337. String extension = "";
  338. if (lastIndex != -1 && lastIndex < m.name.length - 1) {
  339. extension = m.name.substring(lastIndex + 1);
  340. }
  341. switch (extension) {
  342. case "mp4":
  343. archivo = true;
  344. icono = const Icon(Icons.video_file, size: 50);
  345. break;
  346. case "wav":
  347. archivo = true;
  348. icono = Image.asset("assets/audio-file.png");
  349. archivo = true;
  350. break;
  351. case "jpeg":
  352. case "jpg":
  353. case "png":
  354. break;
  355. case "pdf":
  356. icono = Image.asset("assets/pdf-file.png");
  357. archivo = true;
  358. break;
  359. case "csv":
  360. case "docx":
  361. icono = Image.asset("assets/word.png");
  362. archivo = true;
  363. break;
  364. case "xlsx":
  365. icono = Image.asset("assets/excel.png");
  366. archivo = true;
  367. break;
  368. }
  369. String nombre = m.name.toString();
  370. if (nombre.length > 25) {
  371. nombre = "${m.name.toString().substring(0, 24)}...";
  372. }
  373. return InkWell(
  374. onTap: () async {
  375. String url = m.path.toString();
  376. await canLaunch(url)
  377. ? await launch(url, forceSafariVC: false, forceWebView: false)
  378. : print('Could not launch '); //aqui
  379. },
  380. child: Stack(alignment: Alignment.center, children: [
  381. Container(
  382. height: 100.0,
  383. width: 100.0,
  384. clipBehavior: Clip.antiAlias,
  385. decoration: BoxDecoration(
  386. border: Border.all(color: Colors.black, width: 1.0),
  387. borderRadius: const BorderRadius.all(Radius.circular(15.0)),
  388. ),
  389. child: archivo
  390. ? icono
  391. : Image.network(m.path.toString(),
  392. scale:
  393. 1) // _firma == null?const Icon(Icons.pages, size: 30, color: Colors.black): contenedorFirma,
  394. ),
  395. Positioned(
  396. bottom: 0,
  397. child: Container(
  398. width: 200,
  399. height: 40,
  400. color: Colors.grey.shade800,
  401. child: Column(
  402. mainAxisAlignment: MainAxisAlignment.center,
  403. children: [
  404. Text(
  405. nombre,
  406. textAlign: TextAlign.center,
  407. textScaler: const TextScaler.linear(.8),
  408. style: const TextStyle(color: Colors.white),
  409. ),
  410. ]),
  411. )),
  412. ]));
  413. }
  414. Widget wMedia(Media m, {Function()? eliminar}) {
  415. bool archivo = false;
  416. Widget icono = const Icon(Icons.file_copy, size: 50);
  417. switch (m.extension) {
  418. case "mp4":
  419. archivo = true;
  420. icono = const Icon(Icons.video_file, size: 50);
  421. break;
  422. case "wav":
  423. archivo = true;
  424. icono = Image.asset("assets/audio-file.png");
  425. archivo = true;
  426. break;
  427. case "jpeg":
  428. case "jpg":
  429. case "png":
  430. break;
  431. case "pdf":
  432. icono = Image.asset("assets/pdf-file.png");
  433. archivo = true;
  434. break;
  435. case "csv":
  436. case "docx":
  437. icono = Image.asset("assets/word.png");
  438. archivo = true;
  439. break;
  440. case "xlsx":
  441. icono = Image.asset("assets/excel.png");
  442. archivo = true;
  443. break;
  444. }
  445. String fecha = "";
  446. if (m.creado != null) {
  447. String timeZone = 'America/Hermosillo';
  448. fecha = formatFechaConZonaHoraria(m.creado!, timeZone);
  449. }
  450. String nombre = m.nombre.toString();
  451. if (nombre.length > 25) {
  452. nombre = "${m.nombre.toString().substring(0, 24)}...";
  453. }
  454. return InkWell(
  455. onTap: () async {
  456. String url = m.ruta.toString();
  457. await canLaunch(url)
  458. ? await launch(url, forceSafariVC: false, forceWebView: false)
  459. : print('Could not launch '); //aqui
  460. },
  461. child: Stack(alignment: Alignment.center, children: [
  462. Container(
  463. height: 160.0,
  464. width: 160.0,
  465. clipBehavior: Clip.antiAlias,
  466. decoration: BoxDecoration(
  467. border: Border.all(color: Colors.black, width: 1.0),
  468. borderRadius: const BorderRadius.all(Radius.circular(15.0)),
  469. ),
  470. child: archivo
  471. ? icono
  472. : Image.network(m.ruta.toString(),
  473. scale:
  474. 1) // _firma == null?const Icon(Icons.pages, size: 30, color: Colors.black): contenedorFirma,
  475. ),
  476. Positioned(
  477. bottom: 0,
  478. child: Container(
  479. width: 500,
  480. height: 40,
  481. color: Colors.grey.shade800,
  482. child: Column(
  483. mainAxisAlignment: MainAxisAlignment.center,
  484. children: [
  485. Text(
  486. nombre,
  487. textAlign: TextAlign.center,
  488. textScaler: const TextScaler.linear(.8),
  489. style: const TextStyle(color: Colors.white),
  490. ),
  491. Text(
  492. fecha,
  493. textAlign: TextAlign.center,
  494. textScaler: const TextScaler.linear(.8),
  495. style: const TextStyle(color: Colors.white),
  496. ),
  497. ]),
  498. )),
  499. Positioned(
  500. left: 0,
  501. top: 0,
  502. child: ElevatedButton(
  503. onPressed: eliminar,
  504. style: ElevatedButton.styleFrom(
  505. shape: CircleBorder(),
  506. padding: EdgeInsets.all(16),
  507. ),
  508. child: Icon(
  509. Icons.delete,
  510. color: Colors.red.shade800,
  511. ),
  512. ),
  513. ),
  514. ]));
  515. }
  516. Widget agregarMedia(
  517. {Color color = Colors.green,
  518. Function()? accion,
  519. String titulo = "Agregar Media",
  520. Icon? icono,
  521. double tamano = 160}) {
  522. if (icono == null) {
  523. icono = Icon(
  524. Icons.add,
  525. size: tamano < 100 ? 60 : 100,
  526. color: Colors.white,
  527. );
  528. }
  529. return InkWell(
  530. onTap: accion,
  531. child: Stack(alignment: Alignment.center, children: [
  532. // Contenedor con un color de fondo y dimensiones específicas
  533. Container(
  534. width: tamano,
  535. height: tamano,
  536. color: color,
  537. ),
  538. // Texto flotante
  539. Positioned(
  540. child:
  541. Column(mainAxisAlignment: MainAxisAlignment.center, children: [
  542. icono,
  543. titulo.isEmpty
  544. ? Container()
  545. : Text(
  546. titulo,
  547. style: const TextStyle(
  548. color: Colors.white,
  549. fontSize: 16,
  550. ),
  551. ),
  552. ])),
  553. ]));
  554. }
  555. String formatFechaConZonaHoraria(DateTime dateTime, String timeZone) {
  556. // Obtiene la ubicación de la zona horaria
  557. tz.Location location = tz.getLocation(timeZone);
  558. // Convierte la fecha a la zona horaria deseada
  559. tz.TZDateTime fechaConZona = tz.TZDateTime.from(dateTime, location);
  560. // Formatea la fecha con la zona horaria
  561. //String formattedFecha = DateFormat("dd/MM/yyyy HH:mm '($timeZone)'").format(fechaConZona);
  562. String formattedFecha = DateFormat("dd/MM/yyyy HH:mm").format(fechaConZona);
  563. return formattedFecha;
  564. }
  565. html.Location getLocation(String timeZone) {
  566. // Obtiene la ubicación de la zona horaria
  567. return getLocation(timeZone);
  568. }
  569. int obtenerAxiscount(Size s) {
  570. int axiscount = 8;
  571. if (s.width > 1300) {
  572. axiscount = 8;
  573. }
  574. if (s.width > 900 && s.width < 1300) {
  575. axiscount = 5;
  576. }
  577. if (s.width > 700 && s.width < 900) {
  578. axiscount = 4;
  579. }
  580. if (s.width > 600 && s.width < 700) {
  581. axiscount = 3;
  582. }
  583. if (s.width < 600) {
  584. axiscount = 2;
  585. }
  586. return axiscount;
  587. }
  588. imprimirExcel(String url, String nombre) async {
  589. var t = await SessionStorage().getToken();
  590. Map<String, String> headers = {
  591. 'Authorization': 'Bearer $t',
  592. 'Content-Type': 'application/json', // Puedes ajustar según sea necesario
  593. };
  594. http.Response response = await http.get(
  595. Uri.parse(url),
  596. headers: headers,
  597. );
  598. if (response.statusCode == 200) {
  599. // Obtener el contenido del archivo como Uint8List
  600. Uint8List fileBytes = response.bodyBytes;
  601. if (!kIsWeb) {
  602. // Lógica para dispositivos móviles y escritorio
  603. final directory = await getApplicationDocumentsDirectory();
  604. final path = '${directory.path}/$nombre.xlsx';
  605. final file = File(path);
  606. await file.writeAsBytes(fileBytes);
  607. final Uri fileUri = Uri.file(path);
  608. if (await canLaunchUrl(fileUri)) {
  609. await launchUrl(fileUri);
  610. } else {
  611. throw 'No se pudo abrir el archivo';
  612. }
  613. return; // Retorna después de manejar la lógica de dispositivos móviles
  614. }
  615. // Lógica específica para la web sigue aquí
  616. // Asegúrate de que este código solo se ejecute en la web
  617. if (kIsWeb) {
  618. // Crea y descarga el archivo para la web
  619. final blob = html.Blob([fileBytes]);
  620. final url = html.Url.createObjectUrlFromBlob(blob);
  621. final anchor = html.AnchorElement(href: url)
  622. ..setAttribute('download', '$nombre.xlsx')
  623. ..click();
  624. html.Url.revokeObjectUrl(url);
  625. }
  626. } else {
  627. print(
  628. 'Error al descargar el archivo. Código de estado: ${response.statusCode}');
  629. }
  630. }
  631. imprimirPdf(String url, String nombre) async {
  632. var t = await SessionStorage().getToken();
  633. Map<String, String> headers = {
  634. 'Authorization': 'Bearer $t',
  635. 'Content-Type': 'application/json', // Puedes ajustar según sea necesario
  636. };
  637. http.Response response = await http.get(
  638. Uri.parse(url),
  639. headers: headers,
  640. );
  641. if (response.statusCode == 200) {
  642. // Obtener el contenido del archivo como Uint8List
  643. Uint8List fileBytes = response.bodyBytes;
  644. // Crear un blob con los bytes del archivo
  645. final blob = html.Blob([fileBytes]);
  646. // Crear un objeto URL para el blob
  647. final url = html.Url.createObjectUrlFromBlob(blob);
  648. // Crear un enlace de descarga y hacer clic en él para descargar el archivo
  649. final anchor = html.AnchorElement(href: url)
  650. ..target = 'blank'
  651. ..download =
  652. '$nombre.pdf'; // Ajustar el nombre y la extensión del archivo
  653. anchor.click();
  654. // Liberar el objeto URL
  655. html.Url.revokeObjectUrl(url);
  656. } else {
  657. print(
  658. 'Error al descargar el archivo. Código de estado: ${response.statusCode}');
  659. }
  660. }
  661. Widget usuarioHeader(String nombre, String correo) {
  662. return Row(
  663. mainAxisAlignment: MainAxisAlignment.center,
  664. crossAxisAlignment: CrossAxisAlignment.center,
  665. children: [
  666. Column(
  667. mainAxisAlignment: MainAxisAlignment.center,
  668. crossAxisAlignment: CrossAxisAlignment.end,
  669. children: [
  670. Text(nombre,
  671. style: TextStyle(
  672. color: Colors.black, fontWeight: FontWeight.bold),
  673. textAlign: TextAlign.right),
  674. Text(correo,
  675. style: TextStyle(color: Colors.grey.shade900),
  676. textAlign: TextAlign.right),
  677. ]),
  678. Text(" "),
  679. CircleAvatar(
  680. child: Icon(Icons.verified_user, color: Colors.white),
  681. backgroundColor: Colors.black),
  682. Text(" "),
  683. ]);
  684. }
  685. Future eliminarMedia(
  686. BuildContext context, Media m, Function()? confirmacion) async {
  687. return await showDialog(
  688. context: context,
  689. builder: (context) {
  690. return AlertDialog(
  691. surfaceTintColor: AppTheme.secondary,
  692. title: const Text('¿Desea eliminar esta archivo?'),
  693. actions: [
  694. TextButton(
  695. onPressed: () {
  696. Navigator.pop(context);
  697. },
  698. child: const Text('Cancelar'),
  699. ),
  700. TextButton(
  701. onPressed: confirmacion,
  702. child: const Text(
  703. 'Sí, estoy seguro',
  704. style: TextStyle(color: Colors.red),
  705. ),
  706. ),
  707. ],
  708. );
  709. },
  710. );
  711. }