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> superMap = []; + String? comunidad; + String? numero; + String? interior; + + /// datos del progreso + /// mapeado dinamico que espera otro mapeado + var maps2 = {}; + + /// mapeado dinamico que espera dinamico + /// dinamico es tu tipo de variable que toma cualquier valor + var datos = {}; + + /// lista mapeada dinamica que espera otro mapeado + List> superMap2 = []; + + var fechasMap = {}; + var fDatos = {}; + List> fechasSuperMap = []; + + /// Declaraciones de futuras listas en reversa + /// checar la asignacion en la funcion data, antes de cualquier alteracion + /// + List reversedList = []; + List> reversedList2 = []; + List> reversedList3 = []; + List> reversedList4 = []; GetReportes? cuentas; + + var idCom; + var idUser; + var userType; + + /// Activa el guardado en memoria + addata() async { + prefs = await SharedPreferences.getInstance(); + if (mounted) { + setState(() { + /// obtiene el id comunidad y la del usuario + idCom = prefs!.getInt('idCom'); + idUser = prefs!.getInt('userId'); + userType = prefs!.getInt('userType'); + }); + } + } + + /// Llama al service y asigna los datos obtenido a una clase data() async { cuentas = await getReportes(); + await addata(); + for (int i = 0; i < cuentas!.data!.length; i++) { - myList.add(new DataReporte( - descripCorta: cuentas!.data![i].descCorta, - desperfecto: cuentas!.data![i].descDesperfecto, - fechaRep: cuentas!.data![i].fechaRep, - uri: cuentas!.data![i].evidencia!.toList())); + if (userType == 2) { + print('aqui?'); + myList.add(new DataReporte( + id: cuentas!.data![i].idReporte, + descripCorta: cuentas!.data![i].descCorta, + desperfecto: cuentas!.data![i].descDesperfecto, + fechaRep: cuentas!.data![i].fechaRep, + uri: cuentas!.data![i].evidencia!.toList(), + comunidad: cuentas!.data![i].comunidad!.trimRight(), + numero: cuentas!.data![i].numero!.trimRight(), + interior: cuentas!.data![i].interior!.trimRight())); + } else { + myList.add(new DataReporte( + id: cuentas!.data![i].idReporte, + descripCorta: cuentas!.data![i].descCorta, + desperfecto: cuentas!.data![i].descDesperfecto, + fechaRep: cuentas!.data![i].fechaRep, + uri: cuentas!.data![i].evidencia!.toList())); + } + + for (int j = 0; j < cuentas!.data![i].progreso!.length; j++) { + //mapeado del estatus asgigando id + var progress = []; + //añade los estatus a la lista progress + cuentas!.data![i].progreso!.forEach((element) { + setState(() { + progress.add(element.idProgreso); + }); + }); + //se mapea la lista progress + + progreso = {"Progreso": progress}; + + //mapeado + maps.addAll({cuentas!.data![i].idReporte: progreso}); + + var datosProgres = []; + cuentas!.data![i].progreso!.forEach((element) { + setState(() { + datosProgres.add(element.comentario); + }); + }); + datos = {"Datos": datosProgres}; + maps2.addAll({cuentas!.data![i].idReporte: datos}); + + var fechasList = []; + cuentas!.data![i].progreso!.forEach((element) { + setState(() { + fechasList.add(element.fechaSeg); + }); + }); + + fDatos = {"Fechas": fechasList}; + fechasMap.addAll({cuentas!.data![i].idReporte: fDatos}); + } + fechasSuperMap.add(fechasMap); + superMap2.add(maps2); + superMap.add(maps); } + reversedList2 = fechasSuperMap.reversed.toList(); + reversedList3 = superMap2.reversed.toList(); + reversedList4 = superMap.reversed.toList(); + reversedList = myList.reversed.toList(); + + refresh(); } @override void initState() { data(); super.initState(); - Future.delayed(Duration(milliseconds: 988), () => {refresh()}); } refresh() { - setState(() { - listview(); - }); + if (mounted) { + setState(() { + listview(); + }); + } } @override @@ -79,7 +183,7 @@ class _LevantarReporteState extends State { backgroundColor: Colors.blue, title: Text('Reportes'), ), - body: myList.length == 0 + body: reversedList.length == 0 ? SafeArea( child: Center( child: Column( @@ -94,9 +198,11 @@ class _LevantarReporteState extends State { ), ) : listview(), + floatingActionButtonLocation: FloatingActionButtonLocation.centerDocked, floatingActionButton: FloatingActionButton( elevation: 7, - onPressed: () => Navigator.of(context).popAndPushNamed('/screen18'), + onPressed: () => Navigator.of(context) + .push(MaterialPageRoute(builder: (_) => AddReporte())), backgroundColor: Colors.blue, child: Icon( Icons.add, @@ -106,7 +212,7 @@ class _LevantarReporteState extends State { ); } - Container listview() { + listview() { return Container( child: ListView.separated( separatorBuilder: (context, index) { @@ -115,17 +221,23 @@ class _LevantarReporteState extends State { color: Colors.grey[350], ); }, - itemCount: myList.length, + itemCount: reversedList.length, itemBuilder: (context, int index) { return Container( padding: EdgeInsets.all(8), child: ListTile( onTap: () { Navigator.of(context).push(MaterialPageRoute( - builder: (_) => ReportEditPage(report: myList[index]))); + builder: (_) => ReportEditPage( + report: reversedList[index], + data: listProgreso, + progreso: reversedList4[index], + datos: reversedList3[index], + id: reversedList[index].id, + fechas: reversedList2[index]))); }, title: Text( - '${myList[index].descripCorta}', + '${reversedList[index].descripCorta}', style: TextStyle( fontSize: 20, ), @@ -136,13 +248,34 @@ class _LevantarReporteState extends State { SizedBox( width: 160, child: Text( - '${myList[index].desperfecto}', + '${reversedList[index].desperfecto}', style: TextStyle(fontSize: 18), ), ), - Text( - '${myList[index].fechaRep!.day}/${myList[index].fechaRep!.month}/${myList[index].fechaRep!.year}', - style: TextStyle(fontSize: 18), + Column( + children: [ + Text( + '${reversedList[index].fechaRep!.day}/${reversedList[index].fechaRep!.month}/${reversedList[index].fechaRep!.year}', + style: TextStyle(fontSize: 18), + ), + SizedBox( + height: 5, + ), + reversedList[index].comunidad == null + ? Text('') + : SizedBox( + width: 100, + child: Text(reversedList[index].comunidad!)), + reversedList[index].numero == null + ? Text('') + : Row( + children: [ + Text(reversedList[index].numero!), + Text('-'), + Text(reversedList[index].interior!) + ], + ), + ], ) ], ), @@ -154,11 +287,38 @@ class _LevantarReporteState extends State { } } +class Progreso { + int? id; + DateTime? time; + String? comentario; + String? progreso; + + Progreso({this.time, this.comentario, this.progreso, this.id}); + /* @override + String toString() { + return "($id, $time, $comentario, $progreso)"; + } */ +} + class DataReporte { + int? id; String? descripCorta; String? desperfecto; DateTime? fechaRep; List? uri = []; + List? progreso = []; + String? comunidad; + String? numero; + String? interior; - DataReporte({this.descripCorta, this.desperfecto, this.fechaRep, this.uri}); + DataReporte( + {this.id, + this.descripCorta, + this.desperfecto, + this.fechaRep, + this.uri, + this.progreso, + this.comunidad, + this.interior, + this.numero}); } diff --git a/lib/src/extra/vista_tarjeta.dart b/lib/src/extra/vista_tarjeta.dart index 3495ae4..04ce324 100644 --- a/lib/src/extra/vista_tarjeta.dart +++ b/lib/src/extra/vista_tarjeta.dart @@ -1,15 +1,20 @@ import 'package:adcom/json/jsonFinanzas.dart'; +import 'package:adcom/src/extra/detalles_pago.dart'; import 'package:adcom/src/extra/more_view_cuota.dart'; +import 'package:adcom/src/extra/referencia_view.dart'; import 'package:adcom/src/models/event_provider.dart'; import 'package:adcom/src/pantallas/finanzas.dart'; import 'package:flutter/material.dart'; +import 'package:intl/intl.dart'; import 'package:provider/provider.dart'; class VistaTarjeta extends StatefulWidget { - VistaTarjeta({Key? key}) : super(key: key); + List? newList = []; + List? refP = []; + VistaTarjeta({Key? key, this.newList, this.refP}) : super(key: key); @override _VistaTarjetaState createState() => _VistaTarjetaState(); @@ -19,16 +24,17 @@ class _VistaTarjetaState extends State { VoidCallback? _showPersBottomSheetCallBack; Accounts? cuentas; List mylist = []; + List mesFormat = []; + @override void initState() { super.initState(); _showPersBottomSheetCallBack = _showPersBottomSheetCallBack; - data(); - Future.delayed(Duration(seconds: 1), () { - setState(() { - ultimaDeuda(); - estadodepago(); - }); + //data(); + + setState(() { + ultimaDeuda(); + estadodepago(); }); } @@ -41,247 +47,118 @@ class _VistaTarjetaState extends State { Widget build(BuildContext context) { var size = MediaQuery.of(context).size; var size2 = MediaQuery.of(context).size.width; - return mylist.isEmpty - ? SizedBox() - : size.width >= 880 - ? Container( - width: MediaQuery.of(context).size.width, - height: 225, - decoration: BoxDecoration( - boxShadow: [ - BoxShadow( - color: Colors.grey, - blurRadius: 6, - offset: Offset(0, 1)) - ], - color: estadodepagoColor(), - borderRadius: BorderRadius.circular(10)), - child: Padding( - padding: const EdgeInsets.only( - left: 20, right: 20, top: 20, bottom: 30), - child: Column( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text( - 'Monto de cuota', - style: TextStyle( - color: Colors.white, - fontWeight: FontWeight.bold, - fontSize: 17), - ), - SizedBox( - height: 5.0, - ), - Text( - '${estadodepago()}', - style: TextStyle( - color: Colors.black, - fontSize: 15, - ), - ) - ], - ), - Container( - height: 40, - child: OutlinedButton( - onPressed: () { - Navigator.of(context).push(MaterialPageRoute( - builder: (_) => MoreViewCuota())); - }, - child: Icon(Icons.add, - size: 25, color: Colors.white), - style: OutlinedButton.styleFrom( - side: BorderSide( - width: 1.0, color: Colors.transparent)), - ), - ) - ], - ), - Column( - children: [ - Text( - '\$ ${ultimaDeuda()}', - style: TextStyle( - color: Colors.white, - fontWeight: FontWeight.bold, - fontSize: 28), - ), - SizedBox( - height: 10, - ), - Text( - mylist.isEmpty - ? 'Pagar antes del día: ' - : 'Pagar antes del día: ${fechadepago()}', - style: TextStyle( - color: Colors.black, - fontWeight: FontWeight.w400, - fontSize: 14), - ), - ], + + return Container( + width: MediaQuery.of(context).size.width, + height: 220, + decoration: BoxDecoration(boxShadow: [ + BoxShadow(color: Colors.grey, blurRadius: 6, offset: Offset(0, 1)) + ], color: estadodepagoColor(), borderRadius: BorderRadius.circular(10)), + child: Padding( + padding: + const EdgeInsets.only(left: 13, right: 13, top: 13, bottom: 20), + child: Column( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + 'Monto de cuota', + style: TextStyle( + color: Colors.white, + fontWeight: FontWeight.bold, + fontSize: 15), + ), + SizedBox( + height: 2.0, + ), + Text( + '${estadodepago()}', + style: TextStyle( + color: Colors.black, + fontSize: 14, ), - Row( - mainAxisAlignment: MainAxisAlignment.spaceAround, - children: [ - OutlinedButton( - onPressed: () { - _showModalSheet(); - }, - child: Text( - 'Pagar Ahora', - textAlign: TextAlign.center, - style: - TextStyle(color: Colors.white, fontSize: 15), - ), - style: OutlinedButton.styleFrom( - side: BorderSide( - width: 1.0, color: Colors.white)), - ), - //Text('|', style: TextStyle(color: Colors.white, fontSize: 15)), - - OutlinedButton( - onPressed: () { - _showAlertDialog(); - }, - child: Text('Detalles', - textAlign: TextAlign.center, - style: TextStyle( - color: Colors.white, fontSize: 15)), - style: OutlinedButton.styleFrom( - side: BorderSide( - width: 1.0, color: Colors.white)), - ) - ], - ) - ], + ) + ], + ), + Container( + height: 30, + child: OutlinedButton( + onPressed: () { + Navigator.of(context).push(MaterialPageRoute( + builder: (_) => RefView( + list: widget.newList, + ))); + }, + child: Icon(Icons.add, size: 25, color: Colors.white), + style: OutlinedButton.styleFrom( + side: + BorderSide(width: 1.0, color: Colors.transparent)), ), + ) + ], + ), + Column( + children: [ + Text( + '\$ ${saldoDeudor()}', + style: TextStyle( + color: Colors.white, + fontWeight: FontWeight.bold, + fontSize: 28), ), - ) - : Container( - width: MediaQuery.of(context).size.width, - height: 190, - decoration: BoxDecoration( - boxShadow: [ - BoxShadow( - color: Colors.grey, - blurRadius: 6, - offset: Offset(0, 1)) - ], - color: estadodepagoColor(), - borderRadius: BorderRadius.circular(10)), - child: Padding( - padding: const EdgeInsets.only( - left: 10, right: 10, top: 10, bottom: 20), - child: Column( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text( - 'Monto de cuota', - style: TextStyle( - color: Colors.white, - fontWeight: FontWeight.bold, - fontSize: 15), - ), - SizedBox( - height: 2.0, - ), - Text( - '${estadodepago()}', - style: TextStyle( - color: Colors.black, - fontSize: 14, - ), - ) - ], - ), - Container( - height: 30, - child: OutlinedButton( - onPressed: () { - Navigator.of(context).push(MaterialPageRoute( - builder: (_) => MoreViewCuota())); - }, - child: Icon(Icons.add, - size: 25, color: Colors.white), - style: OutlinedButton.styleFrom( - side: BorderSide( - width: 1.0, color: Colors.transparent)), - ), - ) - ], - ), - Column( - children: [ - Text( - '\$ ${ultimaDeuda()}', - style: TextStyle( - color: Colors.white, - fontWeight: FontWeight.bold, - fontSize: 28), - ), - SizedBox( - height: 10, - ), - Text( - mylist.isEmpty - ? 'Pagar antes del día: ' - : 'Pagar antes del día: ${fechadepago()}', - style: TextStyle( - color: Colors.black, - fontWeight: FontWeight.w400, - fontSize: 14), - ), - ], - ), - Row( - mainAxisAlignment: MainAxisAlignment.spaceAround, - children: [ - OutlinedButton( - onPressed: () { - _showModalSheet(); - }, - child: Text( - 'Pagar Ahora', - textAlign: TextAlign.center, - style: - TextStyle(color: Colors.white, fontSize: 14), - ), - style: OutlinedButton.styleFrom( - side: BorderSide( - width: 1.0, color: Colors.white)), - ), - //Text('|', style: TextStyle(color: Colors.white, fontSize: 15)), - - OutlinedButton( - onPressed: () { - _showAlertDialog(size: size2); - }, - child: Text('Detalles', - textAlign: TextAlign.center, - style: TextStyle( - color: Colors.white, fontSize: 15)), - style: OutlinedButton.styleFrom( - side: BorderSide( - width: 1.0, color: Colors.white)), - ) - ], - ) - ], + SizedBox( + height: 10, + ), + Text( + 'Pagar antes del día: ${fechadepago()}', + style: TextStyle( + color: Colors.black, + fontWeight: FontWeight.w400, + fontSize: 14), + ), + ], + ), + Row( + mainAxisAlignment: MainAxisAlignment.spaceAround, + children: [ + OutlinedButton( + onPressed: () { + _showModalSheet(); + }, + child: Text( + 'Pagar Ahora', + textAlign: TextAlign.center, + style: TextStyle(color: Colors.white, fontSize: 14), ), + style: OutlinedButton.styleFrom( + side: BorderSide(width: 1.0, color: Colors.white)), ), - ); + //Text('|', style: TextStyle(color: Colors.white, fontSize: 15)), + + OutlinedButton( + onPressed: () { + Navigator.of(context).push(MaterialPageRoute( + builder: (_) => DetallesPago( + list: widget.newList!, + ))); + }, + child: Text('Detalles', + textAlign: TextAlign.center, + style: TextStyle(color: Colors.white, fontSize: 15)), + style: OutlinedButton.styleFrom( + side: BorderSide(width: 1.0, color: Colors.white)), + ) + ], + ) + ], + ), + ), + ); } void _showModalSheet() { @@ -301,7 +178,7 @@ class _VistaTarjetaState extends State { mainAxisAlignment: MainAxisAlignment.start, children: [ Text( - 'Seleccione su método de pago', + 'Seleccioné su método de pago', style: TextStyle(fontSize: 21), ), SizedBox( @@ -385,55 +262,37 @@ class _VistaTarjetaState extends State { content: Container( width: size / 20, height: 150, - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, + Column( children: [ - Text('Mantenimiento', + Text('Cuota', style: TextStyle( fontSize: size / 20, fontWeight: FontWeight.w400, textBaseline: TextBaseline.alphabetic, )), - Text('\$${ultimaDeuda2()}', - style: TextStyle( - fontSize: 20, - fontWeight: FontWeight.bold, - textBaseline: TextBaseline.alphabetic, - )) ], ), SizedBox( height: 12, ), - Row( + /* Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ - Text( - 'Atraso', - style: TextStyle( - fontSize: 19, - fontWeight: FontWeight.w400, - textBaseline: TextBaseline.alphabetic), - ), - Text('\$${atraso()}', - style: TextStyle( - fontSize: 20, - fontWeight: FontWeight.bold, - textBaseline: TextBaseline.alphabetic, - )) + Column( + children: [Text('${mesesDeAtraso()}')], + ) ], - ), + ), */ SizedBox( height: 15, child: Divider( color: Colors.black, ), ), - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, + Column( children: [ Text( 'Total', @@ -442,7 +301,7 @@ class _VistaTarjetaState extends State { fontWeight: FontWeight.w400, textBaseline: TextBaseline.alphabetic), ), - totalApagars() == null + saldoDeudor() == null ? Text('\$0.0', style: TextStyle( fontSize: 20, @@ -478,28 +337,48 @@ class _VistaTarjetaState extends State { fechaPago: cuentas!.data![i].fechaPago, pago: cuentas!.data![i].pago!, totalApagar: cuentas!.data![i].totalApagar, + referencia: cuentas!.data![i].referencia, pagoTardio: cuentas!.data![i].pagoTardio, montoTardio: cuentas!.data![i].montoPagoTardio)); } } + mesesDeAtraso() { + DateTime? mesesAtrazo; + + for (int i = 0; i < widget.newList!.length; i++) { + if (widget.newList![i].pago == 1) { + } else { + setState(() { + mesesAtrazo = widget.newList![i].fechaGenerada; + mesFormat + .add((DateFormat('MMM').format(DateTime(0, mesesAtrazo!.month)))); + }); + + print(DateFormat('MMM').format(DateTime(0, mesesAtrazo!.month))); + } + } + return DateFormat('MMM').format(DateTime(0, mesesAtrazo!.month)); + } + ultimaDeuda() { double debe = 0.0; double? monto; int? total; - for (int i = 0; i < mylist.length; i++) { - monto = double.parse(mylist[i].montoCuota!); - if (mylist[i].pago == 1 && mylist[i].pagoTardio == 0) { + for (int i = 0; i < widget.newList!.length; i++) { + monto = double.parse(widget.newList![i].montoCuota!); + if (widget.newList![i].pago == 1 && widget.newList![i].pagoTardio == 0) { } else { - if (DateTime.now().day <= mylist[i].fechaLimite!.day && - DateTime.now().month <= mylist[i].fechaLimite!.month && - DateTime.now().year <= mylist[i].fechaLimite!.year) { + if (DateTime.now().day <= widget.newList![i].fechaLimite!.day && + DateTime.now().month <= widget.newList![i].fechaLimite!.month && + DateTime.now().year <= widget.newList![i].fechaLimite!.year) { return debe = monto; } else { - if (mylist[i].pagoTardio == 0 || mylist[i].pagoTardio == null) { + if (widget.newList![i].pagoTardio == 0 || + widget.newList![i].pagoTardio == null) { return debe = monto; } else { - total = int.parse(mylist[i].montoTardio!); + total = int.parse(widget.newList![i].montoTardio!); return debe = monto + total; } } @@ -512,16 +391,16 @@ class _VistaTarjetaState extends State { double debe = 0.0; double? monto; - for (int i = 0; i < mylist.length; i++) { - monto = double.parse(mylist[i].montoCuota!); - if (mylist[i].pago == 1 && mylist[i].pagoTardio == 0) { + for (int i = 0; i < widget.newList!.length; i++) { + monto = double.parse(widget.newList![i].montoCuota!); + if (widget.newList![i].pago == 1 && widget.newList![i].pagoTardio == 0) { } else { - if (DateTime.now().day <= mylist[i].fechaLimite!.day && - DateTime.now().month <= mylist[i].fechaLimite!.month && - DateTime.now().year <= mylist[i].fechaLimite!.year) { + if (DateTime.now().day <= widget.newList![i].fechaLimite!.day && + DateTime.now().month <= widget.newList![i].fechaLimite!.month && + DateTime.now().year <= widget.newList![i].fechaLimite!.year) { return debe = monto; } else { - if (mylist[i].pagoTardio == 0) { + if (widget.newList![i].pagoTardio == 0) { return debe = monto; } else { return debe = monto; @@ -536,14 +415,14 @@ class _VistaTarjetaState extends State { int? dia; int? mes; int? year; - for (int i = 0; i < mylist.length; i++) { - if (mylist[i].pago == 1) { + for (int i = 0; i < widget.newList!.length; i++) { + if (widget.newList![i].pago == 1) { print('no debe'); } else { setState(() { - dia = mylist[i].fechaLimite!.day; - mes = mylist[i].fechaLimite!.month; - year = mylist[i].fechaLimite!.year; + dia = widget.newList![i].fechaLimite!.day; + mes = widget.newList![i].fechaLimite!.month; + year = widget.newList![i].fechaLimite!.year; }); return dia == null ? '' : '$dia/$mes/$year'; } @@ -552,16 +431,53 @@ class _VistaTarjetaState extends State { return dia == null ? '' : '$dia/$mes/$year'; } + saldoDeudor() { + double contador = 0.0; + double deuda; + double tardio; + for (int i = 0; i < widget.newList!.length; i++) { + if (widget.newList![i].montoCuota == null) { + deuda = 0.0; + } else { + deuda = double.parse(widget.newList![i].montoCuota!); + } + + tardio = double.parse(widget.newList![i].montoTardio!); + if (widget.newList![i].pago == 1) { + contador; + } else { + if (widget.newList![i].pagoTardio == 0) { + if (DateTime.now().day <= widget.newList![i].fechaLimite!.day && + DateTime.now().month <= widget.newList![i].fechaLimite!.month && + DateTime.now().year <= widget.newList![i].fechaLimite!.year) { + setState(() { + contador += deuda; + }); + } else { + setState(() { + contador += deuda + tardio; + }); + } + } else { + setState(() { + contador += deuda + tardio; + }); + } + } + } + return contador; + } + estadodepago() { String? estado; - for (int i = 0; i < mylist.length; i++) { - if (mylist[i].pago == 1) { + for (int i = 0; i < widget.newList!.length; i++) { + if (widget.newList![i].pago == 1) { estado = 'No deudas'; } else { - if (DateTime.now().day <= mylist[i].fechaLimite!.day && - DateTime.now().month <= mylist[i].fechaLimite!.month && - DateTime.now().year <= mylist[i].fechaLimite!.year || - mylist[i].fechaLimite!.isAfter(DateTime.now())) { + if (DateTime.now().day <= widget.newList![i].fechaLimite!.day && + DateTime.now().month <= widget.newList![i].fechaLimite!.month && + DateTime.now().year <= widget.newList![i].fechaLimite!.year || + widget.newList![i].fechaLimite!.isAfter(DateTime.now())) { setState(() { estado = 'Pendiente'; }); @@ -579,13 +495,13 @@ class _VistaTarjetaState extends State { cuotaExtra() { bool? estado; - for (int i = 0; i < mylist.length; i++) { - if (mylist[i].pago == 1) { + for (int i = 0; i < widget.newList!.length; i++) { + if (widget.newList![i].pago == 1) { estado = true; } else { - if (DateTime.now().day <= mylist[i].fechaLimite!.day && - DateTime.now().month <= mylist[i].fechaLimite!.month && - DateTime.now().year <= mylist[i].fechaLimite!.year) { + if (DateTime.now().day <= widget.newList![i].fechaLimite!.day && + DateTime.now().month <= widget.newList![i].fechaLimite!.month && + DateTime.now().year <= widget.newList![i].fechaLimite!.year) { return estado = true; } else { return estado = false; @@ -595,16 +511,17 @@ class _VistaTarjetaState extends State { return estado; } + ///ok estadodepagoColor() { Color? estado; - for (int i = 0; i < mylist.length; i++) { - if (mylist[i].pago == 1) { + for (int i = 0; i < widget.newList!.length; i++) { + if (widget.newList![i].pago == 1) { estado = Colors.lightGreen[700]; } else { - if (DateTime.now().day <= mylist[i].fechaLimite!.day && - DateTime.now().month <= mylist[i].fechaLimite!.month && - DateTime.now().year <= mylist[i].fechaLimite!.year || - mylist[i].fechaLimite!.isAfter(DateTime.now())) { + if (DateTime.now().day <= widget.newList![i].fechaLimite!.day && + DateTime.now().month <= widget.newList![i].fechaLimite!.month && + DateTime.now().year <= widget.newList![i].fechaLimite!.year || + widget.newList![i].fechaLimite!.isAfter(DateTime.now())) { return estado = Colors.amber[400]; } else { return estado = Colors.red[700]; @@ -614,25 +531,27 @@ class _VistaTarjetaState extends State { return estado == null ? estado = Colors.lightGreen[700] : estado; } + ///ok atraso() { int? atraso = 0; - for (int i = 0; i < mylist.length; i++) { - if (mylist[i].pago == 1 && mylist[i].pagoTardio == 0) { + for (int i = 0; i < widget.newList!.length; i++) { + if (widget.newList![i].pago == 1 && widget.newList![i].pagoTardio == 0) { return atraso = 0; } else { - return atraso = int.parse(mylist[i].montoTardio!); + return atraso = int.parse(widget.newList![i].montoTardio!); } } return atraso; } + ///ok totalApagars() { late int total; - for (int i = 0; i < mylist.length; i++) { - total = mylist[i].totalApagar!; - if (mylist[i].pagoTardio == 1) { + for (int i = 0; i < widget.newList!.length; i++) { + total = widget.newList![i].totalApagar!; + if (widget.newList![i].pagoTardio == 1) { return total; } else { total = 0; @@ -640,13 +559,14 @@ class _VistaTarjetaState extends State { } } + ///ok referenciaApagar() { String? ref; - for (int i = 0; i < mylist.length; i++) { - if (mylist[i].pago == 1 && mylist[i].pagoTardio == 0) { + for (int i = 0; i < widget.newList!.length; i++) { + if (widget.newList![i].pago == 1 && widget.newList![i].pagoTardio == 0) { } else { setState(() { - ref = mylist[i].referencia!; + ref = widget.newList![i].referencia!; }); return ref; diff --git a/lib/src/methods/avisoDashboard.dart b/lib/src/methods/avisoDashboard.dart deleted file mode 100644 index a12c485..0000000 --- a/lib/src/methods/avisoDashboard.dart +++ /dev/null @@ -1,177 +0,0 @@ -import 'package:adcom/json/jsonReporte.dart'; -import 'package:flutter/material.dart'; -import 'package:shared_preferences/shared_preferences.dart'; - -SharedPreferences? prefs; -int? initScreen; - -class AvisosDashboard extends StatefulWidget { - const AvisosDashboard({Key? key}) : super(key: key); - - @override - _AvisosDashboardState createState() => _AvisosDashboardState(); -} - -class _AvisosDashboardState extends State { - @override - void initState() { - super.initState(); - } - - Items2 item1 = new Items2( - title: "Reportar evento inusual", - route: '/screen17', - icon: Icon( - Icons.warning, - size: 30, - color: Colors.red, - )); - - Items2 item2 = new Items2( - title: 'Seguimiento de reporte', - route: '/screen14', - icon: Icon(Icons.follow_the_signs, size: 30, color: Colors.blue[600])); - - @override - Widget build(BuildContext context) { - var size = MediaQuery.of(context).size; - List myList = [ - item1, - item2, - ]; - return size.width >= 880 - ? Flexible( - child: GridView.count( - padding: EdgeInsets.only(left: 17, right: 17, top: 17), - crossAxisCount: 1, - childAspectRatio: 3.7, - crossAxisSpacing: 15, - mainAxisSpacing: 15, - children: myList.map((data) { - return InkWell( - onTap: () { - Navigator.pushNamed(context, data.route!); - }, - child: Container( - decoration: BoxDecoration( - color: Colors.white, - borderRadius: BorderRadius.circular(20), - boxShadow: [ - BoxShadow( - color: Colors.grey, - blurRadius: 10, - offset: Offset(0, 5)) - ]), - child: Container( - //margin: EdgeInsets.symmetric(vertical: 20), - padding: const EdgeInsets.all(18), - child: Row( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Container( - height: 50, - width: 50, - decoration: BoxDecoration( - color: Colors.grey[300], - shape: BoxShape.circle), - child: data.icon, - ), - SizedBox( - width: 14, - ), - Column( - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - SizedBox( - height: 18, - ), - Text( - data.title!, - style: TextStyle( - color: Colors.black, - fontSize: 16, - fontWeight: FontWeight.w600), - ), - ], - ), - ], - ), - ), - ), - ); - }).toList())) - : Flexible( - child: GridView.count( - padding: EdgeInsets.only(left: 10, right: 10, top: 10), - crossAxisCount: 1, - childAspectRatio: 3.7, - crossAxisSpacing: 15, - mainAxisSpacing: 15, - children: myList.map((data) { - return InkWell( - onTap: () { - Navigator.pushNamed(context, data.route!); - }, - child: Container( - decoration: BoxDecoration( - color: Colors.white, - borderRadius: BorderRadius.circular(20), - boxShadow: [ - BoxShadow( - color: Colors.grey, - blurRadius: 10, - offset: Offset(0, 5)) - ]), - child: Container( - //margin: EdgeInsets.symmetric(vertical: 20), - padding: const EdgeInsets.all(18), - child: Row( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Container( - height: 50, - width: 50, - decoration: BoxDecoration( - color: Colors.grey[300], - shape: BoxShape.circle), - child: data.icon, - ), - SizedBox( - width: 14, - ), - Column( - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - SizedBox( - height: 15, - ), - Text( - data.title!, - style: TextStyle( - color: Colors.black, - fontSize: size.width / 25, - fontWeight: FontWeight.w600), - ), - ], - ), - ], - ), - ), - ), - ); - }).toList())); - } -} - -class Items2 { - String? route; - String? title; - String? numero; - String? id; - String? subtitle; - //el evento puede ayudar a las notificaciones, checar despues - String? event; - Icon? icon; - Items2( - {this.title, this.icon, this.subtitle, this.route, this.id, this.numero}); -} diff --git a/lib/src/methods/emailDashboard.dart b/lib/src/methods/emailDashboard.dart index 30cf9f6..64907cd 100644 --- a/lib/src/methods/emailDashboard.dart +++ b/lib/src/methods/emailDashboard.dart @@ -34,10 +34,12 @@ Future getData() async { prefs = await SharedPreferences.getInstance(); var id = prefs!.getInt('id'); + print(id.toString()); + Uri uri = Uri.parse( - 'http://187.189.53.8:8080/AdcomBackend/backend/web/index.php?r=adcom/get-directorio'); + 'http://187.189.53.8:8081/backend/web/index.php?r=adcom/get-directorio'); final response = await http.post(uri, body: { - "params": json.encode({'usuarioId': id}) + "params": json.encode({"usuarioId": id}) }); if (response.statusCode == 200) { @@ -106,27 +108,29 @@ class _ContactDashboardState extends State { refresh() { setState(() { - vistaContactos(); + var size = MediaQuery.of(context).size.width; + vistaContactos(size); }); } @override Widget build(BuildContext context) { + var size = MediaQuery.of(context).size.width; return myList.isEmpty ? Center( child: CircularProgressIndicator(), ) - : vistaContactos(); + : vistaContactos(size); } - vistaContactos() => Flexible( + vistaContactos(size) => Flexible( child: GridView.builder( shrinkWrap: false, - padding: EdgeInsets.only(left: 4, right: 4, top: 17), + padding: EdgeInsets.only(left: 5, right: 5, top: 17), itemCount: myList.length, gridDelegate: SliverGridDelegateWithFixedCrossAxisCount( crossAxisCount: 1, - childAspectRatio: 3.15, + childAspectRatio: 2.5, crossAxisSpacing: 16, mainAxisSpacing: 16, ), @@ -169,61 +173,39 @@ class _ContactDashboardState extends State { children: [ myList[index].title == null ? Container() - : Text( - myList[index].title!.toUpperCase(), - style: TextStyle( - color: Colors.black, - fontSize: 14.5, - fontWeight: FontWeight.w600), + : SizedBox( + width: size / 2.1, + child: Text( + myList[index].title!.toUpperCase(), + style: TextStyle( + color: Colors.black, + fontSize: size / 29, + fontWeight: FontWeight.bold), + ), ), SizedBox( - height: 10, + height: size / 20, ), Row( children: [ - Text( - 'Comu:', - style: TextStyle( - color: Colors.black, - fontSize: 15, - fontWeight: FontWeight.bold), - ), SizedBox( width: 3, ), myList[index].comNombre == null ? Container() - : Text("${myList[index].comNombre}", - style: TextStyle( - color: Colors.black, - fontSize: 15, - )), + : SizedBox( + width: size / 2, + child: Text("${myList[index].comNombre}", + style: TextStyle( + color: Colors.black, + fontSize: size / 31, + )), + ), ], ), SizedBox( height: 10, ), - Row( - children: [ - Text( - 'Celular:', - style: TextStyle( - color: Colors.black, - fontSize: 15, - fontWeight: FontWeight.bold), - ), - SizedBox( - width: 3, - ), - myList[index].telCel == null - ? Container() - : Text(myList[index].telCel!, - style: TextStyle( - color: Colors.black, - fontSize: 15, - )), - ], - ), ], ), ], diff --git a/lib/src/methods/eventDashboard.dart b/lib/src/methods/eventDashboard.dart index 37bc2c3..20b34fe 100644 --- a/lib/src/methods/eventDashboard.dart +++ b/lib/src/methods/eventDashboard.dart @@ -2,6 +2,7 @@ import 'dart:convert'; import 'package:adcom/json/jsonAmenidades.dart'; import 'package:adcom/src/extra/eventos.dart'; import 'package:flutter/material.dart'; +import 'package:fluttertoast/fluttertoast.dart'; import 'package:http/http.dart' as http; import 'package:shared_preferences/shared_preferences.dart'; @@ -28,11 +29,11 @@ dataOff2(id2, perfil) async { Future amenidades() async { prefs = await SharedPreferences.getInstance(); - var id = prefs!.getInt('idCom'); + var id = prefs!.getInt('idPrimario'); print('?$id'); final Uri url = Uri.parse( - 'http://187.189.53.8:8080/AdcomBackend/backend/web/index.php?r=adcom/get-amenidades'); + 'http://187.189.53.8:8081/backend/web/index.php?r=adcom/get-amenidades'); final response = await http.post(url, body: { "params": json.encode({"usuarioId": id}) }); @@ -72,43 +73,47 @@ class _EventDashboardState extends State { places = (await amenidades())!; var userType = prefs!.getInt('UserType'); - switch (userType) { - case 1: - myList.add( - item2, - ); - break; - case 2: - myList.add( - item1, - ); - break; - default: - } + if (places.data!.isNotEmpty) { + switch (userType) { + case 1: + myList.add( + item2, + ); + break; + case 2: + myList.add( + item1, + ); + break; + default: + } - for (int i = 0; i < places.data!.length; i++) { - myList.add(new Amenidad( - //route: '/screen12', - id: places.data![i].id, - idComu: places.data![i].idCom, - title: places.data![i].amenidadDesc, - route: '/screen12', - subtitle: 'Only residentes', - icon: Icon( - Icons.pool, - size: 30, - color: Colors.deepPurple, - ))); + for (int i = 0; i < places.data!.length; i++) { + myList.add(new Amenidad( + //route: '/screen12', + id: places.data![i].id, + idComu: places.data![i].idCom, + title: places.data![i].amenidadDesc, + route: '/screen12', + subtitle: 'Only residentes', + icon: Icon( + Icons.pool, + size: 30, + color: Colors.deepPurple, + ))); + } + } else { + setState(() { + if (mounted) { + itsTrue = false; + } + }); } } catch (e) { - myList.add(new Amenidad( - error: 'No tiene amenidades', - icon: Icon( - Icons.sms_failed, - color: Colors.red, - ))); setState(() { - itsTrue = false; + if (mounted) { + itsTrue = false; + } }); } } @@ -117,15 +122,20 @@ class _EventDashboardState extends State { void initState() { super.initState(); gtData(); - Future.delayed(Duration(milliseconds: 988), () => {refresh()}); + if (itsTrue == false) { + } else { + Future.delayed(Duration(seconds: 2), () => {refresh()}); + } } refresh() { - setState(() { - var size = MediaQuery.of(context).size.width; - var size2 = MediaQuery.of(context).size.height; - viewAmenidades(width: size, heigth: size2); - }); + if (mounted) { + setState(() { + var size = MediaQuery.of(context).size.width; + var size2 = MediaQuery.of(context).size.height; + viewAmenidades(width: size, heigth: size2); + }); + } } @override @@ -134,9 +144,30 @@ class _EventDashboardState extends State { var size2 = MediaQuery.of(context).size.height; return myList.isEmpty ? Center( - child: CircularProgressIndicator( - backgroundColor: Colors.white, - ), + child: itsTrue == false + ? Container( + padding: EdgeInsets.only(top: size / 6), + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Image.asset( + 'assets/images/zzz.png', + width: size / 1, + height: 200, + ), + Text( + 'Lo sentimos por el momento no dispone amenidades', + style: TextStyle( + fontSize: size / 20, + color: Colors.deepPurple, + ), + textAlign: TextAlign.justify, + ) + ], + )) + : CircularProgressIndicator( + backgroundColor: Colors.white, + ), ) : viewAmenidades(width: size, heigth: size2); } @@ -223,7 +254,6 @@ class _EventDashboardState extends State { SizedBox( height: width / 40, ), - itsTrue == false ? Text('Lo sentimos :(') : Text(''), ], ), ], diff --git a/lib/src/methods/event_editing_page.dart b/lib/src/methods/event_editing_page.dart index ec94a99..deb3634 100644 --- a/lib/src/methods/event_editing_page.dart +++ b/lib/src/methods/event_editing_page.dart @@ -24,12 +24,6 @@ class EventEditingPage extends StatefulWidget { _EventEditingPageState createState() => _EventEditingPageState(); } -accesData(comId, userId) async { - await EventEditingPage.init(); - prefs!.setInt('idCom', comId); - prefs!.setInt('idUser', userId); -} - //intentar llamar id Amenidad de otra manera class _EventEditingPageState extends State { @@ -45,7 +39,7 @@ class _EventEditingPageState extends State { prefs = await SharedPreferences.getInstance(); setState(() { idCom = prefs!.getInt('idCom'); - idUser = prefs!.getInt('idUser'); + idUser = prefs!.getInt('userId'); }); } @@ -230,7 +224,7 @@ class _EventEditingPageState extends State { }); Response response = await dio.post( - 'http://187.189.53.8:8080/AdcomBackend/backend/web/index.php?r=adcom/reserva-amenidad', + 'http://187.189.53.8:8081/backend/web/index.php?r=adcom/reserva-amenidad', data: formData, onSendProgress: (received, total) { if (total != -1) { print((received / total * 100).toStringAsFixed(0) + '%'); diff --git a/lib/src/methods/gridDashboard.dart b/lib/src/methods/gridDashboard.dart index ac3c0b1..9e6a844 100644 --- a/lib/src/methods/gridDashboard.dart +++ b/lib/src/methods/gridDashboard.dart @@ -1,6 +1,11 @@ +import 'package:adcom/json/jsonAmenidades.dart'; +import 'package:adcom/src/methods/eventDashboard.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:flutter_staggered_animations/flutter_staggered_animations.dart'; +import 'package:shared_preferences/shared_preferences.dart'; + +SharedPreferences? prefs; class GridDashboard extends StatefulWidget { final userId; @@ -25,12 +30,13 @@ class _GridDashboardState extends State { )); Items item2 = new Items( - title: 'Proximamente', - //route: '/screen4', - icon: Icon(Icons.announcement_rounded, size: 50, color: Colors.grey)); + title: 'Avisos', + route: '/screen4', + icon: Icon(Icons.announcement_rounded, + size: 50, color: Colors.blueGrey[700])); Items item3 = new Items( - title: 'Proximamente', + title: 'Votaciones', //route: '/screen6', icon: Icon( Icons.book_rounded, @@ -90,27 +96,18 @@ class _GridDashboardState extends State { List myList = []; @override Widget build(BuildContext context) { + var size = MediaQuery.of(context).size; switch (widget.userId) { case 1: - myList = [ - item1, - item5, - item4, - - ]; + myList = [item1, item5, item4, item2]; break; case 2: myList = [ - item1, item9, item4, item5, item2, - item3, - item6, - item7, - item8, ]; break; @@ -118,61 +115,63 @@ class _GridDashboardState extends State { myList = [item8, item9]; break; } - return Flexible( - child: AnimationLimiter( - child: GridView.count( - padding: EdgeInsets.only(left: 16, right: 16, top: 10), - crossAxisCount: 2, - childAspectRatio: 1.1, - crossAxisSpacing: 15, - mainAxisSpacing: 15, - children: myList.map((data) { - return AnimationConfiguration.staggeredGrid( - columnCount: myList.length, - duration: Duration(milliseconds: 375), - position: 2, - child: ScaleAnimation( - scale: 0.5, - child: FadeInAnimation( - child: InkWell( - onTap: () { - HapticFeedback.mediumImpact(); - Navigator.pushNamed(context, data.route!, - arguments: GridDashboard()); - }, - child: Container( - decoration: BoxDecoration( - color: Colors.white, - borderRadius: BorderRadius.circular(20), - boxShadow: [ - BoxShadow( - color: Colors.grey, - blurRadius: 10, - offset: Offset(0, 5)) - ]), - child: Column( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - data.icon!, - SizedBox( - height: 14, - ), - Text( - data.title!, - style: TextStyle( - color: Colors.black, - fontSize: 16, - fontWeight: FontWeight.w600), - ), - ], + return AnimationLimiter( + child: Container( + child: GridView.count( + padding: + EdgeInsets.only(left: 16, right: 16, top: size.height / 2.5), + crossAxisCount: 2, + childAspectRatio: 1.1, + crossAxisSpacing: 15, + mainAxisSpacing: 12, + children: myList.map((data) { + return AnimationConfiguration.staggeredGrid( + columnCount: myList.length, + duration: Duration(milliseconds: 375), + position: 2, + child: ScaleAnimation( + scale: 0.5, + child: FadeInAnimation( + child: InkWell( + onTap: () { + HapticFeedback.mediumImpact(); + Navigator.pushNamed(context, data.route!, + arguments: GridDashboard()); + }, + child: Container( + decoration: BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.circular(20), + boxShadow: [ + BoxShadow( + color: Colors.grey, + blurRadius: 10, + offset: Offset(0, 5)) + ]), + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + data.icon!, + SizedBox( + height: 14, + ), + Text( + data.title!, + style: TextStyle( + color: Colors.black, + fontSize: 16, + fontWeight: FontWeight.w600), + ), + ], + ), ), ), ), ), - ), - ); - }).toList()), - )); + ); + }).toList()), + ), + ); } } diff --git a/lib/src/methods/reporteDashboard.dart b/lib/src/methods/reporteDashboard.dart new file mode 100644 index 0000000..1a77a67 --- /dev/null +++ b/lib/src/methods/reporteDashboard.dart @@ -0,0 +1,115 @@ +import 'package:adcom/json/jsonReporte.dart'; +import 'package:flutter/material.dart'; +import 'package:shared_preferences/shared_preferences.dart'; + +SharedPreferences? prefs; +int? initScreen; + +class ReportesDashboard extends StatefulWidget { + const ReportesDashboard({Key? key}) : super(key: key); + + @override + _ReportesDashboardState createState() => _ReportesDashboardState(); +} + +class _ReportesDashboardState extends State { + @override + void initState() { + super.initState(); + } + + Items2 item1 = new Items2( + title: "Reportar evento inusual", + route: '/screen17', + icon: Icon( + Icons.warning, + size: 30, + color: Colors.red, + )); + + Items2 item2 = new Items2( + title: 'Seguimiento de reporte', + route: '/screen14', + icon: Icon(Icons.follow_the_signs, size: 30, color: Colors.blue[600])); + + @override + Widget build(BuildContext context) { + var size = MediaQuery.of(context).size; + List myList = [ + item1, + item2, + ]; + return Flexible( + child: GridView.count( + padding: EdgeInsets.only(left: 10, right: 10, top: 10), + crossAxisCount: 1, + childAspectRatio: 3.5, + crossAxisSpacing: 15, + mainAxisSpacing: 15, + children: myList.map((data) { + return InkWell( + onTap: () { + Navigator.pushNamed(context, data.route!); + }, + child: Container( + decoration: BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.circular(20), + boxShadow: [ + BoxShadow( + color: Colors.grey, + blurRadius: 10, + offset: Offset(0, 5)) + ]), + child: Container( + //margin: EdgeInsets.symmetric(vertical: 20), + padding: const EdgeInsets.all(18), + child: Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Container( + height: 50, + width: 50, + decoration: BoxDecoration( + color: Colors.grey[300], shape: BoxShape.circle), + child: data.icon, + ), + SizedBox( + width: 14, + ), + Column( + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + SizedBox( + height: 15, + ), + Text( + data.title!, + style: TextStyle( + color: Colors.black, + fontSize: size.width / 25, + fontWeight: FontWeight.w600), + ), + ], + ), + ], + ), + ), + ), + ); + }).toList())); + } +} + +class Items2 { + String? route; + String? title; + String? numero; + String? id; + String? subtitle; + //el evento puede ayudar a las notificaciones, checar despues + String? event; + Icon? icon; + Items2( + {this.title, this.icon, this.subtitle, this.route, this.id, this.numero}); +} diff --git a/lib/src/models/event_data_source.dart b/lib/src/models/event_data_source.dart index 672ad91..81b216b 100644 --- a/lib/src/models/event_data_source.dart +++ b/lib/src/models/event_data_source.dart @@ -3,6 +3,10 @@ import 'dart:ui'; import 'package:adcom/src/models/event.dart'; import 'package:syncfusion_flutter_calendar/calendar.dart'; +/// gets que obtienen caracteristicas del apartado de amenidades +/// datos como el tiempo, el titulo del apartado del evento, +/// el color del guardado del evento, etc + class EventDataSource extends CalendarDataSource { EventDataSource(List appointments) { this.appointments = appointments; @@ -19,9 +23,11 @@ class EventDataSource extends CalendarDataSource { @override String getSubject(int index) => getEvent(index).title; + /// apartar todo el dia @override bool isAllDay(int index) => getEvent(index).isAllDay; + /// cambiar de colores por evento... se puede implementar @override Color getColor(int index) => getEvent(index).color; } diff --git a/lib/src/models/event_provider.dart b/lib/src/models/event_provider.dart index bb0d8d9..203e9ce 100644 --- a/lib/src/models/event_provider.dart +++ b/lib/src/models/event_provider.dart @@ -61,48 +61,92 @@ class EventProvider extends ChangeNotifier { } var userd; - void login(user, pass, ctx) async { - + + /// funcion de login + void login(user, pass, ctx, TextEditingController tk, + TextEditingController tk2) async { _loading = false; notifyListeners(); - _loading = true; - await loginAcces(user, pass).then((value) { - var userId; - var post = value; - if (post!.value == 1) { - userId = post.idResidente; - var comId = post.idCom; - userd = post.nombreResidente; - var userType = post.idPerfil; - somData(userd, userType); - obtainId(userType); - accesData(comId, userId); - dataOff2(comId, userType); - dataOff4(comId); - someData(comId, userId); - //Adeudos - dataOff3(userId); - //amenidades - - dataOff5(userId); - - Navigator.pushReplacementNamed(ctx, '/'); + /// primer intento + try { + await loginAcces(user, pass).then((value) { + /// el estado de carga se vuelve true + _loading = true; + + /// carga todos los datos necesarios para el login + var userId; + var post = value; + if (post!.value == 1) { + var idPrimario = post.id; + userId = post.idResidente; + var comId = post.idCom; + userd = post.nombreResidente; + var userType = post.idPerfil; + somData(userd, userType, comId, idPrimario, userId); + + /// despues de hacer la carga y que todo este bien hace el push a otra pagina + Navigator.pushReplacementNamed(ctx, '/'); + } + /* else { + { + /// caso comentado, en caso de no estar bien los datos pasa aqui + /// se cambio por el try catch + HapticFeedback.lightImpact(); + Widget okButton = TextButton( + onPressed: () { + Navigator.pop(ctx); + }, + child: Text('OK')); + + AlertDialog alert = AlertDialog( + title: Text('Atencion!'), + content: Text('Usuario o Contraseña incorrectos'), + actions: [okButton], + ); + + showDialog(context: ctx, builder: (_) => alert); + } + } */ + }); + + /// informa al estate provider, que todo esta en orden y que permanezca logeado siempre + _loading = true; + if (userd != null) { + _islogged = true; + pref.setBool('isLoggedIn', true); + notifyListeners(); + } else { + _loading = false; + _islogged = false; + notifyListeners(); + } + } catch (e) { + { + _loading = false; + + HapticFeedback.lightImpact(); + Widget okButton = TextButton( + onPressed: () { + Navigator.of(ctx).pushNamedAndRemoveUntil('/', (route) => false); + tk.clear(); + + tk2.clear(); + }, + child: Text('OK')); + + AlertDialog alert = AlertDialog( + title: Text('Atencion!'), + content: Text('Sus datos son incorrectos, vuelva a introducirlos'), + actions: [okButton], + ); + + showDialog(context: ctx, builder: (_) => alert); } - }); - - _loading = true; - if (userd != null) { - _islogged = true; - pref.setBool('isLoggedIn', true); - notifyListeners(); - } else { - _islogged = false; - notifyListeners(); } - } + ///este estado chequea si esta logeado o no void loginState() async { pref = await SharedPreferences.getInstance(); var id = pref.getString('user'); diff --git a/lib/src/pantallas/amenidades.dart b/lib/src/pantallas/amenidades.dart index 0d883e9..0174bbc 100644 --- a/lib/src/pantallas/amenidades.dart +++ b/lib/src/pantallas/amenidades.dart @@ -13,7 +13,7 @@ SharedPreferences? prefs; class Amenidades extends StatefulWidget { final id; - + Amenidades({Key? key, this.id}) : super(key: key); static init() async { prefs = await SharedPreferences.getInstance(); @@ -25,15 +25,15 @@ class Amenidades extends StatefulWidget { dataOff4(id) async { await Amenidades.init(); - prefs!.setInt('id', id); + prefs!.setInt('idPrimario', id); } Future idso() async { prefs = await SharedPreferences.getInstance(); - var id = prefs!.getInt('idCom'); + var id = prefs!.getInt('idPrimario'); final Uri url = Uri.parse( - 'http://187.189.53.8:8080/AdcomBackend/backend/web/index.php?r=adcom/get-amenidades'); + 'http://187.189.53.8:8081/backend/web/index.php?r=adcom/get-amenidades'); final response = await http.post(url, body: { "params": json.encode({"usuarioId": id}) }); @@ -49,17 +49,17 @@ Future idso() async { class _AmenidadesState extends State { gtData() async { + try { + var places = (await idso())!; - try{ - var places = (await idso())!; - - final provider = Provider.of(context, listen: false); - for (int i = 0; i < places.data!.length; i++) { - provider.addAmenidad(new Amenidad(id: places.data![i].id)); - } - }catch(e){ final provider = Provider.of(context, listen: false); - provider.addAmenidad(new Amenidad(error: 'Su comunidad no tiene este servicio')); + for (int i = 0; i < places.data!.length; i++) { + provider.addAmenidad(new Amenidad(id: places.data![i].id)); + } + } catch (e) { + final provider = Provider.of(context, listen: false); + provider.addAmenidad( + new Amenidad(error: 'Su comunidad no tiene este servicio')); } } @@ -72,28 +72,37 @@ class _AmenidadesState extends State { @override Widget build(BuildContext context) { var size = MediaQuery.of(context).size; - + return ChangeNotifierProvider( create: (_) => EventProvider(), child: Scaffold( resizeToAvoidBottomInset: false, appBar: AppBar( + title: Text( + "Amenidades", + style: TextStyle( + color: Colors.white, + fontSize: 30, + fontFamily: 'Roboto', + fontWeight: FontWeight.w700), + ), elevation: 6, backgroundColor: Colors.deepPurpleAccent, ), - body: size.width >= 880 ? Stack( + body: Stack( children: [ Container( - height: size.height * .40, + height: size.height * .31, decoration: BoxDecoration(color: Colors.deepPurpleAccent), ), Container( - padding: EdgeInsets.only(top: 95), + padding: + EdgeInsets.only(top: size.width / 7, right: size.width / 20), alignment: Alignment.topRight, child: Icon( Icons.event, color: Colors.white, - size: 170, + size: size.width / 3, ), ), SafeArea( @@ -103,78 +112,7 @@ class _AmenidadesState extends State { crossAxisAlignment: CrossAxisAlignment.start, children: [ SizedBox( - height: 10, - ), - Text( - "Amenidades", - style: TextStyle( - color: Colors.white, - fontSize: 40, - fontFamily: 'Roboto', - fontWeight: FontWeight.w700), - ), - SizedBox( - height: 25, - ), - Text( - 'Disfruta las ventajas de tu comunidad', - style: TextStyle( - fontWeight: FontWeight.bold, - color: Colors.white, - fontSize: 15), - ), - SizedBox( - height: 35, - ), - SizedBox( - width: size.width * .5, - child: Text( - 'Enterate de la disponibilidad de tus areas recreativas o aparta con tiempo para tus eventos', - style: TextStyle(color: Colors.white, fontSize: size.width >=880?19:17), - ), - ), - SizedBox( - height:20, - ), - EventDashboard() - ], - ), - )) - ], - ): Stack( - children: [ - Container( - height: size.height * .40, - decoration: BoxDecoration(color: Colors.deepPurpleAccent), - ), - Container( - padding: EdgeInsets.only(top: 95), - alignment: Alignment.topRight, - child: Icon( - Icons.event, - color: Colors.white, - size: size.width /3, - ), - ), - SafeArea( - child: Padding( - padding: EdgeInsets.symmetric(horizontal: 20), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - SizedBox( - height: 5, - ), - Text( - "Amenidades", - style: TextStyle( - color: Colors.white, - fontSize: 40, - fontFamily: 'Roboto', - fontWeight: FontWeight.w700), - ), - SizedBox( - height: 15, + height: 20, ), Text( 'Disfruta las ventajas de tu comunidad', @@ -190,11 +128,12 @@ class _AmenidadesState extends State { width: size.width * .5, child: Text( 'Enterate de la disponibilidad de tus areas recreativas o aparta con tiempo para tus eventos', - style: TextStyle(color: Colors.white, fontSize: size.width / 20), + style: TextStyle( + color: Colors.white, fontSize: size.width / 20), ), ), SizedBox( - height:20, + height: 20, ), EventDashboard() ], diff --git a/lib/src/pantallas/avisos.dart b/lib/src/pantallas/avisos.dart index 64204b6..68418fa 100644 --- a/lib/src/pantallas/avisos.dart +++ b/lib/src/pantallas/avisos.dart @@ -1,6 +1,16 @@ +import 'dart:convert'; + +import 'package:adcom/json/json-getComunidades.dart'; +import 'package:adcom/json/obtenerAvisos.dart'; +import 'package:adcom/src/extra/dashboard_Avisos.dart'; +import 'package:adcom/src/extra/nuevo_post.dart'; import 'package:adcom/src/methods/searchBar.dart'; import 'package:flutter/material.dart'; import 'package:onesignal_flutter/onesignal_flutter.dart'; +import 'package:http/http.dart' as http; +import 'package:shared_preferences/shared_preferences.dart'; + +SharedPreferences? prefs; class Avisos extends StatefulWidget { final id; @@ -12,12 +22,234 @@ class Avisos extends StatefulWidget { class _AvisosState extends State { bool _requierConsent = true; + int _selectedIndex = 0; + List comunities = []; + List idComName = []; + + List avisos = []; + List? links; + List? name; + + List hLinks = []; + var nombres = {}; + var Link = {}; + List> superMap2 = []; + var typeUser; + var idComu; + bool itsTrue = true; + //funcion que checa el usuario y llama a las funciones si es el usuario maestro + Future userCheck() async { + prefs = await SharedPreferences.getInstance(); + setState(() { + typeUser = prefs!.getInt('userType'); + idComu = prefs!.getInt('idCom'); + }); + + print('$typeUser'); + print('here $idComu'); + + if (typeUser == 2) { + AvisosCall().getComunidades().then((value) => { + for (int i = 0; i < value!.data!.length; i++) + { + idComName.add(value.data![i].nombreComu!), + comunities.add(AvisosCall( + id: value.data![i].idCom, + nombreComu: value.data![i].nombreComu, + ubicacion: value.data![i].ubicacion, + cp: value.data![i].cp, + idAdmin: value.data![i].idAdministrador == null + ? 0 + : value.data![i].idAdministrador, + idComite: value.data![i].idComite == null + ? 0 + : value.data![i].idComite, + idTipoComu: value.data![i].idTipoComu, + banco: value.data![i].banco, + cuentaBanco: value.data![i].cuentaBanco, + cuentaClabe: value.data![i].cuentaClabe, + RFC: value.data![i].rfc)), + } + }); + } else { + print('usario no aceptado'); + } + + AvisosUsuario() + .getAvisos(idComu) + .then((value) => { + if (value!.data!.isNotEmpty) + { + for (int i = 0; i < value.data!.length; i++) + { + avisos.add(new AvisosUsuario( + avisos: value.data![i].aviso, + tipoAviso: value.data![i].tipoAviso, + fecha: value.data![i].fechaAviso, + )), + }, + links = List.generate( + value.data!.length, + (index2) => List.generate( + value.data![index2].archivos!.length, + (index) => value + .data![index2].archivos![index].direccionArchivo), + growable: true), + name = List.generate( + value.data!.length, + (index2) => List.generate( + value.data![index2].archivos!.length, + (index) => value + .data![index2].archivos![index].nombreArchivo), + growable: true), + } + else + {esFalso()} + }) + .whenComplete(() => mounted == true + ? setState(() { + AvisosDashboard( + avisos: avisos, + ); + }) + : null); + } + + esFalso() { + setState(() { + itsTrue = false; + }); + } @override void initState() { + userCheck(); super.initState(); } + refresh() {} + + @override + Widget build(BuildContext context) { + var size = MediaQuery.of(context).size; + return Scaffold( + appBar: AppBar( + title: Text('Avisos', + style: TextStyle( + color: Colors.white, + fontSize: 25, + fontFamily: 'Roboto', + fontWeight: FontWeight.w700)), + elevation: 4.0, + backgroundColor: Colors.blueGrey[700], + ), + resizeToAvoidBottomInset: false, + body: Stack( + children: [ + Container( + height: size.width / 2.0, + decoration: BoxDecoration(color: Colors.blueGrey[700]), + ), + Container( + padding: EdgeInsets.only( + top: size.height / 30, right: size.width / 20), + alignment: Alignment.topRight, + child: Icon( + Icons.announcement_rounded, + color: Colors.white, + size: size.width / 4.5, + ), + ), + SafeArea( + child: Padding( + padding: EdgeInsets.symmetric(horizontal: 20), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + SizedBox( + height: size.width / 50, + ), + Text( + 'Comunicados de la comunidad', + style: TextStyle( + fontWeight: FontWeight.bold, + color: Colors.white, + fontSize: 15), + ), + SizedBox( + height: 20, + ), + SizedBox( + width: size.width / 1.5, + child: Text( + 'Enterate de lo que sucede en tu comunidad! Desde recordatorios, alertas, novedades y más.', + style: TextStyle( + color: Colors.white, fontSize: size.width / 19), + ), + ), + avisos.isEmpty + ? Center( + child: itsTrue == false + ? Container( + padding: const EdgeInsets.only(top: 90), + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Image.asset( + 'assets/images/magic.png', + width: size.width / 1, + height: 200, + ), + Text( + 'Lo sentimos, por el momento no hay avisos', + style: TextStyle( + fontSize: size.width / 20, + color: Colors.blueGrey[700], + ), + textAlign: TextAlign.justify, + ) + ], + )) + : Container( + padding: EdgeInsets.only(top: size.width / 5), + child: CircularProgressIndicator())) + : AvisosDashboard( + links: links, + name: name, + avisos: avisos, + ) + ], + ), + )) + ], + ), + bottomNavigationBar: typeUser == 2 + ? BottomAppBar( + shape: const CircularNotchedRectangle(), + child: Container(height: 50.0), + ) + : null, + floatingActionButton: typeUser == 2 + ? FloatingActionButton( + elevation: 5, + backgroundColor: Colors.blueGrey[700], + onPressed: () { + Navigator.of(context).push(MaterialPageRoute( + builder: (_) => MakeNewPost( + idComu: idComName, + comunities: comunities, + ))); + }, + tooltip: 'add post', + child: const Icon( + Icons.add, + ), + ) + : null, + floatingActionButtonLocation: + typeUser == 2 ? FloatingActionButtonLocation.centerDocked : null); + } + Future? initStatePlatform() async { if (!mounted) return; @@ -42,72 +274,70 @@ class _AvisosState extends State { print('El permiso ha cambiado ${changes.jsonRepresentation()}'); }); } +} - @override - Widget build(BuildContext context) { - var size = MediaQuery.of(context).size; - return Scaffold( - appBar: AppBar( - elevation: 0.0, - backgroundColor: Colors.blueGrey[700], - ), - resizeToAvoidBottomInset: false, - body: Stack( - children: [ - Container( - height: size.height * .40, - decoration: BoxDecoration(color: Colors.blueGrey[700]), - ), - Container( - padding: EdgeInsets.only(top: 75), - alignment: Alignment.topRight, - child: Icon( - Icons.announcement_rounded, - color: Colors.white, - size: 180, - ), - ), - SafeArea( - child: Padding( - padding: EdgeInsets.symmetric(horizontal: 20), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text( - "Avisos", - style: TextStyle( - color: Colors.white, - fontSize: 40, - fontFamily: 'Roboto', - fontWeight: FontWeight.w700), - ), - SizedBox( - height: 10, - ), - Text( - 'Comunicados de la comunidad', - style: TextStyle( - fontWeight: FontWeight.bold, color: Colors.white), - ), - SizedBox( - height: 10, - ), - SizedBox( - width: size.width * .6, - child: Text( - 'Enterate de lo que sucede en tu comunidad! Desde recordatorios, alertas, novedades y más.', - style: TextStyle(color: Colors.white), - ), - ), - SizedBox( - width: size.width * .5, - child: SearchBar(), - ), - ], - ), - )) - ], - ), - ); +class AvisosCall { + int? id; + String? nombreComu; + String? ubicacion; + int? cp; + int? idAdmin; + int? idComite; + String? idTipoComu; + String? banco; + String? cuentaBanco; + String? cuentaClabe; + String? RFC; + + AvisosCall( + {this.id, + this.nombreComu, + this.RFC, + this.banco, + this.cp, + this.idTipoComu, + this.cuentaBanco, + this.cuentaClabe, + this.idAdmin, + this.idComite, + this.ubicacion}); + + Future getComunidades() async { + Uri url = Uri.parse( + "http://187.189.53.8:8081/backend/web/index.php?r=adcom/get-comunities"); + + final response = await http.get(url); + + if (response.statusCode == 200) { + var data = response.body; + + return comunitiesFromJson(data); + } + } +} + +class AvisosUsuario { + int? id; + String? avisos; + int? tipoAviso; + DateTime? fecha; + + AvisosUsuario({ + this.avisos, + this.fecha, + this.tipoAviso, + this.id, + }); + + Future getAvisos(int id) async { + Uri url = Uri.parse( + "http://187.189.53.8:8081/backend/web/index.php?r=adcom/get-avisos-by-residente"); + final response = await http.post(url, body: {'idCom': id.toString()}); + + if (response.statusCode == 200) { + var data = response.body; + print(data); + return getAvisosFromJson(data); + } } } diff --git a/lib/src/pantallas/contactos.dart b/lib/src/pantallas/contactos.dart index 0545d69..573e85b 100644 --- a/lib/src/pantallas/contactos.dart +++ b/lib/src/pantallas/contactos.dart @@ -1,3 +1,4 @@ +import 'package:adcom/json/json.dart'; import 'package:adcom/src/methods/emailDashboard.dart'; import 'package:adcom/src/models/event_provider.dart'; import 'package:filter_list/filter_list.dart'; @@ -15,7 +16,8 @@ class _ContactosState extends State { List? itemSeleccion = []; List? newArr = []; TextEditingController? _controller = TextEditingController(); - + late Welcome? dt; + List myList = []; @override void initState() { super.initState(); @@ -30,18 +32,27 @@ class _ContactosState extends State { @override Widget build(BuildContext context) { var size = MediaQuery.of(context).size; + var size2 = MediaQuery.of(context).size.width; final residentes = Provider.of(context).items; return Scaffold( resizeToAvoidBottomInset: false, - floatingActionButton: FloatingActionButton( + /* floatingActionButton: FloatingActionButton( backgroundColor: Colors.greenAccent[700], - onPressed: () => _openFilterDialog(residentes), + onPressed: () => _openFilterDialog(myList), child: Icon( Icons.filter_list, ), - ), + ), */ appBar: AppBar( + title: Text( + "Directorio", + style: TextStyle( + color: Colors.white, + fontSize: 30, + fontFamily: 'Roboto', + fontWeight: FontWeight.w700), + ), leading: BackButton( onPressed: () { itemSeleccion!.clear(); @@ -57,7 +68,7 @@ class _ContactosState extends State { body: Stack( children: [ Container( - height: size.height * .31, + height: size.height * .30, decoration: BoxDecoration( borderRadius: BorderRadius.only( bottomRight: Radius.circular(5), @@ -69,12 +80,12 @@ class _ContactosState extends State { color: Colors.greenAccent[700]), ), Container( - padding: EdgeInsets.only(top: 56), + padding: EdgeInsets.only(top: 56, right: size.width / 28), alignment: Alignment.topRight, child: Icon( Icons.contacts, color: Colors.white, - size: 165, + size: size.width / 3, ), ), SafeArea( @@ -84,41 +95,36 @@ class _ContactosState extends State { crossAxisAlignment: CrossAxisAlignment.start, children: [ SizedBox( - height: 10, - ), - Text( - "Directorio", - style: TextStyle( - color: Colors.white, - fontSize: 40, - fontFamily: 'Roboto', - fontWeight: FontWeight.w700), + height: 8, ), SizedBox( - height: 10, - ), - Text( - 'Contacta a tus personas de confianza', - style: TextStyle( - fontWeight: FontWeight.bold, color: Colors.white), + width: size.width / 2, + child: Text( + 'Contacta a tus personas de confianza', + style: TextStyle( + fontSize: 15, + fontWeight: FontWeight.bold, + color: Colors.white), + ), ), SizedBox( height: 10, ), SizedBox( - width: size.width * .5, + width: size.width / 2, + height: size.height / 8, child: Text( 'Mantente conectado con tu comunidad o asesores de tu comunidad', - style: TextStyle(color: Colors.white), + style: TextStyle(color: Colors.white, fontSize: 20), ), ), SizedBox( - width: size.width * .55, + width: size.width / 2, child: searchBar(residentes), ), itemSeleccion == null || itemSeleccion!.length == 0 ? ContactDashboard() - : filterView(), + : filterView(size2), ], ), )), @@ -129,8 +135,8 @@ class _ContactosState extends State { searchBar(List residentes) { return Container( - margin: EdgeInsets.symmetric(vertical: 30), - padding: EdgeInsets.symmetric(horizontal: 30, vertical: 5), + margin: EdgeInsets.symmetric(vertical: 10), + padding: EdgeInsets.symmetric(horizontal: 20, vertical: 5), decoration: BoxDecoration( color: Colors.white, borderRadius: BorderRadius.circular(29.5)), child: TextField( @@ -162,14 +168,14 @@ class _ContactosState extends State { } } - filterView() => Flexible( + filterView(size2) => Flexible( child: GridView.builder( shrinkWrap: false, itemCount: itemSeleccion!.length, padding: EdgeInsets.only(left: 4, right: 4, top: 17), gridDelegate: SliverGridDelegateWithFixedCrossAxisCount( crossAxisCount: 1, - childAspectRatio: 3.1, + childAspectRatio: 2.5, crossAxisSpacing: 15, mainAxisSpacing: 15, ), @@ -210,55 +216,35 @@ class _ContactosState extends State { children: [ itemSeleccion![index].title == null ? Container() - : Text(itemSeleccion![index].title!.toUpperCase(), - style: TextStyle( - color: Colors.black, - fontSize: 14, - fontWeight: FontWeight.w600)), + : SizedBox( + width: size2 / 2.1, + child: Text( + itemSeleccion![index] + .title! + .toUpperCase(), + style: TextStyle( + color: Colors.black, + fontSize: size2 / 33, + fontWeight: FontWeight.bold)), + ), SizedBox( - height: 10, + height: size2 / 20, ), Row( children: [ - Text('Comunidad', - style: TextStyle( - color: Colors.black, - fontSize: 16, - fontWeight: FontWeight.bold)), - SizedBox( - width: 3, - ), itemSeleccion![index].comNombre == null ? Container() - : Text(itemSeleccion![index].comNombre!, - style: TextStyle( - color: Colors.black, - fontSize: 15, - )) + : SizedBox( + width: size2 / 2, + child: + Text(itemSeleccion![index].comNombre!, + style: TextStyle( + color: Colors.black, + fontSize: 16, + )), + ) ], ), - SizedBox( - height: 10, - ), - Row( - children: [ - Text('Numero', - style: TextStyle( - color: Colors.black, - fontSize: 16, - fontWeight: FontWeight.bold)), - SizedBox( - width: 3, - ), - itemSeleccion![index].telCel == null - ? Container() - : Text(itemSeleccion![index].telCel!, - style: TextStyle( - color: Colors.black, - fontSize: 15, - )) - ], - ) ], ) ], @@ -268,6 +254,7 @@ class _ContactosState extends State { ); })); + // ignore: unused_element void _openFilterDialog(res) async { await FilterListDialog.display(context, listData: res, diff --git a/lib/src/pantallas/finanzas.dart b/lib/src/pantallas/finanzas.dart index 66c782c..d3a97d4 100644 --- a/lib/src/pantallas/finanzas.dart +++ b/lib/src/pantallas/finanzas.dart @@ -1,17 +1,11 @@ import 'dart:async'; import 'dart:convert'; import 'package:adcom/json/jsonFinanzas.dart'; -import 'package:adcom/main.dart'; -import 'package:adcom/src/extra/referencia_view.dart'; import 'package:adcom/src/extra/vista_tarjeta.dart'; -import 'package:adcom/src/models/event_provider.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:http/http.dart' as http; -import 'package:provider/provider.dart'; -import 'package:pull_to_refresh/pull_to_refresh.dart'; import 'package:shared_preferences/shared_preferences.dart'; -import 'package:stripe_payment/stripe_payment.dart'; SharedPreferences? prefs; @@ -34,12 +28,12 @@ dataOff3(id) async { Future getAdeudos() async { prefs = await SharedPreferences.getInstance(); - var id = prefs!.getInt('idUser'); - + var id = prefs!.getInt('userId'); + print(id); final Uri url = Uri.parse( - 'http://187.189.53.8:8080/AdcomBackend/backend/web/index.php?r=adcom/get-adeudos'); + 'http://187.189.53.8:8081/backend/web/index.php?r=adcom/get-adeudos'); final response = await http.post(url, body: { - "params": json.encode({"usuarioId": id}) + "params": json.encode({"usuarioId": id.toString()}) }); if (response.statusCode == 200) { @@ -54,62 +48,29 @@ class _FinanzasState extends State { Accounts? cuentas; List mylist = []; List? mylist2 = []; - List localList = []; + List localList = []; int? idComu; var montoCuota; Timer? timer; - List estado = []; VoidCallback? _showPersBottomSheetCallBack; - RefreshController _refreshController = - RefreshController(initialRefresh: false); - - data() async { - cuentas = - await getAdeudos().onError((error, stackTrace) => errorLoSiento()); - - if (cuentas!.value == 1) { - for (int i = 0; i < cuentas!.data!.length; i++) { - localList.add(new DatosCuenta( - idComu: cuentas!.data![i].idComu, - montoCuota: cuentas!.data![i].montoCuota, - fechaGenerada: cuentas!.data![i].fechaGeneracion!, - fechaLimite: cuentas!.data![i].fechaLimite!, - fechaPago: cuentas!.data![i].fechaPago, - pago: cuentas!.data![i].pago)); - } - estado.add(EstadoCuenta()); - estado.add(VistaTarjeta()); - } - } - - errorLoSiento() { - Container( - padding: EdgeInsets.only(top: 0), - child: Center( - child: Image.asset( - 'assets/images/error.png', - width: 192, - ), - )); - } + bool itsTrue = true; + /// El init state inicializa funciones cuando abre el boton mis pagos @override void initState() { super.initState(); + + /// no tocar, muestra la vista para pagar con tarjeta _showPersBottomSheetCallBack = _showPersBottomSheetCallBack; + + /// funcion que obtiene datos del service data(); - StripePayment.setOptions(StripeOptions( - publishableKey: - "pk_test_51JAjdHAoDnRH9C3fzuzLNpJaSlrcUVBJhDzN6ACKV8jocJSLvDCoBa1d1oBTX46CfOpC8wCLQ76H0aDOTZCo3xtO00a3pBNqw1", - merchantId: "Test", - androidPayMode: 'test')); - Future.delayed(Duration(seconds: 1), () => {refresh()}); - } - refresh() { - setState(() { - mainView(); - }); + ///refresqueo cuando hay datos + if (itsTrue == false) { + } else { + Future.delayed(Duration(seconds: 1), () => {refresh()}); + } } @override @@ -117,514 +78,160 @@ class _FinanzasState extends State { var size = MediaQuery.of(context).size; return Scaffold( appBar: AppBar( + title: Text( + 'Mis Pagos', + style: TextStyle( + color: Colors.white, + fontSize: 30, + fontFamily: 'Roboto', + fontWeight: FontWeight.w700), + ), elevation: 7, backgroundColor: Colors.lightGreen[700], ), resizeToAvoidBottomInset: false, - body: SmartRefresher( - controller: _refreshController, - enablePullDown: true, - header: WaterDropHeader(), - onRefresh: _onRefresh, - onLoading: _onLoading, - footer: ClassicFooter( - loadStyle: LoadStyle.ShowWhenLoading, - completeDuration: Duration(milliseconds: 500), - ), - child: size.width >= 880 - ? Stack( - children: [ - Container( - height: size.height * .35, - decoration: BoxDecoration(color: Colors.lightGreen[700]), - ), - Container( - padding: EdgeInsets.only(top: 80), - alignment: Alignment.topRight, - child: Icon( - Icons.show_chart_rounded, - size: 190, - color: Colors.white, - ), - ), - SafeArea( - child: Padding( - padding: EdgeInsets.symmetric(horizontal: 20), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - SizedBox( - height: 12, - ), - Text( - 'Mis Pagos', - style: TextStyle( - color: Colors.white, - fontSize: 40, - fontFamily: 'Roboto', - fontWeight: FontWeight.w700), - ), - SizedBox( - height: size.width >= 880 ? 25 : 20, - ), - Text( - 'Toma el control de tus gastos', - style: TextStyle( - fontWeight: FontWeight.bold, - color: Colors.white, - fontSize: 16), - ), - SizedBox( - height: size.width >= 880 ? 35 : 23, - ), - SizedBox( - width: size.width * .6, - child: Text( - 'Mantente actualizado revisando tus estados de cuenta y adeudos pendientes.', - style: TextStyle( - color: Colors.white, fontSize: 19), - ), - ), - Container( - padding: EdgeInsets.only( - top: size.width >= 880 ? 45 : 25, - left: size.width >= 880 ? 5 : 0, - right: size.width >= 880 ? 5 : 0), - child: localList.isEmpty - ? Center( - child: CircularProgressIndicator(), - ) - : mainView()) - ], - ), - ), - ), - ], - ) - : Stack( - children: [ - Container( - height: size.height * .35, - decoration: BoxDecoration(color: Colors.lightGreen[700]), - ), - Container( - padding: EdgeInsets.only(top: size.height / 12), - alignment: Alignment.topRight, - child: Icon( - Icons.show_chart_rounded, - size: size.width / 2, - color: Colors.white, - ), - ), - SafeArea( - child: Padding( - padding: EdgeInsets.symmetric(horizontal: 20), - child: ListView(shrinkWrap: true, children: [ - Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - SizedBox( - height: size.width / 20, - ), - Text( - 'Mis Pagos', - style: TextStyle( - color: Colors.white, - fontSize: 30, - fontFamily: 'Roboto', - fontWeight: FontWeight.w700), - ), - SizedBox( - height: size.width / 19, - ), - Text( - 'Toma el control de tus gastos', - style: TextStyle( - fontWeight: FontWeight.bold, - color: Colors.white, - fontSize: 17), - ), - SizedBox( - height: size.width / 20, - ), - SizedBox( - width: size.width * .6, - child: Text( - 'Mantente actualizado revisando tus estados de cuenta y adeudos pendientes.', - style: TextStyle( - color: Colors.white, - fontSize: size.width / 21), - ), - ), - Container( - padding: EdgeInsets.only( - top: size.width / 10, - left: size.width >= 880 ? 5 : 0, - right: size.width >= 880 ? 5 : 0), - child: localList.isEmpty - ? Center( - child: CircularProgressIndicator(), - ) - : mainView()) - ], - ), - ]), - ), - ), - ], - ), - )); - } - - mainView() { - return ListView( - shrinkWrap: true, - children: [ - InkWell( - onTap: () { - HapticFeedback.mediumImpact(); - Navigator.of(context) - .push(MaterialPageRoute(builder: (_) => RefView())); - }, - child: VistaTarjeta()), - SizedBox( - height: 15, - ), - InkWell( - /* onTap: () { - HapticFeedback.mediumImpact(); - Navigator.of(context).push(MaterialPageRoute( - builder: (_) => OpcionesEdoCuenta())); - }, */ - child: EstadoCuenta()), - ], - ); - } - - void _onRefresh() async { - // monitor network fetch - await Future.delayed(Duration(milliseconds: 1000), () {}); - // if failed,use refreshFailed() - //getAdeudos(); - _refreshController.refreshCompleted(); - } - - void _onLoading() async { - // monitor network fetch - await Future.delayed(Duration(milliseconds: 1000), () => {}); - // if failed,use loadFailed(),if no data return,use LoadNodata() - Finanzas(); - if (mounted) setState(() {}); - - _refreshController.loadComplete(); - } - - referenciaApagar() { - final deudas = Provider.of(context, listen: false).deudas; - - String? ref; - for (int i = 0; i < deudas.length; i++) { - if (deudas[i].pago == 1) { - //no debe - } else { - //si debe - setState(() { - ref = deudas[i].referencia!; - }); - } - } - return ref; - } -} - -// ignore: must_be_immutable -class EstadoCuenta extends StatefulWidget { - late dynamic? d; - late int? m; - late int? yy; - - EstadoCuenta({Key? key, this.d, this.m, this.yy}) : super(key: key); - - @override - _EstadoCuentaState createState() => _EstadoCuentaState(); -} - -class _EstadoCuentaState extends State { - Accounts? cuentas; - - List mylist = []; - data() async { - cuentas = await getAdeudos(); - - for (int i = 0; i < cuentas!.data!.length; i++) { - mylist.add(new DatosCuenta( - idComu: cuentas!.data![i].idComu, - montoCuota: cuentas!.data![i].montoCuota, - fechaGenerada: cuentas!.data![i].fechaGeneracion!, - fechaLimite: cuentas!.data![i].fechaLimite!, - fechaPago: cuentas!.data![i].fechaPago, - pago: cuentas!.data![i].pago!)); - } - } - - @override - void initState() { - super.initState(); - data(); - Future.delayed(Duration(seconds: 1), () { - setState(() { - saldoDeudor(); - cuantoDebe(); - }); - }); - } - - @override - Widget build(BuildContext context) { - var size = MediaQuery.of(context).size; - return size.width >= 880 - ? Container( - width: MediaQuery.of(context).size.width, - height: 180, - decoration: BoxDecoration(boxShadow: [ - BoxShadow(color: Colors.grey, blurRadius: 6, offset: Offset(0, 1)) - ], color: Colors.white, borderRadius: BorderRadius.circular(10)), - child: Padding( - padding: const EdgeInsets.only( - left: 20, right: 20, top: 20, bottom: 30), - child: Column( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text( - 'Estado de cuenta', - style: TextStyle( - color: Colors.black, - fontWeight: FontWeight.bold, - fontSize: 16), - ), - SizedBox( - height: 10, - ), - Row( - mainAxisAlignment: MainAxisAlignment.spaceAround, - children: [ - Text('Información Actualizada:'), - SizedBox( - width: size.width >= 880 ? 100 : 50, - ), - Text( - '${DateTime.now().day}/${DateTime.now().month}/${DateTime.now().year}', - style: TextStyle(fontWeight: FontWeight.bold), - ) - ], - ) - ], - ), - ], - ), - Row( - children: [ - Expanded( - child: InkWell( - child: Text( - '¿Cuánto debo?', - textAlign: TextAlign.center, - style: TextStyle(color: Colors.black), - ), - )), - Text('|', style: TextStyle(color: Colors.black)), - Expanded( - child: InkWell( - onTap: () { - HapticFeedback.mediumImpact(); - }, - child: Text('Cuotas de atraso', - textAlign: TextAlign.center, - style: TextStyle(color: Colors.black)), - )) - ], - ), - Row( - children: [ - Expanded( - child: Center( - child: Text( - '\$ ${saldoDeudor()} MXN', - style: TextStyle( - color: Colors.black, - fontWeight: FontWeight.bold, - fontSize: 20), - ), - ), - ), - SizedBox( - width: 30, - ), - Expanded( - child: Center( - child: Text( - '${cuantoDebe()}', - style: TextStyle( - fontSize: 20, fontWeight: FontWeight.bold), - ), - )) - ], - ), - ], + body: Stack( + children: [ + Container( + height: size.height * .25, + decoration: BoxDecoration(color: Colors.lightGreen[700]), + ), + Container( + padding: EdgeInsets.only(top: size.height / 20), + alignment: Alignment.topRight, + child: Icon( + Icons.show_chart_rounded, + size: size.width / 2, + color: Colors.white, ), ), - ) - : Container( - width: MediaQuery.of(context).size.width, - height: 170, - decoration: BoxDecoration(boxShadow: [ - BoxShadow(color: Colors.grey, blurRadius: 6, offset: Offset(0, 1)) - ], color: Colors.white, borderRadius: BorderRadius.circular(10)), - child: Padding( - padding: const EdgeInsets.only( - left: 11, right: 11, top: 10, bottom: 20), - child: Column( - mainAxisAlignment: MainAxisAlignment.spaceAround, - children: [ - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, + SafeArea( + child: Padding( + padding: EdgeInsets.symmetric(horizontal: 20), + child: ListView(shrinkWrap: true, children: [ + Column( + crossAxisAlignment: CrossAxisAlignment.start, children: [ - Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text( - 'Estado de cuenta', - style: TextStyle( - color: Colors.black, - fontWeight: FontWeight.bold, - fontSize: 13), - ), - SizedBox( - height: 5, - ), - Row( - mainAxisAlignment: MainAxisAlignment.spaceAround, - children: [ - Text( - 'Información Actualizada:', - style: TextStyle( - fontSize: size.width / 28, - fontWeight: FontWeight.bold), - ), - SizedBox( - width: size.width * .13, - ), - Text( - '${DateTime.now().day}/${DateTime.now().month}/${DateTime.now().year}', - style: TextStyle(fontWeight: FontWeight.bold), - ) - ], - ) - ], + SizedBox( + height: size.width / 20, ), - ], - ), - Row( - children: [ - Expanded( - child: InkWell( - child: Text( - '¿Cuánto debo?', - textAlign: TextAlign.center, - style: TextStyle(color: Colors.black), - ), - )), - Text('|', style: TextStyle(color: Colors.black)), - Expanded( - child: InkWell( - onTap: () { - HapticFeedback.mediumImpact(); - }, - child: Text('Cuotas de atraso', - textAlign: TextAlign.center, - style: TextStyle(color: Colors.black)), - )) - ], - ), - Row( - children: [ - Expanded( - child: Center( - child: Text( - '\$${saldoDeudor()}MXN', - style: TextStyle( - color: Colors.black, - fontWeight: FontWeight.bold, - fontSize: size.width / 17), - ), - ), + Text( + 'Toma el control de tus gastos', + style: TextStyle( + fontWeight: FontWeight.bold, + color: Colors.white, + fontSize: 17), ), SizedBox( - width: 20, + height: size.width / 20, ), - Expanded( - child: Center( + SizedBox( + width: size.width * .6, child: Text( - '${cuantoDebe()}', + 'Mantente actualizado revisando tus estados de cuenta y adeudos pendientes.', style: TextStyle( - fontSize: 20, fontWeight: FontWeight.bold), + color: Colors.white, fontSize: size.width / 21), ), - )) + ), + Container( + padding: EdgeInsets.only( + top: size.width / 5, + ), + child: localList.isEmpty + ? Center( + child: itsTrue == false + ? Container( + padding: + const EdgeInsets.only(top: 90), + child: Column( + mainAxisAlignment: + MainAxisAlignment.center, + children: [ + Image.asset( + 'assets/images/magic.png', + width: size.width / 1, + height: 200, + ), + Text( + 'Lo sentimos, por el momento no cuenta con adeudos', + style: TextStyle( + fontSize: size.width / 20, + color: Colors.lightGreen[700], + ), + textAlign: TextAlign.justify, + ) + ], + )) + : CircularProgressIndicator(), + ) + : mainView()) ], ), - ], + ]), ), ), - ); + ], + )); } - //te dice cuanto dinero debe - saldoDeudor() { - double contador = 0.0; - double deuda; - for (int i = 0; i < mylist.length; i++) { - deuda = double.parse(mylist[i].montoCuota!); - if (mylist[i].pago == 1) { - } else { - if (DateTime.now().day <= mylist[i].fechaLimite!.day && - DateTime.now().month <= mylist[i].fechaLimite!.month && - DateTime.now().year <= mylist[i].fechaLimite!.year) { - } else { - setState(() { - contador += deuda; - }); - } + refresh() { + setState(() { + if (mounted) { + mainView(); } - } - return contador; + }); } - //te dice cuantos meses debe - cuantoDebe() { - int contador = 0; - for (int i = 0; i < mylist.length; i++) { - if (mylist[i].pago == 1) { - } else { - if (DateTime.now().day <= mylist[i].fechaLimite!.day && - DateTime.now().month <= mylist[i].fechaLimite!.month && - DateTime.now().year <= mylist[i].fechaLimite!.year) { + data() async { + cuentas = await getAdeudos(); + + prefs = await SharedPreferences.getInstance(); + if (cuentas!.data!.isNotEmpty) { + for (int i = 0; i < cuentas!.data!.length; i++) { + if (cuentas!.data![i].idConcepto == "PA ") { } else { - setState(() { - contador++; - }); + if (cuentas!.data![i].idConcepto == "ACCTEL ") { + } else { + localList.add(new DatosCuenta( + idComu: cuentas!.data![i].idComu, + montoCuota: cuentas!.data![i].montoCuota, + idConcepto: cuentas!.data![i].idConcepto, + fechaGenerada: cuentas!.data![i].fechaGeneracion!, + fechaLimite: cuentas!.data![i].fechaLimite == null + ? DateTime.now() + : cuentas!.data![i].fechaLimite, + fechaPago: cuentas!.data![i].fechaPago, + pago: cuentas!.data![i].pago!, + montoPago: cuentas!.data![i].montoPago, + totalApagar: cuentas!.data![i].totalApagar, + referencia: cuentas!.data![i].referencia, + pagoTardio: cuentas!.data![i].pagoTardio, + montoTardio: cuentas!.data![i].montoPagoTardio, + )); + } } } + } else { + setState(() { + if (mounted) { + itsTrue = false; + } + }); } - return contador.toString(); + } + + mainView() { + return InkWell( + onTap: () { + HapticFeedback.mediumImpact(); + }, + + /// vista para la tarjeta + child: VistaTarjeta( + newList: localList, + )); } } -// ignore: must_be_immutable class DatosCuenta { int? idComu; diff --git a/lib/src/pantallas/loginPage.dart b/lib/src/pantallas/loginPage.dart index 64cdabf..c600a03 100644 --- a/lib/src/pantallas/loginPage.dart +++ b/lib/src/pantallas/loginPage.dart @@ -24,8 +24,8 @@ class LoginPage extends StatefulWidget { } Future loginAcces(String user, String pass) async { - final Uri uri = Uri.parse( - 'http://187.189.53.8:8080/AdcomBackend/backend/web/index.php?r=adcom/login'); + final Uri uri = + Uri.parse('http://187.189.53.8:8081/backend/web/index.php?r=adcom/login'); final response = await http.post(uri, body: { "params": jsonEncode({'username': user, 'password': pass}), }); @@ -33,8 +33,6 @@ Future loginAcces(String user, String pass) async { var data = response.body; return postingFromJson(data); - } else { - return null; } } @@ -124,7 +122,7 @@ class _LoginPageState extends State { } return null; }, - autofocus: false, + autofocus: true, decoration: InputDecoration( enabledBorder: UnderlineInputBorder( borderSide: @@ -158,7 +156,6 @@ class _LoginPageState extends State { return null; }, obscureText: true, - autofocus: false, decoration: InputDecoration( enabledBorder: UnderlineInputBorder( borderSide: @@ -200,11 +197,10 @@ class _LoginPageState extends State { _formKey2.currentState!.validate()) { try { Provider.of(context, listen: false) - .login(user, pass, context); + .login(user, pass, context, tk, tk2); } catch (e) { HapticFeedback.heavyImpact(); showAlertDialog(); - Navigator.popAndPushNamed(context, '/'); } } else { HapticFeedback.heavyImpact(); @@ -280,7 +276,7 @@ class _LoginPageState extends State { showAlertDialog() { Widget okButton = TextButton( onPressed: () { - Navigator.of(context)..pop(); + Navigator.of(context).popAndPushNamed('/'); }, child: Text('OK')); diff --git a/lib/src/pantallas/mainMenu.dart b/lib/src/pantallas/mainMenu.dart index 837aad8..0b09496 100644 --- a/lib/src/pantallas/mainMenu.dart +++ b/lib/src/pantallas/mainMenu.dart @@ -1,7 +1,6 @@ +import 'package:adcom/json/jsonAmenidades.dart'; import 'package:adcom/src/methods/gridDashboard.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'; SharedPreferences? prefs; @@ -19,16 +18,22 @@ class MainMenu extends StatefulWidget { _MainMenuState createState() => _MainMenuState(); } -somData(user, userType) async { +somData(user, userType, idCom, idPrimario, userId) async { await MainMenu.init(); prefs!.setString('user', user); prefs!.setInt('userType', userType); + prefs!.setInt('idCom', idCom); + prefs!.setInt('idPrimario', idPrimario); + prefs!.setInt('userId', userId); } class _MainMenuState extends State { var user; int? userType; + int? idCom; + bool entrada = true; + Places? acceso; userName() async { prefs = await SharedPreferences.getInstance(); @@ -49,147 +54,94 @@ class _MainMenuState extends State { //final args = ModalRoute.of(context)!.settings.arguments as LoginPage; var size = MediaQuery.of(context).size; return Scaffold( - body: size.width >= 880 - ? Stack( - children: [ - Container( - height: size.height * .40, - decoration: BoxDecoration(color: Colors.red), - ), - Container( - padding: EdgeInsets.only( - top: size.width >= 880 ? 150 : 190, right: 21), - alignment: Alignment.topRight, - child: Image.asset( - 'assets/images/AdCom.png', - width: 192, - )), - SafeArea( - child: Padding( - padding: const EdgeInsets.symmetric(horizontal: 10), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, + body: Stack( + children: [ + Container( + height: size.height * .35, + decoration: BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.only( + bottomLeft: Radius.circular(20), + bottomRight: Radius.circular(20)), + boxShadow: [ + BoxShadow( + color: Colors.grey, blurRadius: 10, offset: Offset(1, 0)) + ], + ), + ), + Container( + padding: + EdgeInsets.only(top: size.height * .18, right: size.width / 15), + alignment: Alignment.topRight, + child: Image.asset( + 'assets/images/AdCom3.png', + width: size.width * .38, + )), + SafeArea( + child: Padding( + padding: const EdgeInsets.symmetric(horizontal: 10), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Padding( + padding: const EdgeInsets.only(left: 12, top: 10), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Column( children: [ SizedBox( - height: size.width >= 880 ? 34 : 24, - ), - Padding( - padding: const EdgeInsets.only( - left: 12, - ), + width: size.height / 3.5, + height: size.width / 2.0, child: Column( crossAxisAlignment: CrossAxisAlignment.start, + mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: [ - SizedBox( - height: size.width / 10, - ), + user == null || user == '' + ? Text('¡${greeting()}!', + style: TextStyle( + color: Colors.black, + fontFamily: 'Roboto', + fontSize: 35, + fontWeight: FontWeight.w700)) + : Text( + '¡${greeting()}!', + style: TextStyle( + color: Colors.black, + fontFamily: 'Roboto', + fontSize: 17, + fontWeight: FontWeight.w700), + ), Text( - '¡${greeting()}! \n${user == null ? '' : user}', + '${user == null || user == '' ? '' : user}', style: TextStyle( - color: Colors.white, + color: Colors.black, fontFamily: 'Roboto', - fontSize: 35, + fontSize: size.width / 10, fontWeight: FontWeight.w700), ), - SizedBox( - height: 10, - ), - Container( - alignment: Alignment.centerLeft, - height: 50, - width: 150, - margin: size.width >= 880 - ? EdgeInsets.all(25) - : EdgeInsets.only(left: 10, top: 46), - child: SizedBox()) ], ), ), - SizedBox( - height: size.width >= 880 ? 35 : 10, - ), - GridDashboard( - userId: userType, - ) ], ), - ), - ) - ], - ) - : Stack( - children: [ - Container( - height: size.height * .34, - decoration: BoxDecoration( - color: Colors.white, - borderRadius: BorderRadius.only( - bottomLeft: Radius.circular(20), - bottomRight: Radius.circular(20)), - boxShadow: [ - BoxShadow( - color: Colors.grey, - blurRadius: 10, - offset: Offset(1, 0)) - ], - ), + SizedBox( + width: size.width / 70, + ), //no mover + ], ), - Container( - padding: EdgeInsets.only( - top: size.height * .18, right: size.width * .10), - alignment: Alignment.topRight, - child: Image.asset( - 'assets/images/AdCom3.png', - width: size.width * .38, - )), - SafeArea( - child: Padding( - padding: const EdgeInsets.symmetric(horizontal: 10), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Padding( - padding: const EdgeInsets.only( - left: 12, - ), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - SizedBox( - height: size.width / 19, - ), - Text( - '¡${greeting()}! \n${user == null ? '' : user}', - style: TextStyle( - color: Colors.black, - fontFamily: 'Roboto', - fontSize: size.width / 11, - fontWeight: FontWeight.w700), - ), - //no mover - SizedBox( - height: size.height >= 640 - ? size.height / 7 - : size.height / 10, - ), - ], - ), - ), + ), - //no mover - SizedBox( - height: size.width <= 640 ? 0 : size.height / 13, - ), - - GridDashboard( - userId: userType, - ) - ], - ), - ), - ) - ], - )); + //no mover + ], + ), + ), + ), + GridDashboard( + userId: userType, + ) + ], + )); } String greeting() { diff --git a/lib/src/pantallas/reportes.dart b/lib/src/pantallas/reportes.dart index cd0d5ea..df88536 100644 --- a/lib/src/pantallas/reportes.dart +++ b/lib/src/pantallas/reportes.dart @@ -1,6 +1,6 @@ import 'package:adcom/json/jsonReporte.dart'; import 'package:adcom/json/jsonRespuesta.dart'; -import 'package:adcom/src/methods/avisoDashboard.dart'; +import 'package:adcom/src/methods/reporteDashboard.dart'; import 'package:adcom/src/methods/searchBar.dart'; import 'package:flutter/material.dart'; @@ -32,79 +32,31 @@ class _ReportesState extends State { return Scaffold( resizeToAvoidBottomInset: false, appBar: AppBar( + title: Text( + "Reportes", + style: TextStyle( + color: Colors.white, + fontSize: 30, + fontFamily: 'Roboto', + fontWeight: FontWeight.w700), + ), elevation: 5, backgroundColor: Colors.blue, ), - body: size.width >= 880 ? Stack( + body: Stack( children: [ Container( - height: size.height * .40, + height: size.height * .35, decoration: BoxDecoration(color: Colors.blue), ), Container( - padding: size.width >= 880 ?EdgeInsets.only(top: 75) : EdgeInsets.only(top: 130), + padding: + EdgeInsets.only(top: size.width / 12, right: size.width / 40), alignment: Alignment.topRight, child: Icon( Icons.report, color: Colors.white, - size: 170, - ), - ), - SafeArea( - child: Padding( - padding: EdgeInsets.symmetric(horizontal: 20), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - SizedBox( - height: 15, - ), - Text( - "Reportes", - style: TextStyle( - color: Colors.white, - fontSize: 40, - fontFamily: 'Roboto', - fontWeight: FontWeight.w700), - ), - SizedBox( - height: 25), - Text( - 'Si vez algo inusual !Reportalo!', - style: TextStyle( - fontWeight: FontWeight.bold, color: Colors.white, fontSize: 16), - ), - SizedBox( - height: 35, - ), - SizedBox( - width: size.width * .6, - child: Text( - 'Reporta incidencias en tu comunidad para que todos estén al tanto de comportamientos inusuales o faltas a la comunidad.', - style: TextStyle(color: Colors.white, fontSize: size.width >= 880 ? 19 : 18), - ), - ), - SizedBox( - height: 20, - ), - AvisosDashboard() - ], - ), - )) - ], - ): Stack( - children: [ - Container( - height: size.height * .40, - decoration: BoxDecoration(color: Colors.blue), - ), - Container( - padding: EdgeInsets.only(top: size.height * .12, left: size.width * .12 ), - alignment: Alignment.topRight, - child: Icon( - Icons.report, - color: Colors.white, - size: size.height*.20 , + size: size.height * .18, ), ), SafeArea( @@ -116,20 +68,13 @@ class _ReportesState extends State { SizedBox( height: 2, ), - Text( - "Reportes", - style: TextStyle( - color: Colors.white, - fontSize: 40, - fontFamily: 'Roboto', - fontWeight: FontWeight.w700), - ), - SizedBox( - height: 15), + SizedBox(height: 15), Text( 'Si vez algo inusual !Reportalo!', style: TextStyle( - fontWeight: FontWeight.bold, color: Colors.white, fontSize: 16), + fontWeight: FontWeight.bold, + color: Colors.white, + fontSize: 16), ), SizedBox( height: 18, @@ -138,13 +83,14 @@ class _ReportesState extends State { width: size.width * .6, child: Text( 'Reporta incidencias en tu comunidad para que todos estén al tanto de comportamientos inusuales o faltas a la comunidad.', - style: TextStyle(color: Colors.white, fontSize: size.width /20), + style: TextStyle( + color: Colors.white, fontSize: size.width / 20), ), ), SizedBox( - height: 20, + height: size.width / 8, ), - AvisosDashboard() + ReportesDashboard() ], ), )) diff --git a/pubspec.lock b/pubspec.lock index 88a3604..39927ae 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -21,7 +21,14 @@ packages: name: async url: "https://pub.dartlang.org" source: hosted - version: "2.6.1" + version: "2.5.0" + badges: + dependency: "direct main" + description: + name: badges + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.1" barcode: dependency: transitive description: @@ -120,6 +127,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "4.0.0" + external_path: + dependency: "direct main" + description: + name: external_path + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.1" fake_async: dependency: transitive description: @@ -141,6 +155,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "6.1.2" + file_picker: + dependency: "direct main" + description: + name: file_picker + url: "https://pub.dartlang.org" + source: hosted + version: "4.0.1" filter_list: dependency: "direct main" description: @@ -202,6 +223,13 @@ packages: description: flutter source: sdk version: "0.0.0" + flutter_downloader: + dependency: "direct main" + description: + name: flutter_downloader + url: "https://pub.dartlang.org" + source: hosted + version: "1.7.0" flutter_launcher_icons: dependency: "direct dev" description: @@ -450,6 +478,20 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.11.1" + permission_handler: + dependency: "direct main" + description: + name: permission_handler + url: "https://pub.dartlang.org" + source: hosted + version: "8.1.4+2" + permission_handler_platform_interface: + dependency: transitive + description: + name: permission_handler_platform_interface + url: "https://pub.dartlang.org" + source: hosted + version: "3.6.1" petitparser: dependency: transitive description: @@ -471,6 +513,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "2.0.1" + printing: + dependency: "direct main" + description: + name: printing + url: "https://pub.dartlang.org" + source: hosted + version: "5.5.0" process: dependency: transitive description: @@ -566,7 +615,7 @@ packages: name: source_span url: "https://pub.dartlang.org" source: hosted - version: "1.8.1" + version: "1.8.0" stack_trace: dependency: transitive description: @@ -671,7 +720,7 @@ packages: name: test_api url: "https://pub.dartlang.org" source: hosted - version: "0.3.0" + version: "0.2.19" timezone: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index bd8fa74..5b2f0e7 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -15,7 +15,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev # In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion. # Read more about iOS versioning at # https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html -version: 2.0.92+11 +version: 2.1.89+40 environment: sdk: ">=2.12.0 <3.0.0" @@ -58,10 +58,16 @@ dependencies: im_stepper: ^0.1.3 pull_to_refresh: ^2.0.0 rename: ^1.3.1 - + printing: ^5.4.3 dio: ^4.0.0 lint: ^1.0.0 - + badges: ^2.0.1 + file_picker: ^4.0.1 + external_path: ^1.0.1 + permission_handler: ^8.1.4+2 + flutter_downloader: ^1.7.0 + + dev_dependencies: flutter_test: