|
@@ -1,12 +1,17 @@
|
|
|
+import 'package:flutter/cupertino.dart';
|
|
|
import 'package:flutter/material.dart';
|
|
|
+import 'package:flutter_linkify/flutter_linkify.dart';
|
|
|
import 'package:provider/provider.dart';
|
|
|
import 'package:sis_flutter/data/session/session_storage.dart';
|
|
|
import 'package:sis_flutter/models/usuario_model.dart';
|
|
|
import 'package:sis_flutter/services/usuario_session_service.dart';
|
|
|
import 'package:sis_flutter/viewmodels/login_view_model.dart';
|
|
|
-import 'package:sis_flutter/viewmodels/tarea_view_model.dart';
|
|
|
+import 'package:sis_flutter/viewmodels/actividad_view_model.dart';
|
|
|
import 'package:sis_flutter/viewmodels/viewmodels.dart';
|
|
|
import 'package:sis_flutter/widgets/app_dropdown_search.dart';
|
|
|
+import 'package:sis_flutter/widgets/app_loader.dart';
|
|
|
+import 'package:url_launcher/url_launcher.dart';
|
|
|
+import 'package:url_launcher/url_launcher_string.dart';
|
|
|
|
|
|
import '../../models/actividad_model.dart';
|
|
|
import '../../themes/themes.dart';
|
|
@@ -68,78 +73,110 @@ class _HomeBodyState extends State<HomeBody> {
|
|
|
|
|
|
return SafeArea(
|
|
|
child: SingleChildScrollView(
|
|
|
- child: Column(
|
|
|
- children: [
|
|
|
- Container(
|
|
|
- padding: const EdgeInsets.all(10),
|
|
|
- decoration: const BoxDecoration(
|
|
|
- color: Colors.white,
|
|
|
- borderRadius:
|
|
|
- BorderRadius.vertical(bottom: Radius.circular(15))),
|
|
|
- child: Padding(
|
|
|
- padding: const EdgeInsets.all(8.0),
|
|
|
- child: Column(
|
|
|
- mainAxisAlignment: MainAxisAlignment.start,
|
|
|
- crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
- children: [
|
|
|
- const Text("Bienvenido ",
|
|
|
- style: TextStyle(
|
|
|
- fontSize: 25,
|
|
|
- )),
|
|
|
- Text(_usuario!.name! ?? usuario.name!,
|
|
|
- style: const TextStyle(
|
|
|
- fontSize: 45,
|
|
|
- fontWeight: FontWeight.bold,
|
|
|
- height: -1)),
|
|
|
- const SizedBox(height: 10),
|
|
|
- Container(
|
|
|
- decoration: BoxDecoration(
|
|
|
- borderRadius: BorderRadius.circular(10),
|
|
|
- ),
|
|
|
- child: AppDropdownSearch<Usuario>(
|
|
|
- controller: _usuariosController,
|
|
|
- itemAsString: (u) => u.name!,
|
|
|
- selectedItem: _usuario,
|
|
|
- compareFn: (item1, item2) {
|
|
|
- return item1.id == item2.id;
|
|
|
- },
|
|
|
- onChanged: (selectedUsuario) {
|
|
|
- if (selectedUsuario != null) {
|
|
|
- _fetchActividad(selectedUsuario.id);
|
|
|
- }
|
|
|
- },
|
|
|
- items: _usuariosList,
|
|
|
- etiqueta: "Actividades",
|
|
|
- )),
|
|
|
- ]),
|
|
|
- ),
|
|
|
+ child: Column(
|
|
|
+ children: [
|
|
|
+ Container(
|
|
|
+ padding: const EdgeInsets.all(10),
|
|
|
+ decoration: const BoxDecoration(
|
|
|
+ color: Colors.white,
|
|
|
+ borderRadius:
|
|
|
+ BorderRadius.vertical(bottom: Radius.circular(15))),
|
|
|
+ child: Padding(
|
|
|
+ padding: const EdgeInsets.all(8.0),
|
|
|
+ child: Column(
|
|
|
+ mainAxisAlignment: MainAxisAlignment.start,
|
|
|
+ crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
+ children: [
|
|
|
+ const Text("Bienvenido ",
|
|
|
+ style: TextStyle(
|
|
|
+ fontSize: 25,
|
|
|
+ )),
|
|
|
+ Text(_usuario?.name! ?? "Cargando...",
|
|
|
+ style: const TextStyle(
|
|
|
+ fontSize: 45,
|
|
|
+ fontWeight: FontWeight.bold,
|
|
|
+ height: -1)),
|
|
|
+ const SizedBox(height: 10),
|
|
|
+ Container(
|
|
|
+ decoration: BoxDecoration(
|
|
|
+ borderRadius: BorderRadius.circular(10),
|
|
|
+ ),
|
|
|
+ child: AppDropdownSearch<Usuario>(
|
|
|
+ controller: _usuariosController,
|
|
|
+ itemAsString: (u) => u.name!,
|
|
|
+ selectedItem: _usuario,
|
|
|
+ compareFn: (item1, item2) {
|
|
|
+ return item1.id == item2.id;
|
|
|
+ },
|
|
|
+ onChanged: (selectedUsuario) {
|
|
|
+ if (selectedUsuario != null) {
|
|
|
+ _fetchActividad(selectedUsuario.id);
|
|
|
+ }
|
|
|
+ },
|
|
|
+ items: _usuariosList,
|
|
|
+ etiqueta: "Actividades",
|
|
|
+ )),
|
|
|
+ ]),
|
|
|
),
|
|
|
- const SizedBox(height: 10),
|
|
|
- SizedBox(
|
|
|
- width: double.infinity,
|
|
|
- height: height * 0.9,
|
|
|
- child: ListView.builder(
|
|
|
- itemCount: actividadDetalle.length,
|
|
|
- itemBuilder: (context, index) {
|
|
|
- var actividad = actividadDetalle[index];
|
|
|
+ ),
|
|
|
+ const SizedBox(height: 10),
|
|
|
+ SizedBox(
|
|
|
+ width: double.infinity,
|
|
|
+ height: height * 0.9,
|
|
|
+ child: ListView.builder(
|
|
|
+ itemCount: actividadDetalle.length,
|
|
|
+ itemBuilder: (context, index) {
|
|
|
+ var actividad = actividadDetalle[index];
|
|
|
|
|
|
- return _infoCard(actividad);
|
|
|
- }),
|
|
|
- ),
|
|
|
- ],
|
|
|
- ),
|
|
|
- ),
|
|
|
+ return _infoCard(actividad);
|
|
|
+ }),
|
|
|
+ ),
|
|
|
+ ],
|
|
|
+ )),
|
|
|
);
|
|
|
}
|
|
|
|
|
|
Card _infoCard(Actividad actividad) {
|
|
|
List<Widget> tareaWidgets = [];
|
|
|
for (var tarea in actividad.tareas!) {
|
|
|
- final posicion = (actividad.tareas!.indexOf(tarea) + 1).toString();
|
|
|
+ // final posicion = (actividad.tareas!.indexOf(tarea) + 1).toString();
|
|
|
+ final Color color = getPrioridadColors(tarea.prioridad!);
|
|
|
tareaWidgets.add(
|
|
|
- ListTile(
|
|
|
- title: Text(tarea.contenido!),
|
|
|
- subtitle: Text("Subtarea ${tarea.iops}"),
|
|
|
+ Column(
|
|
|
+ children: [
|
|
|
+ const FractionallySizedBox(
|
|
|
+ widthFactor: 0.75, // 80% of the parent width
|
|
|
+ child: Divider(
|
|
|
+ color: Colors.grey,
|
|
|
+ ),
|
|
|
+ ),
|
|
|
+ ListTile(
|
|
|
+ leading: CircleAvatar(
|
|
|
+ backgroundColor: color,
|
|
|
+ child: Text(tarea.prioridad.toString()),
|
|
|
+ ),
|
|
|
+ title: Linkify(
|
|
|
+ text: tarea.contenido!,
|
|
|
+ onOpen: (link) async {
|
|
|
+ if (await canLaunchUrlString(link.url)) {
|
|
|
+ await launchUrlString(link.url);
|
|
|
+ } else {
|
|
|
+ throw CupertinoAlertDialog(
|
|
|
+ title: const Text("Error"),
|
|
|
+ content: const Text("No se puede abrir el link"),
|
|
|
+ actions: [
|
|
|
+ CupertinoDialogAction(
|
|
|
+ child: const Text("OK"),
|
|
|
+ onPressed: () {
|
|
|
+ Navigator.of(context).pop();
|
|
|
+ },
|
|
|
+ )
|
|
|
+ ],
|
|
|
+ );
|
|
|
+ }
|
|
|
+ }),
|
|
|
+ ),
|
|
|
+ ],
|
|
|
),
|
|
|
);
|
|
|
}
|
|
@@ -149,7 +186,20 @@ class _HomeBodyState extends State<HomeBody> {
|
|
|
shape: BeveledRectangleBorder(borderRadius: BorderRadius.circular(6.0)),
|
|
|
child: ExpansionTile(
|
|
|
backgroundColor: Colors.white24,
|
|
|
- leading: const Icon(Icons.local_fire_department_rounded),
|
|
|
+ leading: SizedBox(
|
|
|
+ width: 60,
|
|
|
+ child: Row(
|
|
|
+ mainAxisAlignment: MainAxisAlignment.spaceAround,
|
|
|
+ crossAxisAlignment: CrossAxisAlignment.center,
|
|
|
+ children: [
|
|
|
+ Text(
|
|
|
+ actividad.prioridad!.toString(),
|
|
|
+ style: TextStyle(fontSize: 30, fontWeight: FontWeight.bold),
|
|
|
+ ),
|
|
|
+ const Icon(Icons.local_fire_department_rounded),
|
|
|
+ ],
|
|
|
+ ),
|
|
|
+ ),
|
|
|
title: Text(
|
|
|
"${actividad.nombreProyecto!} - ${actividad.nombre!} ",
|
|
|
style: const TextStyle(
|
|
@@ -178,4 +228,16 @@ class _HomeBodyState extends State<HomeBody> {
|
|
|
),
|
|
|
);
|
|
|
}
|
|
|
+
|
|
|
+ Color getPrioridadColors(tarea) {
|
|
|
+ return tarea == 1
|
|
|
+ ? Colors.red
|
|
|
+ : tarea == 2
|
|
|
+ ? Color.fromARGB(255, 253, 211, 1)
|
|
|
+ : tarea == 3
|
|
|
+ ? Colors.green
|
|
|
+ : tarea == 4
|
|
|
+ ? Colors.purple
|
|
|
+ : Colors.grey;
|
|
|
+ }
|
|
|
}
|