Selaa lähdekoodia

separando pantallas de inicio y recepcion

angel-gajon 1 vuosi sitten
vanhempi
commit
129a8160e8

BIN
assets/iee_logo.png


BIN
assets/menu1.png


BIN
assets/menu2.png


BIN
assets/menu3.png


BIN
assets/menu4.png


BIN
assets/menu5.png


BIN
assets/menu6.png


BIN
assets/partido_politico1.png


BIN
assets/partido_politico2.png


BIN
assets/partido_politico3.png


BIN
assets/partido_politico4.png


BIN
assets/partido_politico5.png


BIN
assets/partido_politico6.png


BIN
assets/partido_politico7.png


BIN
assets/partido_politico8.png


BIN
assets/partido_politico9.png


+ 5 - 1
lib/main.dart

@@ -1,4 +1,6 @@
 //import 'package:fluent_ui/fluent_ui.dart';
+import 'package:computo_lite/viewmodels/home_view_model.dart';
+import 'package:computo_lite/views/home/home_screen.dart';
 import 'package:flutter/material.dart';
 import 'package:provider/provider.dart';
 import '../themes/themes.dart';
@@ -6,7 +8,7 @@ import 'package:flutter/services.dart';
 
 import 'viewmodels/viewmodels.dart';
 import 'views/main/main_screen.dart';
-import 'views/home/home_screen.dart';
+import 'views/paquetes/recepcion_screen.dart';
 import 'views/login/login_screen.dart';
 import 'package:timezone/data/latest.dart' as tzdata;
 
@@ -15,6 +17,7 @@ void main() {
   tzdata.initializeTimeZones();
   runApp(MultiProvider(providers: [
     ChangeNotifierProvider(create: (_) => LoginViewModel()),
+    ChangeNotifierProvider(create: (_) => HomeViewModel()),
   ], child: const MyApp()));
 }
 
@@ -34,6 +37,7 @@ class MyApp extends StatelessWidget {
         'main': (context) => const MainScreen(),
         'login': (context) => const LoginScreen(),
         'home': (context) => const HomeScreen(),
+        'recepcion': (context) => const RecepcionScreen(),
       },
     );
   }

+ 23 - 0
lib/viewmodels/home_view_model.dart

@@ -0,0 +1,23 @@
+
+
+import 'package:computo_lite/views/paquetes/recepcion_screen.dart';
+import 'package:flutter/material.dart';
+
+class HomeViewModel extends ChangeNotifier {
+  final List<Map<String, dynamic>> _opciones = [
+    {
+      'opcion': 'Recepción de Paquetes Electorales',
+      'descripcion':
+          'Registrar los recibos de entrega de los paquetes electorales, así como el estado en el que fueron recibidos',
+      'pantalla': const RecepcionScreen(),
+    },
+    // {
+    //   'opcion': 'Bodega Electoral',
+    //   'descripcion':
+    //       'Registrar la bitácora de apertura de bodega, así como el estatus de los paquetes electorales',
+    //   'pantalla': const BodegaElectoralScreen(),
+    // },
+  ];
+
+  List<Map<String, dynamic>> get opciones => _opciones;
+}

+ 66 - 126
lib/views/home/home_screen.dart

@@ -1,138 +1,78 @@
-import 'package:computo_lite/views/package/package_page.dart';
+import 'package:computo_lite/viewmodels/home_view_model.dart';
+import 'package:computo_lite/viewmodels/login_view_model.dart';
+import 'package:computo_lite/widgets/widgets_components.dart';
 import 'package:flutter/material.dart';
-import 'package:computo_lite/widgets/widgets.dart';
+import '../../widgets/app_drawer.dart';
+import '../../themes/themes.dart';
 import 'package:provider/provider.dart';
 
