home_screen.dart 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  1. // ignore_for_file: use_build_context_synchronously
  2. import 'package:flutter/material.dart';
  3. import 'package:provider/provider.dart';
  4. import 'package:sis_flutter/models/actividad_model.dart';
  5. import 'package:sis_flutter/themes/themes.dart';
  6. import 'package:sis_flutter/viewmodels/login_view_model.dart';
  7. import 'package:sis_flutter/viewmodels/tarea_view_model.dart';
  8. import 'package:sis_flutter/widgets/app_drawer.dart';
  9. import 'package:sis_flutter/widgets/custom_bottom_navigation_bar.dart';
  10. import '../../data/session/session_storage.dart';
  11. class HomeScreen extends StatefulWidget {
  12. static const String route = '/home';
  13. const HomeScreen({super.key});
  14. @override
  15. Formulario createState() => Formulario();
  16. }
  17. class Formulario extends State<HomeScreen> {
  18. @override
  19. void initState() {
  20. super.initState();
  21. }
  22. @override
  23. Widget build(BuildContext context) {
  24. return Scaffold(
  25. backgroundColor: AppTheme.progressBackground,
  26. appBar: AppBar(
  27. backgroundColor: Colors.white,
  28. ),
  29. drawerScrimColor:
  30. const Color.fromARGB(255, 119, 119, 119).withOpacity(0.5),
  31. drawer: AppDrawer(),
  32. body: const SafeArea(child: HomeBody()),
  33. bottomNavigationBar: const CustomBottomNavigationBar(),
  34. );
  35. }
  36. }
  37. class HomeBody extends StatefulWidget {
  38. const HomeBody({
  39. super.key,
  40. });
  41. @override
  42. State<HomeBody> createState() => _HomeBodyState();
  43. }
  44. class _HomeBodyState extends State<HomeBody> {
  45. @override
  46. void initState() {
  47. super.initState();
  48. Future(
  49. () async {
  50. final idusuario =
  51. Provider.of<LoginViewModel>(context, listen: false).idUsuario;
  52. Provider.of<PrioridadesViewMode>(context, listen: false)
  53. .fetchActividad(idusuario);
  54. },
  55. );
  56. }
  57. @override
  58. void dispose() {
  59. super.dispose();
  60. }
  61. @override
  62. Widget build(BuildContext context) {
  63. var vm = Provider.of<PrioridadesViewMode>(context);
  64. // var prioridades = vm.prioridades;
  65. var actividadDetalle = vm.actividadList;
  66. var usuario = Provider.of<LoginViewModel>(context, listen: false);
  67. final height = MediaQuery.of(context).size.height;
  68. return SingleChildScrollView(
  69. child: Column(
  70. children: [
  71. Container(
  72. padding: const EdgeInsets.all(10),
  73. decoration: const BoxDecoration(
  74. color: Colors.white,
  75. borderRadius:
  76. BorderRadius.vertical(bottom: Radius.circular(15))),
  77. child: Padding(
  78. padding: const EdgeInsets.all(8.0),
  79. child: Column(
  80. mainAxisAlignment: MainAxisAlignment.start,
  81. crossAxisAlignment: CrossAxisAlignment.start,
  82. children: [
  83. const Text("Bienvenido ",
  84. style: TextStyle(
  85. fontSize: 25,
  86. )),
  87. Text(usuario.name,
  88. style: const TextStyle(
  89. fontSize: 45,
  90. fontWeight: FontWeight.bold,
  91. height: -1)),
  92. const SizedBox(height: 10),
  93. Container(
  94. decoration: BoxDecoration(
  95. borderRadius: BorderRadius.circular(10),
  96. color: const Color.fromARGB(141, 232, 234, 237),
  97. ),
  98. child: const TextField(
  99. decoration: InputDecoration(
  100. contentPadding: EdgeInsets.symmetric(vertical: 15),
  101. border: InputBorder.none,
  102. prefix: Icon(
  103. Icons.search,
  104. color: Colors.black87,
  105. ),
  106. hintText: "Busqueda por Usuarios",
  107. hintStyle:
  108. TextStyle(color: Colors.grey, fontSize: 15)),
  109. ),
  110. ),
  111. ]),
  112. ),
  113. ),
  114. const SizedBox(height: 10),
  115. SizedBox(
  116. width: double.infinity,
  117. height: height * 0.9,
  118. child: ListView.builder(
  119. itemCount: actividadDetalle.length,
  120. itemBuilder: (context, index) {
  121. var actividad = actividadDetalle[index];
  122. return _infoCard(actividad);
  123. }),
  124. ),
  125. ],
  126. ),
  127. );
  128. }
  129. Card _infoCard(Actividad actividad) {
  130. List<Widget> tareaWidgets = [];
  131. for (var tarea in actividad.tareas!) {
  132. final posicion = (actividad.tareas!.indexOf(tarea) + 1).toString();
  133. tareaWidgets.add(
  134. ListTile(
  135. title: Text(tarea.contenido!),
  136. subtitle: Text("Subtarea $posicion"),
  137. ),
  138. );
  139. }
  140. return Card(
  141. margin: const EdgeInsets.symmetric(horizontal: 8.0, vertical: 8),
  142. elevation: 4,
  143. shape: BeveledRectangleBorder(borderRadius: BorderRadius.circular(6.0)),
  144. child: ExpansionTile(
  145. backgroundColor: Colors.white24,
  146. leading: const Icon(Icons.local_fire_department_rounded),
  147. title: Text(
  148. "${actividad.nombreProyecto!} - ${actividad.nombre!} ",
  149. style: const TextStyle(
  150. fontSize: 20, fontWeight: FontWeight.bold, color: Colors.black54),
  151. strutStyle: const StrutStyle(fontWeight: FontWeight.bold),
  152. ),
  153. trailing: const Icon(Icons.arrow_drop_down),
  154. subtitle: Row(
  155. mainAxisAlignment: MainAxisAlignment.start,
  156. crossAxisAlignment: CrossAxisAlignment.center,
  157. children: [
  158. Text(actividad.avance!),
  159. const SizedBox(width: 10),
  160. Expanded(
  161. child: ClipRRect(
  162. borderRadius: const BorderRadius.all(Radius.circular(10)),
  163. child: LinearProgressIndicator(
  164. value: double.parse(actividad.avance!) / 100,
  165. backgroundColor: Colors.grey,
  166. valueColor: const AlwaysStoppedAnimation(AppTheme.primary)),
  167. ),
  168. ),
  169. ],
  170. ),
  171. children: tareaWidgets,
  172. ),
  173. );
  174. }
  175. }