diff --git a/README.md b/README.md
index d7bca36..3787421 100644
--- a/README.md
+++ b/README.md
@@ -1,2 +1,2 @@
-# adcom iosV
- Version ios
+# Adcom iosV
+ Esta version es version android, cuidado con juntar las ramas, ios tiene librerias diferentes a las de android y pueden chocar
diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml
index 1b9bbf4..8da1824 100644
--- a/android/app/src/main/AndroidManifest.xml
+++ b/android/app/src/main/AndroidManifest.xml
@@ -7,6 +7,8 @@
+
+
@@ -18,6 +20,43 @@
android:usesCleartextTraffic="true"
android:icon="@mipmap/ic_launcher">
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
- http://187.189.53.8:8080
+ http://187.189.53.8:8081
http://192.168.1.178/AdcomBackend/backend/web/index.php?r=adcom/get-directorio
http://187.197.53.8/AdcomBackend/backend/web/index.php?r=adcom/get-directorio
diff --git a/assets/images/magic.png b/assets/images/magic.png
new file mode 100644
index 0000000..7c68070
Binary files /dev/null and b/assets/images/magic.png differ
diff --git a/assets/images/zzz.png b/assets/images/zzz.png
new file mode 100644
index 0000000..efdc5c8
Binary files /dev/null and b/assets/images/zzz.png differ
diff --git a/lib/json/json-getComunidades.dart b/lib/json/json-getComunidades.dart
new file mode 100644
index 0000000..0be607b
--- /dev/null
+++ b/lib/json/json-getComunidades.dart
@@ -0,0 +1,94 @@
+// To parse this JSON data, do
+//
+// final progres = progresFromJson(jsonString);
+
+// To parse this JSON data, do
+//
+// final comunities = comunitiesFromJson(jsonString);
+
+import 'dart:convert';
+
+Comunities comunitiesFromJson(String str) =>
+ Comunities.fromJson(json.decode(str));
+
+String comunitiesToJson(Comunities data) => json.encode(data.toJson());
+
+class Comunities {
+ Comunities({
+ this.value,
+ this.message,
+ this.data,
+ });
+
+ int? value;
+ String? message;
+ List? data;
+
+ factory Comunities.fromJson(Map json) => Comunities(
+ value: json["value"],
+ message: json["message"],
+ data: List.from(json["data"].map((x) => Datum.fromJson(x))),
+ );
+
+ Map toJson() => {
+ "value": value,
+ "message": message,
+ "data": List.from(data!.map((x) => x.toJson())),
+ };
+}
+
+class Datum {
+ Datum({
+ this.idCom,
+ this.nombreComu,
+ this.ubicacion,
+ this.cp,
+ this.idAdministrador,
+ this.idComite,
+ this.idTipoComu,
+ this.banco,
+ this.cuentaBanco,
+ this.cuentaClabe,
+ this.rfc,
+ });
+
+ int? idCom;
+ String? nombreComu;
+ String? ubicacion;
+ int? cp;
+ dynamic? idAdministrador;
+ dynamic? idComite;
+ String? idTipoComu;
+ String? banco;
+ String? cuentaBanco;
+ String? cuentaClabe;
+ String? rfc;
+
+ factory Datum.fromJson(Map json) => Datum(
+ idCom: json["ID_COM"],
+ nombreComu: json["NOMBRE_COMU"],
+ ubicacion: json["UBICACION"] == null ? null : json["UBICACION"],
+ cp: json["CP"] == null ? null : json["CP"],
+ idAdministrador: json["ID_ADMINISTRADOR"],
+ idComite: json["ID_COMITE"],
+ idTipoComu: json["ID_TIPO_COMU"] == null ? null : json["ID_TIPO_COMU"],
+ banco: json["BANCO"] == null ? null : json["BANCO"],
+ cuentaBanco: json["CUENTA_BANCO"] == null ? null : json["CUENTA_BANCO"],
+ cuentaClabe: json["CUENTA_CLABE"] == null ? null : json["CUENTA_CLABE"],
+ rfc: json["RFC"] == null ? null : json["RFC"],
+ );
+
+ Map toJson() => {
+ "ID_COM": idCom,
+ "NOMBRE_COMU": nombreComu,
+ "UBICACION": ubicacion == null ? null : ubicacion,
+ "CP": cp == null ? null : cp,
+ "ID_ADMINISTRADOR": idAdministrador,
+ "ID_COMITE": idComite,
+ "ID_TIPO_COMU": idTipoComu == null ? null : idTipoComu,
+ "BANCO": banco == null ? null : banco,
+ "CUENTA_BANCO": cuentaBanco == null ? null : cuentaBanco,
+ "CUENTA_CLABE": cuentaClabe == null ? null : cuentaClabe,
+ "RFC": rfc == null ? null : rfc,
+ };
+}
diff --git a/lib/json/jsonFinanzas.dart b/lib/json/jsonFinanzas.dart
index ce414b4..bb14917 100644
--- a/lib/json/jsonFinanzas.dart
+++ b/lib/json/jsonFinanzas.dart
@@ -1,7 +1,3 @@
-// To parse this JSON data, do
-//
-// final places = placesFromJson(jsonString);
-
// To parse this JSON data, do
//
// final accounts = accountsFromJson(jsonString);
@@ -24,36 +20,44 @@ class Accounts {
List? data;
factory Accounts.fromJson(Map json) => Accounts(
- value: json["value"],
- message: json["message"],
- data: List.from(json["data"].map((x) => Datum.fromJson(x))),
+ value: json["value"] == null ? null : json["value"],
+ message: json["message"] == null ? null : json["message"],
+ data: json["data"] == null
+ ? null
+ : List.from(json["data"].map((x) => Datum.fromJson(x))),
);
Map toJson() => {
- "value": value,
- "message": message,
- "data": List.from(data!.map((x) => x.toJson())),
+ "value": value == null ? null : value,
+ "message": message == null ? null : message,
+ "data": data == null
+ ? null
+ : List.from(data!.map((x) => x.toJson())),
};
}
class Datum {
- Datum(
- {this.idAdeudo,
- this.idComu,
- this.idResidente,
- this.montoCuota,
- this.idConcepto,
- this.fechaGeneracion,
- this.fechaLimite,
- this.fechaPago,
- this.montoPago,
- this.idFormaPago,
- this.idTipoCuota,
- this.referencia,
- this.pagoTardio,
- this.montoPagoTardio,
- this.pago,
- this.totalApagar});
+ Datum({
+ this.idAdeudo,
+ this.idComu,
+ this.idResidente,
+ this.montoCuota,
+ this.idConcepto,
+ this.fechaGeneracion,
+ this.fechaLimite,
+ this.fechaPago,
+ this.montoPago,
+ this.idFormaPago,
+ this.idTipoCuota,
+ this.referencia,
+ this.pagoTardio,
+ this.montoPagoTardio,
+ this.impAplicado,
+ this.impMonto,
+ this.inpcPorcentaje,
+ this.pago,
+ this.totalApagar,
+ });
int? idAdeudo;
int? idComu;
@@ -64,50 +68,68 @@ class Datum {
DateTime? fechaLimite;
DateTime? fechaPago;
String? montoPago;
- int? idFormaPago;
+ dynamic? idFormaPago;
dynamic? idTipoCuota;
String? referencia;
- dynamic? pagoTardio;
+ int? pagoTardio;
String? montoPagoTardio;
+ dynamic? impAplicado;
+ dynamic? impMonto;
+ dynamic? inpcPorcentaje;
int? pago;
int? totalApagar;
factory Datum.fromJson(Map json) => Datum(
- idAdeudo: json["ID_ADEUDO"],
- idComu: json["ID_COMU"],
- idResidente: json["ID_RESIDENTE"],
- montoCuota: json["MONTO_CUOTA"],
- idConcepto: json["ID_CONCEPTO"],
- fechaGeneracion: DateTime.parse(json["FECHA_GENERACION"]),
- fechaLimite: DateTime.parse(json["FECHA_LIMITE"]),
- fechaPago: json["FECHA_PAGO"] == null
- ? null
- : DateTime.parse(json["FECHA_PAGO"]),
- montoPago: json["MONTO_PAGO"],
- idFormaPago: json["ID_FORMA_PAGO"] == null ? null : json["ID_FORMA_PAGO"],
- idTipoCuota: json["ID_TIPO_CUOTA"],
- referencia: json["REFERENCIA"],
- pagoTardio: json["PAGO_TARDIO"],
- montoPagoTardio: json["MONTO_PAGO_TARDIO"],
- pago: json["PAGO"],
- totalApagar: json["TOTAL_APAGAR"]);
+ idAdeudo: json["ID_ADEUDO"] == null ? null : json["ID_ADEUDO"],
+ idComu: json["ID_COMU"] == null ? null : json["ID_COMU"],
+ idResidente: json["ID_RESIDENTE"] == null ? null : json["ID_RESIDENTE"],
+ montoCuota: json["MONTO_CUOTA"] == null ? null : json["MONTO_CUOTA"],
+ idConcepto: json["ID_CONCEPTO"] == null ? null : json["ID_CONCEPTO"],
+ fechaGeneracion: json["FECHA_GENERACION"] == null
+ ? null
+ : DateTime.parse(json["FECHA_GENERACION"]),
+ fechaLimite: json["FECHA_LIMITE"] == null
+ ? null
+ : DateTime.parse(json["FECHA_LIMITE"]),
+ fechaPago: json["FECHA_PAGO"] == null
+ ? null
+ : DateTime.parse(json["FECHA_PAGO"]),
+ montoPago: json["MONTO_PAGO"] == null ? null : json["MONTO_PAGO"],
+ idFormaPago: json["ID_FORMA_PAGO"],
+ idTipoCuota: json["ID_TIPO_CUOTA"],
+ referencia: json["REFERENCIA"] == null ? null : json["REFERENCIA"],
+ pagoTardio: json["PAGO_TARDIO"] == null ? null : json["PAGO_TARDIO"],
+ montoPagoTardio: json["MONTO_PAGO_TARDIO"] == null
+ ? null
+ : json["MONTO_PAGO_TARDIO"],
+ impAplicado: json["IMP_APLICADO"],
+ impMonto: json["IMP_MONTO"],
+ inpcPorcentaje: json["INPC_PORCENTAJE"],
+ pago: json["PAGO"] == null ? null : json["PAGO"],
+ totalApagar: json["TOTAL_APAGAR"] == null ? null : json["TOTAL_APAGAR"],
+ );
Map toJson() => {
- "ID_ADEUDO": idAdeudo,
- "ID_COMU": idComu,
- "ID_RESIDENTE": idResidente,
- "MONTO_CUOTA": montoCuota,
- "ID_CONCEPTO": idConcepto,
- "FECHA_GENERACION": fechaGeneracion!.toIso8601String(),
- "FECHA_LIMITE": fechaLimite!.toIso8601String(),
+ "ID_ADEUDO": idAdeudo == null ? null : idAdeudo,
+ "ID_COMU": idComu == null ? null : idComu,
+ "ID_RESIDENTE": idResidente == null ? null : idResidente,
+ "MONTO_CUOTA": montoCuota == null ? null : montoCuota,
+ "ID_CONCEPTO": idConcepto == null ? null : idConcepto,
+ "FECHA_GENERACION":
+ fechaGeneracion == null ? null : fechaGeneracion!.toIso8601String(),
+ "FECHA_LIMITE":
+ fechaLimite == null ? null : fechaLimite!.toIso8601String(),
"FECHA_PAGO": fechaPago == null ? null : fechaPago!.toIso8601String(),
- "MONTO_PAGO": montoPago,
- "ID_FORMA_PAGO": idFormaPago == null ? null : idFormaPago,
+ "MONTO_PAGO": montoPago == null ? null : montoPago,
+ "ID_FORMA_PAGO": idFormaPago,
"ID_TIPO_CUOTA": idTipoCuota,
- "REFERENCIA": referencia,
- "PAGO_TARDIO": pagoTardio,
- "MONTO_PAGO_TARDIO": montoPagoTardio,
- "PAGO": pago,
- "TOTAL_APAGAR": totalApagar
+ "REFERENCIA": referencia == null ? null : referencia,
+ "PAGO_TARDIO": pagoTardio == null ? null : pagoTardio,
+ "MONTO_PAGO_TARDIO": montoPagoTardio == null ? null : montoPagoTardio,
+ "IMP_APLICADO": impAplicado,
+ "IMP_MONTO": impMonto,
+ "INPC_PORCENTAJE": inpcPorcentaje,
+ "PAGO": pago == null ? null : pago,
+ "TOTAL_APAGAR": totalApagar == null ? null : totalApagar,
};
}
diff --git a/lib/json/jsonReporte.dart b/lib/json/jsonReporte.dart
index 8dd824f..50de85d 100644
--- a/lib/json/jsonReporte.dart
+++ b/lib/json/jsonReporte.dart
@@ -21,15 +21,19 @@ class GetReportes {
List? data;
factory GetReportes.fromJson(Map json) => GetReportes(
- value: json["value"],
- message: json["message"],
- data: List.from(json["data"].map((x) => Datum.fromJson(x))),
+ value: json["value"] == null ? null : json["value"],
+ message: json["message"] == null ? null : json["message"],
+ data: json["data"] == null
+ ? null
+ : List.from(json["data"].map((x) => Datum.fromJson(x))),
);
Map toJson() => {
- "value": value,
- "message": message,
- "data": List.from(data!.map((x) => x.toJson())),
+ "value": value == null ? null : value,
+ "message": message == null ? null : message,
+ "data": data == null
+ ? null
+ : List.from(data!.map((x) => x.toJson())),
};
}
@@ -39,24 +43,84 @@ class Datum {
this.descDesperfecto,
this.fechaRep,
this.evidencia,
+ this.progreso,
+ this.idReporte,
+ this.comunidad,
+ this.interior,
+ this.numero,
});
String? descCorta;
String? descDesperfecto;
DateTime? fechaRep;
List? evidencia;
+ List? progreso;
+ int? idReporte;
+ String? comunidad;
+ String? numero;
+ String? interior;
factory Datum.fromJson(Map json) => Datum(
- descCorta: json["DESC_CORTA"],
- descDesperfecto: json["DESC_DESPERFECTO"],
- fechaRep: DateTime.parse(json["FECHA_REP"]),
- evidencia: List.from(json["EVIDENCIA"].map((x) => x)),
+ descCorta: json["DESC_CORTA"] == null ? null : json["DESC_CORTA"],
+ descDesperfecto:
+ json["DESC_DESPERFECTO"] == null ? null : json["DESC_DESPERFECTO"],
+ fechaRep:
+ json["FECHA_REP"] == null ? null : DateTime.parse(json["FECHA_REP"]),
+ evidencia: json["EVIDENCIA"] == null
+ ? null
+ : List.from(json["EVIDENCIA"].map((x) => x)),
+ progreso: json["PROGRESO"] == null
+ ? null
+ : List.from(
+ json["PROGRESO"].map((x) => Progreso.fromJson(x))),
+ idReporte: json["ID_REPORTE"] == null ? null : json["ID_REPORTE"],
+ comunidad: json["COMUNIDAD"] == null ? null : json["COMUNIDAD"],
+ numero: json["NUMERO"] == null ? null : json["NUMERO"],
+ interior: json["INTERIOR"] == null ? null : json["INTERIOR"]);
+
+ Map toJson() => {
+ "DESC_CORTA": descCorta == null ? null : descCorta,
+ "DESC_DESPERFECTO": descDesperfecto == null ? null : descDesperfecto,
+ "FECHA_REP": fechaRep == null ? null : fechaRep!.toIso8601String(),
+ "EVIDENCIA": evidencia == null
+ ? null
+ : List.from(evidencia!.map((x) => x)),
+ "PROGRESO": progreso == null
+ ? null
+ : List.from(progreso!.map((x) => x.toJson())),
+ "ID_REPORTE": idReporte == null ? null : idReporte,
+ "COMUNIDAD": comunidad == null ? null : comunidad,
+ "NUMERO": numero == null ? null : numero,
+ "INTERIOR": interior == null ? null : interior,
+ };
+}
+
+class Progreso {
+ Progreso({
+ this.fechaSeg,
+ this.comentario,
+ this.progreso,
+ this.idProgreso,
+ });
+
+ DateTime? fechaSeg;
+ String? comentario;
+ String? progreso;
+ int? idProgreso;
+
+ factory Progreso.fromJson(Map json) => Progreso(
+ fechaSeg: json["FECHA_SEG"] == null
+ ? null
+ : DateTime.parse(json["FECHA_SEG"]),
+ comentario: json["COMENTARIO"] == null ? null : json["COMENTARIO"],
+ progreso: json["PROGRESO"] == null ? null : json["PROGRESO"],
+ idProgreso: json["ID_PROGRESO"] == null ? null : json["ID_PROGRESO"],
);
Map toJson() => {
- "DESC_CORTA": descCorta,
- "DESC_DESPERFECTO": descDesperfecto,
- "FECHA_REP": fechaRep!.toIso8601String(),
- "EVIDENCIA": List.from(evidencia!.map((x) => x)),
+ "FECHA_SEG": fechaSeg == null ? null : fechaSeg!.toIso8601String(),
+ "COMENTARIO": comentario == null ? null : comentario,
+ "PROGRESO": progreso == null ? null : progreso,
+ "ID_PROGRESO": idProgreso == null ? null : idProgreso,
};
}
diff --git a/lib/json/obtenerAvisos.dart b/lib/json/obtenerAvisos.dart
new file mode 100644
index 0000000..57ded56
--- /dev/null
+++ b/lib/json/obtenerAvisos.dart
@@ -0,0 +1,78 @@
+// To parse this JSON data, do
+//
+// final getAvisos = getAvisosFromJson(jsonString);
+
+import 'dart:convert';
+
+GetAvisos getAvisosFromJson(String str) => GetAvisos.fromJson(json.decode(str));
+
+String getAvisosToJson(GetAvisos data) => json.encode(data.toJson());
+
+class GetAvisos {
+ GetAvisos({
+ this.value,
+ this.data,
+ });
+
+ int? value;
+ List? data;
+
+ factory GetAvisos.fromJson(Map json) => GetAvisos(
+ value: json["value"],
+ data: List.from(json["data"].map((x) => Datum.fromJson(x))),
+ );
+
+ Map toJson() => {
+ "value": value,
+ "data": List.from(data!.map((x) => x.toJson())),
+ };
+}
+
+class Datum {
+ Datum({
+ this.aviso,
+ this.tipoAviso,
+ this.fechaAviso,
+ this.archivos,
+ });
+
+ String? aviso;
+ int? tipoAviso;
+ DateTime? fechaAviso;
+ List? archivos;
+
+ factory Datum.fromJson(Map json) => Datum(
+ aviso: json["AVISO"],
+ tipoAviso: json["TIPO_AVISO"],
+ fechaAviso: DateTime.parse(json["FECHA_AVISO"]),
+ archivos: List.from(
+ json["ARCHIVOS"].map((x) => Archivo.fromJson(x))),
+ );
+
+ Map toJson() => {
+ "AVISO": aviso,
+ "TIPO_AVISO": tipoAviso,
+ "FECHA_AVISO": fechaAviso!.toIso8601String(),
+ "ARCHIVOS": List.from(archivos!.map((x) => x.toJson())),
+ };
+}
+
+class Archivo {
+ Archivo({
+ this.direccionArchivo,
+ this.nombreArchivo,
+ });
+
+ String? direccionArchivo;
+ String? nombreArchivo;
+
+ factory Archivo.fromJson(Map json) => Archivo(
+ direccionArchivo: json["DIRECCION_ARCHIVO"],
+ nombreArchivo: json["NOMBRE_ARCHIVO"],
+ );
+
+ Map toJson() => {
+ "DIRECCION_ARCHIVO": direccionArchivo,
+ "NOMBRE_ARCHIVO": nombreArchivo,
+ };
+}
diff --git a/lib/json/tipoAvisot.dart b/lib/json/tipoAvisot.dart
new file mode 100644
index 0000000..28ead4f
--- /dev/null
+++ b/lib/json/tipoAvisot.dart
@@ -0,0 +1,57 @@
+// To parse this JSON data, do
+//
+// final tipoAviso = tipoAvisoFromJson(jsonString);
+
+import 'dart:convert';
+
+TipoAviso tipoAvisoFromJson(String str) => TipoAviso.fromJson(json.decode(str));
+
+String tipoAvisoToJson(TipoAviso data) => json.encode(data.toJson());
+
+class TipoAviso {
+ TipoAviso({
+ this.value,
+ this.message,
+ this.data,
+ });
+
+ int? value;
+ String? message;
+ List? data;
+
+ factory TipoAviso.fromJson(Map json) => TipoAviso(
+ value: json["value"],
+ message: json["message"],
+ data: List.from(json["data"].map((x) => Datum.fromJson(x))),
+ );
+
+ Map toJson() => {
+ "value": value,
+ "message": message,
+ "data": List.from(data!.map((x) => x.toJson())),
+ };
+}
+
+class Datum {
+ Datum({
+ this.idCatTipoaviso,
+ this.tipoAviso,
+ this.idCom,
+ });
+
+ int? idCatTipoaviso;
+ String? tipoAviso;
+ int? idCom;
+
+ factory Datum.fromJson(Map json) => Datum(
+ idCatTipoaviso: json["ID_CAT_TIPOAVISO"],
+ tipoAviso: json["TIPO_AVISO"],
+ idCom: json["ID_COM"],
+ );
+
+ Map toJson() => {
+ "ID_CAT_TIPOAVISO": idCatTipoaviso,
+ "TIPO_AVISO": tipoAviso,
+ "ID_COM": idCom,
+ };
+}
diff --git a/lib/main.dart b/lib/main.dart
index a306c71..162570e 100644
--- a/lib/main.dart
+++ b/lib/main.dart
@@ -1,15 +1,21 @@
import 'package:adcom/src/app.dart';
-
+import 'package:flutter_downloader/flutter_downloader.dart';
import 'package:flutter/material.dart';
import 'package:onesignal_flutter/onesignal_flutter.dart';
+import 'package:shared_preferences/shared_preferences.dart';
+SharedPreferences? prefs;
void main() async {
WidgetsFlutterBinding.ensureInitialized();
OneSignal.shared.setAppId("ea109547-8715-4fc2-aa63-f9afe45349b0");
- OneSignal.shared
+ await FlutterDownloader.initialize(
+ // optional: set false to disable printing logs to console
+ );
+
+ /* OneSignal.shared
.getDeviceState()
- .then((value) => {print('${value!.userId}')});
+ .then((value) => {print('${value!.userId}')}); */
// The promptForPushNotificationsWithUserResponse function will show the iOS push notification prompt. We recommend removing the following code and instead using an In-App Message to prompt for notification permission
/* OneSignal.shared.promptUserForPushNotificationPermission().then((accepted) {
diff --git a/lib/src/app.dart b/lib/src/app.dart
index e6667d4..fd86148 100644
--- a/lib/src/app.dart
+++ b/lib/src/app.dart
@@ -18,7 +18,9 @@ import 'package:adcom/src/pantallas/reportes.dart';
import 'package:adcom/src/pantallas/visitantes.dart';
import 'package:adcom/src/pantallas/votaciones.dart';
import 'package:flutter/material.dart';
+
import 'package:provider/provider.dart';
+import 'package:shared_preferences/shared_preferences.dart';
class MyApp extends StatefulWidget {
final user;
@@ -28,15 +30,20 @@ class MyApp extends StatefulWidget {
_MyAppState createState() => _MyAppState();
}
+SharedPreferences? prefs;
+init() async {
+ prefs = await SharedPreferences.getInstance();
+}
+
class _MyAppState extends State {
final heroController = HeroController();
GlobalKey navigatorKey = GlobalKey();
var id = 'icono';
- bool _loggedIn = false;
@override
void initState() {
super.initState();
+ init();
}
@override
@@ -52,6 +59,7 @@ class _MyAppState extends State {
brightness: Brightness.light),
title: 'adcom',
//initialRoute: '/',
+
routes: {
'/': (BuildContext context) {
var state = Provider.of(context);
@@ -76,8 +84,15 @@ class _MyAppState extends State {
'/screen14': (BuildContext context) => LevantarReporte(),
'/screen15': (BuildContext context) => ChatPage(),
'/screen16': (BuildContext context) => Seguimiento(),
- '/screen17': (BuildContext context) => OnBoardReportes(),
- '/screen18': (BuildContext context) => AddReorte()
+ '/screen17': (BuildContext context) {
+ var tru = prefs!.containsKey('UnaVez');
+ if (tru == true) {
+ return AddReporte();
+ } else {
+ return OnBoardReportes();
+ }
+ },
+ '/screen18': (BuildContext context) => AddReporte()
},
),
);
diff --git a/lib/src/extra/OnBoarding_Reporte.dart b/lib/src/extra/OnBoarding_Reporte.dart
index a2aff9a..4c15961 100644
--- a/lib/src/extra/OnBoarding_Reporte.dart
+++ b/lib/src/extra/OnBoarding_Reporte.dart
@@ -2,6 +2,7 @@ import 'package:adcom/src/methods/slide.dart';
import 'package:flutter/material.dart';
import 'package:flutter_onboard/flutter_onboard.dart';
import 'package:gradient_widgets/gradient_widgets.dart';
+import 'package:shared_preferences/shared_preferences.dart';
class OnBoardReportes extends StatefulWidget {
OnBoardReportes({Key? key}) : super(key: key);
@@ -10,16 +11,22 @@ class OnBoardReportes extends StatefulWidget {
_OnBoardReportesState createState() => _OnBoardReportesState();
}
+SharedPreferences? prefs;
+
class _OnBoardReportesState extends State {
int? pages = 0;
List? _slides = [];
PageController? _pageController = PageController();
+ getPref() async {
+ prefs = await SharedPreferences.getInstance();
+ }
+
@override
void initState() {
super.initState();
pages = 0;
-
+ getPref();
_pageController = PageController(initialPage: pages!);
}
@@ -94,10 +101,15 @@ class _OnBoardReportesState extends State {
onBoardData: onBoardData,
pageController: _pageController!,
onSkip: () {
- Navigator.of(context).popAndPushNamed('/screen18');
+ prefs!.setBool('UnaVez', true);
+ Navigator.of(context)
+ .popAndPushNamed('/screen18')
+ .then((value) => prefs!.setBool('UnaVez', true));
},
onDone: () {
- Navigator.of(context).popAndPushNamed('/screen18');
+ Navigator.of(context)
+ .popAndPushNamed('/screen18')
+ .then((value) => {prefs!.setBool('UnaVez', true)});
},
titleStyles: TextStyle(
color: Colors.black,
diff --git a/lib/src/extra/add_reporte.dart b/lib/src/extra/add_reporte.dart
index fa68f42..20ec39b 100644
--- a/lib/src/extra/add_reporte.dart
+++ b/lib/src/extra/add_reporte.dart
@@ -1,42 +1,42 @@
import 'dart:convert';
+import 'package:camera/camera.dart';
import 'package:dio/dio.dart';
import 'dart:io';
import 'package:adcom/src/methods/slide.dart';
-import 'package:adcom/src/models/event_provider.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:image_picker/image_picker.dart';
-import 'package:provider/provider.dart';
import 'package:fluttertoast/fluttertoast.dart';
import 'package:http_parser/http_parser.dart';
import 'package:shared_preferences/shared_preferences.dart';
+import 'package:permission_handler/permission_handler.dart';
SharedPreferences? prefs;
+var cameras;
+var firstCamera;
-class AddReorte extends StatefulWidget {
+class AddReporte extends StatefulWidget {
final Report? report;
static init() async {
- prefs = await SharedPreferences.getInstance();
+ cameras = await availableCameras();
+ firstCamera = cameras.first;
}
- AddReorte({
- Key? key,
- this.report,
- }) : super(key: key);
+ AddReporte({Key? key, this.report}) : super(key: key);
@override
- _AddReorteState createState() => _AddReorteState();
+ _AddReporteState createState() => _AddReporteState();
}
someData(comId, userId) async {
- await AddReorte.init();
+ await AddReporte.init();
prefs!.setInt('idCom', comId);
prefs!.setInt('idUser', userId);
}
-class _AddReorteState extends State {
+class _AddReporteState extends State {
final GlobalKey _formKey = GlobalKey();
final GlobalKey _formKey2 = GlobalKey();
final titleController = TextEditingController();
@@ -45,23 +45,33 @@ class _AddReorteState extends State {
List images = [];
int? pages = 0;
List? _slides = [];
-
+ bool isLoading = false;
int _currentStep = 0;
int? idCom;
int? idUser;
+ late CameraController _controller;
+ late Future _initializeControllerFuture;
+
+ getCameras() async {
+ await Permission.camera.request();
+ await Permission.storage.request();
+ await Permission.manageExternalStorage.request();
+ await Permission.mediaLibrary.request();
+ }
addata() async {
prefs = await SharedPreferences.getInstance();
setState(() {
idCom = prefs!.getInt('idCom');
- idUser = prefs!.getInt('idUser');
+ idUser = prefs!.getInt('userId');
});
}
@override
void initState() {
super.initState();
- addata();
+
+ getCameras();
}
@override
@@ -82,56 +92,21 @@ class _AddReorteState extends State {
Navigator.of(context).pop();
},
),
- actions: buildEditingActions(),
),
resizeToAvoidBottomInset: true,
//stepper, propiedades y acciones
- body: Stepper(
- steps: _stepper()!,
- physics: ClampingScrollPhysics(),
- currentStep: this._currentStep,
- onStepTapped: (step) {
- setState(() {
- this._currentStep = step;
- });
- },
- onStepContinue: () {
- setState(() {
- if (this._currentStep < this._stepper()!.length - 1) {
- this._currentStep = this._currentStep + 1;
- } else {
- if (images.isEmpty) {
- Fluttertoast.showToast(
- msg: "Seccion de fotos vacia",
- toastLength: Toast.LENGTH_SHORT,
- gravity: ToastGravity.CENTER,
- timeInSecForIosWeb: 1,
- backgroundColor: Colors.white,
- textColor: Colors.black,
- fontSize: 17.0);
- } else {
- alerta();
- }
- }
- });
- },
- onStepCancel: () {
- setState(() {
- if (this._currentStep > 0) {
- this._currentStep = this._currentStep - 1;
- } else {
- this._currentStep = 0;
- }
- });
- },
- ),
+ body: stepper(),
//
// Boton que abre la camara
floatingActionButton: FloatingActionButton(
backgroundColor: Colors.blue,
- child: Icon(Icons.camera),
+ child: isLoading == true
+ ? CircularProgressIndicator(
+ backgroundColor: Colors.white,
+ )
+ : Icon(Icons.camera),
onPressed: () => {
HapticFeedback.lightImpact(),
images.length == 3 ? mensaje() : _optionsCamera(),
@@ -139,6 +114,48 @@ class _AddReorteState extends State {
);
}
+ Stepper stepper() {
+ return Stepper(
+ steps: _stepper()!,
+ physics: ClampingScrollPhysics(),
+ currentStep: this._currentStep,
+ onStepTapped: (step) {
+ setState(() {
+ this._currentStep = step;
+ });
+ },
+ onStepContinue: () {
+ setState(() {
+ if (this._currentStep < this._stepper()!.length - 1) {
+ this._currentStep = this._currentStep + 1;
+ } else {
+ if (images.isEmpty) {
+ Fluttertoast.showToast(
+ msg: "Seccion de fotos vacia",
+ toastLength: Toast.LENGTH_SHORT,
+ gravity: ToastGravity.CENTER,
+ timeInSecForIosWeb: 1,
+ backgroundColor: Colors.white,
+ textColor: Colors.black,
+ fontSize: 17.0);
+ } else {
+ alerta();
+ }
+ }
+ });
+ },
+ onStepCancel: () {
+ setState(() {
+ if (this._currentStep > 0) {
+ this._currentStep = this._currentStep - 1;
+ } else {
+ this._currentStep = 0;
+ }
+ });
+ },
+ );
+ }
+
//caracteristica de cada step
List? _stepper() {
List _steps = [
@@ -240,9 +257,10 @@ class _AddReorteState extends State {
inputFormatters: [new LengthLimitingTextInputFormatter(50)],
);
- //funcion que abre la camara y muestra
+ ///funcion que abre la camara y muestra
void openCamera() async {
- var image = await _picker.pickImage(source: ImageSource.camera);
+ var image =
+ await _picker.pickImage(source: ImageSource.camera, imageQuality: 30);
setState(() {
if (image != null) {
@@ -260,6 +278,24 @@ class _AddReorteState extends State {
});
}
+ void openCamera2() async {
+ var image =
+ await _picker.pickImage(source: ImageSource.camera, imageQuality: 50);
+
+ if (image != null) {
+ if (images.length == 3) {
+ // muestra el mensaje de archivo excedido
+ mensaje();
+ Navigator.of(context).pop();
+ } else {
+ images.add(File(image.path));
+ print(images[0].path);
+ }
+ } else {
+ print('No se ha seleccionado una imagen');
+ }
+ }
+
mensaje() => Fluttertoast.showToast(
msg: "Maximo excedido",
toastLength: Toast.LENGTH_SHORT,
@@ -270,7 +306,8 @@ class _AddReorteState extends State {
fontSize: 17.0);
// funcion que abre la galeria para las fotos
void openGallery() async {
- var image = await _picker.pickImage(source: ImageSource.gallery);
+ var image =
+ await _picker.pickImage(source: ImageSource.gallery, imageQuality: 50);
setState(() {
if (image != null) {
images.add(File(image.path));
@@ -285,6 +322,7 @@ class _AddReorteState extends State {
alerta() {
Widget okButton = TextButton(
onPressed: () {
+ Navigator.of(context).pop();
saveForm();
},
child: Text(
@@ -332,12 +370,22 @@ class _AddReorteState extends State {
// envia las fotos al serv mas toda su informacion que reqiere como los params
sendingData(String titulo, String descrip, List file) async {
+ await addata();
+
+ setState(() {
+ isLoading = true;
+ });
+
try {
List filesArr = [];
Dio dio = Dio();
+ print(idCom.toString());
+ print(idUser.toString());
+
for (var item in file) {
filesArr.add(item.path.split('/').last);
+ print(filesArr[0]);
}
var formdata2 = FormData.fromMap({
@@ -350,12 +398,12 @@ class _AddReorteState extends State {
'img[]': [
for (int i = 0; i < file.length; i++)
MultipartFile.fromFileSync(file[i].path,
- filename: filesArr[i], contentType: MediaType('image', '*'))
+ filename: filesArr[i], contentType: MediaType('media', '*'))
]
});
Response response = await dio.post(
- 'http://187.189.53.8:8080/AdcomBackend/backend/web/index.php?r=adcom/reportes',
+ 'http://187.189.53.8:8081/backend/web/index.php?r=adcom/reportes',
data: formdata2, onSendProgress: (received, total) {
if (total != 1) {
print((received / total * 100).toStringAsFixed(0) + '%');
@@ -420,6 +468,12 @@ class _AddReorteState extends State {
},
);
+ cargando() {
+ return isLoading == true
+ ? Center(child: CircularProgressIndicator())
+ : null;
+ }
+
Future saveForm() async {
final isValid = _formKey.currentState!.validate();
final isValid2 = _formKey2.currentState!.validate();
@@ -430,18 +484,22 @@ class _AddReorteState extends State {
description: descriptionController.text,
image: images,
time: DateTime.now());
- final provider = Provider.of(context, listen: false);
+
final Response? response = await sendingData(
titleController.text, descriptionController.text, images)
.then((value) {
- provider.addReport(report);
- Navigator.of(context).popAndPushNamed('/screen14');
+ setState(() {
+ isLoading = false;
+ });
+ Navigator.of(context).pop();
+
ScaffoldMessenger.of(context).showSnackBar(SnackBar(
content: Text(
'Su reporte se ha realizado con exito!',
style: TextStyle(fontSize: 19),
)));
});
+
return response;
}
}
diff --git a/lib/src/extra/dashboard_Avisos.dart b/lib/src/extra/dashboard_Avisos.dart
new file mode 100644
index 0000000..868684b
--- /dev/null
+++ b/lib/src/extra/dashboard_Avisos.dart
@@ -0,0 +1,325 @@
+import 'dart:io';
+import 'dart:isolate';
+import 'dart:ui';
+
+import 'package:adcom/src/pantallas/avisos.dart';
+import 'package:dio/dio.dart';
+import 'package:flutter/material.dart';
+
+import 'package:external_path/external_path.dart';
+import 'package:flutter_downloader/flutter_downloader.dart';
+import 'package:fluttertoast/fluttertoast.dart';
+import 'package:glyphicon/glyphicon.dart';
+import 'package:open_file/open_file.dart';
+import 'package:path_provider/path_provider.dart';
+
+// ignore: must_be_immutable
+class AvisosDashboard extends StatefulWidget {
+ List? avisos = [];
+ List? links;
+ List? name;
+ AvisosDashboard({
+ Key? key,
+ this.links,
+ this.name,
+ this.avisos,
+ }) : super(key: key);
+
+ @override
+ _AvisosDashboardState createState() => _AvisosDashboardState();
+}
+
+class _AvisosDashboardState extends State {
+ List list = [];
+ List names = [];
+ List links = [];
+ VoidCallback? _showPersBottomSheetCallBack;
+ bool downloading = false;
+ String progress = '0';
+ bool isDownloaded = false;
+ List? avisosRevers = [];
+ List namesRev = [];
+ List linksrev = [];
+ var filePath;
+ ReceivePort _receivePort = ReceivePort();
+ reversedList() {
+ avisosRevers = widget.avisos!.reversed.toList();
+ namesRev = widget.name!.reversed.toList();
+ linksrev = widget.links!.reversed.toList();
+ }
+
+ @override
+ void initState() {
+ _showPersBottomSheetCallBack = _showPersBottomSheetCallBack;
+ IsolateNameServer.registerPortWithName(
+ _receivePort.sendPort, "Descargando");
+
+ _receivePort.listen((message) {
+ setState(() {
+ progress = message[2];
+ });
+ });
+ FlutterDownloader.registerCallback(downloadCallback);
+ reversedList();
+ super.initState();
+ }
+
+ @override
+ Widget build(BuildContext context) {
+ var size = MediaQuery.of(context).size.width;
+ return widget.avisos!.isEmpty ? Container() : viewAvisos(size: size);
+ }
+
+ viewAvisos({size}) {
+ return Flexible(
+ child: GridView.builder(
+ padding: EdgeInsets.only(left: 10, right: 10, top: 20),
+ itemCount: avisosRevers!.length,
+ gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
+ crossAxisCount: 1,
+ childAspectRatio: 1.65,
+ crossAxisSpacing: 29,
+ mainAxisSpacing: 20,
+ ),
+ itemBuilder: (_, int data) {
+ return Container(
+ decoration: BoxDecoration(
+ color: Colors.white,
+ borderRadius: BorderRadius.circular(20),
+ boxShadow: [
+ BoxShadow(
+ color: Colors.grey,
+ blurRadius: 7,
+ offset: Offset(0, 5))
+ ]),
+ child: Column(
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: [
+ whoPublish(data, size),
+ Divider(
+ color: Color(0xFF455A64).withOpacity(0.3),
+ ),
+ postMessage(data, size),
+ SizedBox(
+ height: 10,
+ ),
+ ],
+ ),
+ );
+ }));
+ }
+
+ Container postMessage(int data, size) {
+ return Container(
+ padding: EdgeInsets.only(left: 10, right: 10),
+ child: Column(
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: [
+ Padding(
+ padding: EdgeInsets.only(left: size / 50),
+ child: Text(
+ '${avisosRevers![data].avisos}',
+ style: TextStyle(fontSize: size / 20),
+ ),
+ ),
+ SizedBox(
+ height: 15,
+ ),
+ InkWell(
+ onTap: () {
+ _showModalSheet(data);
+ },
+ child: Row(
+ children: [
+ SizedBox(
+ width: 15,
+ ),
+ Icon(Glyphicon.download),
+ SizedBox(
+ width: size / 24,
+ ),
+ Text(
+ 'Archivo adjunto...',
+ style: TextStyle(fontSize: 15, fontWeight: FontWeight.bold),
+ )
+ ],
+ ),
+ )
+ ],
+ ),
+ );
+ }
+
+ void _showModalSheet(int data) {
+ if (names.length == namesRev[data].length) {
+ } else {
+ for (int i = 0; i < namesRev[data].length; i++) {
+ names.add(namesRev[data][i]);
+ }
+ }
+
+ if (links.length == linksrev[data].length) {
+ print('here${links.length}');
+ print(' ya no cabe');
+ } else {
+ for (int i = 0; i < linksrev[data].length; i++) {
+ links.add(linksrev[data][i]);
+
+ print(links[i]);
+ }
+ }
+
+ showModalBottomSheet(
+ elevation: 5,
+ isDismissible: true,
+ clipBehavior: Clip.antiAliasWithSaveLayer,
+ shape: RoundedRectangleBorder(
+ borderRadius: BorderRadius.vertical(top: Radius.circular(20))),
+ context: context,
+ builder: (context) => Container(
+ height: 300,
+ alignment: Alignment.center,
+ child: DraggableScrollableSheet(
+ maxChildSize: 0.9,
+ initialChildSize: 0.9,
+ expand: true,
+ builder: (_, controller) => Column(
+ crossAxisAlignment: CrossAxisAlignment.center,
+ children: [
+ Text(
+ 'Descarga Archivos',
+ style: TextStyle(
+ fontSize: 20, fontWeight: FontWeight.bold),
+ ),
+ SizedBox(
+ height: 40,
+ ),
+ Flexible(
+ child: ListView.separated(
+ separatorBuilder: (context, index) {
+ return Divider(
+ color: Colors.black,
+ );
+ },
+ itemCount: names.length,
+ itemBuilder: (_, int index) {
+ return TextButton(
+ onPressed: () async {
+ try {
+ download2(links[index], names[index])
+ .then((value) {
+ Fluttertoast.showToast(
+ msg: "Descargando",
+ toastLength: Toast.LENGTH_SHORT,
+ gravity: ToastGravity.CENTER,
+ timeInSecForIosWeb: 1,
+ backgroundColor: Colors.white,
+ textColor: Colors.black,
+ fontSize: 17.0);
+ });
+ } catch (e) {
+ print(e);
+ }
+ /* downloadLink(
+ links[index], names[index]); */
+ },
+ child: Text('${names[index]}'),
+ );
+ }))
+ ],
+ )),
+ )).then((value) => {names.clear()});
+ }
+
+ Future download2(String url, String names) async {
+ Dio dio = Dio();
+
+ String savePath = await getPath(names);
+ try {
+ Response response = await dio.get(
+ url,
+ onReceiveProgress: showDownloadProgress,
+ //Received data with List
+ options: Options(
+ responseType: ResponseType.bytes,
+ followRedirects: false,
+ validateStatus: (status) {
+ return status! < 500;
+ }),
+ );
+ print(response.headers);
+ File file = File(savePath);
+ var raf = file.openSync(mode: FileMode.write);
+ // response.data is List type
+ raf.writeFromSync(response.data);
+ await raf.close();
+ } catch (e) {
+ print(e);
+ }
+ await OpenFile.open(filePath);
+ }
+
+ static downloadCallback(id, status, progress) {
+ SendPort? sendPort = IsolateNameServer.lookupPortByName("Descargando");
+
+ sendPort!.send([id, status, progress]);
+ }
+
+ void showDownloadProgress(received, total) {
+ if (total != -1) {
+ print((received / total * 100).toStringAsFixed(0) + "%");
+ }
+ }
+
+ Future getPath(names) async {
+ Directory path = await getApplicationDocumentsDirectory();
+
+ print(path.path);
+
+ setState(() {
+ filePath = path.path + '/$names';
+ });
+
+ return filePath;
+ }
+
+ Container whoPublish(data, size) {
+ return Container(
+ padding: EdgeInsets.only(top: 10, left: 10),
+ child: Row(
+ children: [
+ Container(
+ height: 51,
+ width: size / 9,
+ decoration:
+ BoxDecoration(color: Colors.grey[300], shape: BoxShape.circle),
+ child: Image.asset('assets/images/logo.png'),
+ ),
+ SizedBox(
+ width: size / 45,
+ ),
+ Text(
+ 'Administrador',
+ style: (TextStyle(fontSize: 16, fontWeight: FontWeight.w500)),
+ ),
+ SizedBox(
+ width: size / 35,
+ ),
+ Text(
+ '${avisosRevers![data].fecha!.day}/${avisosRevers![data].fecha!.month}/${avisosRevers![data].fecha!.year}')
+ ],
+ ),
+ );
+ }
+}
+
+class Links {
+ var links;
+
+ Links({this.links});
+}
+
+class NameLinks {
+ var names;
+ NameLinks({this.names});
+}
diff --git a/lib/src/extra/detalles_pago.dart b/lib/src/extra/detalles_pago.dart
new file mode 100644
index 0000000..8ffb5b7
--- /dev/null
+++ b/lib/src/extra/detalles_pago.dart
@@ -0,0 +1,214 @@
+import 'package:adcom/src/pantallas/finanzas.dart';
+import 'package:flutter/material.dart';
+import 'package:intl/intl.dart';
+
+class DetallesPago extends StatefulWidget {
+ late List? list = [];
+ DetallesPago({Key? key, this.list}) : super(key: key);
+
+ @override
+ _DetallesPagoState createState() => _DetallesPagoState();
+}
+
+class _DetallesPagoState extends State {
+ List mesFormat = [];
+ List debt = [];
+
+ @override
+ void initState() {
+ super.initState();
+ sacarMesDeAtrazo();
+ totalApagars();
+ }
+
+ @override
+ Widget build(BuildContext context) {
+ var size = MediaQuery.of(context).size;
+ return Scaffold(
+ appBar: AppBar(
+ title: Text('Detalles de pago'),
+ backgroundColor: Colors.lightGreen[700],
+ ),
+ body: Container(
+ padding: const EdgeInsets.all(12.0),
+ child: Column(
+ children: [
+ Row(
+ children: [
+ Container(
+ padding: EdgeInsets.only(left: 20, top: 10),
+ child: Text(
+ 'Cuotas pendietes',
+ style: TextStyle(fontSize: 25, fontWeight: FontWeight.bold),
+ ),
+ )
+ ],
+ ),
+ SizedBox(
+ height: size.width / 19,
+ ),
+ mesesView(),
+ Row(
+ children: [
+ Container(
+ padding: EdgeInsets.only(left: 180, top: 10),
+ child: Row(
+ children: [
+ Text(
+ 'Total',
+ style: TextStyle(
+ fontSize: 25, fontWeight: FontWeight.bold),
+ ),
+ SizedBox(
+ width: size.width / 25,
+ ),
+ Text(
+ '\$ ${saldoDeudor()}MXN',
+ style: TextStyle(fontSize: 19),
+ )
+ ],
+ ),
+ )
+ ],
+ )
+ ],
+ ),
+ ),
+ );
+ }
+
+ ListView mesesView() {
+ return ListView.separated(
+ shrinkWrap: true,
+ separatorBuilder: (context, index) {
+ return Divider(
+ thickness: 3,
+ color: Colors.grey[350],
+ );
+ },
+ itemCount: mesFormat.length & debt.length,
+ itemBuilder: (context, int index) {
+ return Container(
+ decoration: BoxDecoration(color: Color(0xFFF7F7F9)),
+ padding: EdgeInsets.only(
+ top: 10.0, bottom: 20.0, left: 20.0, right: 20.0),
+ child: Column(
+ children: [
+ Row(
+ mainAxisAlignment: MainAxisAlignment.spaceBetween,
+ children: [
+ Text('Mantenimiento del mes',
+ style: TextStyle(
+ fontSize: 17.0, fontWeight: FontWeight.bold)),
+ Text('Monto',
+ style: TextStyle(
+ fontSize: 17.0, fontWeight: FontWeight.bold))
+ ],
+ ),
+ SizedBox(
+ height: 10.0,
+ ),
+ Row(
+ mainAxisAlignment: MainAxisAlignment.spaceBetween,
+ children: [
+ Text(mesFormat[index],
+ style:
+ TextStyle(color: Colors.grey[800], fontSize: 14.0)),
+ Text('${debt[index]}',
+ style:
+ TextStyle(color: Colors.grey[800], fontSize: 14.0))
+ ],
+ ),
+ ],
+ ),
+ );
+ });
+ }
+
+ sacarMesDeAtrazo() {
+ DateTime? mesesAtrazo;
+
+ for (int i = 0; i < widget.list!.length; i++) {
+ if (widget.list![i].pago == 1) {
+ } else {
+ setState(() {
+ mesesAtrazo = widget.list![i].fechaGenerada;
+ });
+ mesFormat
+ .add((DateFormat('MMM').format(DateTime(0, mesesAtrazo!.month))));
+ //print(DateFormat('MMM').format(DateTime(0, mesesAtrazo!.month)));
+ }
+ }
+ }
+
+ totalApagars() {
+ late double total;
+ double deuda;
+
+ for (int i = 0; i < widget.list!.length; i++) {
+ if (widget.list![i].montoCuota == null) {
+ total = 0.0;
+ } else {
+ total = double.parse(widget.list![i].montoCuota!);
+ }
+ deuda = double.parse(widget.list![i].montoTardio!);
+
+ if (widget.list![i].pago == 1) {
+ } else {
+ //si sigue en fecha
+ if (widget.list![i].pagoTardio == 0) {
+ if (DateTime.now().day <= widget.list![i].fechaLimite!.day &&
+ DateTime.now().month <= widget.list![i].fechaLimite!.month &&
+ DateTime.now().year <= widget.list![i].fechaLimite!.year) {
+ //solo monto cuota
+ debt.add(total);
+ } else {
+ //si no esta en fecha añadir deuda extra
+ total = total + deuda;
+ debt.add(total);
+ }
+ } else {
+ total = total + deuda;
+ debt.add(total);
+ }
+ }
+ }
+ }
+
+ saldoDeudor() {
+ double contador = 0.0;
+ double deuda;
+ double tardio;
+ for (int i = 0; i < widget.list!.length; i++) {
+ if (widget.list![i].montoCuota == null) {
+ deuda = 0.0;
+ } else {
+ deuda = double.parse(widget.list![i].montoCuota!);
+ }
+
+ tardio = double.parse(widget.list![i].montoTardio!);
+ if (widget.list![i].pago == 1) {
+ contador;
+ } else {
+ if (widget.list![i].pagoTardio == 0) {
+ if (DateTime.now().day <= widget.list![i].fechaLimite!.day &&
+ DateTime.now().month <= widget.list![i].fechaLimite!.month &&
+ DateTime.now().year <= widget.list![i].fechaLimite!.year) {
+ setState(() {
+ contador += deuda;
+ });
+ } else {
+ setState(() {
+ contador += deuda + tardio;
+ });
+ }
+ } else {
+ setState(() {
+ contador += deuda + tardio;
+ });
+ }
+ }
+ }
+ return contador;
+ }
+}
diff --git a/lib/src/extra/eventos.dart b/lib/src/extra/eventos.dart
index 5343987..2760e27 100644
--- a/lib/src/extra/eventos.dart
+++ b/lib/src/extra/eventos.dart
@@ -63,7 +63,7 @@ class _CalendarioState extends State {
prefs = await SharedPreferences.getInstance();
Uri uri = Uri.parse(
- 'http://187.189.53.8:8080/AdcomBackend/backend/web/index.php?r=adcom/get-amenidad-reserva');
+ 'http://187.189.53.8:8081/backend/web/index.php?r=adcom/get-amenidad-reserva');
final response =
await http.post(uri, body: {"idAmenidad": "${widget.idA}"});
diff --git a/lib/src/extra/nuevo_post.dart b/lib/src/extra/nuevo_post.dart
new file mode 100644
index 0000000..9245430
--- /dev/null
+++ b/lib/src/extra/nuevo_post.dart
@@ -0,0 +1,447 @@
+import 'dart:convert';
+import 'dart:io';
+import 'package:dio/dio.dart';
+import 'package:file_picker/file_picker.dart';
+import 'package:fluttertoast/fluttertoast.dart';
+import 'package:http/http.dart' as http;
+import 'package:adcom/json/tipoAvisot.dart';
+import 'package:adcom/src/pantallas/avisos.dart';
+import 'package:flutter/material.dart';
+import 'package:flutter/services.dart';
+import 'package:glyphicon/glyphicon.dart';
+import 'package:gradient_widgets/gradient_widgets.dart';
+import 'package:shared_preferences/shared_preferences.dart';
+import 'package:http_parser/src/media_type.dart';
+
+SharedPreferences? prefs;
+
+// ignore: must_be_immutable
+class MakeNewPost extends StatefulWidget {
+ MakeNewPost({Key? key, this.idComu, this.comunities}) : super(key: key);
+ List? idComu;
+ List? comunities = [];
+ @override
+ _MakeNewPostState createState() => _MakeNewPostState();
+}
+
+class _MakeNewPostState extends State {
+ final GlobalKey _formKey = GlobalKey();
+ final titleController = TextEditingController();
+ String? chosenValue;
+ String? chosenValue2;
+ int? idCom;
+ List file = [];
+ int? idA;
+ List avisos = [];
+ List? nameFile = [];
+ List type = [];
+ @override
+ void initState() {
+ super.initState();
+ }
+
+ @override
+ Widget build(BuildContext context) {
+ var size = MediaQuery.of(context).size;
+ return Scaffold(
+ floatingActionButton: FloatingActionButton(
+ backgroundColor: Colors.blueGrey[700],
+ onPressed: onSave,
+ child: Icon(
+ Glyphicon.pencil,
+ color: Colors.white,
+ ),
+ ),
+ appBar: AppBar(
+ title: Text('Nuevo Post'),
+ automaticallyImplyLeading: false,
+ elevation: 4.0,
+ backgroundColor: Colors.blueGrey[700],
+ leading: CloseButton(),
+ ),
+ body: SafeArea(
+ child: ListView(children: [
+ Column(
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: [
+ Row(
+ children: [
+ Padding(
+ padding: const EdgeInsets.only(left: 25, top: 15),
+ child: Container(
+ height: 51,
+ width: size.width / 9,
+ decoration: BoxDecoration(
+ color: Colors.grey[300], shape: BoxShape.circle),
+ child: Image.asset(
+ 'assets/images/logo.png',
+ ),
+ ),
+ ),
+ SizedBox(
+ width: size.width / 55,
+ ),
+ Padding(
+ padding: EdgeInsets.only(top: size.width / 39),
+ child: Text('Administrador',
+ style: (TextStyle(
+ fontSize: 16, fontWeight: FontWeight.w500))),
+ ),
+ SizedBox(
+ width: size.width / 6,
+ ),
+ drop()
+ ],
+ ),
+ Container(
+ padding: EdgeInsets.only(top: 20, left: 20, right: 20),
+ child: Form(
+ key: _formKey,
+ child: TextFormField(
+ controller: titleController,
+ onFieldSubmitted: (_) => onSave(),
+ validator: (title) => title != null && title.isEmpty
+ ? 'Este campo no puede estar vacio'
+ : null,
+ autofocus: true,
+ maxLines: 4,
+ keyboardType: TextInputType.multiline,
+ decoration: InputDecoration(
+ labelText: "¿Algo para decir?",
+ labelStyle: TextStyle(
+ color: Colors.black,
+ fontSize: 16,
+ fontWeight: FontWeight.w500),
+ fillColor: Colors.white,
+ focusedBorder: OutlineInputBorder(
+ borderRadius: BorderRadius.circular(25.0),
+ borderSide: BorderSide(color: Color(0xFF455A64))),
+ ),
+ inputFormatters: [
+ LengthLimitingTextInputFormatter(200)
+ ]),
+ )),
+ SizedBox(
+ height: size.width / 20,
+ ),
+ Divider(
+ color: Color(0xFF455A64).withOpacity(0.3),
+ thickness: 1.1,
+ ),
+ Padding(
+ padding: EdgeInsets.only(left: 20, top: 10, right: 20),
+ child: InkWell(
+ onTap: () async {
+ Fluttertoast.showToast(
+ msg: "Mantenga Presionado el archivo",
+ toastLength: Toast.LENGTH_SHORT,
+ gravity: ToastGravity.CENTER,
+ timeInSecForIosWeb: 1,
+ backgroundColor: Colors.white,
+ textColor: Colors.black,
+ fontSize: 17.0);
+ await filePick().then((value) => {
+ if (value != null)
+ {
+ for (var item in value)
+ {
+ //print('here ${item!.path.split('/').last}'),
+ nameFile!
+ .add(Text(item!.path.split('/').last))
+ }
+ }
+ else
+ {print('no existe')}
+ });
+ setState(() {
+ newFiles();
+ });
+ },
+ child: Column(
+ children: [
+ Row(
+ children: [
+ Icon(
+ Glyphicon.paperclip,
+ color: Colors.pink,
+ size: 25,
+ ),
+ SizedBox(
+ width: size.width / 20,
+ ),
+ Column(
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: [
+ Text('Selecciona varios archivos',
+ style: TextStyle(
+ fontSize: 16,
+ fontWeight: FontWeight.bold)),
+ SizedBox(
+ height: size.width / 20,
+ ),
+ nameFile!.isEmpty ? Container() : newFiles()
+ ],
+ ),
+ ],
+ ),
+ ],
+ ),
+ ),
+ ),
+ SizedBox(
+ height: size.width / 15,
+ child: Divider(
+ color: Color(0xFF455A64).withOpacity(0.3),
+ thickness: 1.1,
+ ),
+ ),
+ Center(
+ child: Padding(
+ padding: const EdgeInsets.only(left: 20, top: 10),
+ child: DropdownButton(
+ elevation: 6,
+ value: chosenValue,
+ style: TextStyle(color: Colors.black),
+ items: widget.idComu!
+ .map>((String value) {
+ return DropdownMenuItem(
+ value: value, child: Text(value));
+ }).toList(),
+ onChanged: (val) {
+ print(val);
+ print(chosenValue);
+ if (chosenValue == null) {
+ setState(() {
+ chosenValue = val;
+ });
+ sendId();
+ } else {
+ if (val != chosenValue) {
+ type.clear();
+ setState(() {
+ chosenValue = val;
+ });
+ sendId();
+ } else {
+ if (val == chosenValue) {
+ } else {
+ type.clear();
+ sendId();
+ }
+ }
+ }
+ },
+ hint: Text("Elige una comunidad",
+ style: TextStyle(
+ color: Colors.black,
+ fontSize: 16,
+ fontWeight: FontWeight.w600)),
+ ),
+ ),
+ ),
+ ],
+ )
+ ]),
+ ),
+ );
+ }
+
+ drop() {
+ return chosenValue == null
+ ? Container()
+ : Container(
+ padding: EdgeInsets.only(top: 10),
+ child: DropdownButton(
+ focusColor: Colors.white,
+ value: chosenValue2,
+ //elevation: 5,
+ style: TextStyle(color: Colors.white),
+ iconEnabledColor: Colors.black,
+ items: type.map>((String value) {
+ return DropdownMenuItem(
+ value: value,
+ child: Text(
+ value,
+ style: TextStyle(color: Colors.black),
+ ),
+ );
+ }).toList(),
+ hint: Text(
+ "Tipo aviso",
+ style: TextStyle(
+ color: Colors.black,
+ fontSize: 14,
+ fontWeight: FontWeight.w500),
+ ),
+ onChanged: (value) {
+ setState(() {
+ chosenValue2 = value;
+ });
+
+ getIdAviso();
+ },
+ ),
+ );
+ }
+
+ Column newFiles() {
+ return Column(
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: nameFile!,
+ );
+ }
+
+ getIdAviso() {
+ for (int i = 0; i < avisos.length; i++) {
+ if (chosenValue2 == avisos[i].tipoAviso) {
+ setState(() {
+ idA = avisos[i].idCatTipoAviso!;
+ });
+ }
+ }
+ }
+
+ Future sendId() async {
+ for (int i = 0; i < widget.comunities!.length; i++) {
+ if (chosenValue == widget.comunities![i].nombreComu) {
+ setState(() {
+ idCom = widget.comunities![i].id;
+ });
+ }
+ }
+
+ await getTipoAviso().then((value) => {
+ for (int i = 0; i < value!.data!.length; i++)
+ {
+ type.add(value.data![i].tipoAviso!),
+ avisos.add(new TipoAvisoS(
+ tipoAviso: value.data![i].tipoAviso,
+ idCatTipoAviso: value.data![i].idCatTipoaviso,
+ idCom: value.data![i].idCom))
+ }
+ });
+ }
+
+ Future?> filePick() async {
+ FilePickerResult? result =
+ await FilePicker.platform.pickFiles(allowMultiple: true);
+
+ if (result != null) {
+ file = result.paths.map((path) => File(path!)).toList();
+
+ return file;
+ } else {
+ Fluttertoast.showToast(
+ msg: "No selecciono archivos",
+ toastLength: Toast.LENGTH_SHORT,
+ gravity: ToastGravity.CENTER,
+ timeInSecForIosWeb: 1,
+ backgroundColor: Colors.white,
+ textColor: Colors.black,
+ fontSize: 17.0);
+ }
+ }
+
+ Future onSave() async {
+ final isValid = _formKey.currentState!.validate();
+ prefs = await SharedPreferences.getInstance();
+ var id = prefs!.getInt('idPrimario');
+ if (isValid) {
+ if (chosenValue != null && chosenValue2 != null) {
+ await sendingData(idCom!, titleController.text, nameFile!, id!, idA!)
+ .then((value) => {
+ Navigator.of(context).pop(),
+ ScaffoldMessenger.of(context).showSnackBar(SnackBar(
+ content: Text(
+ 'Su reporte se ha realizado con exito!',
+ style: TextStyle(fontSize: 19),
+ )))
+ });
+ } else {
+ Fluttertoast.showToast(
+ msg: "Seleccione comunidad",
+ toastLength: Toast.LENGTH_SHORT,
+ gravity: ToastGravity.CENTER,
+ timeInSecForIosWeb: 1,
+ backgroundColor: Colors.white,
+ textColor: Colors.black,
+ fontSize: 17.0);
+ }
+ } else {
+ Fluttertoast.showToast(
+ msg: "Sus datos son incorrectos",
+ toastLength: Toast.LENGTH_SHORT,
+ gravity: ToastGravity.CENTER,
+ timeInSecForIosWeb: 1,
+ backgroundColor: Colors.white,
+ textColor: Colors.black,
+ fontSize: 17.0);
+ }
+ }
+
+ Future sendingData(
+ int idCom,
+ String aviso,
+ List nameFile,
+ int id,
+ int idA,
+ ) async {
+ try {
+ List filesArr = [];
+ Dio dio = Dio();
+
+ for (var item in file) {
+ print(file.length);
+ filesArr.add(item.path.split('/').last);
+ }
+
+ var formdata2 = FormData.fromMap({
+ 'params': json.encode(
+ {'userId': id, 'comId': idCom, 'tipoAvisoId': idA, 'aviso': aviso}),
+ 'archivos[]': [
+ for (int i = 0; i < file.length; i++)
+ MultipartFile.fromFileSync(file[i].path,
+ filename: filesArr[i], contentType: MediaType('*', '*'))
+ ]
+ });
+ Response response = await dio.post(
+ 'http://187.189.53.8:8081/backend/web/index.php?r=adcom/crear-aviso',
+ data: formdata2, onSendProgress: (received, total) {
+ if (total != 1) {
+ print((received / total * 100).toStringAsFixed(0) + '%');
+ }
+ });
+
+ if (response.statusCode == 200) {
+ print('aqui $response');
+ }
+ } on DioError catch (e) {
+ if (e.response!.data == true) {
+ print('aqui1:${e.response!.data.toString()}');
+ return;
+ } else {
+ print('aqui2:${e.response!.data.toString()}');
+ }
+ }
+ }
+
+ Future getTipoAviso() async {
+ final Uri url = Uri.parse(
+ 'http://187.189.53.8:8081/backend/web/index.php?r=adcom/get-tipo-aviso');
+ final response = await http.post(url, body: {"idCom": idCom.toString()});
+
+ if (response.statusCode == 200) {
+ var data = response.body;
+ print(data);
+ return tipoAvisoFromJson(data);
+ }
+ }
+}
+
+class TipoAvisoS {
+ int? idCatTipoAviso;
+ String? tipoAviso;
+ int? idCom;
+
+ TipoAvisoS({this.idCatTipoAviso, this.idCom, this.tipoAviso});
+}
diff --git a/lib/src/extra/opciones_edoCuenta.dart b/lib/src/extra/opciones_edoCuenta.dart
index 5a3cfdc..9ce145a 100644
--- a/lib/src/extra/opciones_edoCuenta.dart
+++ b/lib/src/extra/opciones_edoCuenta.dart
@@ -2,7 +2,8 @@ import 'dart:typed_data';
import 'package:flutter/material.dart';
import 'package:pdf/pdf.dart';
import 'package:pdf/widgets.dart' as pw;
-import 'package:syncfusion_flutter_pdfviewer/pdfviewer.dart';
+import 'package:shared_preferences/shared_preferences.dart';
+import 'package:printing/printing.dart';
class OpcionesEdoCuenta extends StatefulWidget {
OpcionesEdoCuenta({Key? key}) : super(key: key);
@@ -11,8 +12,20 @@ class OpcionesEdoCuenta extends StatefulWidget {
_OpcionesEdoCuentaState createState() => _OpcionesEdoCuentaState();
}
+SharedPreferences? prefs;
+
class _OpcionesEdoCuentaState extends State {
late ImageProvider image;
+ String? user;
+ int? idComu;
+ String? comunidad;
+ String? nombreFrac;
+ String? domicilio;
+ String? numInt;
+ String? tipoLote;
+ String? cp;
+ String? ref;
+ DateTime? timenow = DateTime.now().toUtc();
@override
Widget build(BuildContext context) {
return Scaffold(
@@ -52,14 +65,8 @@ class _OpcionesEdoCuentaState extends State {
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
- Text(item, style: TextStyle(fontSize: 16.0)),
- InkWell(
-
- child: Icon(
- Icons.picture_as_pdf_rounded,
- size: 30,
- ),
- )
+ Text('Cuota', style: TextStyle(fontSize: 16.0)),
+ Text('')
],
),
SizedBox(
@@ -83,36 +90,136 @@ class _OpcionesEdoCuentaState extends State {
pageFormat: format,
build: (context) => [
_buildCustomHeadline(),
+ _buildDataUser(),
+ _buildDataUser()
]));
return await doc.save();
}
_buildCustomHeadline() {
return pw.Header(
- child: pw.Text('Adcom',
- style: pw.TextStyle(
- fontSize: 24,
- fontWeight: pw.FontWeight.bold,
- color: PdfColors.black)),
- padding: pw.EdgeInsets.all(4),
- );
+ child: pw.Row(
+ mainAxisAlignment: pw.MainAxisAlignment.spaceBetween,
+ children: [
+ pw.Text('AdCom',
+ style: pw.TextStyle(
+ fontSize: 24,
+ fontWeight: pw.FontWeight.bold,
+ color: PdfColors.white)),
+ pw.Text('$nombreFrac',
+ style: pw.TextStyle(
+ fontSize: 15,
+ fontWeight: pw.FontWeight.bold,
+ color: PdfColors.white)),
+ pw.Text('Estado de cuenta',
+ style: pw.TextStyle(
+ fontSize: 24,
+ fontWeight: pw.FontWeight.bold,
+ color: PdfColors.white)),
+ ]),
+ padding: pw.EdgeInsets.all(9.0),
+ decoration: pw.BoxDecoration(color: PdfColors.red));
+ }
+
+ _buildTable() {
+ final headers = ['Concepto', 'Referencia', 'Monto', 'Pagado Tardio'];
+ final users = [
+ Users(name: 'Enero', referencia: 190991, monto: 700, pagado: 'No'),
+ Users(name: 'Febrero', referencia: 20123, monto: 750, pagado: 'Si'),
+ Users(name: 'Marzo', referencia: 251231, monto: 700, pagado: 'No')
+ ];
+
+ final data = users
+ .map((users) =>
+ [users.name, users.referencia, users.monto, users.pagado])
+ .toList();
+ return pw.Padding(
+ padding: pw.EdgeInsets.all(10.0),
+ child: pw.Table.fromTextArray(
+ headers: headers,
+ data: data,
+ headerStyle: pw.TextStyle(fontWeight: pw.FontWeight.bold)));
+ }
+
+ _buildDataUser() {
+ return pw.Container(
+ padding: const pw.EdgeInsets.all(11.0),
+ child:
+ pw.Row(crossAxisAlignment: pw.CrossAxisAlignment.start, children: [
+ pw.Column(children: [
+ pw.Paragraph(
+ textAlign: pw.TextAlign.justify,
+ text: 'Residente: $user',
+ style:
+ pw.TextStyle(fontSize: 12, fontWeight: pw.FontWeight.bold)),
+ pw.Paragraph(
+ textAlign: pw.TextAlign.justify,
+ text: 'Domicilio: $domicilio',
+ style:
+ pw.TextStyle(fontSize: 12, fontWeight: pw.FontWeight.bold)),
+ pw.Paragraph(
+ textAlign: pw.TextAlign.justify,
+ text:
+ 'Estado de cuenta del día: ${timenow!.day}/${timenow!.month}/${timenow!.year} ',
+ style:
+ pw.TextStyle(fontSize: 12, fontWeight: pw.FontWeight.bold)),
+ ]),
+ pw.Column(children: [
+ pw.Paragraph(
+ text: 'Tipo Lote: $tipoLote',
+ style:
+ pw.TextStyle(fontSize: 12, fontWeight: pw.FontWeight.bold)),
+ pw.Paragraph(
+ text: 'C.P: $cp ',
+ style:
+ pw.TextStyle(fontSize: 12, fontWeight: pw.FontWeight.bold)),
+ pw.Paragraph(
+ text: 'Saldo del día: ',
+ style:
+ pw.TextStyle(fontSize: 12, fontWeight: pw.FontWeight.bold))
+ ]),
+ pw.Column(children: [
+ pw.Paragraph(
+ text: 'Referencia: $ref ',
+ style:
+ pw.TextStyle(fontSize: 12, fontWeight: pw.FontWeight.bold)),
+ pw.Paragraph(
+ text: 'Saldo para liquidar el año: ',
+ style:
+ pw.TextStyle(fontSize: 12, fontWeight: pw.FontWeight.bold))
+ ]),
+ ]));
+ }
+
+ saveData() async {
+ prefs = await SharedPreferences.getInstance();
+ setState(() {
+ user = prefs!.getString('user');
+ nombreFrac = prefs!.getString('nombreFracc');
+ domicilio = prefs!.getString('domicilio');
+ numInt = prefs!.getString('numInt');
+ tipoLote = prefs!.getString('tipoLote');
+ cp = prefs!.getString('cp');
+ ref = prefs!.getString('reference');
+ });
}
}
-class PdfVista extends StatefulWidget {
- PdfVista({Key? key}) : super(key: key);
+class Users {
+ final String? name;
+ final int? referencia;
+ final int? monto;
+ final String? pagado;
- @override
- _PdfVistaState createState() => _PdfVistaState();
+ const Users({this.name, this.referencia, this.monto, this.pagado});
}
-class _PdfVistaState extends State {
- @override
- Widget build(BuildContext context) {
- return Scaffold(
- body: Container(
- child: SfPdfViewer.network(''),
- ),
- );
- }
+class Comunidad {
+ final String? nombreFracc;
+ final String? domicilio;
+ final String? numInt;
+ final String? tipoLote;
+ final String? cp;
+ const Comunidad(
+ {this.nombreFracc, this.cp, this.domicilio, this.numInt, this.tipoLote});
}
diff --git a/lib/src/extra/referencia_view.dart b/lib/src/extra/referencia_view.dart
index 63edda6..6cf1e44 100644
--- a/lib/src/extra/referencia_view.dart
+++ b/lib/src/extra/referencia_view.dart
@@ -1,11 +1,12 @@
import 'package:adcom/src/models/event_provider.dart';
+import 'package:adcom/src/pantallas/finanzas.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:provider/provider.dart';
class RefView extends StatefulWidget {
- RefView({Key? key}) : super(key: key);
-
+ late List? list = [];
+ RefView({Key? key, this.list}) : super(key: key);
@override
_RefViewState createState() => _RefViewState();
}
@@ -95,15 +96,13 @@ class _RefViewState extends State {
}
referenciaApagar() {
- final deudas = Provider.of(context, listen: false).deudas;
-
String? ref;
- for (int i = 0; i < deudas.length; i++) {
- if (deudas[i].pago == 1 && deudas[i].pagoTardio == 0) {
+ for (int i = 0; i < widget.list!.length; i++) {
+ if (widget.list![i].pago == 1 && widget.list![i].pagoTardio == 0) {
print('no debe');
} else {
setState(() {
- ref = deudas[i].referencia!;
+ ref = widget.list![i].referencia!;
});
return ref == null ? " " : ref;
}
diff --git a/lib/src/extra/report_edit_page.dart b/lib/src/extra/report_edit_page.dart
index 476bd16..2e5c5e1 100644
--- a/lib/src/extra/report_edit_page.dart
+++ b/lib/src/extra/report_edit_page.dart
@@ -3,21 +3,139 @@ import 'package:adcom/src/extra/add_reporte.dart';
import 'package:adcom/src/extra/reporte.dart';
import 'package:flutter/material.dart';
import 'package:im_stepper/stepper.dart';
+import 'dart:convert';
+// ignore: must_be_immutable
class ReportEditPage extends StatefulWidget {
+ final int? id;
final DataReporte report;
+ final List data;
- const ReportEditPage({Key? key, required this.report}) : super(key: key);
+ /// variable que indiga el progreso actual del estatus.
+ Map? progreso;
+
+ /// variable que muestra los comentarios por progreso.
+ Map? datos;
+
+ /// variables que muestra las fechas de los comentarios.
+ Map? fechas;
+
+ Map? superMap = {};
+
+ ReportEditPage(
+ {Key? key,
+ required this.report,
+ required this.data,
+ this.datos,
+ this.progreso,
+ this.fechas,
+ this.id})
+ : super(key: key);
@override
_ReportEditPageState createState() => _ReportEditPageState();
}
class _ReportEditPageState extends State {
- int _activeStep = 0;
+ var activestep = 0;
+ List progreso = [];
+ var data;
+ List progres = [];
+ List datosp = [];
+ bool finalizado = false;
+ List f = [];
+
+ /// funcion que retorna el estatus y lo asigna en arreglo
+ /// recorre el mapeado de dos niveles
+ estatus() {
+ /// recorre el mapeado
+ widget.progreso!.forEach((key, value) {
+ if (widget.id == key) {
+ /// recorre el segundo mapeado
+ value.forEach((key, value) {
+ if (key == 'Progreso') {
+ setState(() {
+ for (int i = 0; i < value.length; i++) {
+ value.sort();
+ progres.add(new ProgressIndicator(id: value[i]));
+ }
+ });
+ }
+ });
+ } else {
+ return;
+ }
+ });
+ }
+
+ ///mismo metodo que el mapeato del estatus
+ /// chechar [estatus]
+ datos() {
+ widget.datos!.forEach((key, value) {
+ if (widget.id == key) {
+ value.forEach((key, value) {
+ if (key == 'Datos') {
+ setState(() {
+ for (int i = 0; i < value.length; i++) {
+ datosp.add(new DatosProgreso(coment: value[i]));
+ }
+ });
+ }
+ });
+ } else {
+ return;
+ }
+ });
+ }
+
+ ///Funcion para mapeado de fecha
+ /// checar estatus
+ fechasR() {
+ widget.fechas!.forEach((key, value) {
+ if (widget.id == key) {
+ value.forEach((key, value) {
+ if (key == 'Fechas') {
+ setState(() {
+ for (int i = 0; i < value.length; i++) {
+ f.add(new FechaReporte(f: value[i]));
+ }
+ });
+ }
+ });
+ }
+ });
+ }
+
+ @override
+ void initState() {
+ /// carga los datos para poder procesarlos
+ /// en lo que abre la pantalla
+ estatus();
+ datos();
+ fechasR();
+
+ super.initState();
+ }
+
+ /// validacion que indica el exito de un proceso
+ isFinalizado() {
+ if (progres.isNotEmpty) {
+ if (progres.last.id == 4) {
+ setState(() {
+ /// enciende estados como el click en el stepper
+ finalizado = true;
+ });
+ } else {
+ finalizado = false;
+ }
+ }
+ return finalizado;
+ }
@override
Widget build(BuildContext context) {
+ var size = MediaQuery.of(context).size.width;
+ //var size2 = MediaQuery.of(context).size.width;
return Scaffold(
appBar: AppBar(
title: Text('Seguimiento de reporte'),
@@ -29,16 +147,22 @@ class _ReportEditPageState extends State {
child: Column(
children: [
IconStepper(
+ enableStepTapping: isFinalizado(),
icons: [
Icon(Icons.supervised_user_circle),
+ Icon(Icons.check),
Icon(Icons.flag),
Icon(Icons.access_alarm),
Icon(Icons.check)
],
- activeStep: _activeStep,
+ activeStep: progres.isEmpty ? 0 : progres.last.id,
onStepReached: (index) {
setState(() {
- _activeStep = index;
+ if (progres.isEmpty) {
+ activestep = index;
+ } else {
+ progres.last.id = index;
+ }
});
},
),
@@ -50,16 +174,18 @@ class _ReportEditPageState extends State {
SizedBox(
height: 20,
),
- plainText()
+ plainText(size)
],
),
));
}
+ /// funcion que muesta el encabezado del proceso
+ /// [setpColor] sirve para cambiar el color segun el proceso
Widget header() {
return Container(
decoration: BoxDecoration(
- color: stepColor()!, borderRadius: BorderRadius.circular(5)),
+ color: stepColor(), borderRadius: BorderRadius.circular(5)),
child: Row(
children: [
Padding(
@@ -75,114 +201,225 @@ class _ReportEditPageState extends State {
);
}
- Widget plainText() {
- switch (_activeStep) {
+ /// Switch case que muestra el estatus del reporte
+ /// cada case es un caso del proceso del 1 al 4
+ Widget plainText(size) {
+ switch (progres.isEmpty ? 0 : progres.last.id) {
case 1:
- return Column(
- crossAxisAlignment: CrossAxisAlignment.start,
- children: [
- Text(
- 'Asesor:',
- style: TextStyle(fontWeight: FontWeight.bold, fontSize: 18),
- ),
- SizedBox(
- height: 10,
- ),
- Text(
- 'Su estado se encuentra en revisión',
- style: TextStyle(fontSize: 18, fontWeight: FontWeight.w300),
- ),
- SizedBox(
- height: 10,
- ),
- Text(
- 'Se le notificara el cambio de estado del reporte',
- style: TextStyle(fontSize: 18, fontWeight: FontWeight.w300),
- )
- ],
- );
+ return datosp.isEmpty
+ ? Container(
+ child: Column(
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: [
+ Text('Asesor:',
+ style: TextStyle(
+ fontWeight: FontWeight.bold,
+ fontSize: 18,
+ )),
+ SizedBox(
+ height: 10,
+ ),
+ Text(
+ 'Tu reporte se encuentra en revision',
+ style:
+ TextStyle(fontWeight: FontWeight.w300, fontSize: 18),
+ )
+ ],
+ ),
+ )
+ : Column(
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: [
+ SizedBox(
+ height: size / 25,
+ ),
+ Padding(
+ padding: const EdgeInsets.only(left: 50),
+ child: Text('Comentarios:',
+ style: TextStyle(
+ fontWeight: FontWeight.bold,
+ fontSize: 18,
+ )),
+ ),
+ respuestaView(size),
+ ],
+ );
case 2:
- return Column(
- crossAxisAlignment: CrossAxisAlignment.start,
- children: [
- Text(
- 'Asesor:',
- style: TextStyle(fontWeight: FontWeight.bold, fontSize: 18),
- ),
- SizedBox(
- height: 10,
- ),
- Text('Tu estado se ha revisado y se esta atendiendo',
- style: TextStyle(
- fontSize: 18,
- fontWeight: FontWeight.w300,
- )),
- SizedBox(
- height: 10,
- ),
- Text(
- 'Comentarios:',
- style: TextStyle(fontWeight: FontWeight.bold, fontSize: 18),
- ),
- SizedBox(
- height: 10,
- ),
- Text(
- '',
- style: TextStyle(fontWeight: FontWeight.w300, fontSize: 18),
- )
- ],
- );
+ return datosp.isEmpty
+ ? Container(
+ child: Column(
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: [
+ Text('Asesor:',
+ style: TextStyle(
+ fontWeight: FontWeight.bold,
+ fontSize: 18,
+ )),
+ SizedBox(
+ height: 10,
+ ),
+ Text(
+ 'Tu reporte esta siendo procesado',
+ style:
+ TextStyle(fontWeight: FontWeight.w300, fontSize: 18),
+ )
+ ],
+ ),
+ )
+ : Column(
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: [
+ Container(
+ padding: EdgeInsets.only(left: 50),
+ child: Text('Comentarios:',
+ style: TextStyle(
+ fontWeight: FontWeight.bold,
+ fontSize: 18,
+ )),
+ ),
+ respuestaView(size),
+ ],
+ );
case 3:
- return Column(
- crossAxisAlignment: CrossAxisAlignment.start,
- children: [
- Text('Asesor:',
- style: TextStyle(
- fontWeight: FontWeight.bold,
- fontSize: 18,
- )),
- SizedBox(
- height: 10,
- ),
- Text(
- 'Tu reporte se ha atendido y ha finalizado con éxito',
- style: TextStyle(fontWeight: FontWeight.w300, fontSize: 18),
- )
- ],
- );
+ return datosp.isEmpty
+ ? Container(
+ child: Column(
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: [
+ Text('Asesor:',
+ style: TextStyle(
+ fontWeight: FontWeight.bold,
+ fontSize: 18,
+ )),
+ SizedBox(
+ height: 10,
+ ),
+ Text(
+ 'No hay comentarios',
+ style:
+ TextStyle(fontWeight: FontWeight.w300, fontSize: 18),
+ )
+ ],
+ ),
+ )
+ : Column(
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: [
+ Text('Respuesta de Asesor:',
+ style: TextStyle(
+ fontWeight: FontWeight.bold,
+ fontSize: 18,
+ )),
+ respuestaView(size),
+ ],
+ );
+ case 4:
+ return datosp.isEmpty
+ ? Container(
+ child: Column(
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: [
+ Text('Asesor:',
+ style: TextStyle(
+ fontWeight: FontWeight.bold,
+ fontSize: 18,
+ )),
+ SizedBox(
+ height: 10,
+ ),
+ Text(
+ 'Tu reporte se ha atendido y ha finalizado con éxito',
+ style:
+ TextStyle(fontWeight: FontWeight.w300, fontSize: 18),
+ )
+ ],
+ ),
+ )
+ : Column(
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: [
+ Container(
+ padding: EdgeInsets.only(left: 30),
+ child: Text('Respuestas:',
+ style: TextStyle(
+ fontWeight: FontWeight.bold,
+ fontSize: 19,
+ )),
+ ),
+ respuestaView(size),
+ ],
+ );
default:
return Container();
}
}
+ /// es la vista de la respuesta
+ ListView respuestaView(size) {
+ return ListView.builder(
+ padding: EdgeInsets.only(left: size / 4.3, top: 10),
+ shrinkWrap: true,
+
+ /// recorre el largo de los datos procesados
+ itemCount: datosp.length,
+ itemBuilder: (_, int index) {
+ return Column(
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: [
+ SizedBox(
+ height: 5,
+ ),
+ Text(
+ '${f[index].f!.day}/${f[index].f!.month}/${f[index].f!.year}',
+ style: TextStyle(fontSize: 15, fontWeight: FontWeight.bold)),
+ SizedBox(
+ height: 5,
+ ),
+ SizedBox(
+ width: size / 2,
+ child: Text(datosp[index].coment,
+ style:
+ TextStyle(fontSize: 15, fontWeight: FontWeight.w400)),
+ ),
+ ],
+ );
+ });
+ }
+
+ /// funcion que cambia de color segun en el estatus
Color? stepColor() {
- switch (_activeStep) {
+ switch (progres.isEmpty ? 0 : progres.last.id) {
case 1:
- return Colors.lightGreen[200];
+ return Colors.yellow;
case 2:
- return Colors.lightGreen[300];
+ return Colors.lightGreen[200];
case 3:
+ return Colors.lightGreen[300];
+ case 4:
return Colors.lightGreen;
+
default:
- return Colors.yellow;
+ return Colors.grey;
}
}
+ ///muesta el nombre segun el estatus
String? headerText() {
- switch (_activeStep) {
+ switch (progres.isEmpty ? 0 : progres.last.id) {
case 1:
return 'Revisión';
case 2:
- return 'Respuesta';
+ return 'En proceso';
case 3:
+ return 'Respuesta';
+ case 4:
return 'Finalizado';
-
default:
- return 'En proceso';
+ return 'Enviado';
}
}
+ /// funcion que constuye la imagen o la cantidad de imagenes
buildImage() => GridView.builder(
shrinkWrap: true,
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
@@ -197,6 +434,8 @@ class _ReportEditPageState extends State {
},
);
+ ///muestra el titulo del reporte y las imagenes del reporte
+ /// chechar buildImage para cualquier detalle de imagenes
help() {
return Column(
children: [
@@ -205,12 +444,17 @@ class _ReportEditPageState extends State {
child: Column(
//crossAxisAlignment: CrossAxisAlignment.start,
children: [
- Container(
- alignment: Alignment.topLeft,
- child: Text(
- widget.report.descripCorta!,
- style: TextStyle(fontSize: 25, fontWeight: FontWeight.bold),
- ),
+ Row(
+ children: [
+ Container(
+ alignment: Alignment.topLeft,
+ child: Text(
+ widget.report.descripCorta!,
+ style:
+ TextStyle(fontSize: 25, fontWeight: FontWeight.bold),
+ ),
+ ),
+ ],
),
SizedBox(
height: 15,
@@ -233,3 +477,21 @@ class _ReportEditPageState extends State {
);
}
}
+
+class ProgressIndicator {
+ var id;
+
+ ProgressIndicator({this.id});
+}
+
+class FechaReporte {
+ DateTime? f;
+
+ FechaReporte({this.f});
+}
+
+class DatosProgreso {
+ var coment;
+
+ DatosProgreso({this.coment});
+}
diff --git a/lib/src/extra/reporte.dart b/lib/src/extra/reporte.dart
index d4a473f..e822bba 100644
--- a/lib/src/extra/reporte.dart
+++ b/lib/src/extra/reporte.dart
@@ -1,10 +1,7 @@
-import 'dart:convert';
-
import 'package:adcom/json/jsonReporte.dart';
+import 'package:adcom/src/extra/add_reporte.dart';
import 'package:adcom/src/extra/report_edit_page.dart';
-import 'package:adcom/src/models/event_provider.dart';
import 'package:flutter/material.dart';
-import 'package:provider/provider.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:http/http.dart' as http;
@@ -12,30 +9,21 @@ SharedPreferences? prefs;
class LevantarReporte extends StatefulWidget {
const LevantarReporte({Key? key}) : super(key: key);
- static init() async {
- prefs = await SharedPreferences.getInstance();
- }
@override
_LevantarReporteState createState() => _LevantarReporteState();
}
-dataOff5(id) async {
- await LevantarReporte.init();
- prefs!.setInt('id', id);
-}
-
Future getReportes() async {
prefs = await SharedPreferences.getInstance();
- var id = prefs!.getInt('id');
+ var id = prefs!.getInt('userId');
Uri url = Uri.parse(
- 'http://187.189.53.8:8080/AdcomBackend/backend/web/index.php?r=adcom/get-reportes');
+ 'http://187.189.53.8:8081/backend/web/index.php?r=adcom/get-reportes');
final response = await http.post(url, body: {"idResidente": id.toString()});
if (response.statusCode == 200) {
var data = response.body;
- print(data);
return getReportesFromJson(data);
} else {
@@ -45,30 +33,146 @@ Future getReportes() async {
class _LevantarReporteState extends State {
List myList = [];
+ List listProgreso = [];
+ List idProgress = [];
+ List myListReversed = [];
+ var progress = [];
+
+ /// progreso data
+ var maps = {};
+ var progreso = {};
+ List