-import '../../viewmodels/viewmodels.dart';
-
-class HomeScreen extends StatefulWidget {
-  const HomeScreen({super.key});
-
-  @override
-  Formulario createState() => Formulario();
-}
-
-class Formulario extends State<HomeScreen> {
-  @override
-  void initState() {
-    super.initState();
-    Future(() async {
-      await Provider.of<LoginViewModel>(context, listen: false).setValores();
-    });
-  }
-
-  final PackageViewModel _packageViewModel = PackageViewModel();
-  bool _loading = false;
-
-  Future<void> _scanner() async {
-    try {
-      if (_loading) return;
-
-      if (mounted) setState(() => _loading = true);
-
-      Widget header = Row(
-        children: [
-          Icon(Icons.error),
-          SizedBox(width: 5),
-          Text("Aviso"),
-        ],
-      );
-
-      Map<String, dynamic>? response = await _packageViewModel.scanner("");
-
-      if (response == null ||
-          response["resultado"] == null ||
-          List.from(response["resultado"]).length == 0) {
-        if (mounted) setState(() => _loading = false);
-
-        await HelpersViewModel.dialog(
-            2,
-            header,
-            "No se encontro el Acta-Paquete, intenelo de nuevo.",
-            context,
-            "Cerrar",
-            "Reintentar",
-            () {}, () async {
-          await _scanner();
-        });
-
-        return;
-      }
-
-      Map<String, dynamic>? binnacle = await _packageViewModel
-          .getBinnacle(response["resultado"][0]["idActa"]);
-
-      Navigator.push(
-        context,
-        MaterialPageRoute(
-            builder: (context) => PackagePage(
-                response["resultado"][0],
-                binnacle != null
-                    ? List<Map<String, dynamic>>.from(binnacle["resultado"])
-                        .map((e) => ({
-                              "entradaSalida": e["entradaSalida"],
-                              "fecha": e["fecha"],
-                              "motivo": e["motivoPaquete"]["descripcion"]
-                            }))
-                        .toList()
-                    : [],
-                response["resultado"][0]["ultimaBitacora"] != null
-                    ? response["resultado"][0]["ultimaBitacora"]
-                        ["entradaSalida"]
-                    : "E",
-                true,
-                response["resultado"][0]["ultimaBitacora"] != null
-                    ? response["resultado"][0]["ultimaBitacora"]
-                        ["idConsejoElectoral"]
-                    : 0,
-                response["resultado"][0]["idTipoEleccion"])),
-      );
-    } catch (e) {
-      print(e);
-    } finally {
-      if (mounted) setState(() => _loading = false);
-    }
-  }
+class HomeScreen extends StatelessWidget {
+  const HomeScreen({Key? key}) : super(key: key);
 
   @override
   Widget build(BuildContext context) {
+    final homeViewModel = Provider.of<HomeViewModel>(context);
+    final opciones = homeViewModel.opciones;
     String correo = Provider.of<LoginViewModel>(context).correo;
-    return Scaffold(
-      backgroundColor: Colors.grey.shade200,
-      appBar: AppBar(
-        elevation: 0,
-        title: const Text(
-          'Inicio',
-          style: TextStyle(color: Colors.white),
+    return WillPopScope(
+      onWillPop: () async {
+        return false;
+      },
+      child: Scaffold(
+        drawer: AppDrawer(),
+        appBar: AppBar(
+          elevation: 0,
+          title: const Text(
+            'Inicio',
+            style: TextStyle( color: Colors.white),
+          ),
+          iconTheme: const IconThemeData(color: Colors.white),
+          actions: [usuarioHeader(correo)],
+        ),
+        body: GridView.builder(
+          gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(
+              crossAxisCount: 1),
+          itemCount: opciones.length,
+          itemBuilder: (context, index) {
+            final opcion = opciones[index];
+            return Padding(
+              padding: const EdgeInsets.all(8.0),
+              child: InkWell(
+                onTap: () {
+                  Navigator.of(context).push(
+                    MaterialPageRoute(
+                      builder: (context) => opcion['pantalla'],
+                    ),
+                  );
+                },
+                child: Card(
+                  surfaceTintColor: AppTheme.secondary,
+                  elevation: 5,
+                  child: Column(
+                    children: [
+                      Expanded(
+                        child: Image(
+                          image: AssetImage('assets/menu${index + 1}.png'),
+                        ),
+                      ),
+                      ListTile(
+                        title: Text(
+                          opcion['opcion'],
+                          style: const TextStyle(fontSize: 18),
+                        ),
+                        subtitle: Text(opcion['descripcion']),
+                      ),
+                      const SizedBox(
+                        height: 5,
+                      ),
+                    ],
+                  ),
+                ),
+              ),
+            );
+          },
         ),
-        iconTheme: const IconThemeData(color: Colors.white),
-        actions: [usuarioHeader(correo)],
       ),
-      drawer: AppDrawer(),
-      body: Column(children: [
-        const SizedBox(height: 150),
-        Center(
-            child: Image.asset(
-          "assets/Elecciones2024.png",
-          height: 150,
-        )),
-        const SizedBox(height: 100),
-        Center(
-            child: GestureDetector(
-          onTap: _scanner,
-          child: CircleAvatar(
-              radius: 100,
-              child: _loading
-                  ? CircularProgressIndicator(
-                      valueColor:
-                          new AlwaysStoppedAnimation<Color>(Colors.white),
-                    )
-                  : const Icon(
-                      Icons.camera_alt,
-                      size: 100,
-                    )),
-        )),
-      ]),
     );
   }
 }

+ 2 - 1
lib/views/main/main_screen.dart

@@ -1,9 +1,10 @@
+import 'package:computo_lite/views/home/home_screen.dart';
 import 'package:flutter/material.dart';
 import 'package:provider/provider.dart';
 
 import '../../viewmodels/viewmodels.dart';
 import '../../views/login/login_screen.dart';
-import '../home/home_screen.dart';
+import '../paquetes/recepcion_screen.dart';
 
 class MainScreen extends StatefulWidget {
   const MainScreen({super.key});

+ 138 - 0
lib/views/paquetes/recepcion_screen.dart

@@ -0,0 +1,138 @@
+import 'package:computo_lite/views/package/package_page.dart';
+import 'package:flutter/material.dart';
+import 'package:computo_lite/widgets/widgets.dart';
+import 'package:provider/provider.dart';
+
+import '../../viewmodels/viewmodels.dart';
+
+class RecepcionScreen extends StatefulWidget {
+  const RecepcionScreen({super.key});
+
+  @override
+  Formulario createState() => Formulario();
+}
+
+class Formulario extends State<RecepcionScreen> {
+  @override
+  void initState() {
+    super.initState();
+    Future(() async {
+      await Provider.of<LoginViewModel>(context, listen: false).setValores();
+    });
+  }
+
+  final PackageViewModel _packageViewModel = PackageViewModel();
+  bool _loading = false;
+
+  Future<void> _scanner() async {
+    try {
+      if (_loading) return;
+
+      if (mounted) setState(() => _loading = true);
+
+      Widget header = Row(
+        children: [
+          Icon(Icons.error),
+          SizedBox(width: 5),
+          Text("Aviso"),
+        ],
+      );
+
+      Map<String, dynamic>? response = await _packageViewModel.scanner("");
+
+      if (response == null ||
+          response["resultado"] == null ||
+          List.from(response["resultado"]).length == 0) {
+        if (mounted) setState(() => _loading = false);
+
+        await HelpersViewModel.dialog(
+            2,
+            header,
+            "No se encontro el Acta-Paquete, intenelo de nuevo.",
+            context,
+            "Cerrar",
+            "Reintentar",
+            () {}, () async {
+          await _scanner();
+        });
+
+        return;
+      }
+
+      Map<String, dynamic>? binnacle = await _packageViewModel
+          .getBinnacle(response["resultado"][0]["idActa"]);
+
+      Navigator.push(
+        context,
+        MaterialPageRoute(
+            builder: (context) => PackagePage(
+                response["resultado"][0],
+                binnacle != null
+                    ? List<Map<String, dynamic>>.from(binnacle["resultado"])
+                        .map((e) => ({
+                              "entradaSalida": e["entradaSalida"],
+                              "fecha": e["fecha"],
+                              "motivo": e["motivoPaquete"]["descripcion"]
+                            }))
+                        .toList()
+                    : [],
+                response["resultado"][0]["ultimaBitacora"] != null
+                    ? response["resultado"][0]["ultimaBitacora"]
+                        ["entradaSalida"]
+                    : "E",
+                true,
+                response["resultado"][0]["ultimaBitacora"] != null
+                    ? response["resultado"][0]["ultimaBitacora"]
+                        ["idConsejoElectoral"]
+                    : 0,
+                response["resultado"][0]["idTipoEleccion"])),
+      );
+    } catch (e) {
+      print(e);
+    } finally {
+      if (mounted) setState(() => _loading = false);
+    }
+  }
+
+  @override
+  Widget build(BuildContext context) {
+    String correo = Provider.of<LoginViewModel>(context).correo;
+    return Scaffold(
+      backgroundColor: Colors.grey.shade200,
+      appBar: AppBar(
+        elevation: 0,
+        title: const Text(
+          'Recepcion',
+          style: TextStyle(color: Colors.white),
+        ),
+        iconTheme: const IconThemeData(color: Colors.white),
+        actions: [usuarioHeader(correo)],
+      ),
+      drawer: AppDrawer(),
+      body: Column(children: [
+        const SizedBox(height: 150),
+        Center(
+            child: Image.asset(
+          "assets/Elecciones2024.png",
+          height: 150,
+        )),
+        const SizedBox(height: 100),
+        Center(
+            child: GestureDetector(
+          onTap: _scanner,
+          child: CircleAvatar(
+              radius: 100,
+              child: _loading
+                  ? CircularProgressIndicator(
+                      valueColor:
+                          new AlwaysStoppedAnimation<Color>(Colors.white),
+                    )
+                  : const Icon(
+                      Icons.camera_alt,
+                      size: 100,
+                    )),
+        )),
+      ]),
+    );
+  }
+}

+ 24 - 0
lib/widgets/app_drawer.dart

@@ -87,6 +87,30 @@ class AppDrawer extends StatelessWidget {
             ),
           ),
           //HEADER
+          // ListTile(
+          //   leading: const Icon(Icons.inventory_2_sharp),
+          //   title: const Text("Recepción de Paquetes Electorales"),
+          //   onTap: () => {
+          //     Navigator.pop(context),
+          //     Navigator.of(context).push(
+          //       MaterialPageRoute(
+          //         builder: (context) => const RecepcionScreen(),
+          //       ),
+          //     ),
+          //   },
+          // ),
+          // ListTile(
+          //   leading: const Icon(Icons.warehouse),
+          //   title: const Text("Bodega Electoral"),
+          //   onTap: () => {
+          //     Navigator.pop(context),
+          //     Navigator.of(context).push(
+          //       MaterialPageRoute(
+          //         builder: (context) => const BodegaElectoralScreen(),
+          //       ),
+          //     ),
+          //   },
+          // ),
           Expanded(
               child: ListView(children: [
             ListTile(

+ 40 - 8
pubspec.lock

@@ -352,6 +352,30 @@ packages:
       url: "https://pub.dev"
     source: hosted
     version: "0.6.7"
+  leak_tracker:
+    dependency: transitive
+    description:
+      name: leak_tracker
+      sha256: "78eb209deea09858f5269f5a5b02be4049535f568c07b275096836f01ea323fa"
+      url: "https://pub.dev"
+    source: hosted
+    version: "10.0.0"
+  leak_tracker_flutter_testing:
+    dependency: transitive
+    description:
+      name: leak_tracker_flutter_testing
+      sha256: b46c5e37c19120a8a01918cfaf293547f47269f7cb4b0058f21531c2465d6ef0
+      url: "https://pub.dev"
+    source: hosted
+    version: "2.0.1"
+  leak_tracker_testing:
+    dependency: transitive
+    description:
+      name: leak_tracker_testing
+      sha256: a597f72a664dbd293f3bfc51f9ba69816f84dcd403cdac7066cb3f6003f3ab47
+      url: "https://pub.dev"
+    source: hosted
+    version: "2.0.1"
   lints:
     dependency: transitive
     description:
@@ -364,26 +388,26 @@ packages:
     dependency: transitive
     description:
       name: matcher
-      sha256: "1803e76e6653768d64ed8ff2e1e67bea3ad4b923eb5c56a295c3e634bad5960e"
+      sha256: d2323aa2060500f906aa31a895b4030b6da3ebdcc5619d14ce1aada65cd161cb
       url: "https://pub.dev"
     source: hosted
-    version: "0.12.16"
+    version: "0.12.16+1"
   material_color_utilities:
     dependency: transitive
     description:
       name: material_color_utilities
-      sha256: "9528f2f296073ff54cb9fee677df673ace1218163c3bc7628093e7eed5203d41"
+      sha256: "0e0a020085b65b6083975e499759762399b4475f766c21668c4ecca34ea74e5a"
       url: "https://pub.dev"
     source: hosted
-    version: "0.5.0"
+    version: "0.8.0"
   meta:
     dependency: transitive
     description:
       name: meta
-      sha256: a6e590c838b18133bb482a2745ad77c5bb7715fb0451209e1a7567d416678b8e
+      sha256: d584fa6707a52763a52446f02cc621b077888fb63b93bbcb1143a7be5a0c0c04
       url: "https://pub.dev"
     source: hosted
-    version: "1.10.0"
+    version: "1.11.0"
   nested:
     dependency: transitive
     description:
@@ -404,10 +428,10 @@ packages:
     dependency: transitive
     description:
       name: path
-      sha256: "8829d8a55c13fc0e37127c29fedf290c102f4e40ae94ada574091fe0ff96c917"
+      sha256: "087ce49c3f0dc39180befefc60fdb4acd8f8620e5682fe2476afd0b3688bb4af"
       url: "https://pub.dev"
     source: hosted
-    version: "1.8.3"
+    version: "1.9.0"
   path_provider:
     dependency: "direct main"
     description:
@@ -733,6 +757,14 @@ packages:
       url: "https://pub.dev"
     source: hosted
     version: "2.1.4"
+  vm_service:
+    dependency: transitive
+    description:
+      name: vm_service
+      sha256: b3d56ff4341b8f182b96aceb2fa20e3dcb336b9f867bc0eafc0de10f1048e957
+      url: "https://pub.dev"
+    source: hosted
+    version: "13.0.0"
   web:
     dependency: transitive
     description:

+ 1 - 2
pubspec.yaml

@@ -76,8 +76,7 @@ flutter:
 
   # To add assets to your application, add an assets section, like this:
   assets:
-    - assets/Elecciones2024.png
-    - assets/logo_iee.png
+    - assets/
   #   - images/a_dot_ham.jpeg
 
   # An image asset can refer to one or more resolution-specific "variants", see