home_screen.dart 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. import 'package:computo_lite/viewmodels/home_view_model.dart';
  2. import 'package:computo_lite/viewmodels/login_view_model.dart';
  3. import 'package:computo_lite/widgets/widgets_components.dart';
  4. import 'package:flutter/material.dart';
  5. import '../../widgets/app_drawer.dart';
  6. import '../../themes/themes.dart';
  7. import 'package:provider/provider.dart';
  8. class HomeScreen extends StatelessWidget {
  9. const HomeScreen({Key? key}) : super(key: key);
  10. @override
  11. Widget build(BuildContext context) {
  12. final homeViewModel = Provider.of<HomeViewModel>(context);
  13. final opciones = homeViewModel.opciones;
  14. String correo = Provider.of<LoginViewModel>(context).correo;
  15. return WillPopScope(
  16. onWillPop: () async {
  17. return false;
  18. },
  19. child: Scaffold(
  20. drawer: AppDrawer(),
  21. appBar: AppBar(
  22. elevation: 0,
  23. title: const Text(
  24. 'Inicio',
  25. style: TextStyle( color: Colors.white),
  26. ),
  27. iconTheme: const IconThemeData(color: Colors.white),
  28. actions: [usuarioHeader(correo)],
  29. ),
  30. body: GridView.builder(
  31. gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(
  32. crossAxisCount: 1),
  33. itemCount: opciones.length,
  34. itemBuilder: (context, index) {
  35. final opcion = opciones[index];
  36. return Padding(
  37. padding: const EdgeInsets.all(8.0),
  38. child: InkWell(
  39. onTap: () {
  40. Navigator.of(context).push(
  41. MaterialPageRoute(
  42. builder: (context) => opcion['pantalla'],
  43. ),
  44. );
  45. },
  46. child: Card(
  47. surfaceTintColor: AppTheme.secondary,
  48. elevation: 5,
  49. child: Column(
  50. children: [
  51. Expanded(
  52. child: Image(
  53. image: AssetImage('assets/menu${index + 1}.png'),
  54. ),
  55. ),
  56. ListTile(
  57. title: Text(
  58. opcion['opcion'],
  59. style: const TextStyle(fontSize: 18),
  60. ),
  61. subtitle: Text(opcion['descripcion']),
  62. ),
  63. const SizedBox(
  64. height: 5,
  65. ),
  66. ],
  67. ),
  68. ),
  69. ),
  70. );
  71. },
  72. ),
  73. ),
  74. );
  75. }
  76. }