From 3dbdfba675b7bcd4153ce7dff3b8c29f99caa77f Mon Sep 17 00:00:00 2001 From: Angel David Carlos Silva Date: Tue, 18 Jun 2024 19:51:33 -0600 Subject: [PATCH 01/19] Agregando mueva pagina de inicio --- .../lib/config/router.dart | 7 + .../lib/pages/login.dart | 10 +- .../lib/pages/star_page2.dart | 145 ++++++++++++++++++ .../lib/pages/start_page.dart | 50 +++--- .../lib/utilerias/Images.dart | 107 ++++++++++--- 5 files changed, 267 insertions(+), 52 deletions(-) create mode 100644 fronted/aplicacionrutasturisticas/lib/pages/star_page2.dart diff --git a/fronted/aplicacionrutasturisticas/lib/config/router.dart b/fronted/aplicacionrutasturisticas/lib/config/router.dart index 5c03c71..97d8961 100644 --- a/fronted/aplicacionrutasturisticas/lib/config/router.dart +++ b/fronted/aplicacionrutasturisticas/lib/config/router.dart @@ -1,5 +1,6 @@ import 'package:aplicacionrutasturisticas/pages/login.dart'; import 'package:aplicacionrutasturisticas/pages/register.dart'; +import 'package:aplicacionrutasturisticas/pages/star_page2.dart'; import 'package:aplicacionrutasturisticas/pages/start_page.dart'; import 'package:flutter/cupertino.dart'; import 'package:go_router/go_router.dart'; @@ -24,5 +25,11 @@ final GoRouter router = GoRouter(routes: [ path: '/startpage', builder: (BuildContext context, GoRouterState state) { return const StartedPage(); + }), + GoRoute( + name: "StartPage2", + path: '/startpage2', + builder: (BuildContext context, GoRouterState state) { + return const StartedPage2(); }) ]); diff --git a/fronted/aplicacionrutasturisticas/lib/pages/login.dart b/fronted/aplicacionrutasturisticas/lib/pages/login.dart index 84a9aa2..3d1213e 100644 --- a/fronted/aplicacionrutasturisticas/lib/pages/login.dart +++ b/fronted/aplicacionrutasturisticas/lib/pages/login.dart @@ -77,20 +77,20 @@ class _TextFielEjemploState extends State { texto: "Invitado", onPression: botonRegistrar) ], ), - ], - ), + ], ), ), ), - ); + ), + ); } void botonIniciaSesion() { corr = correo.text; pass = password.text; print(corr + " " + pass); - loginDatos(corr, pass); - context.goNamed("StartPage"); + //loginDatos(corr, pass); + context.goNamed("StartPage2"); } void botonRegistrar() { diff --git a/fronted/aplicacionrutasturisticas/lib/pages/star_page2.dart b/fronted/aplicacionrutasturisticas/lib/pages/star_page2.dart new file mode 100644 index 0000000..7e0c0f8 --- /dev/null +++ b/fronted/aplicacionrutasturisticas/lib/pages/star_page2.dart @@ -0,0 +1,145 @@ +import 'package:flutter/material.dart'; + +class StartedPage2 extends StatefulWidget { + const StartedPage2({super.key}); + + @override + StartedPageState2 createState() => StartedPageState2(); +} + +class StartedPageState2 extends State { + @override + Widget build(BuildContext context) { + return MaterialApp( + home: Scaffold( + body: Stack( + children: [ + Container( + decoration: BoxDecoration( + image: DecorationImage( + image: NetworkImage( + 'https://www.turimexico.com/wp-content/uploads/2015/10/ciudad-de-zacatecas.jpg'), + fit: BoxFit.cover, + colorFilter: ColorFilter.mode( + Colors.black.withOpacity(0.5), + BlendMode.darken, + ), + ), + ), + ), + const Column(mainAxisAlignment: MainAxisAlignment.start, children: [ + SizedBox( + height: 20, + ), + Padding( + padding: EdgeInsets.all(16.0), + child: Text( + 'Bienvenido a Zacatecas', + style: TextStyle( + color: Colors.white, + fontSize: 24, + fontWeight: FontWeight.bold, + ), + textAlign: TextAlign.center, + ), + ) + ]), + DraggableScrollableSheet( + initialChildSize: 0.1, + minChildSize: 0.1, + builder: + (BuildContext context, ScrollController scrollController) { + return Padding( + padding: const EdgeInsets.symmetric(horizontal: 10.0), + child: ClipRRect( + borderRadius: BorderRadius.only( + topLeft: Radius.circular(50.0), + topRight: Radius.circular(50.0), + ), + child: Container( + color: Colors.white, + child: Column( + children: [ + Container( + height: 5.0, + width: 50.0, + margin: const EdgeInsets.symmetric(vertical: 10.0), + decoration: BoxDecoration( + color: Colors.grey[300], + borderRadius: BorderRadius.circular(10.0), + ), + ), + Expanded( + child: ListView( + controller: scrollController, + children: [ + ListTile( + leading: Icon(Icons.location_history), + title: Text('Crea Ruta'), + onTap: () { + // Acción al tocar la opción + }, + ), + ListTile( + leading: Icon(Icons.map), + title: Text('Ruta Recomendada'), + onTap: () { + // Acción al tocar la opción + }, + ), + ListTile( + leading: Icon(Icons.list), + title: Text('Lista de Lugares'), + onTap: () { + // Acción al tocar la opción + }, + ), + ListTile( + leading: Icon(Icons.star), + title: Text('Rutas Completadas'), + onTap: () { + // Acción al tocar la opción + }, + ), + ], + ), + ), + ], + ), + ), + ), + ); + }, + ), + ], + ), + ), + ); + } + + Card buildCard(String title, IconData icon, BuildContext context) { + return Card( + margin: EdgeInsets.all(16.0), + child: InkWell( + onTap: () { + // Acción al tocar la tarjeta + }, + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Icon( + icon, + size: 80.0, + color: Colors.blue, + ), + SizedBox(height: 16.0), + Text( + title, + style: TextStyle(fontSize: 18.0, fontWeight: FontWeight.bold), + ), + ], + ), + ), + ); + } +} diff --git a/fronted/aplicacionrutasturisticas/lib/pages/start_page.dart b/fronted/aplicacionrutasturisticas/lib/pages/start_page.dart index 18138e9..3ec025c 100644 --- a/fronted/aplicacionrutasturisticas/lib/pages/start_page.dart +++ b/fronted/aplicacionrutasturisticas/lib/pages/start_page.dart @@ -30,38 +30,42 @@ class StartedPageState extends State { child: SingleChildScrollView( child: Column( children: [ - Row( + Column( mainAxisAlignment: MainAxisAlignment.center, children: [ - ImagesWithTextNetwork( - text: "Crear Ruta", + WithTextImage( + text: "", onTap: buttonCrearRuta, imageURL: - "https://www.eluniversal.com.mx/resizer/cyelyPh4C4pSbIBjHdO0WSF8FSs=/1100x666/cloudfront-us-east-1.images.arcpublishing.com/eluniversal/DWSWJNA4B5HDBKAXYD6YTFUUUI.jpg"), - //WithText(text: "Crear Ruta", onTap: buttonCrearRuta), - const SizedBox(width: 20), - ImagesWithTextNetwork( - text: "Ruta Recomendada", + "https://i.ibb.co/wyC46vL/imagen-2024-05-21-114114963.png"), + Text("Crea Ruta"), + SizedBox( + height: 30, + ), + WithTextImage( + text: "", onTap: buttonRutaRecomendada, imageURL: - "https://assets.turismocity.com/cdn-cgi/image/format=auto,width=500,fit=scale-down/ruta-40-argentina.jpeg") - ], - ), - const SizedBox(height: 30), - Row( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - ImagesWithTextNetwork( - text: "Lista de Lugares", + "https://i.ibb.co/wwBP6pZ/imagen-2024-05-21-114421156.png"), + Text("Ruta Recomendada"), + SizedBox( + height: 30, + ), + WithTextImage( + text: "", onTap: buttonListadeLugares, imageURL: - "https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQhuG72NEweDkbylMmq7Mh3MSI0orCC4Xupsg&usqp=CAU"), - const SizedBox(width: 20), - ImagesWithTextNetwork( - text: "Rutas Completadas", - onTap: buttonRutasCompletadas, + "https://i.ibb.co/djsffFB/imagen-2024-05-21-115417206.png"), + Text("Lista de Lugares"), + SizedBox( + height: 30, + ), + WithTextImage( + text: "", + onTap: buttonListadeLugares, imageURL: - "https://static.vecteezy.com/system/resources/previews/015/954/844/non_2x/all-systems-are-ready-tasks-completed-conditions-met-full-readiness-fact-check-series-of-correct-decisions-implementation-of-roadmap-agreement-compliance-with-criteria-fulfill-all-requirements-photo.jpg") + "https://i.ibb.co/fFX7Ng5/imagen-2024-05-21-115900870.png"), + Text("Rutas Completadas") ], ) ], diff --git a/fronted/aplicacionrutasturisticas/lib/utilerias/Images.dart b/fronted/aplicacionrutasturisticas/lib/utilerias/Images.dart index 3167ecb..4db4487 100644 --- a/fronted/aplicacionrutasturisticas/lib/utilerias/Images.dart +++ b/fronted/aplicacionrutasturisticas/lib/utilerias/Images.dart @@ -23,8 +23,8 @@ class ImagesWithTextNetwork extends StatelessWidget { children: [ Image.network( imageURL, - height: 100, - width: 150, + height: 150, + width: 250, ), Container( color: Colors.black54, @@ -41,11 +41,11 @@ class ImagesWithTextNetwork extends StatelessWidget { } } -class WithText extends StatelessWidget { +class WithTextOnli extends StatelessWidget { final String text; final VoidCallback? onTap; - const WithText({ + const WithTextOnli({ Key? key, required this.text, required this.onTap, @@ -54,30 +54,89 @@ class WithText extends StatelessWidget { @override Widget build(BuildContext context) { return InkWell( - customBorder: Border.all( - color: Colors.black, - width: 500, - ), onTap: onTap, - child: ClipRRect( - borderRadius: BorderRadius.circular(30), - child: Stack( - alignment: Alignment.center, - children: [ - Container( - width: 100, - height: 100, - color: Colors.white, - child: Center( - child: Text( - text, - style: TextStyle( - color: Colors.black, + child: Container( + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(30), + border: Border.all(color: Colors.black, width: 2)), + child: ClipRRect( + borderRadius: BorderRadius.circular(30), + child: Stack( + alignment: Alignment.center, + children: [ + Container( + width: 200, + height: 100, + color: Colors.white, + child: Center( + child: Text( + text, + style: TextStyle( + color: Colors.black, + ), + ), + ), + ) + ], + ), + ), + )); + } +} + +class WithTextImage extends StatelessWidget { + final String text; + final VoidCallback? onTap; + final String imageURL; + + const WithTextImage( + {Key? key, + required this.text, + required this.onTap, + required this.imageURL}) + : super(key: key); + + @override + Widget build(BuildContext context) { + return InkWell( + onTap: onTap, + child: Container( + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(30), + border: Border.all(color: Colors.black, width: 2)), + child: ClipRRect( + borderRadius: BorderRadius.circular(28), + child: Stack( + alignment: Alignment.center, + children: [ + Container( + width: 250, + height: 125, + color: Colors.white, + child: Center( + child: Stack( + alignment: Alignment.center, + children: [ + Image.network(imageURL, + color: Colors.grey.withOpacity(0.7), + colorBlendMode: BlendMode.darken, + width: 250, + height: 150, + fit: BoxFit.cover), + Container( + child: Text( + text, + style: TextStyle( + color: Colors.white, + ), + ), + ) + ], ), ), ), - ) - ], + ], + ), ), )); } -- GitLab From 2ffa8825d55a7ca4622a481e1d7fdf1a5298bb23 Mon Sep 17 00:00:00 2001 From: Angel David Carlos Silva Date: Fri, 21 Jun 2024 20:24:15 -0600 Subject: [PATCH 02/19] Perfil en barra lateral Se agrego el apartado de perfil para los usuarios, pero se integro como barra lateral, se agregaron las utilirias para poder usarlo en mas de una pagina --- .../lib/pages/star_page2.dart | 98 ++++++++----------- .../lib/utilerias/Perfil/AppBar_Perfil.dart | 30 ++++++ .../lib/utilerias/Perfil/Drawer_Perfil.dart | 44 +++++++++ 3 files changed, 115 insertions(+), 57 deletions(-) create mode 100644 fronted/aplicacionrutasturisticas/lib/utilerias/Perfil/AppBar_Perfil.dart create mode 100644 fronted/aplicacionrutasturisticas/lib/utilerias/Perfil/Drawer_Perfil.dart diff --git a/fronted/aplicacionrutasturisticas/lib/pages/star_page2.dart b/fronted/aplicacionrutasturisticas/lib/pages/star_page2.dart index 7e0c0f8..0272c44 100644 --- a/fronted/aplicacionrutasturisticas/lib/pages/star_page2.dart +++ b/fronted/aplicacionrutasturisticas/lib/pages/star_page2.dart @@ -1,3 +1,6 @@ +import 'package:aplicacionrutasturisticas/utilerias/Perfil/AppBar_Perfil.dart'; +import 'package:aplicacionrutasturisticas/utilerias/Perfil/Drawer_Perfil.dart'; +import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; class StartedPage2 extends StatefulWidget { @@ -18,7 +21,8 @@ class StartedPageState2 extends State { decoration: BoxDecoration( image: DecorationImage( image: NetworkImage( - 'https://www.turimexico.com/wp-content/uploads/2015/10/ciudad-de-zacatecas.jpg'), + 'https://www.turimexico.com/wp-content/uploads/2015/10/ciudad-de-zacatecas.jpg', + ), fit: BoxFit.cover, colorFilter: ColorFilter.mode( Colors.black.withOpacity(0.5), @@ -27,34 +31,39 @@ class StartedPageState2 extends State { ), ), ), - const Column(mainAxisAlignment: MainAxisAlignment.start, children: [ - SizedBox( - height: 20, - ), - Padding( - padding: EdgeInsets.all(16.0), - child: Text( - 'Bienvenido a Zacatecas', - style: TextStyle( - color: Colors.white, - fontSize: 24, - fontWeight: FontWeight.bold, + SingleChildScrollView( + child: Column( + children: [ + SizedBox( + height: kToolbarHeight, // Espacio para el AppBar ), - textAlign: TextAlign.center, - ), - ) - ]), - DraggableScrollableSheet( - initialChildSize: 0.1, - minChildSize: 0.1, - builder: - (BuildContext context, ScrollController scrollController) { - return Padding( - padding: const EdgeInsets.symmetric(horizontal: 10.0), - child: ClipRRect( - borderRadius: BorderRadius.only( - topLeft: Radius.circular(50.0), - topRight: Radius.circular(50.0), + Padding( + padding: const EdgeInsets.all(16.0), + child: Text( + 'Bienvenido a Zacatecas', + style: TextStyle( + color: Colors.white, + fontSize: 24, + fontWeight: FontWeight.bold, + ), + textAlign: TextAlign.center, + ), + ), + ], + ), + ), + AppBar_Perfil(), //Este app se establece en el body, para que no genere conflictos de colicion + Padding( + padding: const EdgeInsets.symmetric(horizontal: 10.0), + child: DraggableScrollableSheet( + initialChildSize: 0.3, + minChildSize: 0.1, + builder: + (BuildContext context, ScrollController scrollController) { + return ClipRRect( + borderRadius: const BorderRadius.only( + topLeft: Radius.circular(60.0), + topRight: Radius.circular(60.0), ), child: Container( color: Colors.white, @@ -107,38 +116,13 @@ class StartedPageState2 extends State { ], ), ), - ), - ); - }, - ), - ], - ), - ), - ); - } - - Card buildCard(String title, IconData icon, BuildContext context) { - return Card( - margin: EdgeInsets.all(16.0), - child: InkWell( - onTap: () { - // Acción al tocar la tarjeta - }, - child: Column( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Icon( - icon, - size: 80.0, - color: Colors.blue, - ), - SizedBox(height: 16.0), - Text( - title, - style: TextStyle(fontSize: 18.0, fontWeight: FontWeight.bold), + ); + }, + ), ), ], ), + endDrawer: Perfil(), ), ); } diff --git a/fronted/aplicacionrutasturisticas/lib/utilerias/Perfil/AppBar_Perfil.dart b/fronted/aplicacionrutasturisticas/lib/utilerias/Perfil/AppBar_Perfil.dart new file mode 100644 index 0000000..fdad9d4 --- /dev/null +++ b/fronted/aplicacionrutasturisticas/lib/utilerias/Perfil/AppBar_Perfil.dart @@ -0,0 +1,30 @@ +import 'package:flutter/material.dart'; + +class AppBar_Perfil extends StatelessWidget { + @override + Widget build(BuildContext context) { + return Positioned( + top: 0, + left: 0, + right: 0, + child: AppBar( + backgroundColor: Colors.transparent, + elevation: 0, + actions: [ + Builder( + builder: (BuildContext context) { + return IconButton( + icon: Image.network( + 'https://i.ibb.co/Vw6XLpR/actualizar.png', + ), + onPressed: () { + Scaffold.of(context).openEndDrawer(); + }, + ); + }, + ), + ], + ), + ); + } +} diff --git a/fronted/aplicacionrutasturisticas/lib/utilerias/Perfil/Drawer_Perfil.dart b/fronted/aplicacionrutasturisticas/lib/utilerias/Perfil/Drawer_Perfil.dart new file mode 100644 index 0000000..f2e0e5b --- /dev/null +++ b/fronted/aplicacionrutasturisticas/lib/utilerias/Perfil/Drawer_Perfil.dart @@ -0,0 +1,44 @@ +import 'package:flutter/cupertino.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter/widgets.dart'; + +class Perfil extends StatelessWidget { + @override + Widget build(BuildContext context) { + return Drawer( + child: ListView( + padding: EdgeInsets.zero, + children: [ + const DrawerHeader( + decoration: BoxDecoration( + color: Colors.blue, + ), + child: Text( + 'Bienvenido', + style: TextStyle( + color: Colors.white, + fontSize: 24, + fontWeight: FontWeight.bold, + ), + ), + ), + ListTile( + leading: Icon(Icons.message), + title: Text('Messages'), + onTap: () {}, + ), + ListTile( + leading: Icon(Icons.account_circle), + title: Text('Profile'), + onTap: () {}, + ), + ListTile( + leading: Icon(Icons.settings), + title: Text('Settings'), + onTap: () {}, + ), + ], + ), + ); + } +} -- GitLab From 9afa2cd3953f571ad8cba943b18163a749b179e4 Mon Sep 17 00:00:00 2001 From: Angel David Carlos Silva Date: Fri, 21 Jun 2024 23:40:10 -0600 Subject: [PATCH 03/19] Bases para el cambio de idioma El cambio de idioma, parte visual --- .../lib/config/metodos/perfil_metodos.dart | 12 +++++ .../lib/utilerias/MensajeEnMEdio.dart | 29 +++++++++++ .../Perfil/CupertinoPicker_Perfil.dart | 49 +++++++++++++++++++ .../lib/utilerias/Perfil/Drawer_Perfil.dart | 47 +++++++++++++++--- .../lib/variables/perfil_variables.dart | 7 +++ 5 files changed, 138 insertions(+), 6 deletions(-) create mode 100644 fronted/aplicacionrutasturisticas/lib/config/metodos/perfil_metodos.dart create mode 100644 fronted/aplicacionrutasturisticas/lib/utilerias/MensajeEnMEdio.dart create mode 100644 fronted/aplicacionrutasturisticas/lib/utilerias/Perfil/CupertinoPicker_Perfil.dart create mode 100644 fronted/aplicacionrutasturisticas/lib/variables/perfil_variables.dart diff --git a/fronted/aplicacionrutasturisticas/lib/config/metodos/perfil_metodos.dart b/fronted/aplicacionrutasturisticas/lib/config/metodos/perfil_metodos.dart new file mode 100644 index 0000000..e2a284b --- /dev/null +++ b/fronted/aplicacionrutasturisticas/lib/config/metodos/perfil_metodos.dart @@ -0,0 +1,12 @@ +import 'package:aplicacionrutasturisticas/variables/perfil_variables.dart' + as globals; + +class Perfil_metodos { + void precionasteIdioma() { + print("Haz precionado idoma"); + } + + void seleccionasteIdioma(String idioma) { + print("Selecionaste el idioma: " + globals.getLenguaje); + } +} diff --git a/fronted/aplicacionrutasturisticas/lib/utilerias/MensajeEnMEdio.dart b/fronted/aplicacionrutasturisticas/lib/utilerias/MensajeEnMEdio.dart new file mode 100644 index 0000000..6b15c64 --- /dev/null +++ b/fronted/aplicacionrutasturisticas/lib/utilerias/MensajeEnMEdio.dart @@ -0,0 +1,29 @@ +import 'package:flutter/material.dart'; + +class SnackBarMensaje { + static void show(BuildContext context, String message) { + final snackBar = SnackBar( + content: Text(message), + duration: Duration(seconds: 2), + behavior: SnackBarBehavior.floating, + backgroundColor: Colors.blue, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(10), + ), + ); + + ScaffoldMessenger.of(context).showSnackBar(snackBar); + } +} + +class SnackBarButton extends StatelessWidget { + @override + Widget build(BuildContext context) { + return ElevatedButton( + onPressed: () { + SnackBarMensaje.show(context, 'Este es un SnackBar'); + }, + child: Text('Mostrar SnackBar'), + ); + } +} diff --git a/fronted/aplicacionrutasturisticas/lib/utilerias/Perfil/CupertinoPicker_Perfil.dart b/fronted/aplicacionrutasturisticas/lib/utilerias/Perfil/CupertinoPicker_Perfil.dart new file mode 100644 index 0000000..8fa06ed --- /dev/null +++ b/fronted/aplicacionrutasturisticas/lib/utilerias/Perfil/CupertinoPicker_Perfil.dart @@ -0,0 +1,49 @@ +import 'package:aplicacionrutasturisticas/config/metodos/perfil_metodos.dart'; +import 'package:aplicacionrutasturisticas/utilerias/MensajeEnMEdio.dart'; +import 'package:aplicacionrutasturisticas/variables/perfil_variables.dart' + as globals; +import 'package:flutter/cupertino.dart'; +import 'package:flutter/material.dart'; + +class CupertinoPickerWidget_perfil extends StatefulWidget { + @override + _CupertinoPickerWidget_perfilState createState() => + _CupertinoPickerWidget_perfilState(); +} + +class _CupertinoPickerWidget_perfilState + extends State { + int _selectedValue = 0; + final List _options = ['Español', 'Inglés', 'Portuges']; + + @override + Widget build(BuildContext context) { + return Container( + height: MediaQuery.of(context).size.height / 3, + child: Column( + children: [ + Expanded( + child: CupertinoPicker( + backgroundColor: Colors.white, + onSelectedItemChanged: (value) { + setState(() { + _selectedValue = value; + }); + }, + itemExtent: 32.0, + children: _options.map((option) => Text(option)).toList(), + ), + ), + ElevatedButton( + onPressed: () { + globals.setLenguaje = '${_options[_selectedValue]}'; + Perfil_metodos() + .seleccionasteIdioma('${_options[_selectedValue]}'); + }, + child: Text('Confirmar', style: TextStyle(fontSize: 20)), + ) + ], + ), + ); + } +} diff --git a/fronted/aplicacionrutasturisticas/lib/utilerias/Perfil/Drawer_Perfil.dart b/fronted/aplicacionrutasturisticas/lib/utilerias/Perfil/Drawer_Perfil.dart index f2e0e5b..a0ab4ed 100644 --- a/fronted/aplicacionrutasturisticas/lib/utilerias/Perfil/Drawer_Perfil.dart +++ b/fronted/aplicacionrutasturisticas/lib/utilerias/Perfil/Drawer_Perfil.dart @@ -1,8 +1,40 @@ +import 'package:aplicacionrutasturisticas/utilerias/Perfil/CupertinoPicker_Perfil.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter/widgets.dart'; +import 'package:aplicacionrutasturisticas/config/metodos/perfil_metodos.dart'; + +class Perfil extends StatefulWidget { + @override + _PerfilState createState() => _PerfilState(); +} + +class _PerfilState extends State { + void llamridioma() { + showModalBottomSheet( + context: context, + builder: (BuildContext context) { + return Container( + child: Padding( + padding: const EdgeInsets.all(10), + child: Column( + mainAxisSize: MainAxisSize + .min, // Ajusta el tamaño de la columna al contenido + children: [ + Text( + "Selecciona tu idioma", + textAlign: TextAlign.center, + style: TextStyle(fontSize: 20), + ), + CupertinoPickerWidget_perfil() + ], + ), + ), + ); + }, + ); + } -class Perfil extends StatelessWidget { @override Widget build(BuildContext context) { return Drawer( @@ -24,18 +56,21 @@ class Perfil extends StatelessWidget { ), ListTile( leading: Icon(Icons.message), - title: Text('Messages'), + title: Text('Informacion Personal'), onTap: () {}, ), ListTile( leading: Icon(Icons.account_circle), - title: Text('Profile'), + title: Text('Notificaciones'), onTap: () {}, ), ListTile( - leading: Icon(Icons.settings), - title: Text('Settings'), - onTap: () {}, + leading: Icon(Icons.sunny), + title: Text('Idioma'), + onTap: () { + Perfil_metodos().precionasteIdioma(); + llamridioma(); // Llama al método para mostrar el modal + }, ), ], ), diff --git a/fronted/aplicacionrutasturisticas/lib/variables/perfil_variables.dart b/fronted/aplicacionrutasturisticas/lib/variables/perfil_variables.dart new file mode 100644 index 0000000..b7298b5 --- /dev/null +++ b/fronted/aplicacionrutasturisticas/lib/variables/perfil_variables.dart @@ -0,0 +1,7 @@ +String idioma = "Español"; + +String get getLenguaje => idioma; + +set setLenguaje(String lenguaje) { + idioma = lenguaje; +} -- GitLab From b5a25e0ba0eff701f7c57f8d5d18e1393d722bf5 Mon Sep 17 00:00:00 2001 From: Angel David Carlos Silva Date: Sat, 22 Jun 2024 15:34:47 -0600 Subject: [PATCH 04/19] Se agrego las dependencias para poder hacer los cambios de idiioma en la aplicacion --- fronted/aplicacionrutasturisticas/l10n.yaml | 4 + .../lib/generated/intl/messages_all.dart | 67 ++++++++ .../lib/generated/intl/messages_en.dart | 35 ++++ .../lib/generated/intl/messages_es.dart | 35 ++++ .../lib/generated/l10n.dart | 129 ++++++++++++++ .../lib/l10n/intl_en.arb | 22 +++ .../lib/l10n/intl_es.arb | 23 +++ .../lib/l10n/json/intl_en.json | 7 + .../lib/l10n/json/intl_es.json | 8 + .../aplicacionrutasturisticas/lib/main.dart | 2 + .../lib/pages/star_page2.dart | 4 +- .../lib/utilerias/MensajeEnMEdio.dart | 29 +--- .../Perfil/CupertinoPicker_Perfil.dart | 4 + .../aplicacionrutasturisticas/pubspec.lock | 159 +++++++++++++++++- .../aplicacionrutasturisticas/pubspec.yaml | 8 +- 15 files changed, 509 insertions(+), 27 deletions(-) create mode 100644 fronted/aplicacionrutasturisticas/l10n.yaml create mode 100644 fronted/aplicacionrutasturisticas/lib/generated/intl/messages_all.dart create mode 100644 fronted/aplicacionrutasturisticas/lib/generated/intl/messages_en.dart create mode 100644 fronted/aplicacionrutasturisticas/lib/generated/intl/messages_es.dart create mode 100644 fronted/aplicacionrutasturisticas/lib/generated/l10n.dart create mode 100644 fronted/aplicacionrutasturisticas/lib/l10n/intl_en.arb create mode 100644 fronted/aplicacionrutasturisticas/lib/l10n/intl_es.arb create mode 100644 fronted/aplicacionrutasturisticas/lib/l10n/json/intl_en.json create mode 100644 fronted/aplicacionrutasturisticas/lib/l10n/json/intl_es.json diff --git a/fronted/aplicacionrutasturisticas/l10n.yaml b/fronted/aplicacionrutasturisticas/l10n.yaml new file mode 100644 index 0000000..8230d35 --- /dev/null +++ b/fronted/aplicacionrutasturisticas/l10n.yaml @@ -0,0 +1,4 @@ +arb_dir: lib/l10n +template_arbs: + - lib/l10n/intl_en.arb +output_dir: lib/generated diff --git a/fronted/aplicacionrutasturisticas/lib/generated/intl/messages_all.dart b/fronted/aplicacionrutasturisticas/lib/generated/intl/messages_all.dart new file mode 100644 index 0000000..83aec8d --- /dev/null +++ b/fronted/aplicacionrutasturisticas/lib/generated/intl/messages_all.dart @@ -0,0 +1,67 @@ +// DO NOT EDIT. This is code generated via package:intl/generate_localized.dart +// This is a library that looks up messages for specific locales by +// delegating to the appropriate library. + +// Ignore issues from commonly used lints in this file. +// ignore_for_file:implementation_imports, file_names, unnecessary_new +// ignore_for_file:unnecessary_brace_in_string_interps, directives_ordering +// ignore_for_file:argument_type_not_assignable, invalid_assignment +// ignore_for_file:prefer_single_quotes, prefer_generic_function_type_aliases +// ignore_for_file:comment_references + +import 'dart:async'; + +import 'package:flutter/foundation.dart'; +import 'package:intl/intl.dart'; +import 'package:intl/message_lookup_by_library.dart'; +import 'package:intl/src/intl_helpers.dart'; + +import 'messages_en.dart' as messages_en; +import 'messages_es.dart' as messages_es; + +typedef Future LibraryLoader(); +Map _deferredLibraries = { + 'en': () => new SynchronousFuture(null), + 'es': () => new SynchronousFuture(null), +}; + +MessageLookupByLibrary? _findExact(String localeName) { + switch (localeName) { + case 'en': + return messages_en.messages; + case 'es': + return messages_es.messages; + default: + return null; + } +} + +/// User programs should call this before using [localeName] for messages. +Future initializeMessages(String localeName) { + var availableLocale = Intl.verifiedLocale( + localeName, (locale) => _deferredLibraries[locale] != null, + onFailure: (_) => null); + if (availableLocale == null) { + return new SynchronousFuture(false); + } + var lib = _deferredLibraries[availableLocale]; + lib == null ? new SynchronousFuture(false) : lib(); + initializeInternalMessageLookup(() => new CompositeMessageLookup()); + messageLookup.addLocale(availableLocale, _findGeneratedMessagesFor); + return new SynchronousFuture(true); +} + +bool _messagesExistFor(String locale) { + try { + return _findExact(locale) != null; + } catch (e) { + return false; + } +} + +MessageLookupByLibrary? _findGeneratedMessagesFor(String locale) { + var actualLocale = + Intl.verifiedLocale(locale, _messagesExistFor, onFailure: (_) => null); + if (actualLocale == null) return null; + return _findExact(actualLocale); +} diff --git a/fronted/aplicacionrutasturisticas/lib/generated/intl/messages_en.dart b/fronted/aplicacionrutasturisticas/lib/generated/intl/messages_en.dart new file mode 100644 index 0000000..b608d89 --- /dev/null +++ b/fronted/aplicacionrutasturisticas/lib/generated/intl/messages_en.dart @@ -0,0 +1,35 @@ +// DO NOT EDIT. This is code generated via package:intl/generate_localized.dart +// This is a library that provides messages for a en locale. All the +// messages from the main program should be duplicated here with the same +// function name. + +// Ignore issues from commonly used lints in this file. +// ignore_for_file:unnecessary_brace_in_string_interps, unnecessary_new +// ignore_for_file:prefer_single_quotes,comment_references, directives_ordering +// ignore_for_file:annotate_overrides,prefer_generic_function_type_aliases +// ignore_for_file:unused_import, file_names, avoid_escaping_inner_quotes +// ignore_for_file:unnecessary_string_interpolations, unnecessary_string_escapes + +import 'package:intl/intl.dart'; +import 'package:intl/message_lookup_by_library.dart'; + +final messages = new MessageLookup(); + +typedef String MessageIfAbsent(String messageStr, List args); + +class MessageLookup extends MessageLookupByLibrary { + String get localeName => 'en'; + + final messages = _notInlinedMessages(_notInlinedMessages); + static Map _notInlinedMessages(_) => { + "complete_rutes": + MessageLookupByLibrary.simpleMessage("Complete Routes"), + "create_route": MessageLookupByLibrary.simpleMessage("Create Route"), + "list_of_places": + MessageLookupByLibrary.simpleMessage("List of Places"), + "recommended_route": + MessageLookupByLibrary.simpleMessage("Recommended Route"), + "welcome_start_page": + MessageLookupByLibrary.simpleMessage("Welcome to ") + }; +} diff --git a/fronted/aplicacionrutasturisticas/lib/generated/intl/messages_es.dart b/fronted/aplicacionrutasturisticas/lib/generated/intl/messages_es.dart new file mode 100644 index 0000000..958f93b --- /dev/null +++ b/fronted/aplicacionrutasturisticas/lib/generated/intl/messages_es.dart @@ -0,0 +1,35 @@ +// DO NOT EDIT. This is code generated via package:intl/generate_localized.dart +// This is a library that provides messages for a es locale. All the +// messages from the main program should be duplicated here with the same +// function name. + +// Ignore issues from commonly used lints in this file. +// ignore_for_file:unnecessary_brace_in_string_interps, unnecessary_new +// ignore_for_file:prefer_single_quotes,comment_references, directives_ordering +// ignore_for_file:annotate_overrides,prefer_generic_function_type_aliases +// ignore_for_file:unused_import, file_names, avoid_escaping_inner_quotes +// ignore_for_file:unnecessary_string_interpolations, unnecessary_string_escapes + +import 'package:intl/intl.dart'; +import 'package:intl/message_lookup_by_library.dart'; + +final messages = new MessageLookup(); + +typedef String MessageIfAbsent(String messageStr, List args); + +class MessageLookup extends MessageLookupByLibrary { + String get localeName => 'es'; + + final messages = _notInlinedMessages(_notInlinedMessages); + static Map _notInlinedMessages(_) => { + "complete_rutes": + MessageLookupByLibrary.simpleMessage("Rutas Completas"), + "create_route": MessageLookupByLibrary.simpleMessage("Crear Ruta"), + "list_of_places": + MessageLookupByLibrary.simpleMessage("Lista de Lugares"), + "recommended_route": + MessageLookupByLibrary.simpleMessage("Ruta Recomendada"), + "welcome_start_page": + MessageLookupByLibrary.simpleMessage("Bienvenido a ") + }; +} diff --git a/fronted/aplicacionrutasturisticas/lib/generated/l10n.dart b/fronted/aplicacionrutasturisticas/lib/generated/l10n.dart new file mode 100644 index 0000000..4a27a61 --- /dev/null +++ b/fronted/aplicacionrutasturisticas/lib/generated/l10n.dart @@ -0,0 +1,129 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND +import 'package:flutter/material.dart'; +import 'package:intl/intl.dart'; +import 'intl/messages_all.dart'; + +// ************************************************************************** +// Generator: Flutter Intl IDE plugin +// Made by Localizely +// ************************************************************************** + +// ignore_for_file: non_constant_identifier_names, lines_longer_than_80_chars +// ignore_for_file: join_return_with_assignment, prefer_final_in_for_each +// ignore_for_file: avoid_redundant_argument_values, avoid_escaping_inner_quotes + +class S { + S(); + + static S? _current; + + static S get current { + assert(_current != null, + 'No instance of S was loaded. Try to initialize the S delegate before accessing S.current.'); + return _current!; + } + + static const AppLocalizationDelegate delegate = AppLocalizationDelegate(); + + static Future load(Locale locale) { + final name = (locale.countryCode?.isEmpty ?? false) + ? locale.languageCode + : locale.toString(); + final localeName = Intl.canonicalizedLocale(name); + return initializeMessages(localeName).then((_) { + Intl.defaultLocale = localeName; + final instance = S(); + S._current = instance; + + return instance; + }); + } + + static S of(BuildContext context) { + final instance = S.maybeOf(context); + assert(instance != null, + 'No instance of S present in the widget tree. Did you add S.delegate in localizationsDelegates?'); + return instance!; + } + + static S? maybeOf(BuildContext context) { + return Localizations.of(context, S); + } + + /// `Welcome to ` + String get welcome_start_page { + return Intl.message( + 'Welcome to ', + name: 'welcome_start_page', + desc: 'Welcome message at the start page', + args: [], + ); + } + + /// `Create Route` + String get create_route { + return Intl.message( + 'Create Route', + name: 'create_route', + desc: 'Label for creating a new route', + args: [], + ); + } + + /// `Recommended Route` + String get recommended_route { + return Intl.message( + 'Recommended Route', + name: 'recommended_route', + desc: 'Label for recommended routes', + args: [], + ); + } + + /// `List of Places` + String get list_of_places { + return Intl.message( + 'List of Places', + name: 'list_of_places', + desc: 'Label for listing places', + args: [], + ); + } + + /// `Complete Routes` + String get complete_rutes { + return Intl.message( + 'Complete Routes', + name: 'complete_rutes', + desc: 'Label for complete routes', + args: [], + ); + } +} + +class AppLocalizationDelegate extends LocalizationsDelegate { + const AppLocalizationDelegate(); + + List get supportedLocales { + return const [ + Locale.fromSubtags(languageCode: 'en'), + Locale.fromSubtags(languageCode: 'es'), + ]; + } + + @override + bool isSupported(Locale locale) => _isSupported(locale); + @override + Future load(Locale locale) => S.load(locale); + @override + bool shouldReload(AppLocalizationDelegate old) => false; + + bool _isSupported(Locale locale) { + for (var supportedLocale in supportedLocales) { + if (supportedLocale.languageCode == locale.languageCode) { + return true; + } + } + return false; + } +} diff --git a/fronted/aplicacionrutasturisticas/lib/l10n/intl_en.arb b/fronted/aplicacionrutasturisticas/lib/l10n/intl_en.arb new file mode 100644 index 0000000..05972ea --- /dev/null +++ b/fronted/aplicacionrutasturisticas/lib/l10n/intl_en.arb @@ -0,0 +1,22 @@ +{ + "welcome_start_page": "Welcome to ", + "create_route": "Create Route", + "recommended_route": "Recommended Route", + "list_of_places": "List of Places", + "complete_rutes": "Complete Routes", + "@welcome_start_page": { + "description": "Welcome message at the start page" + }, + "@create_route": { + "description": "Label for creating a new route" + }, + "@recommended_route": { + "description": "Label for recommended routes" + }, + "@list_of_places": { + "description": "Label for listing places" + }, + "@complete_rutes": { + "description": "Label for complete routes" + } +} diff --git a/fronted/aplicacionrutasturisticas/lib/l10n/intl_es.arb b/fronted/aplicacionrutasturisticas/lib/l10n/intl_es.arb new file mode 100644 index 0000000..250831a --- /dev/null +++ b/fronted/aplicacionrutasturisticas/lib/l10n/intl_es.arb @@ -0,0 +1,23 @@ +{ + "welcome_start_page": "Bienvenido a ", + "create_route": "Crear Ruta", + "recommended_route": "Ruta Recomendada", + "list_of_places": "Lista de Lugares", + "complete_rutes": "Rutas Completas", + "@welcome_start_page": { + "description": "Mensaje de bienvenida en la página de inicio" + }, + "@create_route": { + "description": "Texto del botón para crear una ruta" + }, + "@recommended_route": { + "description": "Texto del botón para ruta recomendada" + }, + "@list_of_places": { + "description": "Texto del botón para lista de lugares" + }, + "@complete_rutes": { + "description": "Texto del botón para rutas completas" + } + } + \ No newline at end of file diff --git a/fronted/aplicacionrutasturisticas/lib/l10n/json/intl_en.json b/fronted/aplicacionrutasturisticas/lib/l10n/json/intl_en.json new file mode 100644 index 0000000..154446b --- /dev/null +++ b/fronted/aplicacionrutasturisticas/lib/l10n/json/intl_en.json @@ -0,0 +1,7 @@ +{ + "welcome_start_page": "Welcome to ", + "create_route": "Create Route", + "recommended_route":"Recommended Route", + "list_of_places":"List of Places", + "complete_rutes":"Complete Rutes" +} \ No newline at end of file diff --git a/fronted/aplicacionrutasturisticas/lib/l10n/json/intl_es.json b/fronted/aplicacionrutasturisticas/lib/l10n/json/intl_es.json new file mode 100644 index 0000000..beca90c --- /dev/null +++ b/fronted/aplicacionrutasturisticas/lib/l10n/json/intl_es.json @@ -0,0 +1,8 @@ +{ + "welcome_start_page": "Bienvenido a ", + "create_route": "Crear Ruta", + "recommended_route":"Ruta Recomendada", + "list_of_places":"Lista de Lugares", + "complete_rutes":"Rutas Completadas" +} + \ No newline at end of file diff --git a/fronted/aplicacionrutasturisticas/lib/main.dart b/fronted/aplicacionrutasturisticas/lib/main.dart index 066ade6..e3c1ba1 100644 --- a/fronted/aplicacionrutasturisticas/lib/main.dart +++ b/fronted/aplicacionrutasturisticas/lib/main.dart @@ -13,3 +13,5 @@ class MyApp extends StatelessWidget { return MaterialApp.router(routerConfig: router); } } +// Recuerda usar el comando cada vez que actualices los idiomas +//flutter pub run intl_utils:generate \ No newline at end of file diff --git a/fronted/aplicacionrutasturisticas/lib/pages/star_page2.dart b/fronted/aplicacionrutasturisticas/lib/pages/star_page2.dart index 0272c44..013baee 100644 --- a/fronted/aplicacionrutasturisticas/lib/pages/star_page2.dart +++ b/fronted/aplicacionrutasturisticas/lib/pages/star_page2.dart @@ -31,14 +31,14 @@ class StartedPageState2 extends State { ), ), ), - SingleChildScrollView( + const SingleChildScrollView( child: Column( children: [ SizedBox( height: kToolbarHeight, // Espacio para el AppBar ), Padding( - padding: const EdgeInsets.all(16.0), + padding: EdgeInsets.all(16.0), child: Text( 'Bienvenido a Zacatecas', style: TextStyle( diff --git a/fronted/aplicacionrutasturisticas/lib/utilerias/MensajeEnMEdio.dart b/fronted/aplicacionrutasturisticas/lib/utilerias/MensajeEnMEdio.dart index 6b15c64..68298c4 100644 --- a/fronted/aplicacionrutasturisticas/lib/utilerias/MensajeEnMEdio.dart +++ b/fronted/aplicacionrutasturisticas/lib/utilerias/MensajeEnMEdio.dart @@ -1,29 +1,14 @@ import 'package:flutter/material.dart'; -class SnackBarMensaje { +class MensajeErrorDialog { static void show(BuildContext context, String message) { - final snackBar = SnackBar( - content: Text(message), - duration: Duration(seconds: 2), - behavior: SnackBarBehavior.floating, - backgroundColor: Colors.blue, - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(10), - ), - ); - - ScaffoldMessenger.of(context).showSnackBar(snackBar); - } -} - -class SnackBarButton extends StatelessWidget { - @override - Widget build(BuildContext context) { - return ElevatedButton( - onPressed: () { - SnackBarMensaje.show(context, 'Este es un SnackBar'); + showDialog( + context: context, + builder: (BuildContext context) { + return AlertDialog( + content: Text(message), + ); }, - child: Text('Mostrar SnackBar'), ); } } diff --git a/fronted/aplicacionrutasturisticas/lib/utilerias/Perfil/CupertinoPicker_Perfil.dart b/fronted/aplicacionrutasturisticas/lib/utilerias/Perfil/CupertinoPicker_Perfil.dart index 8fa06ed..2970cd6 100644 --- a/fronted/aplicacionrutasturisticas/lib/utilerias/Perfil/CupertinoPicker_Perfil.dart +++ b/fronted/aplicacionrutasturisticas/lib/utilerias/Perfil/CupertinoPicker_Perfil.dart @@ -39,6 +39,10 @@ class _CupertinoPickerWidget_perfilState globals.setLenguaje = '${_options[_selectedValue]}'; Perfil_metodos() .seleccionasteIdioma('${_options[_selectedValue]}'); + MensajeErrorDialog.show( + context, + "El idioma a sido cambiado el idioma a: " + + globals.getLenguaje); }, child: Text('Confirmar', style: TextStyle(fontSize: 20)), ) diff --git a/fronted/aplicacionrutasturisticas/pubspec.lock b/fronted/aplicacionrutasturisticas/pubspec.lock index 723ddd6..fa49882 100644 --- a/fronted/aplicacionrutasturisticas/pubspec.lock +++ b/fronted/aplicacionrutasturisticas/pubspec.lock @@ -1,6 +1,38 @@ # Generated by pub # See https://dart.dev/tools/pub/glossary#lockfile packages: + _fe_analyzer_shared: + dependency: transitive + description: + name: _fe_analyzer_shared + sha256: "0b2f2bd91ba804e53a61d757b986f89f1f9eaed5b11e4b2f5a2468d86d6c9fc7" + url: "https://pub.dev" + source: hosted + version: "67.0.0" + analyzer: + dependency: transitive + description: + name: analyzer + sha256: "37577842a27e4338429a1cbc32679d508836510b056f1eedf0c8d20e39c1383d" + url: "https://pub.dev" + source: hosted + version: "6.4.1" + archive: + dependency: transitive + description: + name: archive + sha256: cb6a278ef2dbb298455e1a713bda08524a175630ec643a242c399c932a0a1f7d + url: "https://pub.dev" + source: hosted + version: "3.6.1" + args: + dependency: transitive + description: + name: args + sha256: "7cf60b9f0cc88203c5a190b4cd62a99feea42759a7fa695010eb5de1c0b2252a" + url: "https://pub.dev" + source: hosted + version: "2.5.0" async: dependency: transitive description: @@ -41,6 +73,22 @@ packages: url: "https://pub.dev" source: hosted version: "1.18.0" + convert: + dependency: transitive + description: + name: convert + sha256: "0f08b14755d163f6e2134cb58222dd25ea2a2ee8a195e53983d57c075324d592" + url: "https://pub.dev" + source: hosted + version: "3.1.1" + crypto: + dependency: transitive + description: + name: crypto + sha256: ff625774173754681d66daaf4a448684fb04b78f902da9cb3d308c19cc5e8bab + url: "https://pub.dev" + source: hosted + version: "3.0.3" cupertino_icons: dependency: "direct main" description: @@ -49,6 +97,14 @@ packages: url: "https://pub.dev" source: hosted version: "1.0.8" + dart_style: + dependency: transitive + description: + name: dart_style + sha256: "99e066ce75c89d6b29903d788a7bb9369cf754f7b24bf70bf4b6d6d6b26853b9" + url: "https://pub.dev" + source: hosted + version: "2.3.6" dio: dependency: "direct main" description: @@ -65,6 +121,14 @@ packages: url: "https://pub.dev" source: hosted version: "1.3.1" + file: + dependency: transitive + description: + name: file + sha256: "5fc22d7c25582e38ad9a8515372cd9a93834027aacf1801cf01164dac0ffa08c" + url: "https://pub.dev" + source: hosted + version: "7.0.0" flutter: dependency: "direct main" description: flutter @@ -78,6 +142,11 @@ packages: url: "https://pub.dev" source: hosted version: "2.0.3" + flutter_localizations: + dependency: "direct main" + description: flutter + source: sdk + version: "0.0.0" flutter_test: dependency: "direct dev" description: flutter @@ -88,6 +157,14 @@ packages: description: flutter source: sdk version: "0.0.0" + glob: + dependency: transitive + description: + name: glob + sha256: "0e7014b3b7d4dac1ca4d6114f82bf1782ee86745b9b42a92c9289c23d8a0ab63" + url: "https://pub.dev" + source: hosted + version: "2.1.2" go_router: dependency: "direct main" description: @@ -96,6 +173,14 @@ packages: url: "https://pub.dev" source: hosted version: "13.2.5" + http: + dependency: transitive + description: + name: http + sha256: "761a297c042deedc1ffbb156d6e2af13886bb305c2a343a4d972504cd67dd938" + url: "https://pub.dev" + source: hosted + version: "1.2.1" http_parser: dependency: transitive description: @@ -104,6 +189,30 @@ packages: url: "https://pub.dev" source: hosted version: "4.0.2" + intl: + dependency: "direct main" + description: + name: intl + sha256: "3bc132a9dbce73a7e4a21a17d06e1878839ffbf975568bc875c60537824b0c4d" + url: "https://pub.dev" + source: hosted + version: "0.18.1" + intl_translation: + dependency: "direct dev" + description: + name: intl_translation + sha256: b858d88b569f3c529e992ba7186aa495f3e862897df60edb932563c619943610 + url: "https://pub.dev" + source: hosted + version: "0.20.0" + intl_utils: + dependency: "direct dev" + description: + name: intl_utils + sha256: c2b1f5c72c25512cbeef5ab015c008fc50fe7e04813ba5541c25272300484bf4 + url: "https://pub.dev" + source: hosted + version: "2.8.7" leak_tracker: dependency: transitive description: @@ -168,6 +277,14 @@ packages: url: "https://pub.dev" source: hosted version: "1.11.0" + package_config: + dependency: transitive + description: + name: package_config + sha256: "1c5b77ccc91e4823a5af61ee74e6b972db1ef98c2ff5a18d3161c982a55448bd" + url: "https://pub.dev" + source: hosted + version: "2.1.0" path: dependency: transitive description: @@ -176,6 +293,22 @@ packages: url: "https://pub.dev" source: hosted version: "1.9.0" + petitparser: + dependency: transitive + description: + name: petitparser + sha256: c15605cd28af66339f8eb6fbe0e541bfe2d1b72d5825efc6598f3e0a31b9ad27 + url: "https://pub.dev" + source: hosted + version: "6.0.2" + pub_semver: + dependency: transitive + description: + name: pub_semver + sha256: "40d3ab1bbd474c4c2328c91e3a7df8c6dd629b79ece4c4bd04bee496a224fb0c" + url: "https://pub.dev" + source: hosted + version: "2.1.4" sky_engine: dependency: transitive description: flutter @@ -253,6 +386,30 @@ packages: url: "https://pub.dev" source: hosted version: "13.0.0" + watcher: + dependency: transitive + description: + name: watcher + sha256: "3d2ad6751b3c16cf07c7fca317a1413b3f26530319181b37e3b9039b84fc01d8" + url: "https://pub.dev" + source: hosted + version: "1.1.0" + web: + dependency: transitive + description: + name: web + sha256: "97da13628db363c635202ad97068d47c5b8aa555808e7a9411963c533b449b27" + url: "https://pub.dev" + source: hosted + version: "0.5.1" + yaml: + dependency: transitive + description: + name: yaml + sha256: "75769501ea3489fca56601ff33454fe45507ea3bfb014161abc3b43ae25989d5" + url: "https://pub.dev" + source: hosted + version: "3.1.2" sdks: - dart: ">=3.2.6 <4.0.0" + dart: ">=3.3.0 <4.0.0" flutter: ">=3.16.0" diff --git a/fronted/aplicacionrutasturisticas/pubspec.yaml b/fronted/aplicacionrutasturisticas/pubspec.yaml index a66ab6a..c6c0db1 100644 --- a/fronted/aplicacionrutasturisticas/pubspec.yaml +++ b/fronted/aplicacionrutasturisticas/pubspec.yaml @@ -30,13 +30,15 @@ environment: dependencies: flutter: sdk: flutter - - + flutter_localizations: + sdk: flutter # The following adds the Cupertino Icons font to your application. # Use with the CupertinoIcons class for iOS style icons. cupertino_icons: ^1.0.2 go_router: ^13.2.4 dio: ^5.4.3+1 + intl: ^0.18.1 + dev_dependencies: flutter_test: @@ -48,6 +50,8 @@ dev_dependencies: # package. See that file for information about deactivating specific lint # rules and activating additional ones. flutter_lints: ^2.0.0 + intl_translation: ^0.20.0 + intl_utils: ^2.3.0 # For information on the generic Dart part of this file, see the # following page: https://dart.dev/tools/pub/pubspec -- GitLab From 26af37689d99d5829fa9bf25670082a93f78b13a Mon Sep 17 00:00:00 2001 From: Angel David Carlos Silva Date: Sat, 22 Jun 2024 19:48:50 -0600 Subject: [PATCH 05/19] Cambio de idioma hecho llamen a dios --- fronted/aplicacionrutasturisticas/l10n.yaml | 8 +- .../lib/config/idioma/locale_provider.dart | 29 +++ .../lib/config/metodos/cambio_idioma.dart | 19 ++ .../lib/l10n/app_en.arb | 23 ++ .../lib/l10n/app_es.arb | 23 ++ .../lib/l10n/arb/intl_en.arb | 23 ++ .../lib/l10n/arb/intl_es.arb | 23 ++ .../lib/l10n/intl_en.arb | 41 ++-- .../aplicacionrutasturisticas/lib/main.dart | 28 ++- .../lib/pages/star_page2.dart | 199 +++++++++--------- .../Perfil/CupertinoPicker_Perfil.dart | 15 +- .../aplicacionrutasturisticas/pubspec.lock | 16 ++ .../aplicacionrutasturisticas/pubspec.yaml | 6 +- 13 files changed, 318 insertions(+), 135 deletions(-) create mode 100644 fronted/aplicacionrutasturisticas/lib/config/idioma/locale_provider.dart create mode 100644 fronted/aplicacionrutasturisticas/lib/config/metodos/cambio_idioma.dart create mode 100644 fronted/aplicacionrutasturisticas/lib/l10n/app_en.arb create mode 100644 fronted/aplicacionrutasturisticas/lib/l10n/app_es.arb create mode 100644 fronted/aplicacionrutasturisticas/lib/l10n/arb/intl_en.arb create mode 100644 fronted/aplicacionrutasturisticas/lib/l10n/arb/intl_es.arb diff --git a/fronted/aplicacionrutasturisticas/l10n.yaml b/fronted/aplicacionrutasturisticas/l10n.yaml index 8230d35..9cff297 100644 --- a/fronted/aplicacionrutasturisticas/l10n.yaml +++ b/fronted/aplicacionrutasturisticas/l10n.yaml @@ -1,4 +1,4 @@ -arb_dir: lib/l10n -template_arbs: - - lib/l10n/intl_en.arb -output_dir: lib/generated +arb-dir: lib/l10n/arb/ +template-arb-file: intl_es.arb +output-localization-file: l10n.dart +output-class: S diff --git a/fronted/aplicacionrutasturisticas/lib/config/idioma/locale_provider.dart b/fronted/aplicacionrutasturisticas/lib/config/idioma/locale_provider.dart new file mode 100644 index 0000000..451d6aa --- /dev/null +++ b/fronted/aplicacionrutasturisticas/lib/config/idioma/locale_provider.dart @@ -0,0 +1,29 @@ +import 'package:flutter/material.dart'; + +class LocaleProvider extends ChangeNotifier { + Locale? _locale = + Locale('es'); // Establece español como idioma predeterminado + + Locale? get locale => _locale; + + void setLocale(Locale locale) { + if (!L10n.supportedLocales.contains(locale)) return; + + _locale = locale; + notifyListeners(); + } + + void clearLocale() { + _locale = null; + notifyListeners(); + } +} + +class L10n { + static final all = [ + const Locale('en'), + const Locale('es'), + ]; + + static List get supportedLocales => all; +} diff --git a/fronted/aplicacionrutasturisticas/lib/config/metodos/cambio_idioma.dart b/fronted/aplicacionrutasturisticas/lib/config/metodos/cambio_idioma.dart new file mode 100644 index 0000000..ffab696 --- /dev/null +++ b/fronted/aplicacionrutasturisticas/lib/config/metodos/cambio_idioma.dart @@ -0,0 +1,19 @@ +import 'package:aplicacionrutasturisticas/variables/perfil_variables.dart' + as globals; +import 'package:aplicacionrutasturisticas/config/idioma/locale_provider.dart'; +import 'package:flutter/material.dart'; +import 'package:provider/provider.dart'; + +class CambiarIdioma { + void verificarCambio(BuildContext context) { + final provider = Provider.of(context, listen: false); + print(globals.getLenguaje); + if (globals.getLenguaje == "Inglés") { + print("Inglessss"); + provider.setLocale(Locale('en')); + } else if (globals.getLenguaje == "Español") { + provider.setLocale(Locale('es')); + print("Es"); + } + } +} diff --git a/fronted/aplicacionrutasturisticas/lib/l10n/app_en.arb b/fronted/aplicacionrutasturisticas/lib/l10n/app_en.arb new file mode 100644 index 0000000..2c19cfd --- /dev/null +++ b/fronted/aplicacionrutasturisticas/lib/l10n/app_en.arb @@ -0,0 +1,23 @@ +{ + "welcome_start_page": "Welcome to ", + "create_route": "Create Route", + "recommended_route": "Recommended Route", + "list_of_places": "List of Places", + "complete_rutes": "Complete Routes", + "@welcome_start_page": { + "description": "Welcome message at the start page" + }, + "@create_route": { + "description": "Label for creating a new route" + }, + "@recommended_route": { + "description": "Label for recommended routes" + }, + "@list_of_places": { + "description": "Label for listing places" + }, + "@complete_rutes": { + "description": "Label for complete routes" + } + } + \ No newline at end of file diff --git a/fronted/aplicacionrutasturisticas/lib/l10n/app_es.arb b/fronted/aplicacionrutasturisticas/lib/l10n/app_es.arb new file mode 100644 index 0000000..250831a --- /dev/null +++ b/fronted/aplicacionrutasturisticas/lib/l10n/app_es.arb @@ -0,0 +1,23 @@ +{ + "welcome_start_page": "Bienvenido a ", + "create_route": "Crear Ruta", + "recommended_route": "Ruta Recomendada", + "list_of_places": "Lista de Lugares", + "complete_rutes": "Rutas Completas", + "@welcome_start_page": { + "description": "Mensaje de bienvenida en la página de inicio" + }, + "@create_route": { + "description": "Texto del botón para crear una ruta" + }, + "@recommended_route": { + "description": "Texto del botón para ruta recomendada" + }, + "@list_of_places": { + "description": "Texto del botón para lista de lugares" + }, + "@complete_rutes": { + "description": "Texto del botón para rutas completas" + } + } + \ No newline at end of file diff --git a/fronted/aplicacionrutasturisticas/lib/l10n/arb/intl_en.arb b/fronted/aplicacionrutasturisticas/lib/l10n/arb/intl_en.arb new file mode 100644 index 0000000..2c19cfd --- /dev/null +++ b/fronted/aplicacionrutasturisticas/lib/l10n/arb/intl_en.arb @@ -0,0 +1,23 @@ +{ + "welcome_start_page": "Welcome to ", + "create_route": "Create Route", + "recommended_route": "Recommended Route", + "list_of_places": "List of Places", + "complete_rutes": "Complete Routes", + "@welcome_start_page": { + "description": "Welcome message at the start page" + }, + "@create_route": { + "description": "Label for creating a new route" + }, + "@recommended_route": { + "description": "Label for recommended routes" + }, + "@list_of_places": { + "description": "Label for listing places" + }, + "@complete_rutes": { + "description": "Label for complete routes" + } + } + \ No newline at end of file diff --git a/fronted/aplicacionrutasturisticas/lib/l10n/arb/intl_es.arb b/fronted/aplicacionrutasturisticas/lib/l10n/arb/intl_es.arb new file mode 100644 index 0000000..250831a --- /dev/null +++ b/fronted/aplicacionrutasturisticas/lib/l10n/arb/intl_es.arb @@ -0,0 +1,23 @@ +{ + "welcome_start_page": "Bienvenido a ", + "create_route": "Crear Ruta", + "recommended_route": "Ruta Recomendada", + "list_of_places": "Lista de Lugares", + "complete_rutes": "Rutas Completas", + "@welcome_start_page": { + "description": "Mensaje de bienvenida en la página de inicio" + }, + "@create_route": { + "description": "Texto del botón para crear una ruta" + }, + "@recommended_route": { + "description": "Texto del botón para ruta recomendada" + }, + "@list_of_places": { + "description": "Texto del botón para lista de lugares" + }, + "@complete_rutes": { + "description": "Texto del botón para rutas completas" + } + } + \ No newline at end of file diff --git a/fronted/aplicacionrutasturisticas/lib/l10n/intl_en.arb b/fronted/aplicacionrutasturisticas/lib/l10n/intl_en.arb index 05972ea..2c19cfd 100644 --- a/fronted/aplicacionrutasturisticas/lib/l10n/intl_en.arb +++ b/fronted/aplicacionrutasturisticas/lib/l10n/intl_en.arb @@ -1,22 +1,23 @@ { - "welcome_start_page": "Welcome to ", - "create_route": "Create Route", - "recommended_route": "Recommended Route", - "list_of_places": "List of Places", - "complete_rutes": "Complete Routes", - "@welcome_start_page": { - "description": "Welcome message at the start page" - }, - "@create_route": { - "description": "Label for creating a new route" - }, - "@recommended_route": { - "description": "Label for recommended routes" - }, - "@list_of_places": { - "description": "Label for listing places" - }, - "@complete_rutes": { - "description": "Label for complete routes" + "welcome_start_page": "Welcome to ", + "create_route": "Create Route", + "recommended_route": "Recommended Route", + "list_of_places": "List of Places", + "complete_rutes": "Complete Routes", + "@welcome_start_page": { + "description": "Welcome message at the start page" + }, + "@create_route": { + "description": "Label for creating a new route" + }, + "@recommended_route": { + "description": "Label for recommended routes" + }, + "@list_of_places": { + "description": "Label for listing places" + }, + "@complete_rutes": { + "description": "Label for complete routes" + } } -} + \ No newline at end of file diff --git a/fronted/aplicacionrutasturisticas/lib/main.dart b/fronted/aplicacionrutasturisticas/lib/main.dart index e3c1ba1..5665054 100644 --- a/fronted/aplicacionrutasturisticas/lib/main.dart +++ b/fronted/aplicacionrutasturisticas/lib/main.dart @@ -1,7 +1,9 @@ -import 'package:aplicacionrutasturisticas/config/router.dart'; import 'package:flutter/material.dart'; -import 'package:aplicacionrutasturisticas/pages/login.dart'; -import 'package:aplicacionrutasturisticas/pages/register.dart'; +import 'package:flutter_localizations/flutter_localizations.dart'; +import 'package:provider/provider.dart'; +import 'package:aplicacionrutasturisticas/config/router.dart'; +import 'package:aplicacionrutasturisticas/config/idioma/locale_provider.dart'; +import 'generated/l10n.dart'; void main() { runApp(MyApp()); @@ -10,8 +12,26 @@ void main() { class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { - return MaterialApp.router(routerConfig: router); + return ChangeNotifierProvider( + create: (_) => LocaleProvider(), + child: Consumer( + builder: (context, localeProvider, child) { + return MaterialApp.router( + locale: localeProvider.locale, + supportedLocales: S.delegate.supportedLocales, + localizationsDelegates: [ + S.delegate, + GlobalMaterialLocalizations.delegate, + GlobalWidgetsLocalizations.delegate, + GlobalCupertinoLocalizations.delegate, + ], + routerConfig: router, + ); + }, + ), + ); } } + // Recuerda usar el comando cada vez que actualices los idiomas //flutter pub run intl_utils:generate \ No newline at end of file diff --git a/fronted/aplicacionrutasturisticas/lib/pages/star_page2.dart b/fronted/aplicacionrutasturisticas/lib/pages/star_page2.dart index 013baee..47b0521 100644 --- a/fronted/aplicacionrutasturisticas/lib/pages/star_page2.dart +++ b/fronted/aplicacionrutasturisticas/lib/pages/star_page2.dart @@ -1,5 +1,6 @@ import 'package:aplicacionrutasturisticas/utilerias/Perfil/AppBar_Perfil.dart'; import 'package:aplicacionrutasturisticas/utilerias/Perfil/Drawer_Perfil.dart'; +import 'package:aplicacionrutasturisticas/generated/l10n.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; @@ -13,117 +14,115 @@ class StartedPage2 extends StatefulWidget { class StartedPageState2 extends State { @override Widget build(BuildContext context) { - return MaterialApp( - home: Scaffold( - body: Stack( - children: [ - Container( - decoration: BoxDecoration( - image: DecorationImage( - image: NetworkImage( - 'https://www.turimexico.com/wp-content/uploads/2015/10/ciudad-de-zacatecas.jpg', - ), - fit: BoxFit.cover, - colorFilter: ColorFilter.mode( - Colors.black.withOpacity(0.5), - BlendMode.darken, - ), + return Scaffold( + body: Stack( + children: [ + Container( + decoration: BoxDecoration( + image: DecorationImage( + image: NetworkImage( + 'https://www.turimexico.com/wp-content/uploads/2015/10/ciudad-de-zacatecas.jpg', + ), + fit: BoxFit.cover, + colorFilter: ColorFilter.mode( + Colors.black.withOpacity(0.5), + BlendMode.darken, ), ), ), - const SingleChildScrollView( - child: Column( - children: [ - SizedBox( - height: kToolbarHeight, // Espacio para el AppBar - ), - Padding( - padding: EdgeInsets.all(16.0), - child: Text( - 'Bienvenido a Zacatecas', - style: TextStyle( - color: Colors.white, - fontSize: 24, - fontWeight: FontWeight.bold, - ), - textAlign: TextAlign.center, + ), + SingleChildScrollView( + child: Column( + children: [ + const SizedBox( + height: kToolbarHeight, // Espacio para el AppBar + ), + Padding( + padding: EdgeInsets.all(16.0), + child: Text( + S.of(context).welcome_start_page, + style: const TextStyle( + color: Colors.white, + fontSize: 24, + fontWeight: FontWeight.bold, ), + textAlign: TextAlign.center, ), - ], - ), + ), + ], ), - AppBar_Perfil(), //Este app se establece en el body, para que no genere conflictos de colicion - Padding( - padding: const EdgeInsets.symmetric(horizontal: 10.0), - child: DraggableScrollableSheet( - initialChildSize: 0.3, - minChildSize: 0.1, - builder: - (BuildContext context, ScrollController scrollController) { - return ClipRRect( - borderRadius: const BorderRadius.only( - topLeft: Radius.circular(60.0), - topRight: Radius.circular(60.0), - ), - child: Container( - color: Colors.white, - child: Column( - children: [ - Container( - height: 5.0, - width: 50.0, - margin: const EdgeInsets.symmetric(vertical: 10.0), - decoration: BoxDecoration( - color: Colors.grey[300], - borderRadius: BorderRadius.circular(10.0), - ), + ), + AppBar_Perfil(), //Este app se establece en el body, para que no genere conflictos de colicion + Padding( + padding: const EdgeInsets.symmetric(horizontal: 10.0), + child: DraggableScrollableSheet( + initialChildSize: 0.3, + minChildSize: 0.1, + builder: + (BuildContext context, ScrollController scrollController) { + return ClipRRect( + borderRadius: const BorderRadius.only( + topLeft: Radius.circular(60.0), + topRight: Radius.circular(60.0), + ), + child: Container( + color: Colors.white, + child: Column( + children: [ + Container( + height: 5.0, + width: 50.0, + margin: const EdgeInsets.symmetric(vertical: 10.0), + decoration: BoxDecoration( + color: Colors.grey[300], + borderRadius: BorderRadius.circular(10.0), ), - Expanded( - child: ListView( - controller: scrollController, - children: [ - ListTile( - leading: Icon(Icons.location_history), - title: Text('Crea Ruta'), - onTap: () { - // Acción al tocar la opción - }, - ), - ListTile( - leading: Icon(Icons.map), - title: Text('Ruta Recomendada'), - onTap: () { - // Acción al tocar la opción - }, - ), - ListTile( - leading: Icon(Icons.list), - title: Text('Lista de Lugares'), - onTap: () { - // Acción al tocar la opción - }, - ), - ListTile( - leading: Icon(Icons.star), - title: Text('Rutas Completadas'), - onTap: () { - // Acción al tocar la opción - }, - ), - ], - ), + ), + Expanded( + child: ListView( + controller: scrollController, + children: [ + ListTile( + leading: Icon(Icons.location_history), + title: Text(S.of(context).create_route), + onTap: () { + // Acción al tocar la opción + }, + ), + ListTile( + leading: Icon(Icons.map), + title: Text(S.of(context).recommended_route), + onTap: () { + // Acción al tocar la opción + }, + ), + ListTile( + leading: Icon(Icons.list), + title: Text(S.of(context).list_of_places), + onTap: () { + // Acción al tocar la opción + }, + ), + ListTile( + leading: Icon(Icons.star), + title: Text(S.of(context).complete_rutes), + onTap: () { + // Acción al tocar la opción + }, + ), + ], ), - ], - ), + ), + ], ), - ); - }, - ), + ), + ); + }, ), - ], - ), - endDrawer: Perfil(), + ), + ], ), + endDrawer: Perfil(), ); } } diff --git a/fronted/aplicacionrutasturisticas/lib/utilerias/Perfil/CupertinoPicker_Perfil.dart b/fronted/aplicacionrutasturisticas/lib/utilerias/Perfil/CupertinoPicker_Perfil.dart index 2970cd6..4102efb 100644 --- a/fronted/aplicacionrutasturisticas/lib/utilerias/Perfil/CupertinoPicker_Perfil.dart +++ b/fronted/aplicacionrutasturisticas/lib/utilerias/Perfil/CupertinoPicker_Perfil.dart @@ -1,3 +1,5 @@ +import 'package:aplicacionrutasturisticas/config/metodos/cambio_idioma.dart'; +import 'package:aplicacionrutasturisticas/config/idioma/locale_provider.dart'; import 'package:aplicacionrutasturisticas/config/metodos/perfil_metodos.dart'; import 'package:aplicacionrutasturisticas/utilerias/MensajeEnMEdio.dart'; import 'package:aplicacionrutasturisticas/variables/perfil_variables.dart' @@ -36,13 +38,14 @@ class _CupertinoPickerWidget_perfilState ), ElevatedButton( onPressed: () { - globals.setLenguaje = '${_options[_selectedValue]}'; - Perfil_metodos() - .seleccionasteIdioma('${_options[_selectedValue]}'); + globals.setLenguaje = _options[_selectedValue]; + Perfil_metodos().seleccionasteIdioma(_options[_selectedValue]); + CambiarIdioma().verificarCambio(context); + MensajeErrorDialog.show( - context, - "El idioma a sido cambiado el idioma a: " + - globals.getLenguaje); + context, + "El idioma ha sido cambiado a: ${globals.getLenguaje}", + ); }, child: Text('Confirmar', style: TextStyle(fontSize: 20)), ) diff --git a/fronted/aplicacionrutasturisticas/pubspec.lock b/fronted/aplicacionrutasturisticas/pubspec.lock index fa49882..b4d61b6 100644 --- a/fronted/aplicacionrutasturisticas/pubspec.lock +++ b/fronted/aplicacionrutasturisticas/pubspec.lock @@ -277,6 +277,14 @@ packages: url: "https://pub.dev" source: hosted version: "1.11.0" + nested: + dependency: transitive + description: + name: nested + sha256: "03bac4c528c64c95c722ec99280375a6f2fc708eec17c7b3f07253b626cd2a20" + url: "https://pub.dev" + source: hosted + version: "1.0.0" package_config: dependency: transitive description: @@ -301,6 +309,14 @@ packages: url: "https://pub.dev" source: hosted version: "6.0.2" + provider: + dependency: "direct main" + description: + name: provider + sha256: c8a055ee5ce3fd98d6fc872478b03823ffdb448699c6ebdbbc71d59b596fd48c + url: "https://pub.dev" + source: hosted + version: "6.1.2" pub_semver: dependency: transitive description: diff --git a/fronted/aplicacionrutasturisticas/pubspec.yaml b/fronted/aplicacionrutasturisticas/pubspec.yaml index c6c0db1..0ffbb36 100644 --- a/fronted/aplicacionrutasturisticas/pubspec.yaml +++ b/fronted/aplicacionrutasturisticas/pubspec.yaml @@ -32,6 +32,7 @@ dependencies: sdk: flutter flutter_localizations: sdk: flutter + provider: ^6.0.3 # The following adds the Cupertino Icons font to your application. # Use with the CupertinoIcons class for iOS style icons. cupertino_icons: ^1.0.2 @@ -43,7 +44,6 @@ dependencies: dev_dependencies: flutter_test: sdk: flutter - # The "flutter_lints" package below contains a set of recommended lints to # encourage good coding practices. The lint set provided by the package is # activated in the `analysis_options.yaml` file located at the root of your @@ -62,8 +62,12 @@ flutter: # The following line ensures that the Material Icons font is # included with your application, so that you can use the icons in # the material Icons class. + generate: true uses-material-design: true + assets: + - lib/l10n/arb/ + # To add assets to your application, add an assets section, like this: # assets: # - images/a_dot_burr.jpeg -- GitLab From 1aaeb97b2b480696892384ffdca3920ac1951c36 Mon Sep 17 00:00:00 2001 From: Angel David Carlos Silva Date: Tue, 2 Jul 2024 13:43:07 -0600 Subject: [PATCH 06/19] Se agrego la opcion de cambio de idioma, y se borro la creacion de la columna phone El cambio de idioma solo funciona con texto que este solo dentro de la app de la aplicacion, --- backend/src/user/dto/create-user.dto.ts | 1 - backend/src/user/entities/user.entity.ts | 3 - .../lib/config/dio.dart | 15 +- .../lib/config/idioma/locale_provider.dart | 27 +++- .../lib/generated/intl/messages_en.dart | 18 +++ .../lib/generated/intl/messages_es.dart | 18 +++ .../lib/generated/l10n.dart | 140 +++++++++++++++++- .../lib/l10n/app_en.arb | 58 +++++--- .../lib/l10n/app_es.arb | 58 +++++--- .../lib/l10n/arb/intl_en.arb | 58 +++++--- .../lib/l10n/arb/intl_es.arb | 17 +++ .../lib/l10n/intl_en.arb | 94 +++++++++--- .../lib/l10n/intl_es.arb | 94 +++++++++--- .../lib/pages/login.dart | 22 ++- .../lib/pages/register.dart | 1 + .../Perfil/CupertinoPicker_Perfil.dart | 8 +- .../lib/utilerias/Perfil/Drawer_Perfil.dart | 25 +--- .../aplicacionrutasturisticas/pubspec.lock | 122 ++++++++++++++- .../aplicacionrutasturisticas/pubspec.yaml | 1 + 19 files changed, 620 insertions(+), 160 deletions(-) diff --git a/backend/src/user/dto/create-user.dto.ts b/backend/src/user/dto/create-user.dto.ts index b9f5a75..ba46ede 100644 --- a/backend/src/user/dto/create-user.dto.ts +++ b/backend/src/user/dto/create-user.dto.ts @@ -3,5 +3,4 @@ export class CreateUserDto { lastname: string; password: string; email: string; - phone: number; } diff --git a/backend/src/user/entities/user.entity.ts b/backend/src/user/entities/user.entity.ts index b363286..dbe15f9 100644 --- a/backend/src/user/entities/user.entity.ts +++ b/backend/src/user/entities/user.entity.ts @@ -16,7 +16,4 @@ export class User { @Column() email: string - - @Column() - phone: number } diff --git a/fronted/aplicacionrutasturisticas/lib/config/dio.dart b/fronted/aplicacionrutasturisticas/lib/config/dio.dart index 5bc2d6d..103fa98 100644 --- a/fronted/aplicacionrutasturisticas/lib/config/dio.dart +++ b/fronted/aplicacionrutasturisticas/lib/config/dio.dart @@ -1,27 +1,26 @@ import 'package:dio/dio.dart'; final dio = Dio(); -void Registro_Datos(String nombre, String lastname, String email, - String password) async { +void Registro_Datos( + String nombre, String lastname, String email, String password) async { Response response; //response = await dio.get("http://172.26.128.1:3000") response = - await dio.post("http://192.168.1.81:3000/auth-user/register", data: { + await dio.post("http://192.168.101.13:3000/auth-user/register", data: { "name": nombre, "lastname": lastname, "password": password, "email": email, }); - print(response.data.toString()); - - + print("Hola" + "\n\n" + response.data.toString() + "\n\n"); } + void loginDatos(String email, String password) async { Response responselogin; - responselogin = await dio.post("http://192.168.1.81:3000/auth-user/login", data: { + responselogin = + await dio.post("http://192.168.101.13:3000/auth-user/login", data: { "email": email, "password": password, }); print(responselogin.data.toString()); } - diff --git a/fronted/aplicacionrutasturisticas/lib/config/idioma/locale_provider.dart b/fronted/aplicacionrutasturisticas/lib/config/idioma/locale_provider.dart index 451d6aa..e192969 100644 --- a/fronted/aplicacionrutasturisticas/lib/config/idioma/locale_provider.dart +++ b/fronted/aplicacionrutasturisticas/lib/config/idioma/locale_provider.dart @@ -1,19 +1,37 @@ import 'package:flutter/material.dart'; +import 'package:shared_preferences/shared_preferences.dart'; class LocaleProvider extends ChangeNotifier { - Locale? _locale = - Locale('es'); // Establece español como idioma predeterminado + Locale? _locale; Locale? get locale => _locale; - void setLocale(Locale locale) { + LocaleProvider() { + _loadLocale(); + } + + Future _loadLocale() async { + final prefs = await SharedPreferences.getInstance(); + final localeCode = + prefs.getString('locale') ?? 'es'; // Por defecto en español + _locale = Locale(localeCode); + notifyListeners(); + } + + Future setLocale(Locale locale) async { if (!L10n.supportedLocales.contains(locale)) return; + final prefs = await SharedPreferences.getInstance(); + await prefs.setString('locale', locale.languageCode); + _locale = locale; notifyListeners(); } - void clearLocale() { + void clearLocale() async { + final prefs = await SharedPreferences.getInstance(); + await prefs.remove('locale'); + _locale = null; notifyListeners(); } @@ -23,6 +41,7 @@ class L10n { static final all = [ const Locale('en'), const Locale('es'), + const Locale('pt'), ]; static List get supportedLocales => all; diff --git a/fronted/aplicacionrutasturisticas/lib/generated/intl/messages_en.dart b/fronted/aplicacionrutasturisticas/lib/generated/intl/messages_en.dart index b608d89..2a6994a 100644 --- a/fronted/aplicacionrutasturisticas/lib/generated/intl/messages_en.dart +++ b/fronted/aplicacionrutasturisticas/lib/generated/intl/messages_en.dart @@ -24,11 +24,29 @@ class MessageLookup extends MessageLookupByLibrary { static Map _notInlinedMessages(_) => { "complete_rutes": MessageLookupByLibrary.simpleMessage("Complete Routes"), + "confirm": MessageLookupByLibrary.simpleMessage("Confirm"), + "correo": MessageLookupByLibrary.simpleMessage("Email"), "create_route": MessageLookupByLibrary.simpleMessage("Create Route"), + "formulario": MessageLookupByLibrary.simpleMessage("Form"), + "idiom": MessageLookupByLibrary.simpleMessage("Language"), + "informacion_personal": + MessageLookupByLibrary.simpleMessage("Personal Information"), + "inicia_sesion": MessageLookupByLibrary.simpleMessage("Log In"), + "inicio_nuevo_aplicacion": + MessageLookupByLibrary.simpleMessage("New to the app?"), + "inicio_sesion_entrar_invitado": + MessageLookupByLibrary.simpleMessage("Enter as"), + "invitado": MessageLookupByLibrary.simpleMessage("Guest"), "list_of_places": MessageLookupByLibrary.simpleMessage("List of Places"), + "notificacion_cambio_idioma": MessageLookupByLibrary.simpleMessage( + "The language has been changed to:"), + "pasword": MessageLookupByLibrary.simpleMessage("Password"), "recommended_route": MessageLookupByLibrary.simpleMessage("Recommended Route"), + "registrarte": MessageLookupByLibrary.simpleMessage("Register"), + "seleciona_tu_idioma": + MessageLookupByLibrary.simpleMessage("Select your language"), "welcome_start_page": MessageLookupByLibrary.simpleMessage("Welcome to ") }; diff --git a/fronted/aplicacionrutasturisticas/lib/generated/intl/messages_es.dart b/fronted/aplicacionrutasturisticas/lib/generated/intl/messages_es.dart index 958f93b..9f1ee59 100644 --- a/fronted/aplicacionrutasturisticas/lib/generated/intl/messages_es.dart +++ b/fronted/aplicacionrutasturisticas/lib/generated/intl/messages_es.dart @@ -24,11 +24,29 @@ class MessageLookup extends MessageLookupByLibrary { static Map _notInlinedMessages(_) => { "complete_rutes": MessageLookupByLibrary.simpleMessage("Rutas Completas"), + "confirm": MessageLookupByLibrary.simpleMessage("Confirmar"), + "correo": MessageLookupByLibrary.simpleMessage("Correo electrónico"), "create_route": MessageLookupByLibrary.simpleMessage("Crear Ruta"), + "formulario": MessageLookupByLibrary.simpleMessage("Formulario"), + "idiom": MessageLookupByLibrary.simpleMessage("Idioma"), + "informacion_personal": + MessageLookupByLibrary.simpleMessage("Información Personal"), + "inicia_sesion": MessageLookupByLibrary.simpleMessage("Inicia Sesión"), + "inicio_nuevo_aplicacion": + MessageLookupByLibrary.simpleMessage("¿Nuevo en la aplicación?"), + "inicio_sesion_entrar_invitado": + MessageLookupByLibrary.simpleMessage("Entra como"), + "invitado": MessageLookupByLibrary.simpleMessage("Invitado"), "list_of_places": MessageLookupByLibrary.simpleMessage("Lista de Lugares"), + "notificacion_cambio_idioma": MessageLookupByLibrary.simpleMessage( + "El idioma ha sido cambiado a:"), + "pasword": MessageLookupByLibrary.simpleMessage("Contraseña"), "recommended_route": MessageLookupByLibrary.simpleMessage("Ruta Recomendada"), + "registrarte": MessageLookupByLibrary.simpleMessage("Registrarte"), + "seleciona_tu_idioma": + MessageLookupByLibrary.simpleMessage("Selecciona tu idioma"), "welcome_start_page": MessageLookupByLibrary.simpleMessage("Bienvenido a ") }; diff --git a/fronted/aplicacionrutasturisticas/lib/generated/l10n.dart b/fronted/aplicacionrutasturisticas/lib/generated/l10n.dart index 4a27a61..4b6ef2b 100644 --- a/fronted/aplicacionrutasturisticas/lib/generated/l10n.dart +++ b/fronted/aplicacionrutasturisticas/lib/generated/l10n.dart @@ -55,7 +55,7 @@ class S { return Intl.message( 'Welcome to ', name: 'welcome_start_page', - desc: 'Welcome message at the start page', + desc: 'Welcome message on the start page', args: [], ); } @@ -65,7 +65,7 @@ class S { return Intl.message( 'Create Route', name: 'create_route', - desc: 'Label for creating a new route', + desc: 'Button text for creating a route', args: [], ); } @@ -75,7 +75,7 @@ class S { return Intl.message( 'Recommended Route', name: 'recommended_route', - desc: 'Label for recommended routes', + desc: 'Button text for recommended route', args: [], ); } @@ -85,7 +85,7 @@ class S { return Intl.message( 'List of Places', name: 'list_of_places', - desc: 'Label for listing places', + desc: 'Button text for list of places', args: [], ); } @@ -95,7 +95,137 @@ class S { return Intl.message( 'Complete Routes', name: 'complete_rutes', - desc: 'Label for complete routes', + desc: 'Button text for complete routes', + args: [], + ); + } + + /// `Confirm` + String get confirm { + return Intl.message( + 'Confirm', + name: 'confirm', + desc: 'Text for confirming something', + args: [], + ); + } + + /// `Language` + String get idiom { + return Intl.message( + 'Language', + name: 'idiom', + desc: 'Text for language', + args: [], + ); + } + + /// `Personal Information` + String get informacion_personal { + return Intl.message( + 'Personal Information', + name: 'informacion_personal', + desc: 'Button text for personal information', + args: [], + ); + } + + /// `Form` + String get formulario { + return Intl.message( + 'Form', + name: 'formulario', + desc: 'Text for form', + args: [], + ); + } + + /// `Select your language` + String get seleciona_tu_idioma { + return Intl.message( + 'Select your language', + name: 'seleciona_tu_idioma', + desc: 'Button text for selecting language', + args: [], + ); + } + + /// `The language has been changed to:` + String get notificacion_cambio_idioma { + return Intl.message( + 'The language has been changed to:', + name: 'notificacion_cambio_idioma', + desc: 'Text to notify language change', + args: [], + ); + } + + /// `Log In` + String get inicia_sesion { + return Intl.message( + 'Log In', + name: 'inicia_sesion', + desc: 'Text for logging in', + args: [], + ); + } + + /// `Email` + String get correo { + return Intl.message( + 'Email', + name: 'correo', + desc: 'Text for email', + args: [], + ); + } + + /// `Password` + String get pasword { + return Intl.message( + 'Password', + name: 'pasword', + desc: 'Text for password', + args: [], + ); + } + + /// `Register` + String get registrarte { + return Intl.message( + 'Register', + name: 'registrarte', + desc: 'Text for registering', + args: [], + ); + } + + /// `Guest` + String get invitado { + return Intl.message( + 'Guest', + name: 'invitado', + desc: 'Text for guest', + args: [], + ); + } + + /// `New to the app?` + String get inicio_nuevo_aplicacion { + return Intl.message( + 'New to the app?', + name: 'inicio_nuevo_aplicacion', + desc: 'Text for new to the app question', + args: [], + ); + } + + /// `Enter as` + String get inicio_sesion_entrar_invitado { + return Intl.message( + 'Enter as', + name: 'inicio_sesion_entrar_invitado', + desc: 'Text for entering as a guest', args: [], ); } diff --git a/fronted/aplicacionrutasturisticas/lib/l10n/app_en.arb b/fronted/aplicacionrutasturisticas/lib/l10n/app_en.arb index 2c19cfd..576e00b 100644 --- a/fronted/aplicacionrutasturisticas/lib/l10n/app_en.arb +++ b/fronted/aplicacionrutasturisticas/lib/l10n/app_en.arb @@ -1,23 +1,39 @@ { - "welcome_start_page": "Welcome to ", - "create_route": "Create Route", - "recommended_route": "Recommended Route", - "list_of_places": "List of Places", - "complete_rutes": "Complete Routes", - "@welcome_start_page": { - "description": "Welcome message at the start page" - }, - "@create_route": { - "description": "Label for creating a new route" - }, - "@recommended_route": { - "description": "Label for recommended routes" - }, - "@list_of_places": { - "description": "Label for listing places" - }, - "@complete_rutes": { - "description": "Label for complete routes" - } + "welcome_start_page": "Welcome to ", + "create_route": "Create Route", + "recommended_route": "Recommended Route", + "list_of_places": "List of Places", + "complete_rutes": "Complete Routes", + "confirm": "Confirm", + "idiom": "Language", + "informacion_personal": "Personal Information", + "formulario": "Form", + + "@welcome_start_page": { + "description": "Welcome message on the start page" + }, + "@create_route": { + "description": "Button text for creating a route" + }, + "@recommended_route": { + "description": "Button text for recommended route" + }, + "@list_of_places": { + "description": "Button text for list of places" + }, + "@complete_rutes": { + "description": "Button text for complete routes" + }, + "@confirm": { + "description": "Text for confirming something" + }, + "@idiom": { + "description": "Text for language" + }, + "@informacion_personal": { + "description": "Text for personal information button" + }, + "@formulario": { + "description": "Text for form" } - \ No newline at end of file +} diff --git a/fronted/aplicacionrutasturisticas/lib/l10n/app_es.arb b/fronted/aplicacionrutasturisticas/lib/l10n/app_es.arb index 250831a..97368ef 100644 --- a/fronted/aplicacionrutasturisticas/lib/l10n/app_es.arb +++ b/fronted/aplicacionrutasturisticas/lib/l10n/app_es.arb @@ -1,23 +1,39 @@ { - "welcome_start_page": "Bienvenido a ", - "create_route": "Crear Ruta", - "recommended_route": "Ruta Recomendada", - "list_of_places": "Lista de Lugares", - "complete_rutes": "Rutas Completas", - "@welcome_start_page": { - "description": "Mensaje de bienvenida en la página de inicio" - }, - "@create_route": { - "description": "Texto del botón para crear una ruta" - }, - "@recommended_route": { - "description": "Texto del botón para ruta recomendada" - }, - "@list_of_places": { - "description": "Texto del botón para lista de lugares" - }, - "@complete_rutes": { - "description": "Texto del botón para rutas completas" - } + "welcome_start_page": "Bienvenido a ", + "create_route": "Crear Ruta", + "recommended_route": "Ruta Recomendada", + "list_of_places": "Lista de Lugares", + "complete_rutes": "Rutas Completas", + "confirm":"Confirmar", + "idiom":"Idioma", + "informacion_personal":"Información Personal", + "formulario":"Formulario", + + "@welcome_start_page": { + "description": "Mensaje de bienvenida en la página de inicio" + }, + "@create_route": { + "description": "Texto del botón para crear una ruta" + }, + "@recommended_route": { + "description": "Texto del botón para ruta recomendada" + }, + "@list_of_places": { + "description": "Texto del botón para lista de lugares" + }, + "@complete_rutes": { + "description": "Texto del botón para rutas completas" + }, + "@confirm":{ + "description":"Texto para confirmar algo" + }, + "@idiom":{ + "description":"Texto para idioma" + }, + "@informacion_personal":{ + "description":"Texto para boton informacion personal" + }, + "@formulario":{ + "description":"Texto para formulario" } - \ No newline at end of file +} diff --git a/fronted/aplicacionrutasturisticas/lib/l10n/arb/intl_en.arb b/fronted/aplicacionrutasturisticas/lib/l10n/arb/intl_en.arb index 2c19cfd..576e00b 100644 --- a/fronted/aplicacionrutasturisticas/lib/l10n/arb/intl_en.arb +++ b/fronted/aplicacionrutasturisticas/lib/l10n/arb/intl_en.arb @@ -1,23 +1,39 @@ { - "welcome_start_page": "Welcome to ", - "create_route": "Create Route", - "recommended_route": "Recommended Route", - "list_of_places": "List of Places", - "complete_rutes": "Complete Routes", - "@welcome_start_page": { - "description": "Welcome message at the start page" - }, - "@create_route": { - "description": "Label for creating a new route" - }, - "@recommended_route": { - "description": "Label for recommended routes" - }, - "@list_of_places": { - "description": "Label for listing places" - }, - "@complete_rutes": { - "description": "Label for complete routes" - } + "welcome_start_page": "Welcome to ", + "create_route": "Create Route", + "recommended_route": "Recommended Route", + "list_of_places": "List of Places", + "complete_rutes": "Complete Routes", + "confirm": "Confirm", + "idiom": "Language", + "informacion_personal": "Personal Information", + "formulario": "Form", + + "@welcome_start_page": { + "description": "Welcome message on the start page" + }, + "@create_route": { + "description": "Button text for creating a route" + }, + "@recommended_route": { + "description": "Button text for recommended route" + }, + "@list_of_places": { + "description": "Button text for list of places" + }, + "@complete_rutes": { + "description": "Button text for complete routes" + }, + "@confirm": { + "description": "Text for confirming something" + }, + "@idiom": { + "description": "Text for language" + }, + "@informacion_personal": { + "description": "Text for personal information button" + }, + "@formulario": { + "description": "Text for form" } - \ No newline at end of file +} diff --git a/fronted/aplicacionrutasturisticas/lib/l10n/arb/intl_es.arb b/fronted/aplicacionrutasturisticas/lib/l10n/arb/intl_es.arb index 250831a..f6248cf 100644 --- a/fronted/aplicacionrutasturisticas/lib/l10n/arb/intl_es.arb +++ b/fronted/aplicacionrutasturisticas/lib/l10n/arb/intl_es.arb @@ -4,6 +4,11 @@ "recommended_route": "Ruta Recomendada", "list_of_places": "Lista de Lugares", "complete_rutes": "Rutas Completas", + "confirm":"Confirmar", + "idiom":"Idioma", + "informacion_personal":"Información Personal", + "formulario":"Formulario", + "@welcome_start_page": { "description": "Mensaje de bienvenida en la página de inicio" }, @@ -18,6 +23,18 @@ }, "@complete_rutes": { "description": "Texto del botón para rutas completas" + }, + "@confirm":{ + "description":"Texto para confirmar algo" + }, + "@idiom":{ + "description":"Texto para idioma" + }, + "@informacion_personal":{ + "description":"Texto para boton informacion personal" + }, + "@formulario":{ + "description":"Texto para formulario" } } \ No newline at end of file diff --git a/fronted/aplicacionrutasturisticas/lib/l10n/intl_en.arb b/fronted/aplicacionrutasturisticas/lib/l10n/intl_en.arb index 2c19cfd..498ca11 100644 --- a/fronted/aplicacionrutasturisticas/lib/l10n/intl_en.arb +++ b/fronted/aplicacionrutasturisticas/lib/l10n/intl_en.arb @@ -1,23 +1,75 @@ { - "welcome_start_page": "Welcome to ", - "create_route": "Create Route", - "recommended_route": "Recommended Route", - "list_of_places": "List of Places", - "complete_rutes": "Complete Routes", - "@welcome_start_page": { - "description": "Welcome message at the start page" - }, - "@create_route": { - "description": "Label for creating a new route" - }, - "@recommended_route": { - "description": "Label for recommended routes" - }, - "@list_of_places": { - "description": "Label for listing places" - }, - "@complete_rutes": { - "description": "Label for complete routes" - } + "welcome_start_page": "Welcome to ", + "create_route": "Create Route", + "recommended_route": "Recommended Route", + "list_of_places": "List of Places", + "complete_rutes": "Complete Routes", + "confirm": "Confirm", + "idiom": "Language", + "informacion_personal": "Personal Information", + "formulario": "Form", + "seleciona_tu_idioma": "Select your language", + "notificacion_cambio_idioma": "The language has been changed to:", + "inicia_sesion": "Log In", + "correo": "Email", + "pasword": "Password", + "registrarte": "Register", + "invitado": "Guest", + "inicio_nuevo_aplicacion": "New to the app?", + "inicio_sesion_entrar_invitado": "Enter as", + + "@welcome_start_page": { + "description": "Welcome message on the start page" + }, + "@create_route": { + "description": "Button text for creating a route" + }, + "@recommended_route": { + "description": "Button text for recommended route" + }, + "@list_of_places": { + "description": "Button text for list of places" + }, + "@complete_rutes": { + "description": "Button text for complete routes" + }, + "@confirm": { + "description": "Text for confirming something" + }, + "@idiom": { + "description": "Text for language" + }, + "@informacion_personal": { + "description": "Button text for personal information" + }, + "@formulario": { + "description": "Text for form" + }, + "@seleciona_tu_idioma": { + "description": "Button text for selecting language" + }, + "@notificacion_cambio_idioma": { + "description": "Text to notify language change" + }, + "@inicia_sesion": { + "description": "Text for logging in" + }, + "@correo": { + "description": "Text for email" + }, + "@pasword": { + "description": "Text for password" + }, + "@registrarte": { + "description": "Text for registering" + }, + "@invitado": { + "description": "Text for guest" + }, + "@inicio_nuevo_aplicacion": { + "description": "Text for new to the app question" + }, + "@inicio_sesion_entrar_invitado": { + "description": "Text for entering as a guest" } - \ No newline at end of file +} diff --git a/fronted/aplicacionrutasturisticas/lib/l10n/intl_es.arb b/fronted/aplicacionrutasturisticas/lib/l10n/intl_es.arb index 250831a..6be271c 100644 --- a/fronted/aplicacionrutasturisticas/lib/l10n/intl_es.arb +++ b/fronted/aplicacionrutasturisticas/lib/l10n/intl_es.arb @@ -1,23 +1,75 @@ { - "welcome_start_page": "Bienvenido a ", - "create_route": "Crear Ruta", - "recommended_route": "Ruta Recomendada", - "list_of_places": "Lista de Lugares", - "complete_rutes": "Rutas Completas", - "@welcome_start_page": { - "description": "Mensaje de bienvenida en la página de inicio" - }, - "@create_route": { - "description": "Texto del botón para crear una ruta" - }, - "@recommended_route": { - "description": "Texto del botón para ruta recomendada" - }, - "@list_of_places": { - "description": "Texto del botón para lista de lugares" - }, - "@complete_rutes": { - "description": "Texto del botón para rutas completas" - } + "welcome_start_page": "Bienvenido a ", + "create_route": "Crear Ruta", + "recommended_route": "Ruta Recomendada", + "list_of_places": "Lista de Lugares", + "complete_rutes": "Rutas Completas", + "confirm": "Confirmar", + "idiom": "Idioma", + "informacion_personal": "Información Personal", + "formulario": "Formulario", + "seleciona_tu_idioma": "Selecciona tu idioma", + "notificacion_cambio_idioma": "El idioma ha sido cambiado a:", + "inicia_sesion": "Inicia Sesión", + "correo": "Correo electrónico", + "pasword": "Contraseña", + "registrarte": "Registrarte", + "invitado": "Invitado", + "inicio_nuevo_aplicacion": "¿Nuevo en la aplicación?", + "inicio_sesion_entrar_invitado": "Entra como", + + "@welcome_start_page": { + "description": "Mensaje de bienvenida en la página de inicio" + }, + "@create_route": { + "description": "Texto del botón para crear una ruta" + }, + "@recommended_route": { + "description": "Texto del botón para ruta recomendada" + }, + "@list_of_places": { + "description": "Texto del botón para lista de lugares" + }, + "@complete_rutes": { + "description": "Texto del botón para rutas completas" + }, + "@confirm": { + "description": "Texto para confirmar algo" + }, + "@idiom": { + "description": "Texto para idioma" + }, + "@informacion_personal": { + "description": "Texto para botón de información personal" + }, + "@formulario": { + "description": "Texto para formulario" + }, + "@seleciona_tu_idioma": { + "description": "Texto para botón selecciona idioma" + }, + "@notificacion_cambio_idioma": { + "description": "Texto para notificar cambio de idioma" + }, + "@inicia_sesion": { + "description": "Texto para iniciar sesión" + }, + "@correo": { + "description": "Texto para correo electrónico" + }, + "@pasword": { + "description": "Texto para contraseña" + }, + "@registrarte": { + "description": "Texto para registrarte" + }, + "@invitado": { + "description": "Texto para invitado" + }, + "@inicio_nuevo_aplicacion": { + "description": "Texto para pregunta de nuevo en la aplicación" + }, + "@inicio_sesion_entrar_invitado": { + "description": "Texto para entrar como invitado" } - \ No newline at end of file +} diff --git a/fronted/aplicacionrutasturisticas/lib/pages/login.dart b/fronted/aplicacionrutasturisticas/lib/pages/login.dart index 3d1213e..edb2661 100644 --- a/fronted/aplicacionrutasturisticas/lib/pages/login.dart +++ b/fronted/aplicacionrutasturisticas/lib/pages/login.dart @@ -1,7 +1,7 @@ import 'package:aplicacionrutasturisticas/config/dio.dart'; import 'package:aplicacionrutasturisticas/utilerias/TextButtons.dart'; import 'package:flutter/material.dart'; - +import 'package:aplicacionrutasturisticas/generated/l10n.dart'; import 'package:aplicacionrutasturisticas/utilerias/Buttons.dart'; import 'package:aplicacionrutasturisticas/utilerias/Textfields.dart'; import 'package:go_router/go_router.dart'; @@ -26,7 +26,7 @@ class _TextFielEjemploState extends State { appBar: AppBar( title: SizedBox( child: Center( - child: Text("Inicia Sesión", + child: Text(S().inicia_sesion, style: const TextStyle(fontWeight: FontWeight.bold), selectionColor: Colors.black))), ), @@ -40,16 +40,14 @@ class _TextFielEjemploState extends State { height: 20.0, ), hacerTextField( - controller: correo, - texto: "Correo electronico", - ocultar: false), + controller: correo, texto: S().correo, ocultar: false), SizedBox(height: 20), Row( mainAxisAlignment: MainAxisAlignment.center, children: [ hacerTextField( controller: password, - texto: "Contraseña", + texto: S().pasword, ocultar: true, ), ], @@ -58,23 +56,23 @@ class _TextFielEjemploState extends State { ColoredBox( color: Colors.white, child: boton_Escribir( - texto: "Iniciar sesión", + texto: S().inicia_sesion, onPression: botonIniciaSesion, )), SizedBox(height: 20), Row( children: [ - const Text(" ¿Nuevo en la aplicacion?"), + Text(" ${S().inicio_nuevo_aplicacion}"), HacerTextButtons( - texto: "Registrarte", onPression: botonRegistrar) + texto: S().registrarte, onPression: botonRegistrar) ], ), SizedBox(height: 15), Row( children: [ - const Text(" Entrar como"), + Text(" ${S().inicio_sesion_entrar_invitado}"), HacerTextButtons( - texto: "Invitado", onPression: botonRegistrar) + texto: S().invitado, onPression: botonRegistrar) ], ), ], @@ -89,7 +87,7 @@ class _TextFielEjemploState extends State { corr = correo.text; pass = password.text; print(corr + " " + pass); - //loginDatos(corr, pass); + loginDatos(corr, pass); context.goNamed("StartPage2"); } diff --git a/fronted/aplicacionrutasturisticas/lib/pages/register.dart b/fronted/aplicacionrutasturisticas/lib/pages/register.dart index 3a05ced..b7b2b49 100644 --- a/fronted/aplicacionrutasturisticas/lib/pages/register.dart +++ b/fronted/aplicacionrutasturisticas/lib/pages/register.dart @@ -115,6 +115,7 @@ class RegistroPageState extends State { if (pass == passc) { Registro_Datos(nom, ape, ema, pass); + //print("Se regitraron los datos"); context.goNamed("LoginPage"); } else { print("La contraseña es incorrecta"); diff --git a/fronted/aplicacionrutasturisticas/lib/utilerias/Perfil/CupertinoPicker_Perfil.dart b/fronted/aplicacionrutasturisticas/lib/utilerias/Perfil/CupertinoPicker_Perfil.dart index 4102efb..4209c40 100644 --- a/fronted/aplicacionrutasturisticas/lib/utilerias/Perfil/CupertinoPicker_Perfil.dart +++ b/fronted/aplicacionrutasturisticas/lib/utilerias/Perfil/CupertinoPicker_Perfil.dart @@ -1,5 +1,5 @@ import 'package:aplicacionrutasturisticas/config/metodos/cambio_idioma.dart'; -import 'package:aplicacionrutasturisticas/config/idioma/locale_provider.dart'; +import 'package:aplicacionrutasturisticas/generated/l10n.dart'; import 'package:aplicacionrutasturisticas/config/metodos/perfil_metodos.dart'; import 'package:aplicacionrutasturisticas/utilerias/MensajeEnMEdio.dart'; import 'package:aplicacionrutasturisticas/variables/perfil_variables.dart' @@ -16,7 +16,7 @@ class CupertinoPickerWidget_perfil extends StatefulWidget { class _CupertinoPickerWidget_perfilState extends State { int _selectedValue = 0; - final List _options = ['Español', 'Inglés', 'Portuges']; + final List _options = ['Español', 'Inglés']; @override Widget build(BuildContext context) { @@ -44,10 +44,10 @@ class _CupertinoPickerWidget_perfilState MensajeErrorDialog.show( context, - "El idioma ha sido cambiado a: ${globals.getLenguaje}", + S().notificacion_cambio_idioma + " ${globals.getLenguaje}", ); }, - child: Text('Confirmar', style: TextStyle(fontSize: 20)), + child: Text(S().confirm, style: TextStyle(fontSize: 20)), ) ], ), diff --git a/fronted/aplicacionrutasturisticas/lib/utilerias/Perfil/Drawer_Perfil.dart b/fronted/aplicacionrutasturisticas/lib/utilerias/Perfil/Drawer_Perfil.dart index a0ab4ed..15be244 100644 --- a/fronted/aplicacionrutasturisticas/lib/utilerias/Perfil/Drawer_Perfil.dart +++ b/fronted/aplicacionrutasturisticas/lib/utilerias/Perfil/Drawer_Perfil.dart @@ -1,4 +1,6 @@ import 'package:aplicacionrutasturisticas/utilerias/Perfil/CupertinoPicker_Perfil.dart'; +import 'package:aplicacionrutasturisticas/generated/l10n.dart'; +import 'package:aplicacionrutasturisticas/utilerias/Textfields.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter/widgets.dart'; @@ -22,7 +24,7 @@ class _PerfilState extends State { .min, // Ajusta el tamaño de la columna al contenido children: [ Text( - "Selecciona tu idioma", + S().seleciona_tu_idioma, textAlign: TextAlign.center, style: TextStyle(fontSize: 20), ), @@ -41,32 +43,21 @@ class _PerfilState extends State { child: ListView( padding: EdgeInsets.zero, children: [ - const DrawerHeader( - decoration: BoxDecoration( - color: Colors.blue, - ), - child: Text( - 'Bienvenido', - style: TextStyle( - color: Colors.white, - fontSize: 24, - fontWeight: FontWeight.bold, - ), - ), - ), + iconButton(), + Text("Nombre", textAlign: TextAlign.center), ListTile( leading: Icon(Icons.message), - title: Text('Informacion Personal'), + title: Text(S().informacion_personal), onTap: () {}, ), ListTile( leading: Icon(Icons.account_circle), - title: Text('Notificaciones'), + title: Text(S().formulario), onTap: () {}, ), ListTile( leading: Icon(Icons.sunny), - title: Text('Idioma'), + title: Text(S().idiom), onTap: () { Perfil_metodos().precionasteIdioma(); llamridioma(); // Llama al método para mostrar el modal diff --git a/fronted/aplicacionrutasturisticas/pubspec.lock b/fronted/aplicacionrutasturisticas/pubspec.lock index b4d61b6..1588cfe 100644 --- a/fronted/aplicacionrutasturisticas/pubspec.lock +++ b/fronted/aplicacionrutasturisticas/pubspec.lock @@ -121,6 +121,14 @@ packages: url: "https://pub.dev" source: hosted version: "1.3.1" + ffi: + dependency: transitive + description: + name: ffi + sha256: "493f37e7df1804778ff3a53bd691d8692ddf69702cf4c1c1096a2e41b4779e21" + url: "https://pub.dev" + source: hosted + version: "2.1.2" file: dependency: transitive description: @@ -301,6 +309,30 @@ packages: url: "https://pub.dev" source: hosted version: "1.9.0" + path_provider_linux: + dependency: transitive + description: + name: path_provider_linux + sha256: f7a1fe3a634fe7734c8d3f2766ad746ae2a2884abe22e241a8b301bf5cac3279 + url: "https://pub.dev" + source: hosted + version: "2.2.1" + path_provider_platform_interface: + dependency: transitive + description: + name: path_provider_platform_interface + sha256: "88f5779f72ba699763fa3a3b06aa4bf6de76c8e5de842cf6f29e2e06476c2334" + url: "https://pub.dev" + source: hosted + version: "2.1.2" + path_provider_windows: + dependency: transitive + description: + name: path_provider_windows + sha256: "8bc9f22eee8690981c22aa7fc602f5c85b497a6fb2ceb35ee5a5e5ed85ad8170" + url: "https://pub.dev" + source: hosted + version: "2.2.1" petitparser: dependency: transitive description: @@ -309,6 +341,22 @@ packages: url: "https://pub.dev" source: hosted version: "6.0.2" + platform: + dependency: transitive + description: + name: platform + sha256: "9b71283fc13df574056616011fb138fd3b793ea47cc509c189a6c3fa5f8a1a65" + url: "https://pub.dev" + source: hosted + version: "3.1.5" + plugin_platform_interface: + dependency: transitive + description: + name: plugin_platform_interface + sha256: "4820fbfdb9478b1ebae27888254d445073732dae3d6ea81f0b7e06d5dedc3f02" + url: "https://pub.dev" + source: hosted + version: "2.1.8" provider: dependency: "direct main" description: @@ -325,6 +373,62 @@ packages: url: "https://pub.dev" source: hosted version: "2.1.4" + shared_preferences: + dependency: "direct main" + description: + name: shared_preferences + sha256: d3bbe5553a986e83980916ded2f0b435ef2e1893dfaa29d5a7a790d0eca12180 + url: "https://pub.dev" + source: hosted + version: "2.2.3" + shared_preferences_android: + dependency: transitive + description: + name: shared_preferences_android + sha256: "1ee8bf911094a1b592de7ab29add6f826a7331fb854273d55918693d5364a1f2" + url: "https://pub.dev" + source: hosted + version: "2.2.2" + shared_preferences_foundation: + dependency: transitive + description: + name: shared_preferences_foundation + sha256: "0a8a893bf4fd1152f93fec03a415d11c27c74454d96e2318a7ac38dd18683ab7" + url: "https://pub.dev" + source: hosted + version: "2.4.0" + shared_preferences_linux: + dependency: transitive + description: + name: shared_preferences_linux + sha256: "9f2cbcf46d4270ea8be39fa156d86379077c8a5228d9dfdb1164ae0bb93f1faa" + url: "https://pub.dev" + source: hosted + version: "2.3.2" + shared_preferences_platform_interface: + dependency: transitive + description: + name: shared_preferences_platform_interface + sha256: "22e2ecac9419b4246d7c22bfbbda589e3acf5c0351137d87dd2939d984d37c3b" + url: "https://pub.dev" + source: hosted + version: "2.3.2" + shared_preferences_web: + dependency: transitive + description: + name: shared_preferences_web + sha256: "9aee1089b36bd2aafe06582b7d7817fd317ef05fc30e6ba14bff247d0933042a" + url: "https://pub.dev" + source: hosted + version: "2.3.0" + shared_preferences_windows: + dependency: transitive + description: + name: shared_preferences_windows + sha256: "841ad54f3c8381c480d0c9b508b89a34036f512482c407e6df7a9c4aa2ef8f59" + url: "https://pub.dev" + source: hosted + version: "2.3.2" sky_engine: dependency: transitive description: flutter @@ -418,6 +522,22 @@ packages: url: "https://pub.dev" source: hosted version: "0.5.1" + win32: + dependency: transitive + description: + name: win32 + sha256: "0eaf06e3446824099858367950a813472af675116bf63f008a4c2a75ae13e9cb" + url: "https://pub.dev" + source: hosted + version: "5.5.0" + xdg_directories: + dependency: transitive + description: + name: xdg_directories + sha256: faea9dee56b520b55a566385b84f2e8de55e7496104adada9962e0bd11bcff1d + url: "https://pub.dev" + source: hosted + version: "1.0.4" yaml: dependency: transitive description: @@ -428,4 +548,4 @@ packages: version: "3.1.2" sdks: dart: ">=3.3.0 <4.0.0" - flutter: ">=3.16.0" + flutter: ">=3.19.0" diff --git a/fronted/aplicacionrutasturisticas/pubspec.yaml b/fronted/aplicacionrutasturisticas/pubspec.yaml index 0ffbb36..45d79c7 100644 --- a/fronted/aplicacionrutasturisticas/pubspec.yaml +++ b/fronted/aplicacionrutasturisticas/pubspec.yaml @@ -32,6 +32,7 @@ dependencies: sdk: flutter flutter_localizations: sdk: flutter + shared_preferences: ^2.0.11 provider: ^6.0.3 # The following adds the Cupertino Icons font to your application. # Use with the CupertinoIcons class for iOS style icons. -- GitLab From 21ae064ec3d1c0051a97150548fa8b95e919f4ae Mon Sep 17 00:00:00 2001 From: Angel David Carlos Silva Date: Tue, 2 Jul 2024 13:50:32 -0600 Subject: [PATCH 07/19] Rorganuzar carpetas fronted --- .../lib/{config => }/metodos/cambio_idioma.dart | 0 .../lib/{config => }/metodos/perfil_metodos.dart | 0 .../lib/utilerias/Perfil/CupertinoPicker_Perfil.dart | 4 ++-- .../lib/utilerias/Perfil/Drawer_Perfil.dart | 2 +- 4 files changed, 3 insertions(+), 3 deletions(-) rename fronted/aplicacionrutasturisticas/lib/{config => }/metodos/cambio_idioma.dart (100%) rename fronted/aplicacionrutasturisticas/lib/{config => }/metodos/perfil_metodos.dart (100%) diff --git a/fronted/aplicacionrutasturisticas/lib/config/metodos/cambio_idioma.dart b/fronted/aplicacionrutasturisticas/lib/metodos/cambio_idioma.dart similarity index 100% rename from fronted/aplicacionrutasturisticas/lib/config/metodos/cambio_idioma.dart rename to fronted/aplicacionrutasturisticas/lib/metodos/cambio_idioma.dart diff --git a/fronted/aplicacionrutasturisticas/lib/config/metodos/perfil_metodos.dart b/fronted/aplicacionrutasturisticas/lib/metodos/perfil_metodos.dart similarity index 100% rename from fronted/aplicacionrutasturisticas/lib/config/metodos/perfil_metodos.dart rename to fronted/aplicacionrutasturisticas/lib/metodos/perfil_metodos.dart diff --git a/fronted/aplicacionrutasturisticas/lib/utilerias/Perfil/CupertinoPicker_Perfil.dart b/fronted/aplicacionrutasturisticas/lib/utilerias/Perfil/CupertinoPicker_Perfil.dart index 4209c40..ec33d13 100644 --- a/fronted/aplicacionrutasturisticas/lib/utilerias/Perfil/CupertinoPicker_Perfil.dart +++ b/fronted/aplicacionrutasturisticas/lib/utilerias/Perfil/CupertinoPicker_Perfil.dart @@ -1,6 +1,6 @@ -import 'package:aplicacionrutasturisticas/config/metodos/cambio_idioma.dart'; +import 'package:aplicacionrutasturisticas/metodos/cambio_idioma.dart'; import 'package:aplicacionrutasturisticas/generated/l10n.dart'; -import 'package:aplicacionrutasturisticas/config/metodos/perfil_metodos.dart'; +import 'package:aplicacionrutasturisticas/metodos/perfil_metodos.dart'; import 'package:aplicacionrutasturisticas/utilerias/MensajeEnMEdio.dart'; import 'package:aplicacionrutasturisticas/variables/perfil_variables.dart' as globals; diff --git a/fronted/aplicacionrutasturisticas/lib/utilerias/Perfil/Drawer_Perfil.dart b/fronted/aplicacionrutasturisticas/lib/utilerias/Perfil/Drawer_Perfil.dart index 15be244..5fce22c 100644 --- a/fronted/aplicacionrutasturisticas/lib/utilerias/Perfil/Drawer_Perfil.dart +++ b/fronted/aplicacionrutasturisticas/lib/utilerias/Perfil/Drawer_Perfil.dart @@ -4,7 +4,7 @@ import 'package:aplicacionrutasturisticas/utilerias/Textfields.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter/widgets.dart'; -import 'package:aplicacionrutasturisticas/config/metodos/perfil_metodos.dart'; +import 'package:aplicacionrutasturisticas/metodos/perfil_metodos.dart'; class Perfil extends StatefulWidget { @override -- GitLab From 0c6a3fa1e8050031528d09e661a553a611b9e6c0 Mon Sep 17 00:00:00 2001 From: Angel David Carlos Silva Date: Tue, 2 Jul 2024 16:08:27 -0600 Subject: [PATCH 08/19] Se crea la tabla city en la base de datos :D --- backend/src/app.module.ts | 5 ++++- backend/src/city/city.controller.ts | 13 +++++++++++++ backend/src/city/city.module.ts | 13 +++++++++++++ backend/src/city/city.service.spec.ts | 17 +++++++++++++++++ backend/src/city/city.service.ts | 16 ++++++++++++++++ backend/src/city/dto/create-city.dto.ts | 4 ++++ backend/src/city/dto/update-city.dto.ts | 6 ++++++ backend/src/city/entities/city.entity.ts | 12 ++++++++++++ backend/src/user/user.service.ts | 2 +- .../test/widget_test.dart | 2 +- 10 files changed, 87 insertions(+), 3 deletions(-) create mode 100644 backend/src/city/city.controller.ts create mode 100644 backend/src/city/city.module.ts create mode 100644 backend/src/city/city.service.spec.ts create mode 100644 backend/src/city/city.service.ts create mode 100644 backend/src/city/dto/create-city.dto.ts create mode 100644 backend/src/city/dto/update-city.dto.ts create mode 100644 backend/src/city/entities/city.entity.ts diff --git a/backend/src/app.module.ts b/backend/src/app.module.ts index 636933b..da4c8c8 100644 --- a/backend/src/app.module.ts +++ b/backend/src/app.module.ts @@ -9,6 +9,8 @@ import { Admin } from './admin/entities/admin.entity'; import { User } from './user/entities/user.entity'; import { JwtModule } from '@nestjs/jwt'; import { AuthUserModule } from './auth-user/auth-user.module'; +import { CityModule } from './city/city.module'; +import { City } from './city/entities/city.entity'; dotenv.config() @Module({ @@ -20,13 +22,14 @@ dotenv.config() username: process.env.DATABASE_USER, password: process.env.DATABASE_PASSWORD, database: process.env.DATABASE_NAME, - entities: [Admin, User], + entities: [Admin, User,City], synchronize: true, }), AdminModule, UserModule, JwtModule, AuthUserModule, + CityModule ], controllers: [AppController], //rutas providers: [AppService], //funciones para comunicarse en la bd diff --git a/backend/src/city/city.controller.ts b/backend/src/city/city.controller.ts new file mode 100644 index 0000000..04eef5d --- /dev/null +++ b/backend/src/city/city.controller.ts @@ -0,0 +1,13 @@ +import { Controller, Get, Post, Body, Patch, Param, Delete } from '@nestjs/common'; +import { CityService } from './city.service'; +import { CreateCityDto } from './dto/create-city.dto'; + +@Controller('city') +export class CityController{ + constructor(private readonly cityService: CityService){} + + @Post() + findALL(@Body()createCityDto:CreateCityDto){ + return this.cityService.findAll; + } +} \ No newline at end of file diff --git a/backend/src/city/city.module.ts b/backend/src/city/city.module.ts new file mode 100644 index 0000000..493341d --- /dev/null +++ b/backend/src/city/city.module.ts @@ -0,0 +1,13 @@ +import { TypeOrmModule } from '@nestjs/typeorm'; +import { Module } from '@nestjs/common'; +import { CityService } from './city.service'; +import { CityController } from './city.controller'; +import { City } from './entities/city.entity'; + +@Module({ + imports: [TypeOrmModule.forFeature([City])], + controllers:[CityController], + providers:[CityService], + exports:[CityService] +}) +export class CityModule{} \ No newline at end of file diff --git a/backend/src/city/city.service.spec.ts b/backend/src/city/city.service.spec.ts new file mode 100644 index 0000000..070afa1 --- /dev/null +++ b/backend/src/city/city.service.spec.ts @@ -0,0 +1,17 @@ +import { Test,TestingModule } from "@nestjs/testing"; +import { CityService } from "./city.service"; + +describe('CityService',()=>{ + let service: CityService; + + beforeEach(async()=>{ + const module: TestingModule=await Test.createTestingModule({ + providers: [CityService], + }).compile(); + service=module.get(CityService); + }) + + it('should be defined',()=>{ + expect(service).toBeDefined(); + }) +}) \ No newline at end of file diff --git a/backend/src/city/city.service.ts b/backend/src/city/city.service.ts new file mode 100644 index 0000000..fb890b1 --- /dev/null +++ b/backend/src/city/city.service.ts @@ -0,0 +1,16 @@ +import { Inject, Injectable } from "@nestjs/common"; +import { CreateCityDto } from "./dto/create-city.dto"; +import { InjectRepository } from "@nestjs/typeorm"; +import { City } from "./entities/city.entity"; +import { Repository } from "typeorm"; + +@Injectable() +export class CityService{ + constructor( + @InjectRepository(City) + private readonly cityRepository: Repository, + ){} + async findAll(): Promise {//Obtiene en forma de arreglos todo el contenido de la tabla + return await this.cityRepository.find(); + } +} \ No newline at end of file diff --git a/backend/src/city/dto/create-city.dto.ts b/backend/src/city/dto/create-city.dto.ts new file mode 100644 index 0000000..f30c01a --- /dev/null +++ b/backend/src/city/dto/create-city.dto.ts @@ -0,0 +1,4 @@ +export class CreateCityDto { + name: string; + description: string; +} \ No newline at end of file diff --git a/backend/src/city/dto/update-city.dto.ts b/backend/src/city/dto/update-city.dto.ts new file mode 100644 index 0000000..8f64ecc --- /dev/null +++ b/backend/src/city/dto/update-city.dto.ts @@ -0,0 +1,6 @@ +import { PartialType } from '@nestjs/mapped-types'; +import { CreateCityDto } from './create-city.dto'; + +export class UpdateUserDto extends PartialType(CreateCityDto) { + +} \ No newline at end of file diff --git a/backend/src/city/entities/city.entity.ts b/backend/src/city/entities/city.entity.ts new file mode 100644 index 0000000..a346244 --- /dev/null +++ b/backend/src/city/entities/city.entity.ts @@ -0,0 +1,12 @@ +import { Column, Entity, PrimaryColumn, PrimaryGeneratedColumn } from "typeorm"; + @Entity() + export class City{ + @PrimaryGeneratedColumn() + idCity:number + + @Column() + name:string + + @Column() + description:string + } diff --git a/backend/src/user/user.service.ts b/backend/src/user/user.service.ts index 96a338d..0eac84c 100644 --- a/backend/src/user/user.service.ts +++ b/backend/src/user/user.service.ts @@ -18,4 +18,4 @@ export class UserService { return await this.userRepository.findOneBy({ email }); } -} +} \ No newline at end of file diff --git a/fronted/aplicacionrutasturisticas/test/widget_test.dart b/fronted/aplicacionrutasturisticas/test/widget_test.dart index 86dbf6d..2e8c3d8 100644 --- a/fronted/aplicacionrutasturisticas/test/widget_test.dart +++ b/fronted/aplicacionrutasturisticas/test/widget_test.dart @@ -13,7 +13,7 @@ import 'package:aplicacionrutasturisticas/main.dart'; void main() { testWidgets('Counter increments smoke test', (WidgetTester tester) async { // Build our app and trigger a frame. - await tester.pumpWidget(const MyApp()); + await tester.pumpWidget(MyApp()); // Verify that our counter starts at 0. expect(find.text('0'), findsOneWidget); -- GitLab From 67e02725c2b7ac62dfbae98e5f7f0862febfae18 Mon Sep 17 00:00:00 2001 From: Angel David Carlos Silva Date: Tue, 2 Jul 2024 16:48:21 -0600 Subject: [PATCH 09/19] Inicia datos en city Al crear la tabla city y no hay ningun dato creeara solo 1 dato --- backend/src/app.module.ts | 17 +++++++++++++++-- backend/src/city/city.service.ts | 16 ++++++++++++++++ backend/src/city/entities/city.entity.ts | 2 +- 3 files changed, 32 insertions(+), 3 deletions(-) diff --git a/backend/src/app.module.ts b/backend/src/app.module.ts index da4c8c8..54dfda9 100644 --- a/backend/src/app.module.ts +++ b/backend/src/app.module.ts @@ -1,4 +1,4 @@ -import { Module } from '@nestjs/common'; +import { Module, OnModuleDestroy, OnModuleInit } from '@nestjs/common'; import { AppController } from './app.controller'; import { AppService } from './app.service'; import { TypeOrmModule } from '@nestjs/typeorm'; @@ -11,6 +11,7 @@ import { JwtModule } from '@nestjs/jwt'; import { AuthUserModule } from './auth-user/auth-user.module'; import { CityModule } from './city/city.module'; import { City } from './city/entities/city.entity'; +import { CityService } from './city/city.service'; dotenv.config() @Module({ @@ -34,4 +35,16 @@ dotenv.config() controllers: [AppController], //rutas providers: [AppService], //funciones para comunicarse en la bd }) -export class AppModule {} +/* +Esta clase solo se usara al principio para no tener que ingresar los datos manuelamente a la tabala city + +Este deberia de ser el adecuando una vez finalizado +export class AppModule{} + +*/ +export class AppModule implements OnModuleInit{ + constructor(private readonly cityService:CityService){} + async onModuleInit() { + await this.cityService.initializeData(); // Inicialización de datos de City al inicio + } +} diff --git a/backend/src/city/city.service.ts b/backend/src/city/city.service.ts index fb890b1..a811f58 100644 --- a/backend/src/city/city.service.ts +++ b/backend/src/city/city.service.ts @@ -13,4 +13,20 @@ export class CityService{ async findAll(): Promise {//Obtiene en forma de arreglos todo el contenido de la tabla return await this.cityRepository.find(); } + + async initializeData() { + const info_tabla = await this.cityRepository.count(); // Verifica si ya existen datos en la tabla + + if (info_tabla === 0) { + const citiesToCreate = [ + { name: 'Zacatecas', + description: ' Zacatecas es un estado diverso y de variadas altitudes que deslumbra por su colorido y generosidad, ofreciendo experiencias extravagantes y contemplativas por igual. Su cielo, el más azul del país, contrasta con el rojo intenso de su tierra fértil, de donde se extrae la típica cantera rosa que adorna las edificaciones de la capital y que también da vida a deliciosos sabores campestres en todo el estado. Zacatecas resplandece con una luz dorada única, mientras el orgullo por su historia minera se refleja desde las profundidades de la tierra hasta su influencia en la gastronomía local. Sus paisajes naturales, pintados en tonos ocres y verdes, son especialmente hermosos y revelan la belleza única de esta tierra. ' } + ]; + + // Guarda las ciudades en la base de datos + await Promise.all( + citiesToCreate.map(cityData => this.cityRepository.save(cityData)), + ); + } + } } \ No newline at end of file diff --git a/backend/src/city/entities/city.entity.ts b/backend/src/city/entities/city.entity.ts index a346244..aeca867 100644 --- a/backend/src/city/entities/city.entity.ts +++ b/backend/src/city/entities/city.entity.ts @@ -7,6 +7,6 @@ import { Column, Entity, PrimaryColumn, PrimaryGeneratedColumn } from "typeorm"; @Column() name:string - @Column() + @Column({ length: 1000 }) description:string } -- GitLab From e34198e3f8e8963d36d925f37ad5c471068e8e54 Mon Sep 17 00:00:00 2001 From: Angel David Carlos Silva Date: Tue, 2 Jul 2024 19:50:32 -0600 Subject: [PATCH 10/19] Se agrega la ciudad zacatecas Zacayecas se genera automaticamente si es la primera vez al crear la tabla city, tambien ya se muestra en la pagina de inicio --- backend/src/city/city.controller.ts | 25 ++++++++++++- backend/src/city/city.service.ts | 25 +++++++++++++ .../lib/config/dio.dart | 32 +++++++++++++++-- .../lib/pages/star_page2.dart | 35 ++++++++++++++++++- 4 files changed, 113 insertions(+), 4 deletions(-) diff --git a/backend/src/city/city.controller.ts b/backend/src/city/city.controller.ts index 04eef5d..e72242b 100644 --- a/backend/src/city/city.controller.ts +++ b/backend/src/city/city.controller.ts @@ -1,6 +1,7 @@ -import { Controller, Get, Post, Body, Patch, Param, Delete } from '@nestjs/common'; +import { Controller, Get, Post, Body, Patch, Param, Delete, Query, BadRequestException } from '@nestjs/common'; import { CityService } from './city.service'; import { CreateCityDto } from './dto/create-city.dto'; +import { get } from 'http'; @Controller('city') export class CityController{ @@ -10,4 +11,26 @@ export class CityController{ findALL(@Body()createCityDto:CreateCityDto){ return this.cityService.findAll; } + + @Get('name') + async getCityName(@Query('id') id: string): Promise<{ name: string }> { + const cityId = parseInt(id, 10); + if (isNaN(cityId)) { + throw new BadRequestException('Invalid city ID'); + } + + const name = await this.cityService.getCityNameById(cityId); + return { name }; + } + + @Get('description') + async getCityDescirption(@Query('id') id: string): Promise<{ description: string }> { + const cityId = parseInt(id, 10); + if (isNaN(cityId)) { + throw new BadRequestException('Invalid city ID'); + } + + const description = await this.cityService.getCityDescriptionById(cityId); + return { description }; + } } \ No newline at end of file diff --git a/backend/src/city/city.service.ts b/backend/src/city/city.service.ts index a811f58..91dc2a7 100644 --- a/backend/src/city/city.service.ts +++ b/backend/src/city/city.service.ts @@ -5,6 +5,12 @@ import { City } from "./entities/city.entity"; import { Repository } from "typeorm"; @Injectable() +export class AppService { + getHello(): string { + return 'Adios'; + } + +} export class CityService{ constructor( @InjectRepository(City) @@ -29,4 +35,23 @@ export class CityService{ ); } } + + //Obtener el name + async getCityNameById(cityId: number): Promise { + const city = await this.cityRepository.findOne({ where: { idCity: cityId } }); + if (!city) { + throw new Error('City not found'); + } + return city.name; + } + + //Obtener el description + async getCityDescriptionById(cityId: number): Promise { + const city = await this.cityRepository.findOne({ where: { idCity: cityId } }); + if (!city) { + throw new Error('City not found'); + } + return city.description; + } + } \ No newline at end of file diff --git a/fronted/aplicacionrutasturisticas/lib/config/dio.dart b/fronted/aplicacionrutasturisticas/lib/config/dio.dart index 103fa98..84036cd 100644 --- a/fronted/aplicacionrutasturisticas/lib/config/dio.dart +++ b/fronted/aplicacionrutasturisticas/lib/config/dio.dart @@ -1,10 +1,10 @@ import 'package:dio/dio.dart'; final dio = Dio(); + void Registro_Datos( String nombre, String lastname, String email, String password) async { Response response; - //response = await dio.get("http://172.26.128.1:3000") response = await dio.post("http://192.168.101.13:3000/auth-user/register", data: { "name": nombre, @@ -12,7 +12,6 @@ void Registro_Datos( "password": password, "email": email, }); - print("Hola" + "\n\n" + response.data.toString() + "\n\n"); } void loginDatos(String email, String password) async { @@ -24,3 +23,32 @@ void loginDatos(String email, String password) async { }); print(responselogin.data.toString()); } + +Future datosStartPage(int cityId) async { + Response responseCity = await dio.get( + "http://192.168.101.13:3000/city/name", + queryParameters: {"id": cityId}, + ); + if (responseCity.statusCode == 200) { + dynamic cityData = responseCity.data; + String cityName = cityData['name'].toString(); + return cityName; + } else { + return "Cargando...."; + } +} + +Future datosTextStartPage(int cityId) async { + Response responseCity = await dio.get( + "http://192.168.101.13:3000/city/description", + queryParameters: {"id": cityId}, + ); + if (responseCity.statusCode == 200) { + dynamic cityData = responseCity.data; + String cityDes = cityData['description'].toString(); + print(cityData.toString()); + return cityDes; + } else { + return "Cargando...."; + } +} diff --git a/fronted/aplicacionrutasturisticas/lib/pages/star_page2.dart b/fronted/aplicacionrutasturisticas/lib/pages/star_page2.dart index 47b0521..4271e46 100644 --- a/fronted/aplicacionrutasturisticas/lib/pages/star_page2.dart +++ b/fronted/aplicacionrutasturisticas/lib/pages/star_page2.dart @@ -1,3 +1,4 @@ +import 'package:aplicacionrutasturisticas/config/dio.dart'; import 'package:aplicacionrutasturisticas/utilerias/Perfil/AppBar_Perfil.dart'; import 'package:aplicacionrutasturisticas/utilerias/Perfil/Drawer_Perfil.dart'; import 'package:aplicacionrutasturisticas/generated/l10n.dart'; @@ -12,6 +13,30 @@ class StartedPage2 extends StatefulWidget { } class StartedPageState2 extends State { + String cityName = ""; + String cityDescription = ""; + + @override + void initState() { + super.initState(); + loadCityName(); + loadCityNameDescription(); + } + + void loadCityName() async { + String name = await datosStartPage(1); + setState(() { + cityName = name ?? 'Error al cargar el nombre de la ciudad'; + }); + } + + void loadCityNameDescription() async { + String description = await datosTextStartPage(1); + setState(() { + cityDescription = description ?? 'Error al cargar el nombre de la ciudad'; + }); + } + @override Widget build(BuildContext context) { return Scaffold( @@ -40,7 +65,7 @@ class StartedPageState2 extends State { Padding( padding: EdgeInsets.all(16.0), child: Text( - S.of(context).welcome_start_page, + S.of(context).welcome_start_page + cityName, style: const TextStyle( color: Colors.white, fontSize: 24, @@ -49,6 +74,14 @@ class StartedPageState2 extends State { textAlign: TextAlign.center, ), ), + const SizedBox(height: 20), + Center( + child: Padding( + padding: EdgeInsets.all(20.0), + child: Text(cityDescription, + style: const TextStyle(color: Colors.white, fontSize: 15), + textAlign: TextAlign.justify), + )) ], ), ), -- GitLab From 789db038b002a9e5430449d644f483b2d7c0961f Mon Sep 17 00:00:00 2001 From: Angel David Carlos Silva Date: Sat, 6 Jul 2024 13:20:04 -0600 Subject: [PATCH 11/19] Agregar un sistema de imagenes EL programa se agrego un carusel para obtener iamgenes atravez de firebasestroe_databases de google --- .../android/app/build.gradle | 3 + .../android/app/google-services.json | 48 ++++ .../android/app/src/main/AndroidManifest.xml | 3 +- .../android/settings.gradle | 3 + .../aplicacionrutasturisticas/firebase.json | 1 + .../ios/Runner/GoogleService-Info.plist | 30 +++ .../lib/config/dio.dart | 1 - .../lib/firebase_options.dart | 76 +++++++ .../aplicacionrutasturisticas/lib/main.dart | 9 +- .../images/star_page/images_starpage.dart | 38 ++++ .../star_page/obtener_imagenes_lista.dart | 31 +++ .../lib/pages/star_page2.dart | 34 ++- .../lib/utilerias/Carusels.dart | 30 +++ .../aplicacionrutasturisticas/pubspec.lock | 208 ++++++++++++++++++ .../aplicacionrutasturisticas/pubspec.yaml | 5 + .../flutter/generated_plugin_registrant.cc | 9 + .../windows/flutter/generated_plugins.cmake | 3 + 17 files changed, 523 insertions(+), 9 deletions(-) create mode 100644 fronted/aplicacionrutasturisticas/android/app/google-services.json create mode 100644 fronted/aplicacionrutasturisticas/firebase.json create mode 100644 fronted/aplicacionrutasturisticas/ios/Runner/GoogleService-Info.plist create mode 100644 fronted/aplicacionrutasturisticas/lib/firebase_options.dart create mode 100644 fronted/aplicacionrutasturisticas/lib/metodos/images/star_page/images_starpage.dart create mode 100644 fronted/aplicacionrutasturisticas/lib/metodos/images/star_page/obtener_imagenes_lista.dart create mode 100644 fronted/aplicacionrutasturisticas/lib/utilerias/Carusels.dart diff --git a/fronted/aplicacionrutasturisticas/android/app/build.gradle b/fronted/aplicacionrutasturisticas/android/app/build.gradle index b3bd10b..78bf98d 100644 --- a/fronted/aplicacionrutasturisticas/android/app/build.gradle +++ b/fronted/aplicacionrutasturisticas/android/app/build.gradle @@ -1,5 +1,8 @@ plugins { id "com.android.application" + // START: FlutterFire Configuration + id 'com.google.gms.google-services' + // END: FlutterFire Configuration id "kotlin-android" id "dev.flutter.flutter-gradle-plugin" } diff --git a/fronted/aplicacionrutasturisticas/android/app/google-services.json b/fronted/aplicacionrutasturisticas/android/app/google-services.json new file mode 100644 index 0000000..ff73e6a --- /dev/null +++ b/fronted/aplicacionrutasturisticas/android/app/google-services.json @@ -0,0 +1,48 @@ +{ + "project_info": { + "project_number": "121490225279", + "project_id": "rutas-a9c1d", + "storage_bucket": "rutas-a9c1d.appspot.com" + }, + "client": [ + { + "client_info": { + "mobilesdk_app_id": "1:121490225279:android:06e0216317235ce9f0a74a", + "android_client_info": { + "package_name": "com.aplicacionrutasturisticas.android" + } + }, + "oauth_client": [], + "api_key": [ + { + "current_key": "AIzaSyBMTmimLOKaCtevqhJLwIxE63rZdZgItO8" + } + ], + "services": { + "appinvite_service": { + "other_platform_oauth_client": [] + } + } + }, + { + "client_info": { + "mobilesdk_app_id": "1:121490225279:android:d75202951f20f9e9f0a74a", + "android_client_info": { + "package_name": "com.example.aplicacionrutasturisticas" + } + }, + "oauth_client": [], + "api_key": [ + { + "current_key": "AIzaSyBMTmimLOKaCtevqhJLwIxE63rZdZgItO8" + } + ], + "services": { + "appinvite_service": { + "other_platform_oauth_client": [] + } + } + } + ], + "configuration_version": "1" +} \ No newline at end of file diff --git a/fronted/aplicacionrutasturisticas/android/app/src/main/AndroidManifest.xml b/fronted/aplicacionrutasturisticas/android/app/src/main/AndroidManifest.xml index f031770..2523646 100644 --- a/fronted/aplicacionrutasturisticas/android/app/src/main/AndroidManifest.xml +++ b/fronted/aplicacionrutasturisticas/android/app/src/main/AndroidManifest.xml @@ -1,4 +1,5 @@ - + + + + + API_KEY + AIzaSyBbi3oeS7mOhZX8aRt3T9N-HU7tnIUzxDM + GCM_SENDER_ID + 121490225279 + PLIST_VERSION + 1 + BUNDLE_ID + com.aplicacionrutaturistica.ios + PROJECT_ID + rutas-a9c1d + STORAGE_BUCKET + rutas-a9c1d.appspot.com + IS_ADS_ENABLED + + IS_ANALYTICS_ENABLED + + IS_APPINVITE_ENABLED + + IS_GCM_ENABLED + + IS_SIGNIN_ENABLED + + GOOGLE_APP_ID + 1:121490225279:ios:b2b0d8ace3257f5af0a74a + + \ No newline at end of file diff --git a/fronted/aplicacionrutasturisticas/lib/config/dio.dart b/fronted/aplicacionrutasturisticas/lib/config/dio.dart index 84036cd..8f3ba58 100644 --- a/fronted/aplicacionrutasturisticas/lib/config/dio.dart +++ b/fronted/aplicacionrutasturisticas/lib/config/dio.dart @@ -46,7 +46,6 @@ Future datosTextStartPage(int cityId) async { if (responseCity.statusCode == 200) { dynamic cityData = responseCity.data; String cityDes = cityData['description'].toString(); - print(cityData.toString()); return cityDes; } else { return "Cargando...."; diff --git a/fronted/aplicacionrutasturisticas/lib/firebase_options.dart b/fronted/aplicacionrutasturisticas/lib/firebase_options.dart new file mode 100644 index 0000000..be0490c --- /dev/null +++ b/fronted/aplicacionrutasturisticas/lib/firebase_options.dart @@ -0,0 +1,76 @@ +// File generated by FlutterFire CLI. +// ignore_for_file: type=lint +import 'package:firebase_core/firebase_core.dart' show FirebaseOptions; +import 'package:flutter/foundation.dart' + show defaultTargetPlatform, kIsWeb, TargetPlatform; + +/// Default [FirebaseOptions] for use with your Firebase apps. +/// +/// Example: +/// ```dart +/// import 'firebase_options.dart'; +/// // ... +/// await Firebase.initializeApp( +/// options: DefaultFirebaseOptions.currentPlatform, +/// ); +/// ``` +class DefaultFirebaseOptions { + static FirebaseOptions get currentPlatform { + if (kIsWeb) { + throw UnsupportedError( + 'DefaultFirebaseOptions have not been configured for web - ' + 'you can reconfigure this by running the FlutterFire CLI again.', + ); + } + switch (defaultTargetPlatform) { + case TargetPlatform.android: + return android; + case TargetPlatform.iOS: + return ios; + case TargetPlatform.macOS: + throw UnsupportedError( + 'DefaultFirebaseOptions have not been configured for macos - ' + 'you can reconfigure this by running the FlutterFire CLI again.', + ); + case TargetPlatform.windows: + return windows; + case TargetPlatform.linux: + throw UnsupportedError( + 'DefaultFirebaseOptions have not been configured for linux - ' + 'you can reconfigure this by running the FlutterFire CLI again.', + ); + default: + throw UnsupportedError( + 'DefaultFirebaseOptions are not supported for this platform.', + ); + } + } + + static const FirebaseOptions android = FirebaseOptions( + apiKey: 'AIzaSyBMTmimLOKaCtevqhJLwIxE63rZdZgItO8', + appId: '1:121490225279:android:d75202951f20f9e9f0a74a', + messagingSenderId: '121490225279', + projectId: 'rutas-a9c1d', + storageBucket: 'rutas-a9c1d.appspot.com', + ); + + static const FirebaseOptions ios = FirebaseOptions( + apiKey: 'AIzaSyBbi3oeS7mOhZX8aRt3T9N-HU7tnIUzxDM', + appId: '1:121490225279:ios:ba1813516d46015bf0a74a', + messagingSenderId: '121490225279', + projectId: 'rutas-a9c1d', + storageBucket: 'rutas-a9c1d.appspot.com', + iosBundleId: 'com.example.aplicacionrutasturisticas', + ); + + static const FirebaseOptions windows = FirebaseOptions( + apiKey: 'AIzaSyDFfsust5E8ibfp2q4EsydMbz3yZ41cQmQ', + appId: '1:121490225279:web:8d3c4a52da16f22bf0a74a', + messagingSenderId: '121490225279', + projectId: 'rutas-a9c1d', + authDomain: 'rutas-a9c1d.firebaseapp.com', + storageBucket: 'rutas-a9c1d.appspot.com', + measurementId: 'G-F08WD3VKP3', + ); + +} \ No newline at end of file diff --git a/fronted/aplicacionrutasturisticas/lib/main.dart b/fronted/aplicacionrutasturisticas/lib/main.dart index 5665054..fbb8237 100644 --- a/fronted/aplicacionrutasturisticas/lib/main.dart +++ b/fronted/aplicacionrutasturisticas/lib/main.dart @@ -1,11 +1,18 @@ import 'package:flutter/material.dart'; import 'package:flutter_localizations/flutter_localizations.dart'; import 'package:provider/provider.dart'; +import 'package:firebase_core/firebase_core.dart'; +import 'firebase_options.dart'; import 'package:aplicacionrutasturisticas/config/router.dart'; import 'package:aplicacionrutasturisticas/config/idioma/locale_provider.dart'; import 'generated/l10n.dart'; -void main() { +void main() async { + WidgetsFlutterBinding + .ensureInitialized(); // Asegura que Flutter esté inicializado + await Firebase.initializeApp( + options: DefaultFirebaseOptions.currentPlatform, + ); runApp(MyApp()); } diff --git a/fronted/aplicacionrutasturisticas/lib/metodos/images/star_page/images_starpage.dart b/fronted/aplicacionrutasturisticas/lib/metodos/images/star_page/images_starpage.dart new file mode 100644 index 0000000..8fcb0fc --- /dev/null +++ b/fronted/aplicacionrutasturisticas/lib/metodos/images/star_page/images_starpage.dart @@ -0,0 +1,38 @@ +import 'package:aplicacionrutasturisticas/metodos/images/star_page/obtener_imagenes_lista.dart'; +import 'package:flutter/material.dart'; +import 'package:firebase_storage/firebase_storage.dart' as firebase_storage; +import 'package:cached_network_image/cached_network_image.dart'; +import 'package:firebase_auth/firebase_auth.dart'; + +class ImagenSola extends StatefulWidget { + @override + _ImagenSolaState createState() => _ImagenSolaState(); +} + +class _ImagenSolaState extends State { + String imageURL = ""; + @override + void initState() { + super.initState(); + // Llamar a getImageUrl en initState para obtener la URL de la imagen cuando se inicie el widget + getImageUrl(); + } + + Future getImageUrl() async { + try { + firebase_storage.Reference ref = firebase_storage.FirebaseStorage.instance + .ref('zacatecas/zacatecas-mexico-street-sunshine.jpeg'); + + // Obtener la URL del archivo + String downloadUrl = await ref.getDownloadURL(); + imageURL = downloadUrl; + } catch (e) { + print('Error al obtener la URL de la imagen: $e'); + } + } + + @override + Widget build(BuildContext context) { + return Image.network(imageURL); + } +} diff --git a/fronted/aplicacionrutasturisticas/lib/metodos/images/star_page/obtener_imagenes_lista.dart b/fronted/aplicacionrutasturisticas/lib/metodos/images/star_page/obtener_imagenes_lista.dart new file mode 100644 index 0000000..96af0c8 --- /dev/null +++ b/fronted/aplicacionrutasturisticas/lib/metodos/images/star_page/obtener_imagenes_lista.dart @@ -0,0 +1,31 @@ +import 'package:flutter/material.dart'; +import 'package:firebase_storage/firebase_storage.dart' as firebase_storage; +import 'package:cached_network_image/cached_network_image.dart'; +import 'package:firebase_auth/firebase_auth.dart'; + +class ImagenesDesdeStorage { + Future> ImagesFromStorage(String tu_carpeta) async { + List imageURLs = []; + + // Aquí definimos la carpeta específica de la que queremos obtener las imágenes + String folderPath = tu_carpeta; + try { + // Obtenemos la referencia a la carpeta en Firebase Storage + firebase_storage.ListResult listResult = await firebase_storage + .FirebaseStorage.instance + .ref(tu_carpeta) + .list(); + + // Iteramos sobre los elementos en la carpeta + for (firebase_storage.Reference ref in listResult.items) { + // Obtenemos la URL de descarga del archivo + String downloadURL = await ref.getDownloadURL(); + imageURLs.add(downloadURL); + } + } catch (e) { + print("Error: " + e.toString()); + } + + return imageURLs; + } +} diff --git a/fronted/aplicacionrutasturisticas/lib/pages/star_page2.dart b/fronted/aplicacionrutasturisticas/lib/pages/star_page2.dart index 4271e46..807e6ec 100644 --- a/fronted/aplicacionrutasturisticas/lib/pages/star_page2.dart +++ b/fronted/aplicacionrutasturisticas/lib/pages/star_page2.dart @@ -1,4 +1,7 @@ import 'package:aplicacionrutasturisticas/config/dio.dart'; +import 'package:aplicacionrutasturisticas/metodos/images/star_page/images_starpage.dart'; +import 'package:aplicacionrutasturisticas/metodos/images/star_page/obtener_imagenes_lista.dart'; +import 'package:aplicacionrutasturisticas/utilerias/Carusels.dart'; import 'package:aplicacionrutasturisticas/utilerias/Perfil/AppBar_Perfil.dart'; import 'package:aplicacionrutasturisticas/utilerias/Perfil/Drawer_Perfil.dart'; import 'package:aplicacionrutasturisticas/generated/l10n.dart'; @@ -15,12 +18,15 @@ class StartedPage2 extends StatefulWidget { class StartedPageState2 extends State { String cityName = ""; String cityDescription = ""; + List imgList = []; + bool isLoading = true; @override void initState() { super.initState(); loadCityName(); loadCityNameDescription(); + loadImgList(); } void loadCityName() async { @@ -37,6 +43,15 @@ class StartedPageState2 extends State { }); } + void loadImgList() async { + ImagenesDesdeStorage ima = ImagenesDesdeStorage(); + List urls = await ima.ImagesFromStorage("zacatecas/"); + setState(() { + imgList = urls; + isLoading = false; + }); + } + @override Widget build(BuildContext context) { return Scaffold( @@ -75,13 +90,20 @@ class StartedPageState2 extends State { ), ), const SizedBox(height: 20), + isLoading + ? Center(child: CupertinoActivityIndicator()) + : carusel_images_list(imgList: imgList), + const SizedBox(height: 5), Center( child: Padding( - padding: EdgeInsets.all(20.0), - child: Text(cityDescription, - style: const TextStyle(color: Colors.white, fontSize: 15), - textAlign: TextAlign.justify), - )) + padding: EdgeInsets.all(20.0), + child: Container( + child: Text(cityDescription, + style: const TextStyle( + color: Colors.white, fontSize: 15), + textAlign: TextAlign.justify), + ))), + const SizedBox(height: 80) ], ), ), @@ -89,7 +111,7 @@ class StartedPageState2 extends State { Padding( padding: const EdgeInsets.symmetric(horizontal: 10.0), child: DraggableScrollableSheet( - initialChildSize: 0.3, + initialChildSize: 0.2, minChildSize: 0.1, builder: (BuildContext context, ScrollController scrollController) { diff --git a/fronted/aplicacionrutasturisticas/lib/utilerias/Carusels.dart b/fronted/aplicacionrutasturisticas/lib/utilerias/Carusels.dart new file mode 100644 index 0000000..a97c5e9 --- /dev/null +++ b/fronted/aplicacionrutasturisticas/lib/utilerias/Carusels.dart @@ -0,0 +1,30 @@ +import 'package:flutter/material.dart'; +import 'package:carousel_slider/carousel_slider.dart'; + +class carusel_images_list extends StatelessWidget { + final List imgList; + + const carusel_images_list({Key? key, required this.imgList}) + : super(key: key); + + @override + Widget build(BuildContext context) { + return CarouselSlider( + items: imgList + .map((item) => Center( + child: ClipRRect( + borderRadius: BorderRadius.circular(20), + child: Image.network(item, fit: BoxFit.cover, width: 1000), + ))) + .toList(), + options: CarouselOptions( + height: 200.0, + autoPlay: true, + autoPlayInterval: Duration(seconds: 5), + autoPlayAnimationDuration: Duration(milliseconds: 800), + autoPlayCurve: Curves.easeIn, + pauseAutoPlayOnTouch: true, + scrollDirection: Axis.horizontal, + enlargeCenterPage: true)); + } +} diff --git a/fronted/aplicacionrutasturisticas/pubspec.lock b/fronted/aplicacionrutasturisticas/pubspec.lock index 1588cfe..e08eff2 100644 --- a/fronted/aplicacionrutasturisticas/pubspec.lock +++ b/fronted/aplicacionrutasturisticas/pubspec.lock @@ -9,6 +9,14 @@ packages: url: "https://pub.dev" source: hosted version: "67.0.0" + _flutterfire_internals: + dependency: transitive + description: + name: _flutterfire_internals + sha256: "37a42d06068e2fe3deddb2da079a8c4d105f241225ba27b7122b37e9865fd8f7" + url: "https://pub.dev" + source: hosted + version: "1.3.35" analyzer: dependency: transitive description: @@ -49,6 +57,38 @@ packages: url: "https://pub.dev" source: hosted version: "2.1.1" + cached_network_image: + dependency: "direct main" + description: + name: cached_network_image + sha256: "28ea9690a8207179c319965c13cd8df184d5ee721ae2ce60f398ced1219cea1f" + url: "https://pub.dev" + source: hosted + version: "3.3.1" + cached_network_image_platform_interface: + dependency: transitive + description: + name: cached_network_image_platform_interface + sha256: "9e90e78ae72caa874a323d78fa6301b3fb8fa7ea76a8f96dc5b5bf79f283bf2f" + url: "https://pub.dev" + source: hosted + version: "4.0.0" + cached_network_image_web: + dependency: transitive + description: + name: cached_network_image_web + sha256: "205d6a9f1862de34b93184f22b9d2d94586b2f05c581d546695e3d8f6a805cd7" + url: "https://pub.dev" + source: hosted + version: "1.2.0" + carousel_slider: + dependency: "direct main" + description: + name: carousel_slider + sha256: "9c695cc963bf1d04a47bd6021f68befce8970bcd61d24938e1fb0918cf5d9c42" + url: "https://pub.dev" + source: hosted + version: "4.2.1" characters: dependency: transitive description: @@ -137,11 +177,99 @@ packages: url: "https://pub.dev" source: hosted version: "7.0.0" + firebase_auth: + dependency: "direct main" + description: + name: firebase_auth + sha256: cfc2d970829202eca09e2896f0a5aa7c87302817ecc0bdfa954f026046bf10ba + url: "https://pub.dev" + source: hosted + version: "4.20.0" + firebase_auth_platform_interface: + dependency: transitive + description: + name: firebase_auth_platform_interface + sha256: a0270e1db3b2098a14cb2a2342b3cd2e7e458e0c391b1f64f6f78b14296ec093 + url: "https://pub.dev" + source: hosted + version: "7.3.0" + firebase_auth_web: + dependency: transitive + description: + name: firebase_auth_web + sha256: "64e067e763c6378b7e774e872f0f59f6812885e43020e25cde08f42e9459837b" + url: "https://pub.dev" + source: hosted + version: "5.12.0" + firebase_core: + dependency: "direct main" + description: + name: firebase_core + sha256: "26de145bb9688a90962faec6f838247377b0b0d32cc0abecd9a4e43525fc856c" + url: "https://pub.dev" + source: hosted + version: "2.32.0" + firebase_core_platform_interface: + dependency: transitive + description: + name: firebase_core_platform_interface + sha256: "1003a5a03a61fc9a22ef49f37cbcb9e46c86313a7b2e7029b9390cf8c6fc32cb" + url: "https://pub.dev" + source: hosted + version: "5.1.0" + firebase_core_web: + dependency: transitive + description: + name: firebase_core_web + sha256: "6643fe3dbd021e6ccfb751f7882b39df355708afbdeb4130fc50f9305a9d1a3d" + url: "https://pub.dev" + source: hosted + version: "2.17.2" + firebase_storage: + dependency: "direct main" + description: + name: firebase_storage + sha256: "2ae478ceec9f458c1bcbf0ee3e0100e4e909708979e83f16d5d9fba35a5b42c1" + url: "https://pub.dev" + source: hosted + version: "11.7.7" + firebase_storage_platform_interface: + dependency: transitive + description: + name: firebase_storage_platform_interface + sha256: "4e18662e6a66e2e0e181c06f94707de06d5097d70cfe2b5141bf64660c5b5da9" + url: "https://pub.dev" + source: hosted + version: "5.1.22" + firebase_storage_web: + dependency: transitive + description: + name: firebase_storage_web + sha256: "3a44aacd38a372efb159f6fe36bb4a7d79823949383816457fd43d3d47602a53" + url: "https://pub.dev" + source: hosted + version: "3.9.7" + fixnum: + dependency: transitive + description: + name: fixnum + sha256: "25517a4deb0c03aa0f32fd12db525856438902d9c16536311e76cdc57b31d7d1" + url: "https://pub.dev" + source: hosted + version: "1.1.0" flutter: dependency: "direct main" description: flutter source: sdk version: "0.0.0" + flutter_cache_manager: + dependency: transitive + description: + name: flutter_cache_manager + sha256: "395d6b7831f21f3b989ebedbb785545932adb9afe2622c1ffacf7f4b53a7e544" + url: "https://pub.dev" + source: hosted + version: "3.3.2" flutter_lints: dependency: "direct dev" description: @@ -293,6 +421,14 @@ packages: url: "https://pub.dev" source: hosted version: "1.0.0" + octo_image: + dependency: transitive + description: + name: octo_image + sha256: "45b40f99622f11901238e18d48f5f12ea36426d8eced9f4cbf58479c7aa2430d" + url: "https://pub.dev" + source: hosted + version: "2.0.0" package_config: dependency: transitive description: @@ -309,6 +445,30 @@ packages: url: "https://pub.dev" source: hosted version: "1.9.0" + path_provider: + dependency: transitive + description: + name: path_provider + sha256: c9e7d3a4cd1410877472158bee69963a4579f78b68c65a2b7d40d1a7a88bb161 + url: "https://pub.dev" + source: hosted + version: "2.1.3" + path_provider_android: + dependency: transitive + description: + name: path_provider_android + sha256: a248d8146ee5983446bf03ed5ea8f6533129a12b11f12057ad1b4a67a2b3b41d + url: "https://pub.dev" + source: hosted + version: "2.2.4" + path_provider_foundation: + dependency: transitive + description: + name: path_provider_foundation + sha256: f234384a3fdd67f989b4d54a5d73ca2a6c422fa55ae694381ae0f4375cd1ea16 + url: "https://pub.dev" + source: hosted + version: "2.4.0" path_provider_linux: dependency: transitive description: @@ -373,6 +533,14 @@ packages: url: "https://pub.dev" source: hosted version: "2.1.4" + rxdart: + dependency: transitive + description: + name: rxdart + sha256: "0c7c0cedd93788d996e33041ffecda924cc54389199cde4e6a34b440f50044cb" + url: "https://pub.dev" + source: hosted + version: "0.27.7" shared_preferences: dependency: "direct main" description: @@ -442,6 +610,30 @@ packages: url: "https://pub.dev" source: hosted version: "1.10.0" + sprintf: + dependency: transitive + description: + name: sprintf + sha256: "1fc9ffe69d4df602376b52949af107d8f5703b77cda567c4d7d86a0693120f23" + url: "https://pub.dev" + source: hosted + version: "7.0.0" + sqflite: + dependency: transitive + description: + name: sqflite + sha256: a43e5a27235518c03ca238e7b4732cf35eabe863a369ceba6cbefa537a66f16d + url: "https://pub.dev" + source: hosted + version: "2.3.3+1" + sqflite_common: + dependency: transitive + description: + name: sqflite_common + sha256: "3da423ce7baf868be70e2c0976c28a1bb2f73644268b7ffa7d2e08eab71f16a4" + url: "https://pub.dev" + source: hosted + version: "2.5.4" stack_trace: dependency: transitive description: @@ -466,6 +658,14 @@ packages: url: "https://pub.dev" source: hosted version: "1.2.0" + synchronized: + dependency: transitive + description: + name: synchronized + sha256: "539ef412b170d65ecdafd780f924e5be3f60032a1128df156adad6c5b373d558" + url: "https://pub.dev" + source: hosted + version: "3.1.0+1" term_glyph: dependency: transitive description: @@ -490,6 +690,14 @@ packages: url: "https://pub.dev" source: hosted version: "1.3.2" + uuid: + dependency: transitive + description: + name: uuid + sha256: "814e9e88f21a176ae1359149021870e87f7cddaf633ab678a5d2b0bff7fd1ba8" + url: "https://pub.dev" + source: hosted + version: "4.4.0" vector_math: dependency: transitive description: diff --git a/fronted/aplicacionrutasturisticas/pubspec.yaml b/fronted/aplicacionrutasturisticas/pubspec.yaml index 45d79c7..09b012d 100644 --- a/fronted/aplicacionrutasturisticas/pubspec.yaml +++ b/fronted/aplicacionrutasturisticas/pubspec.yaml @@ -40,6 +40,11 @@ dependencies: go_router: ^13.2.4 dio: ^5.4.3+1 intl: ^0.18.1 + firebase_core: ^2.32.0 + firebase_storage: ^11.7.7 + firebase_auth: ^4.8.1 + cached_network_image: ^3.3.1 + carousel_slider: ^4.0.0 dev_dependencies: diff --git a/fronted/aplicacionrutasturisticas/windows/flutter/generated_plugin_registrant.cc b/fronted/aplicacionrutasturisticas/windows/flutter/generated_plugin_registrant.cc index 8b6d468..6013891 100644 --- a/fronted/aplicacionrutasturisticas/windows/flutter/generated_plugin_registrant.cc +++ b/fronted/aplicacionrutasturisticas/windows/flutter/generated_plugin_registrant.cc @@ -6,6 +6,15 @@ #include "generated_plugin_registrant.h" +#include +#include +#include void RegisterPlugins(flutter::PluginRegistry* registry) { + FirebaseAuthPluginCApiRegisterWithRegistrar( + registry->GetRegistrarForPlugin("FirebaseAuthPluginCApi")); + FirebaseCorePluginCApiRegisterWithRegistrar( + registry->GetRegistrarForPlugin("FirebaseCorePluginCApi")); + FirebaseStoragePluginCApiRegisterWithRegistrar( + registry->GetRegistrarForPlugin("FirebaseStoragePluginCApi")); } diff --git a/fronted/aplicacionrutasturisticas/windows/flutter/generated_plugins.cmake b/fronted/aplicacionrutasturisticas/windows/flutter/generated_plugins.cmake index b93c4c3..3976ac4 100644 --- a/fronted/aplicacionrutasturisticas/windows/flutter/generated_plugins.cmake +++ b/fronted/aplicacionrutasturisticas/windows/flutter/generated_plugins.cmake @@ -3,6 +3,9 @@ # list(APPEND FLUTTER_PLUGIN_LIST + firebase_auth + firebase_core + firebase_storage ) list(APPEND FLUTTER_FFI_PLUGIN_LIST -- GitLab From 6aec60174adb2b772d32db0a99805670338cde82 Mon Sep 17 00:00:00 2001 From: Angel David Carlos Silva Date: Sat, 6 Jul 2024 15:06:46 -0600 Subject: [PATCH 12/19] Restructuracion para el cambio de idioma se restructuro los archivos que son necesarios para el cambio de idioma que son de palabras locales de la aplicacion --- fronted/aplicacionrutasturisticas/lib/main.dart | 2 +- .../lib/metodos/cambio_idioma.dart | 11 ++--------- .../locale_translade_provider.dart} | 0 .../lib/variables/perfil_variables.dart | 8 ++++++-- 4 files changed, 9 insertions(+), 12 deletions(-) rename fronted/aplicacionrutasturisticas/lib/{config/idioma/locale_provider.dart => providers/locale_translade_provider.dart} (100%) diff --git a/fronted/aplicacionrutasturisticas/lib/main.dart b/fronted/aplicacionrutasturisticas/lib/main.dart index fbb8237..c0b48a6 100644 --- a/fronted/aplicacionrutasturisticas/lib/main.dart +++ b/fronted/aplicacionrutasturisticas/lib/main.dart @@ -4,7 +4,7 @@ import 'package:provider/provider.dart'; import 'package:firebase_core/firebase_core.dart'; import 'firebase_options.dart'; import 'package:aplicacionrutasturisticas/config/router.dart'; -import 'package:aplicacionrutasturisticas/config/idioma/locale_provider.dart'; +import 'package:aplicacionrutasturisticas/providers/locale_translade_provider.dart'; import 'generated/l10n.dart'; void main() async { diff --git a/fronted/aplicacionrutasturisticas/lib/metodos/cambio_idioma.dart b/fronted/aplicacionrutasturisticas/lib/metodos/cambio_idioma.dart index ffab696..a2b2084 100644 --- a/fronted/aplicacionrutasturisticas/lib/metodos/cambio_idioma.dart +++ b/fronted/aplicacionrutasturisticas/lib/metodos/cambio_idioma.dart @@ -1,19 +1,12 @@ import 'package:aplicacionrutasturisticas/variables/perfil_variables.dart' as globals; -import 'package:aplicacionrutasturisticas/config/idioma/locale_provider.dart'; +import 'package:aplicacionrutasturisticas/providers/locale_translade_provider.dart'; import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; class CambiarIdioma { void verificarCambio(BuildContext context) { final provider = Provider.of(context, listen: false); - print(globals.getLenguaje); - if (globals.getLenguaje == "Inglés") { - print("Inglessss"); - provider.setLocale(Locale('en')); - } else if (globals.getLenguaje == "Español") { - provider.setLocale(Locale('es')); - print("Es"); - } + provider.setLocale(Locale(globals.getLenguaje)); } } diff --git a/fronted/aplicacionrutasturisticas/lib/config/idioma/locale_provider.dart b/fronted/aplicacionrutasturisticas/lib/providers/locale_translade_provider.dart similarity index 100% rename from fronted/aplicacionrutasturisticas/lib/config/idioma/locale_provider.dart rename to fronted/aplicacionrutasturisticas/lib/providers/locale_translade_provider.dart diff --git a/fronted/aplicacionrutasturisticas/lib/variables/perfil_variables.dart b/fronted/aplicacionrutasturisticas/lib/variables/perfil_variables.dart index b7298b5..a048286 100644 --- a/fronted/aplicacionrutasturisticas/lib/variables/perfil_variables.dart +++ b/fronted/aplicacionrutasturisticas/lib/variables/perfil_variables.dart @@ -1,7 +1,11 @@ -String idioma = "Español"; +String idioma = "es"; String get getLenguaje => idioma; set setLenguaje(String lenguaje) { - idioma = lenguaje; + if (lenguaje == "Inglés") { + idioma = 'en'; + } else if (lenguaje == "Español") { + idioma = 'es'; + } } -- GitLab From 1d1e5ee7740fd86bb4c5b33a34aece054d345fa0 Mon Sep 17 00:00:00 2001 From: Angel David Carlos Silva Date: Mon, 8 Jul 2024 11:58:10 -0600 Subject: [PATCH 13/19] Traducciones dinamicas Se integro el sistema de traduccion para la base de datos, usando la API de google --- .../aplicacionrutasturisticas/lib/main.dart | 20 ++++++--- .../lib/metodos/cambio_idioma.dart | 10 ++++- .../lib/pages/star_page2.dart | 30 +++++++------ .../database_translade_provider.dart | 45 +++++++++++++++++++ .../lib/utilerias/FutureBuilder.dart | 32 +++++++++++++ .../Perfil/CupertinoPicker_Perfil.dart | 24 ++++++---- .../aplicacionrutasturisticas/pubspec.lock | 10 ++--- .../aplicacionrutasturisticas/pubspec.yaml | 4 +- 8 files changed, 138 insertions(+), 37 deletions(-) create mode 100644 fronted/aplicacionrutasturisticas/lib/providers/database_translade_provider.dart create mode 100644 fronted/aplicacionrutasturisticas/lib/utilerias/FutureBuilder.dart diff --git a/fronted/aplicacionrutasturisticas/lib/main.dart b/fronted/aplicacionrutasturisticas/lib/main.dart index c0b48a6..717df46 100644 --- a/fronted/aplicacionrutasturisticas/lib/main.dart +++ b/fronted/aplicacionrutasturisticas/lib/main.dart @@ -5,11 +5,11 @@ import 'package:firebase_core/firebase_core.dart'; import 'firebase_options.dart'; import 'package:aplicacionrutasturisticas/config/router.dart'; import 'package:aplicacionrutasturisticas/providers/locale_translade_provider.dart'; +import 'package:aplicacionrutasturisticas/providers/database_translade_provider.dart'; import 'generated/l10n.dart'; void main() async { - WidgetsFlutterBinding - .ensureInitialized(); // Asegura que Flutter esté inicializado + WidgetsFlutterBinding.ensureInitialized(); await Firebase.initializeApp( options: DefaultFirebaseOptions.currentPlatform, ); @@ -19,10 +19,17 @@ void main() async { class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { - return ChangeNotifierProvider( - create: (_) => LocaleProvider(), - child: Consumer( - builder: (context, localeProvider, child) { + return MultiProvider( + providers: [ + ChangeNotifierProvider( + create: (_) => LocaleProvider(), + ), + ChangeNotifierProvider( + create: (_) => TranslationProvider(), + ), + ], + child: Consumer2( + builder: (context, localeProvider, translationProvider, child) { return MaterialApp.router( locale: localeProvider.locale, supportedLocales: S.delegate.supportedLocales, @@ -40,5 +47,6 @@ class MyApp extends StatelessWidget { } } + // Recuerda usar el comando cada vez que actualices los idiomas //flutter pub run intl_utils:generate \ No newline at end of file diff --git a/fronted/aplicacionrutasturisticas/lib/metodos/cambio_idioma.dart b/fronted/aplicacionrutasturisticas/lib/metodos/cambio_idioma.dart index a2b2084..41829c0 100644 --- a/fronted/aplicacionrutasturisticas/lib/metodos/cambio_idioma.dart +++ b/fronted/aplicacionrutasturisticas/lib/metodos/cambio_idioma.dart @@ -1,3 +1,4 @@ +import 'package:aplicacionrutasturisticas/providers/database_translade_provider.dart'; import 'package:aplicacionrutasturisticas/variables/perfil_variables.dart' as globals; import 'package:aplicacionrutasturisticas/providers/locale_translade_provider.dart'; @@ -5,8 +6,15 @@ import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; class CambiarIdioma { - void verificarCambio(BuildContext context) { + // Método para cambiar el idioma del texto fijo + void cambiarIdiomaLocal(BuildContext context) { final provider = Provider.of(context, listen: false); provider.setLocale(Locale(globals.getLenguaje)); } + + // Método para cambiar dinámicamente el idioma del texto + Future cambiarIdiomaDinamico(BuildContext context, String texto) { + return Provider.of(context, listen: false) + .translateText(texto); + } } diff --git a/fronted/aplicacionrutasturisticas/lib/pages/star_page2.dart b/fronted/aplicacionrutasturisticas/lib/pages/star_page2.dart index 807e6ec..aadaa99 100644 --- a/fronted/aplicacionrutasturisticas/lib/pages/star_page2.dart +++ b/fronted/aplicacionrutasturisticas/lib/pages/star_page2.dart @@ -1,12 +1,14 @@ import 'package:aplicacionrutasturisticas/config/dio.dart'; -import 'package:aplicacionrutasturisticas/metodos/images/star_page/images_starpage.dart'; import 'package:aplicacionrutasturisticas/metodos/images/star_page/obtener_imagenes_lista.dart'; +import 'package:aplicacionrutasturisticas/utilerias/FutureBuilder.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter/cupertino.dart'; +import 'package:provider/provider.dart'; +import 'package:aplicacionrutasturisticas/generated/l10n.dart'; +import 'package:aplicacionrutasturisticas/providers/database_translade_provider.dart'; import 'package:aplicacionrutasturisticas/utilerias/Carusels.dart'; import 'package:aplicacionrutasturisticas/utilerias/Perfil/AppBar_Perfil.dart'; import 'package:aplicacionrutasturisticas/utilerias/Perfil/Drawer_Perfil.dart'; -import 'package:aplicacionrutasturisticas/generated/l10n.dart'; -import 'package:flutter/cupertino.dart'; -import 'package:flutter/material.dart'; class StartedPage2 extends StatefulWidget { const StartedPage2({super.key}); @@ -39,7 +41,8 @@ class StartedPageState2 extends State { void loadCityNameDescription() async { String description = await datosTextStartPage(1); setState(() { - cityDescription = description ?? 'Error al cargar el nombre de la ciudad'; + cityDescription = + description ?? 'Error al cargar la descripción de la ciudad'; }); } @@ -54,6 +57,7 @@ class StartedPageState2 extends State { @override Widget build(BuildContext context) { + final translationProvider = Provider.of(context); return Scaffold( body: Stack( children: [ @@ -95,19 +99,17 @@ class StartedPageState2 extends State { : carusel_images_list(imgList: imgList), const SizedBox(height: 5), Center( - child: Padding( - padding: EdgeInsets.all(20.0), - child: Container( - child: Text(cityDescription, - style: const TextStyle( - color: Colors.white, fontSize: 15), - textAlign: TextAlign.justify), - ))), + child: Padding( + padding: EdgeInsets.all(20.0), + child: + Container(child: textoDinamico(texto: cityDescription)), + ), + ), const SizedBox(height: 80) ], ), ), - AppBar_Perfil(), //Este app se establece en el body, para que no genere conflictos de colicion + AppBar_Perfil(), //Este app se establece en el body, para que no genere conflictos de colision Padding( padding: const EdgeInsets.symmetric(horizontal: 10.0), child: DraggableScrollableSheet( diff --git a/fronted/aplicacionrutasturisticas/lib/providers/database_translade_provider.dart b/fronted/aplicacionrutasturisticas/lib/providers/database_translade_provider.dart new file mode 100644 index 0000000..9031dfc --- /dev/null +++ b/fronted/aplicacionrutasturisticas/lib/providers/database_translade_provider.dart @@ -0,0 +1,45 @@ +import 'package:flutter/material.dart'; +import 'package:dio/dio.dart'; +import 'package:aplicacionrutasturisticas/variables/perfil_variables.dart' + as globals; + +class TranslationProvider with ChangeNotifier { + final dio = Dio(); + final apiKey = 'AIzaSyCy0fR6vgP-I8bPe9C_rFFP8ZiHpOwQz6w'; + + Future translateText(String text) async { + try { + // Validar si el idioma de destino es español ('es') + String targetLanguage = + globals.getLenguaje == 'es' ? 'es' : globals.getLenguaje; + + Response response = await dio.post( + 'https://translation.googleapis.com/language/translate/v2', + queryParameters: { + 'key': apiKey, + 'q': text, + 'source': + 'es', // Código del idioma de origen (siempre es español aquí) + 'target': targetLanguage, // Código del idioma de destino + }, + ); + + if (response.statusCode == 200) { + print( + "Translated text: ${response.data['data']['translations'][0]['translatedText']}"); + return response.data['data']['translations'][0]['translatedText']; + } else { + print("Error status code: ${response.statusCode}"); + return text; + } + } catch (e) { + print("Error translating text: $e"); + return text; + } + } + + void changeLanguage(String language) { + globals.setLenguaje = language; + notifyListeners(); // Notificar cambios a los listeners (como FutureBuilder) + } +} diff --git a/fronted/aplicacionrutasturisticas/lib/utilerias/FutureBuilder.dart b/fronted/aplicacionrutasturisticas/lib/utilerias/FutureBuilder.dart new file mode 100644 index 0000000..288a6a3 --- /dev/null +++ b/fronted/aplicacionrutasturisticas/lib/utilerias/FutureBuilder.dart @@ -0,0 +1,32 @@ +import 'package:flutter/material.dart'; +import 'package:provider/provider.dart'; +import 'package:aplicacionrutasturisticas/metodos/cambio_idioma.dart'; + +class textoDinamico extends StatelessWidget { + final String texto; + + const textoDinamico({Key? key, required this.texto}) : super(key: key); + + @override + Widget build(BuildContext context) { + return FutureBuilder( + future: CambiarIdioma().cambiarIdiomaDinamico(context, texto), + builder: (context, AsyncSnapshot snapshot) { + if (snapshot.connectionState == ConnectionState.waiting) { + return CircularProgressIndicator(); + } else if (snapshot.hasError) { + return const Text('Error al cargar la descripción'); + } else { + return Text( + snapshot.data ?? 'Cargando...', + style: const TextStyle( + color: Colors.white, + fontSize: 15, + ), + textAlign: TextAlign.justify, + ); + } + }, + ); + } +} diff --git a/fronted/aplicacionrutasturisticas/lib/utilerias/Perfil/CupertinoPicker_Perfil.dart b/fronted/aplicacionrutasturisticas/lib/utilerias/Perfil/CupertinoPicker_Perfil.dart index ec33d13..00d4ed6 100644 --- a/fronted/aplicacionrutasturisticas/lib/utilerias/Perfil/CupertinoPicker_Perfil.dart +++ b/fronted/aplicacionrutasturisticas/lib/utilerias/Perfil/CupertinoPicker_Perfil.dart @@ -1,11 +1,12 @@ -import 'package:aplicacionrutasturisticas/metodos/cambio_idioma.dart'; import 'package:aplicacionrutasturisticas/generated/l10n.dart'; -import 'package:aplicacionrutasturisticas/metodos/perfil_metodos.dart'; -import 'package:aplicacionrutasturisticas/utilerias/MensajeEnMEdio.dart'; -import 'package:aplicacionrutasturisticas/variables/perfil_variables.dart' - as globals; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; +import 'package:provider/provider.dart'; +import 'package:aplicacionrutasturisticas/variables/perfil_variables.dart' + as globals; +import 'package:aplicacionrutasturisticas/metodos/perfil_metodos.dart'; +import 'package:aplicacionrutasturisticas/utilerias/MensajeEnMEdio.dart'; +import 'package:aplicacionrutasturisticas/metodos/cambio_idioma.dart'; class CupertinoPickerWidget_perfil extends StatefulWidget { @override @@ -38,17 +39,24 @@ class _CupertinoPickerWidget_perfilState ), ElevatedButton( onPressed: () { + // Actualizar el idioma globalmente en la aplicación globals.setLenguaje = _options[_selectedValue]; + + // Opcional: Ejecutar métodos adicionales según la selección de idioma Perfil_metodos().seleccionasteIdioma(_options[_selectedValue]); - CambiarIdioma().verificarCambio(context); + CambiarIdioma().cambiarIdiomaLocal(context); + // Mostrar mensaje de confirmación MensajeErrorDialog.show( context, S().notificacion_cambio_idioma + " ${globals.getLenguaje}", ); }, - child: Text(S().confirm, style: TextStyle(fontSize: 20)), - ) + child: Text( + S().confirm, + style: TextStyle(fontSize: 20), + ), + ), ], ), ); diff --git a/fronted/aplicacionrutasturisticas/pubspec.lock b/fronted/aplicacionrutasturisticas/pubspec.lock index e08eff2..fe6c032 100644 --- a/fronted/aplicacionrutasturisticas/pubspec.lock +++ b/fronted/aplicacionrutasturisticas/pubspec.lock @@ -266,10 +266,10 @@ packages: dependency: transitive description: name: flutter_cache_manager - sha256: "395d6b7831f21f3b989ebedbb785545932adb9afe2622c1ffacf7f4b53a7e544" + sha256: "8207f27539deb83732fdda03e259349046a39a4c767269285f449ade355d54ba" url: "https://pub.dev" source: hosted - version: "3.3.2" + version: "3.3.1" flutter_lints: dependency: "direct dev" description: @@ -310,13 +310,13 @@ packages: source: hosted version: "13.2.5" http: - dependency: transitive + dependency: "direct main" description: name: http - sha256: "761a297c042deedc1ffbb156d6e2af13886bb305c2a343a4d972504cd67dd938" + sha256: "5895291c13fa8a3bd82e76d5627f69e0d85ca6a30dcac95c4ea19a5d555879c2" url: "https://pub.dev" source: hosted - version: "1.2.1" + version: "0.13.6" http_parser: dependency: transitive description: diff --git a/fronted/aplicacionrutasturisticas/pubspec.yaml b/fronted/aplicacionrutasturisticas/pubspec.yaml index 09b012d..f74e2e6 100644 --- a/fronted/aplicacionrutasturisticas/pubspec.yaml +++ b/fronted/aplicacionrutasturisticas/pubspec.yaml @@ -34,8 +34,6 @@ dependencies: sdk: flutter shared_preferences: ^2.0.11 provider: ^6.0.3 - # The following adds the Cupertino Icons font to your application. - # Use with the CupertinoIcons class for iOS style icons. cupertino_icons: ^1.0.2 go_router: ^13.2.4 dio: ^5.4.3+1 @@ -45,8 +43,8 @@ dependencies: firebase_auth: ^4.8.1 cached_network_image: ^3.3.1 carousel_slider: ^4.0.0 + http: ^0.13.4 - dev_dependencies: flutter_test: sdk: flutter -- GitLab From d2c41a4ffd6c9f3dc86800914d41db04ff439593 Mon Sep 17 00:00:00 2001 From: Angel David Carlos Silva Date: Tue, 9 Jul 2024 13:54:35 -0600 Subject: [PATCH 14/19] Reorganizacion start page Eliminacion de la pagina de inicio2 --- .../lib/config/router.dart | 10 +- .../lib/pages/Calis.dart | 1 + .../lib/pages/login.dart | 2 +- .../pages/{star_page2.dart => star_page.dart} | 8 +- .../lib/pages/start_page.dart | 94 ------------------- 5 files changed, 8 insertions(+), 107 deletions(-) create mode 100644 fronted/aplicacionrutasturisticas/lib/pages/Calis.dart rename fronted/aplicacionrutasturisticas/lib/pages/{star_page2.dart => star_page.dart} (97%) delete mode 100644 fronted/aplicacionrutasturisticas/lib/pages/start_page.dart diff --git a/fronted/aplicacionrutasturisticas/lib/config/router.dart b/fronted/aplicacionrutasturisticas/lib/config/router.dart index 97d8961..14e5ea8 100644 --- a/fronted/aplicacionrutasturisticas/lib/config/router.dart +++ b/fronted/aplicacionrutasturisticas/lib/config/router.dart @@ -1,7 +1,7 @@ import 'package:aplicacionrutasturisticas/pages/login.dart'; import 'package:aplicacionrutasturisticas/pages/register.dart'; -import 'package:aplicacionrutasturisticas/pages/star_page2.dart'; -import 'package:aplicacionrutasturisticas/pages/start_page.dart'; +import 'package:aplicacionrutasturisticas/pages/star_page.dart'; +import 'package:aplicacionrutasturisticas/pages/Calis.dart'; import 'package:flutter/cupertino.dart'; import 'package:go_router/go_router.dart'; @@ -26,10 +26,4 @@ final GoRouter router = GoRouter(routes: [ builder: (BuildContext context, GoRouterState state) { return const StartedPage(); }), - GoRoute( - name: "StartPage2", - path: '/startpage2', - builder: (BuildContext context, GoRouterState state) { - return const StartedPage2(); - }) ]); diff --git a/fronted/aplicacionrutasturisticas/lib/pages/Calis.dart b/fronted/aplicacionrutasturisticas/lib/pages/Calis.dart new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/fronted/aplicacionrutasturisticas/lib/pages/Calis.dart @@ -0,0 +1 @@ + diff --git a/fronted/aplicacionrutasturisticas/lib/pages/login.dart b/fronted/aplicacionrutasturisticas/lib/pages/login.dart index edb2661..4d5bae0 100644 --- a/fronted/aplicacionrutasturisticas/lib/pages/login.dart +++ b/fronted/aplicacionrutasturisticas/lib/pages/login.dart @@ -88,7 +88,7 @@ class _TextFielEjemploState extends State { pass = password.text; print(corr + " " + pass); loginDatos(corr, pass); - context.goNamed("StartPage2"); + context.goNamed("StartPage"); } void botonRegistrar() { diff --git a/fronted/aplicacionrutasturisticas/lib/pages/star_page2.dart b/fronted/aplicacionrutasturisticas/lib/pages/star_page.dart similarity index 97% rename from fronted/aplicacionrutasturisticas/lib/pages/star_page2.dart rename to fronted/aplicacionrutasturisticas/lib/pages/star_page.dart index aadaa99..f531a0c 100644 --- a/fronted/aplicacionrutasturisticas/lib/pages/star_page2.dart +++ b/fronted/aplicacionrutasturisticas/lib/pages/star_page.dart @@ -10,14 +10,14 @@ import 'package:aplicacionrutasturisticas/utilerias/Carusels.dart'; import 'package:aplicacionrutasturisticas/utilerias/Perfil/AppBar_Perfil.dart'; import 'package:aplicacionrutasturisticas/utilerias/Perfil/Drawer_Perfil.dart'; -class StartedPage2 extends StatefulWidget { - const StartedPage2({super.key}); +class StartedPage extends StatefulWidget { + const StartedPage({super.key}); @override - StartedPageState2 createState() => StartedPageState2(); + StartedPageState createState() => StartedPageState(); } -class StartedPageState2 extends State { +class StartedPageState extends State { String cityName = ""; String cityDescription = ""; List imgList = []; diff --git a/fronted/aplicacionrutasturisticas/lib/pages/start_page.dart b/fronted/aplicacionrutasturisticas/lib/pages/start_page.dart deleted file mode 100644 index 3ec025c..0000000 --- a/fronted/aplicacionrutasturisticas/lib/pages/start_page.dart +++ /dev/null @@ -1,94 +0,0 @@ -import 'dart:ui'; - -import 'package:aplicacionrutasturisticas/utilerias/Images.dart'; -import 'package:flutter/cupertino.dart'; -import 'package:flutter/material.dart'; -import 'package:flutter/widgets.dart'; - -class StartedPage extends StatefulWidget { - const StartedPage({super.key}); - - @override - StartedPageState createState() => StartedPageState(); -} - -class StartedPageState extends State { - final String nombre = "Pancho"; - final String bienvenida = "Bienvenido!"; - - @override - Widget build(BuildContext context) { - return MaterialApp( - home: Scaffold( - appBar: AppBar( - title: Text(bienvenida, - style: const TextStyle(fontWeight: FontWeight.bold), - selectionColor: Colors.black, - textScaleFactor: lerpDouble(2, 2, 3)), - ), - body: Center( - child: SingleChildScrollView( - child: Column( - children: [ - Column( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - WithTextImage( - text: "", - onTap: buttonCrearRuta, - imageURL: - "https://i.ibb.co/wyC46vL/imagen-2024-05-21-114114963.png"), - Text("Crea Ruta"), - SizedBox( - height: 30, - ), - WithTextImage( - text: "", - onTap: buttonRutaRecomendada, - imageURL: - "https://i.ibb.co/wwBP6pZ/imagen-2024-05-21-114421156.png"), - Text("Ruta Recomendada"), - SizedBox( - height: 30, - ), - WithTextImage( - text: "", - onTap: buttonListadeLugares, - imageURL: - "https://i.ibb.co/djsffFB/imagen-2024-05-21-115417206.png"), - Text("Lista de Lugares"), - SizedBox( - height: 30, - ), - WithTextImage( - text: "", - onTap: buttonListadeLugares, - imageURL: - "https://i.ibb.co/fFX7Ng5/imagen-2024-05-21-115900870.png"), - Text("Rutas Completadas") - ], - ) - ], - ), - ), - ), - ), - ); - } - - void buttonCrearRuta() { - print("Haz presionado Crear Ruta"); - } - - void buttonRutaRecomendada() { - print("Haz presionado Ruta Recomendada"); - } - - void buttonListadeLugares() { - print("Haz precionado Lista de Lugares"); - } - - void buttonRutasCompletadas() { - print("Haz precionado Rutas Recomendadas"); - } -} -- GitLab From e1ba5c65731414d8afd1968fb7405f12ea8fdf9b Mon Sep 17 00:00:00 2001 From: Angel David Carlos Silva Date: Thu, 11 Jul 2024 18:12:27 -0600 Subject: [PATCH 15/19] Se agrego la tabla places --- backend/src/app.module.ts | 7 ++- backend/src/city/entities/city.entity.ts | 6 ++- backend/src/place/dto/create-place.dto.ts | 7 +++ backend/src/place/dto/update-place.dto.ts | 6 +++ backend/src/place/entities/place.entity.ts | 33 ++++++++++++ backend/src/place/place.controller.ts | 21 ++++++++ backend/src/place/place.module.ts | 13 +++++ backend/src/place/place.service.spec.ts | 17 +++++++ backend/src/place/place.service.ts | 36 +++++++++++++ .../lib/config/router.dart | 17 +++++-- .../lib/pages/Calis.dart | 51 +++++++++++++++++++ .../lib/pages/star_page.dart | 4 +- 12 files changed, 211 insertions(+), 7 deletions(-) create mode 100644 backend/src/place/dto/create-place.dto.ts create mode 100644 backend/src/place/dto/update-place.dto.ts create mode 100644 backend/src/place/entities/place.entity.ts create mode 100644 backend/src/place/place.controller.ts create mode 100644 backend/src/place/place.module.ts create mode 100644 backend/src/place/place.service.spec.ts create mode 100644 backend/src/place/place.service.ts diff --git a/backend/src/app.module.ts b/backend/src/app.module.ts index 54dfda9..2e4eec9 100644 --- a/backend/src/app.module.ts +++ b/backend/src/app.module.ts @@ -12,6 +12,8 @@ import { AuthUserModule } from './auth-user/auth-user.module'; import { CityModule } from './city/city.module'; import { City } from './city/entities/city.entity'; import { CityService } from './city/city.service'; +import { Place } from './place/entities/place.entity'; +import { PlaceModule } from './place/place.module'; dotenv.config() @Module({ @@ -23,14 +25,15 @@ dotenv.config() username: process.env.DATABASE_USER, password: process.env.DATABASE_PASSWORD, database: process.env.DATABASE_NAME, - entities: [Admin, User,City], + entities: [Admin, User,City,Place], synchronize: true, }), AdminModule, UserModule, JwtModule, AuthUserModule, - CityModule + CityModule, + PlaceModule ], controllers: [AppController], //rutas providers: [AppService], //funciones para comunicarse en la bd diff --git a/backend/src/city/entities/city.entity.ts b/backend/src/city/entities/city.entity.ts index aeca867..3a72f8a 100644 --- a/backend/src/city/entities/city.entity.ts +++ b/backend/src/city/entities/city.entity.ts @@ -1,4 +1,5 @@ -import { Column, Entity, PrimaryColumn, PrimaryGeneratedColumn } from "typeorm"; +import { Place } from "src/place/entities/place.entity"; +import { Column, Entity, OneToMany, PrimaryColumn, PrimaryGeneratedColumn } from "typeorm"; @Entity() export class City{ @PrimaryGeneratedColumn() @@ -9,4 +10,7 @@ import { Column, Entity, PrimaryColumn, PrimaryGeneratedColumn } from "typeorm"; @Column({ length: 1000 }) description:string + + @OneToMany(()=>Place,place=>place.city) //Relacion inversa con place + place:Place[] } diff --git a/backend/src/place/dto/create-place.dto.ts b/backend/src/place/dto/create-place.dto.ts new file mode 100644 index 0000000..6988e52 --- /dev/null +++ b/backend/src/place/dto/create-place.dto.ts @@ -0,0 +1,7 @@ +export class CreatePlaceDto { + name: string; + description: string; + schedule: string; + adress: string; + geographic_location:string; +} \ No newline at end of file diff --git a/backend/src/place/dto/update-place.dto.ts b/backend/src/place/dto/update-place.dto.ts new file mode 100644 index 0000000..a488505 --- /dev/null +++ b/backend/src/place/dto/update-place.dto.ts @@ -0,0 +1,6 @@ +import { PartialType } from '@nestjs/mapped-types'; +import { CreatePlaceDto } from './create-place.dto'; + +export class UpdatePlaceDto extends PartialType(CreatePlaceDto) { + +} \ No newline at end of file diff --git a/backend/src/place/entities/place.entity.ts b/backend/src/place/entities/place.entity.ts new file mode 100644 index 0000000..fc9f1b7 --- /dev/null +++ b/backend/src/place/entities/place.entity.ts @@ -0,0 +1,33 @@ +// place.entity.ts +import { City } from "src/city/entities/city.entity"; +import { Column, Entity, JoinColumn, ManyToOne, PrimaryGeneratedColumn } from "typeorm"; + +@Entity() +export class Place { + @PrimaryGeneratedColumn() + idPlace: number; + + @Column() + name: string; + + @Column({ length: 1000 }) + description: string; + + @Column() + schedule: string; + + @Column() + address: string; + + @Column({ type: "point", nullable: true, spatialFeatureType: "Point" }) + geographic_location: string; + + @Column({ length: 1000 }) + categories: string; + + @ManyToOne(() => City, city => city.place) + @JoinColumn({ name: "nameCity" }) // Nombre de la columna en Place que será la llave foránea + city: City; + + // No es necesario tener cityName como una columna si estás usando la relación city +} diff --git a/backend/src/place/place.controller.ts b/backend/src/place/place.controller.ts new file mode 100644 index 0000000..ec24fe3 --- /dev/null +++ b/backend/src/place/place.controller.ts @@ -0,0 +1,21 @@ +// place.controller.ts +import { Controller, Get, Param } from '@nestjs/common'; +import { PlaceService } from './place.service'; + +@Controller('places') +export class PlaceController { + constructor(private readonly placeService: PlaceService) {} + + @Get(':nameCity/:namePlace') + async findOnePlace( + @Param('nameCity') nameCity: string, + @Param('namePlace') namePlace: string, + ): Promise { + return await this.placeService.findOnePlace(namePlace, nameCity); + } + + @Get(':nameCity') + async findAllPlaceNames(@Param('nameCity') nameCity: string): Promise { + return await this.placeService.findAllPlaceNames(nameCity); + } +} diff --git a/backend/src/place/place.module.ts b/backend/src/place/place.module.ts new file mode 100644 index 0000000..0afd983 --- /dev/null +++ b/backend/src/place/place.module.ts @@ -0,0 +1,13 @@ +import { TypeOrmModule } from '@nestjs/typeorm'; +import { Module } from '@nestjs/common'; +import { PlaceService } from './place.service'; +import { Place } from './entities/place.entity'; +import { PlaceController } from './place.controller'; + +@Module({ + imports:[TypeOrmModule.forFeature([Place])], + controllers:[PlaceController], + providers:[PlaceService], + exports:[PlaceService] +}) +export class PlaceModule{} \ No newline at end of file diff --git a/backend/src/place/place.service.spec.ts b/backend/src/place/place.service.spec.ts new file mode 100644 index 0000000..d8d3a0d --- /dev/null +++ b/backend/src/place/place.service.spec.ts @@ -0,0 +1,17 @@ +import { Test,TestingModule } from "@nestjs/testing"; +import { PlaceService } from "./place.service"; + +describe('PlaceService',()=>{ + let service:PlaceService; + + beforeEach(async()=>{ + const module:TestingModule=await Test.createTestingModule({ + providers:[PlaceService] + }).compile(); + service=module.get(PlaceService); + }) + + it('should be defined',()=>{ + expect(service).toBeDefined(); + }) +}) \ No newline at end of file diff --git a/backend/src/place/place.service.ts b/backend/src/place/place.service.ts new file mode 100644 index 0000000..6061647 --- /dev/null +++ b/backend/src/place/place.service.ts @@ -0,0 +1,36 @@ +// place.service.ts +import { Injectable } from "@nestjs/common"; +import { InjectRepository } from "@nestjs/typeorm"; +import { Repository } from "typeorm"; +import { Place } from "./entities/place.entity"; + +@Injectable() +export class PlaceService { + constructor( + @InjectRepository(Place) + private readonly placeRepository: Repository + ) {} + + async findOnePlace(namePlace: string, nameCity: string): Promise { + const place = await this.placeRepository.findOne({ + where: { + name: namePlace, + city: { name: nameCity } // Busca por nombre de ciudad usando la relación city + }, + relations: ['city'] // Carga la relación city para obtener el objeto completo de City + }); + + return place; + } + + async findAllPlaceNames(nameCity: string): Promise { + const places = await this.placeRepository + .createQueryBuilder("place") + .select("place.name") + .leftJoin("place.city", "city") + .where("city.name = :nameCity", { nameCity }) + .getMany(); + + return places.map(place => place.name); + } +} diff --git a/fronted/aplicacionrutasturisticas/lib/config/router.dart b/fronted/aplicacionrutasturisticas/lib/config/router.dart index 14e5ea8..e4a21a6 100644 --- a/fronted/aplicacionrutasturisticas/lib/config/router.dart +++ b/fronted/aplicacionrutasturisticas/lib/config/router.dart @@ -1,9 +1,9 @@ +import 'package:flutter/material.dart'; +import 'package:go_router/go_router.dart'; import 'package:aplicacionrutasturisticas/pages/login.dart'; import 'package:aplicacionrutasturisticas/pages/register.dart'; import 'package:aplicacionrutasturisticas/pages/star_page.dart'; import 'package:aplicacionrutasturisticas/pages/Calis.dart'; -import 'package:flutter/cupertino.dart'; -import 'package:go_router/go_router.dart'; final GoRouter router = GoRouter(routes: [ GoRoute( @@ -25,5 +25,16 @@ final GoRouter router = GoRouter(routes: [ path: '/startpage', builder: (BuildContext context, GoRouterState state) { return const StartedPage(); - }), + }, + routes: [ + GoRoute( + name: "PlaceBase", + path: "placebase/:place", + builder: (BuildContext context, GoRouterState state) { + final place = int.parse(state.pathParameters[ + 'place']!); // Obtén el parámetro y conviértelo a entero + return PlaceBase(place: place); + }, + ) + ]), ]); diff --git a/fronted/aplicacionrutasturisticas/lib/pages/Calis.dart b/fronted/aplicacionrutasturisticas/lib/pages/Calis.dart index 8b13789..778de03 100644 --- a/fronted/aplicacionrutasturisticas/lib/pages/Calis.dart +++ b/fronted/aplicacionrutasturisticas/lib/pages/Calis.dart @@ -1 +1,52 @@ +import 'package:flutter/material.dart'; +class PlaceBase extends StatefulWidget { + final int place; + + const PlaceBase({Key? key, required this.place}) : super(key: key); + + @override + _PlaceBaseState createState() => _PlaceBaseState(); +} + +class _PlaceBaseState extends State { + @override + Widget build(BuildContext context) { + return Scaffold( + body: CustomScrollView( + slivers: [ + SliverAppBar( + title: Text('Title: ${widget.place}'), + floating: true, + snap: true, + leading: IconButton( + icon: Icon(Icons.close), + onPressed: () { + Navigator.of(context).pop(); + }, + ), + ), + SliverList( + delegate: SliverChildListDelegate([ + // Aqui se ponen los widgets + Container( + height: 800, + color: Colors.red, + child: Padding( + padding: EdgeInsets.all(25), + child: ClipRRect( + borderRadius: BorderRadius.circular(35), + child: Container( + height: 3.0, + width: 2.0, + color: Colors.white, + ), + ), + )), + ]), + ), + ], + ), + ); + } +} diff --git a/fronted/aplicacionrutasturisticas/lib/pages/star_page.dart b/fronted/aplicacionrutasturisticas/lib/pages/star_page.dart index f531a0c..b4d9b98 100644 --- a/fronted/aplicacionrutasturisticas/lib/pages/star_page.dart +++ b/fronted/aplicacionrutasturisticas/lib/pages/star_page.dart @@ -3,6 +3,7 @@ import 'package:aplicacionrutasturisticas/metodos/images/star_page/obtener_image import 'package:aplicacionrutasturisticas/utilerias/FutureBuilder.dart'; import 'package:flutter/material.dart'; import 'package:flutter/cupertino.dart'; +import 'package:go_router/go_router.dart'; import 'package:provider/provider.dart'; import 'package:aplicacionrutasturisticas/generated/l10n.dart'; import 'package:aplicacionrutasturisticas/providers/database_translade_provider.dart'; @@ -157,7 +158,8 @@ class StartedPageState extends State { leading: Icon(Icons.list), title: Text(S.of(context).list_of_places), onTap: () { - // Acción al tocar la opción + context.goNamed("PlaceBase", + pathParameters: {'place': '6'}); }, ), ListTile( -- GitLab From 155e29bf47b859a348ee8d771a3ac639d9727714 Mon Sep 17 00:00:00 2001 From: Angel David Carlos Silva Date: Wed, 17 Jul 2024 15:19:57 -0600 Subject: [PATCH 16/19] Se corrigio el controller de place Tambien se agrego una variable para la aplicacion --- backend/src/place/dto/create-place.dto.ts | 2 + backend/src/place/entities/place.entity.ts | 7 +- backend/src/place/place.controller.ts | 33 ++++-- backend/src/place/place.service.ts | 17 ++- .../lib/config/dio.dart | 24 +++++ .../lib/config/router.dart | 4 +- .../star_page/obtener_imagenes_lista.dart | 4 +- .../lib/metodos/places/datos_places.dart | 11 ++ .../lib/pages/Calis.dart | 52 --------- .../lib/pages/place.dart | 100 ++++++++++++++++++ .../lib/pages/star_page.dart | 5 +- .../lib/variables/perfil_variables.dart | 3 + 12 files changed, 186 insertions(+), 76 deletions(-) create mode 100644 fronted/aplicacionrutasturisticas/lib/metodos/places/datos_places.dart delete mode 100644 fronted/aplicacionrutasturisticas/lib/pages/Calis.dart create mode 100644 fronted/aplicacionrutasturisticas/lib/pages/place.dart diff --git a/backend/src/place/dto/create-place.dto.ts b/backend/src/place/dto/create-place.dto.ts index 6988e52..7d0137c 100644 --- a/backend/src/place/dto/create-place.dto.ts +++ b/backend/src/place/dto/create-place.dto.ts @@ -4,4 +4,6 @@ export class CreatePlaceDto { schedule: string; adress: string; geographic_location:string; + categories:string; + idCity:number; } \ No newline at end of file diff --git a/backend/src/place/entities/place.entity.ts b/backend/src/place/entities/place.entity.ts index fc9f1b7..ec879e7 100644 --- a/backend/src/place/entities/place.entity.ts +++ b/backend/src/place/entities/place.entity.ts @@ -25,9 +25,10 @@ export class Place { @Column({ length: 1000 }) categories: string; + @Column() + idCity: number; // Debe ser un string para almacenar el nombre de la ciudad + @ManyToOne(() => City, city => city.place) - @JoinColumn({ name: "nameCity" }) // Nombre de la columna en Place que será la llave foránea + @JoinColumn({ name: "idCity" }) // Nombre de la columna en Place que será la llave foránea hacia City city: City; - - // No es necesario tener cityName como una columna si estás usando la relación city } diff --git a/backend/src/place/place.controller.ts b/backend/src/place/place.controller.ts index ec24fe3..37e606c 100644 --- a/backend/src/place/place.controller.ts +++ b/backend/src/place/place.controller.ts @@ -2,20 +2,35 @@ import { Controller, Get, Param } from '@nestjs/common'; import { PlaceService } from './place.service'; -@Controller('places') +@Controller('place') export class PlaceController { constructor(private readonly placeService: PlaceService) {} - @Get(':nameCity/:namePlace') + @Get(':idCity/:name') async findOnePlace( - @Param('nameCity') nameCity: string, - @Param('namePlace') namePlace: string, - ): Promise { - return await this.placeService.findOnePlace(namePlace, nameCity); + @Param('idCity') idCity: number, + @Param('name') name: string, + ): Promise { + console.log(`idCity: ${idCity}, name: ${name}`); + try { + const result = await this.placeService.findOnePlace(name, idCity); + const values=Object.values(result); + console.log(`Result: ${JSON.stringify(values)}`); + return values; + } catch (error) { + console.error(`Error: ${error.message}`); + throw error; + } } - @Get(':nameCity') - async findAllPlaceNames(@Param('nameCity') nameCity: string): Promise { - return await this.placeService.findAllPlaceNames(nameCity); + @Get(':idCity') + async findAllPlaceNames(@Param('idCity') idCity: number): Promise { + return await this.placeService.findAllPlaceNames(idCity); } + + @Get('test') + getTest(): string { + return 'Test endpoint works!'; +} + } diff --git a/backend/src/place/place.service.ts b/backend/src/place/place.service.ts index 6061647..a399e97 100644 --- a/backend/src/place/place.service.ts +++ b/backend/src/place/place.service.ts @@ -4,6 +4,7 @@ import { InjectRepository } from "@nestjs/typeorm"; import { Repository } from "typeorm"; import { Place } from "./entities/place.entity"; + @Injectable() export class PlaceService { constructor( @@ -11,24 +12,30 @@ export class PlaceService { private readonly placeRepository: Repository ) {} - async findOnePlace(namePlace: string, nameCity: string): Promise { + async findOnePlace(namePlace: string, idCity: number): Promise { const place = await this.placeRepository.findOne({ + select: [ + "name", + "description", + "schedule", + "address", + "categories" + ], where: { name: namePlace, - city: { name: nameCity } // Busca por nombre de ciudad usando la relación city + idCity: idCity }, - relations: ['city'] // Carga la relación city para obtener el objeto completo de City }); return place; } - async findAllPlaceNames(nameCity: string): Promise { + async findAllPlaceNames(idCity: number): Promise { const places = await this.placeRepository .createQueryBuilder("place") .select("place.name") .leftJoin("place.city", "city") - .where("city.name = :nameCity", { nameCity }) + .where("city.idCity = :idCity", { idCity }) .getMany(); return places.map(place => place.name); diff --git a/fronted/aplicacionrutasturisticas/lib/config/dio.dart b/fronted/aplicacionrutasturisticas/lib/config/dio.dart index 8f3ba58..fac0678 100644 --- a/fronted/aplicacionrutasturisticas/lib/config/dio.dart +++ b/fronted/aplicacionrutasturisticas/lib/config/dio.dart @@ -1,3 +1,5 @@ +import 'dart:convert'; + import 'package:dio/dio.dart'; final dio = Dio(); @@ -24,6 +26,7 @@ void loginDatos(String email, String password) async { print(responselogin.data.toString()); } +//Star page Future datosStartPage(int cityId) async { Response responseCity = await dio.get( "http://192.168.101.13:3000/city/name", @@ -51,3 +54,24 @@ Future datosTextStartPage(int cityId) async { return "Cargando...."; } } + +//Place page +Future> findAllDatPlace( + String placeName, int idCity) async { + try { + Response responsePlace = + await dio.get("http://192.168.101.13:3000/place/$idCity/$placeName"); + + if (responsePlace.statusCode == 200) { + // Si la petición fue exitosa + Map places = responsePlace.data; + return places; + } else { + // Manejar errores aquí según sea necesario + throw Exception('Error al obtener lugares'); + } + } catch (e) { + // Manejar cualquier error que ocurra durante la solicitud + throw Exception('Error en la solicitud HTTP: $e'); + } +} diff --git a/fronted/aplicacionrutasturisticas/lib/config/router.dart b/fronted/aplicacionrutasturisticas/lib/config/router.dart index e4a21a6..dd1ab3b 100644 --- a/fronted/aplicacionrutasturisticas/lib/config/router.dart +++ b/fronted/aplicacionrutasturisticas/lib/config/router.dart @@ -3,7 +3,7 @@ import 'package:go_router/go_router.dart'; import 'package:aplicacionrutasturisticas/pages/login.dart'; import 'package:aplicacionrutasturisticas/pages/register.dart'; import 'package:aplicacionrutasturisticas/pages/star_page.dart'; -import 'package:aplicacionrutasturisticas/pages/Calis.dart'; +import 'package:aplicacionrutasturisticas/pages/place.dart'; final GoRouter router = GoRouter(routes: [ GoRoute( @@ -31,7 +31,7 @@ final GoRouter router = GoRouter(routes: [ name: "PlaceBase", path: "placebase/:place", builder: (BuildContext context, GoRouterState state) { - final place = int.parse(state.pathParameters[ + final place = (state.pathParameters[ 'place']!); // Obtén el parámetro y conviértelo a entero return PlaceBase(place: place); }, diff --git a/fronted/aplicacionrutasturisticas/lib/metodos/images/star_page/obtener_imagenes_lista.dart b/fronted/aplicacionrutasturisticas/lib/metodos/images/star_page/obtener_imagenes_lista.dart index 96af0c8..aa0b3e9 100644 --- a/fronted/aplicacionrutasturisticas/lib/metodos/images/star_page/obtener_imagenes_lista.dart +++ b/fronted/aplicacionrutasturisticas/lib/metodos/images/star_page/obtener_imagenes_lista.dart @@ -22,9 +22,7 @@ class ImagenesDesdeStorage { String downloadURL = await ref.getDownloadURL(); imageURLs.add(downloadURL); } - } catch (e) { - print("Error: " + e.toString()); - } + } catch (e) {} return imageURLs; } diff --git a/fronted/aplicacionrutasturisticas/lib/metodos/places/datos_places.dart b/fronted/aplicacionrutasturisticas/lib/metodos/places/datos_places.dart new file mode 100644 index 0000000..5baecb7 --- /dev/null +++ b/fronted/aplicacionrutasturisticas/lib/metodos/places/datos_places.dart @@ -0,0 +1,11 @@ +import 'package:aplicacionrutasturisticas/config/dio.dart'; + +class DatosPlaces { + Future> loadCityNameDescription( + String name, int idCity) async { + Map description = await findAllDatPlace(name, idCity); + print("La descripcion es:\n"); + print(description); + return description; + } +} diff --git a/fronted/aplicacionrutasturisticas/lib/pages/Calis.dart b/fronted/aplicacionrutasturisticas/lib/pages/Calis.dart deleted file mode 100644 index 778de03..0000000 --- a/fronted/aplicacionrutasturisticas/lib/pages/Calis.dart +++ /dev/null @@ -1,52 +0,0 @@ -import 'package:flutter/material.dart'; - -class PlaceBase extends StatefulWidget { - final int place; - - const PlaceBase({Key? key, required this.place}) : super(key: key); - - @override - _PlaceBaseState createState() => _PlaceBaseState(); -} - -class _PlaceBaseState extends State { - @override - Widget build(BuildContext context) { - return Scaffold( - body: CustomScrollView( - slivers: [ - SliverAppBar( - title: Text('Title: ${widget.place}'), - floating: true, - snap: true, - leading: IconButton( - icon: Icon(Icons.close), - onPressed: () { - Navigator.of(context).pop(); - }, - ), - ), - SliverList( - delegate: SliverChildListDelegate([ - // Aqui se ponen los widgets - Container( - height: 800, - color: Colors.red, - child: Padding( - padding: EdgeInsets.all(25), - child: ClipRRect( - borderRadius: BorderRadius.circular(35), - child: Container( - height: 3.0, - width: 2.0, - color: Colors.white, - ), - ), - )), - ]), - ), - ], - ), - ); - } -} diff --git a/fronted/aplicacionrutasturisticas/lib/pages/place.dart b/fronted/aplicacionrutasturisticas/lib/pages/place.dart new file mode 100644 index 0000000..d83ae79 --- /dev/null +++ b/fronted/aplicacionrutasturisticas/lib/pages/place.dart @@ -0,0 +1,100 @@ +import 'package:aplicacionrutasturisticas/metodos/images/star_page/obtener_imagenes_lista.dart'; +import 'package:aplicacionrutasturisticas/utilerias/Carusels.dart'; +import 'package:aplicacionrutasturisticas/metodos/places/datos_places.dart'; +import 'package:aplicacionrutasturisticas/variables/perfil_variables.dart'; +import 'package:flutter/cupertino.dart'; +import 'package:flutter/material.dart'; + +class PlaceBase extends StatefulWidget { + final String place; +//El Rodillote + const PlaceBase({Key? key, required this.place}) : super(key: key); + + @override + _PlaceBaseState createState() => _PlaceBaseState(); +} + +class _PlaceBaseState extends State { + List imgList = []; + bool isLoading = true; + + @override + void initState() { + super.initState(); + loadImgList(); + print(getIdCity); + DatosPlaces().loadCityNameDescription(widget.place, 1); + } + + void loadImgList() async { + ImagenesDesdeStorage ima = ImagenesDesdeStorage(); + List urls = + await ima.ImagesFromStorage("zacatecas/places/${widget.place}/"); + setState(() { + imgList = urls; + isLoading = false; + }); + } + + @override + Widget build(BuildContext context) { + return Scaffold( + body: CustomScrollView( + slivers: [ + SliverAppBar( + title: Text('Title: ${widget.place}'), + backgroundColor: Colors.black.withOpacity(0.5), + floating: true, + snap: true, + leading: IconButton( + icon: Icon(Icons.close), + onPressed: () { + Navigator.of(context).pop(); + }, + ), + ), + SliverList( + delegate: SliverChildListDelegate([ + // Aqui se ponen los widgets + Container( + height: 800, + decoration: BoxDecoration( + image: DecorationImage( + image: NetworkImage( + 'https://www.turimexico.com/wp-content/uploads/2015/10/ciudad-de-zacatecas.jpg', + ), + fit: BoxFit.cover, + colorFilter: ColorFilter.mode( + Colors.black.withOpacity(0.5), + BlendMode.darken, + ), + ), + ), + child: Padding( + padding: EdgeInsets.all(25), + child: ClipRRect( + borderRadius: BorderRadius.circular(35), + child: Container( + height: 3.0, + width: 2.0, + color: Colors.white.withOpacity(0.5), + child: Center( + child: Column( + children: [ + isLoading + ? const Center( + child: CupertinoActivityIndicator()) + : carusel_images_list(imgList: imgList), + ], + ), + ), + ), + ), + )), + ]), + ), + ], + ), + ); + } +} diff --git a/fronted/aplicacionrutasturisticas/lib/pages/star_page.dart b/fronted/aplicacionrutasturisticas/lib/pages/star_page.dart index b4d9b98..4a1ebff 100644 --- a/fronted/aplicacionrutasturisticas/lib/pages/star_page.dart +++ b/fronted/aplicacionrutasturisticas/lib/pages/star_page.dart @@ -158,8 +158,9 @@ class StartedPageState extends State { leading: Icon(Icons.list), title: Text(S.of(context).list_of_places), onTap: () { - context.goNamed("PlaceBase", - pathParameters: {'place': '6'}); + context.goNamed("PlaceBase", pathParameters: { + 'place': 'El Rodillote' + }); }, ), ListTile( diff --git a/fronted/aplicacionrutasturisticas/lib/variables/perfil_variables.dart b/fronted/aplicacionrutasturisticas/lib/variables/perfil_variables.dart index a048286..04e608d 100644 --- a/fronted/aplicacionrutasturisticas/lib/variables/perfil_variables.dart +++ b/fronted/aplicacionrutasturisticas/lib/variables/perfil_variables.dart @@ -9,3 +9,6 @@ set setLenguaje(String lenguaje) { idioma = 'es'; } } + +int idCity = 1; +int get getIdCity => idCity; -- GitLab From c0e0bd8fe147d09c189f6bc7d0f7619d92958c21 Mon Sep 17 00:00:00 2001 From: Angel David Carlos Silva Date: Fri, 23 Aug 2024 15:29:36 -0600 Subject: [PATCH 17/19] New proyect --- .../lib/config/dio.dart | 21 +++-- .../lib/metodos/places/datos_places.dart | 37 +++++++-- .../lib/pages/login.dart | 2 +- .../lib/pages/place.dart | 80 ++++++++++++++----- .../lib/pages/star_page.dart | 6 +- .../lib/utilerias/FutureBuilder.dart | 10 ++- 6 files changed, 112 insertions(+), 44 deletions(-) diff --git a/fronted/aplicacionrutasturisticas/lib/config/dio.dart b/fronted/aplicacionrutasturisticas/lib/config/dio.dart index fac0678..f523ec8 100644 --- a/fronted/aplicacionrutasturisticas/lib/config/dio.dart +++ b/fronted/aplicacionrutasturisticas/lib/config/dio.dart @@ -4,11 +4,12 @@ import 'package:dio/dio.dart'; final dio = Dio(); +const String localhost = "http://192.168.100.4:3000"; + void Registro_Datos( String nombre, String lastname, String email, String password) async { Response response; - response = - await dio.post("http://192.168.101.13:3000/auth-user/register", data: { + response = await dio.post("$localhost/auth-user/register", data: { "name": nombre, "lastname": lastname, "password": password, @@ -18,8 +19,7 @@ void Registro_Datos( void loginDatos(String email, String password) async { Response responselogin; - responselogin = - await dio.post("http://192.168.101.13:3000/auth-user/login", data: { + responselogin = await dio.post("$localhost/auth-user/login", data: { "email": email, "password": password, }); @@ -29,7 +29,7 @@ void loginDatos(String email, String password) async { //Star page Future datosStartPage(int cityId) async { Response responseCity = await dio.get( - "http://192.168.101.13:3000/city/name", + "$localhost/city/name", queryParameters: {"id": cityId}, ); if (responseCity.statusCode == 200) { @@ -43,7 +43,7 @@ Future datosStartPage(int cityId) async { Future datosTextStartPage(int cityId) async { Response responseCity = await dio.get( - "http://192.168.101.13:3000/city/description", + "$localhost/city/description", queryParameters: {"id": cityId}, ); if (responseCity.statusCode == 200) { @@ -56,22 +56,19 @@ Future datosTextStartPage(int cityId) async { } //Place page -Future> findAllDatPlace( - String placeName, int idCity) async { +Future> findAllDatPlace(String placeName, int idCity) async { try { Response responsePlace = - await dio.get("http://192.168.101.13:3000/place/$idCity/$placeName"); + await dio.get("$localhost/place/$idCity/$placeName"); if (responsePlace.statusCode == 200) { // Si la petición fue exitosa - Map places = responsePlace.data; + List places = responsePlace.data; return places; } else { - // Manejar errores aquí según sea necesario throw Exception('Error al obtener lugares'); } } catch (e) { - // Manejar cualquier error que ocurra durante la solicitud throw Exception('Error en la solicitud HTTP: $e'); } } diff --git a/fronted/aplicacionrutasturisticas/lib/metodos/places/datos_places.dart b/fronted/aplicacionrutasturisticas/lib/metodos/places/datos_places.dart index 5baecb7..0d5a4e6 100644 --- a/fronted/aplicacionrutasturisticas/lib/metodos/places/datos_places.dart +++ b/fronted/aplicacionrutasturisticas/lib/metodos/places/datos_places.dart @@ -1,11 +1,36 @@ import 'package:aplicacionrutasturisticas/config/dio.dart'; class DatosPlaces { - Future> loadCityNameDescription( - String name, int idCity) async { - Map description = await findAllDatPlace(name, idCity); - print("La descripcion es:\n"); - print(description); - return description; + late List description_base; + + Future loadCityNameDescription(String name, int idCity) async { + // Usa await para esperar la carga de datos + List description = await findAllDatPlace(name, idCity); + description_base = description; + } + + String loadNamePlace() { + // Accede al nombre utilizando la clave 'name' + return description_base[0] ?? ''; + } + + String loadDescriptionPlace() { + // Accede a la descripción utilizando la clave 'description' + return description_base[1] ?? ''; + } + + String loadSchedulePlace() { + // Accede al horario utilizando la clave 'schedule' + return description_base[2] ?? ''; + } + + String loadAddressPlace() { + // Accede a la dirección utilizando la clave 'address' + return description_base[3] ?? ''; + } + + String loadCategories() { + // Accede a las categorías utilizando la clave 'categories' + return description_base[4] ?? ''; } } diff --git a/fronted/aplicacionrutasturisticas/lib/pages/login.dart b/fronted/aplicacionrutasturisticas/lib/pages/login.dart index 4d5bae0..a799dd7 100644 --- a/fronted/aplicacionrutasturisticas/lib/pages/login.dart +++ b/fronted/aplicacionrutasturisticas/lib/pages/login.dart @@ -87,7 +87,7 @@ class _TextFielEjemploState extends State { corr = correo.text; pass = password.text; print(corr + " " + pass); - loginDatos(corr, pass); + //loginDatos(corr, pass); context.goNamed("StartPage"); } diff --git a/fronted/aplicacionrutasturisticas/lib/pages/place.dart b/fronted/aplicacionrutasturisticas/lib/pages/place.dart index d83ae79..6255635 100644 --- a/fronted/aplicacionrutasturisticas/lib/pages/place.dart +++ b/fronted/aplicacionrutasturisticas/lib/pages/place.dart @@ -1,6 +1,7 @@ import 'package:aplicacionrutasturisticas/metodos/images/star_page/obtener_imagenes_lista.dart'; import 'package:aplicacionrutasturisticas/utilerias/Carusels.dart'; import 'package:aplicacionrutasturisticas/metodos/places/datos_places.dart'; +import 'package:aplicacionrutasturisticas/utilerias/FutureBuilder.dart'; import 'package:aplicacionrutasturisticas/variables/perfil_variables.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; @@ -17,13 +18,39 @@ class PlaceBase extends StatefulWidget { class _PlaceBaseState extends State { List imgList = []; bool isLoading = true; + String namePlace = ""; + String descriprionPlace = ""; + String schedulePlace = ""; + String adrresPlace = ""; + String categoriesPlace = ""; - @override + @override //Es el contructor que se inicializa al momento de inicar la pagina void initState() { super.initState(); loadImgList(); - print(getIdCity); - DatosPlaces().loadCityNameDescription(widget.place, 1); + loadData(); + } + + //Este metodo manda a llamar a la clase Datos Place para obtener la infomacion del lugar + void loadData() async { + try { + DatosPlaces datos = DatosPlaces(); + await datos.loadCityNameDescription(widget.place, getIdCity); + + setState(() { + namePlace = datos.loadNamePlace(); + descriprionPlace = datos.loadDescriptionPlace(); + schedulePlace = datos.loadSchedulePlace(); + adrresPlace = datos.loadAddressPlace(); + categoriesPlace = datos.loadCategories(); + }); + loadImgList(); + } catch (error) { + print('Error loading data: $error'); + setState(() { + isLoading = false; + }); + } } void loadImgList() async { @@ -41,18 +68,6 @@ class _PlaceBaseState extends State { return Scaffold( body: CustomScrollView( slivers: [ - SliverAppBar( - title: Text('Title: ${widget.place}'), - backgroundColor: Colors.black.withOpacity(0.5), - floating: true, - snap: true, - leading: IconButton( - icon: Icon(Icons.close), - onPressed: () { - Navigator.of(context).pop(); - }, - ), - ), SliverList( delegate: SliverChildListDelegate([ // Aqui se ponen los widgets @@ -65,7 +80,7 @@ class _PlaceBaseState extends State { ), fit: BoxFit.cover, colorFilter: ColorFilter.mode( - Colors.black.withOpacity(0.5), + Colors.white.withOpacity(0.5), BlendMode.darken, ), ), @@ -77,14 +92,41 @@ class _PlaceBaseState extends State { child: Container( height: 3.0, width: 2.0, - color: Colors.white.withOpacity(0.5), + color: Colors.white.withOpacity(0.0), child: Center( child: Column( children: [ + //Aqui van los objetos + SizedBox(height: 50), + Text( + namePlace, + textAlign: TextAlign.center, + style: TextStyle( + color: Colors.white, + fontWeight: FontWeight.bold, + fontSize: 24, + ), + ), isLoading - ? const Center( - child: CupertinoActivityIndicator()) + ? Center(child: CupertinoActivityIndicator()) : carusel_images_list(imgList: imgList), + SizedBox(height: 20), + TextoDinamico( + texto: descriprionPlace, + colors: Colors.white, + ), + TextoDinamico( + texto: 'Horario: $schedulePlace', + colors: Colors.white), + SizedBox(height: 10), + Text( + 'Dirección: $adrresPlace', + style: TextStyle( + fontSize: 16, color: Colors.white), + ), + TextoDinamico( + texto: 'Categorías: $categoriesPlace', + colors: Colors.white) ], ), ), diff --git a/fronted/aplicacionrutasturisticas/lib/pages/star_page.dart b/fronted/aplicacionrutasturisticas/lib/pages/star_page.dart index 4a1ebff..0eebce4 100644 --- a/fronted/aplicacionrutasturisticas/lib/pages/star_page.dart +++ b/fronted/aplicacionrutasturisticas/lib/pages/star_page.dart @@ -102,8 +102,10 @@ class StartedPageState extends State { Center( child: Padding( padding: EdgeInsets.all(20.0), - child: - Container(child: textoDinamico(texto: cityDescription)), + child: Container( + child: TextoDinamico( + texto: cityDescription, + colors: Color.fromARGB(255, 255, 255, 255))), ), ), const SizedBox(height: 80) diff --git a/fronted/aplicacionrutasturisticas/lib/utilerias/FutureBuilder.dart b/fronted/aplicacionrutasturisticas/lib/utilerias/FutureBuilder.dart index 288a6a3..9c33557 100644 --- a/fronted/aplicacionrutasturisticas/lib/utilerias/FutureBuilder.dart +++ b/fronted/aplicacionrutasturisticas/lib/utilerias/FutureBuilder.dart @@ -2,10 +2,12 @@ import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; import 'package:aplicacionrutasturisticas/metodos/cambio_idioma.dart'; -class textoDinamico extends StatelessWidget { +class TextoDinamico extends StatelessWidget { final String texto; + final Color colors; - const textoDinamico({Key? key, required this.texto}) : super(key: key); + const TextoDinamico({Key? key, required this.texto, required this.colors}) + : super(key: key); @override Widget build(BuildContext context) { @@ -19,8 +21,8 @@ class textoDinamico extends StatelessWidget { } else { return Text( snapshot.data ?? 'Cargando...', - style: const TextStyle( - color: Colors.white, + style: TextStyle( + color: colors, fontSize: 15, ), textAlign: TextAlign.justify, -- GitLab From 9c1be8ef0b66a4ffbedadb61511970d4ed7d8996 Mon Sep 17 00:00:00 2001 From: Angel David Carlos Silva Date: Tue, 27 Aug 2024 14:26:13 -0600 Subject: [PATCH 18/19] Update place.dart --- fronted/aplicacionrutasturisticas/lib/pages/place.dart | 2 ++ 1 file changed, 2 insertions(+) diff --git a/fronted/aplicacionrutasturisticas/lib/pages/place.dart b/fronted/aplicacionrutasturisticas/lib/pages/place.dart index 6255635..26c8456 100644 --- a/fronted/aplicacionrutasturisticas/lib/pages/place.dart +++ b/fronted/aplicacionrutasturisticas/lib/pages/place.dart @@ -140,3 +140,5 @@ class _PlaceBaseState extends State { ); } } + +//Seb \ No newline at end of file -- GitLab From 5c8d90a5b1bbf5d4d5a2296ea219c391c22d3524 Mon Sep 17 00:00:00 2001 From: Arcangel7651 Date: Tue, 27 Aug 2024 17:25:14 -0600 Subject: [PATCH 19/19] new proyect --- .../lib/config/dio.dart | 21 +++-- .../lib/metodos/places/datos_places.dart | 37 +++++++-- .../lib/pages/login.dart | 2 +- .../lib/pages/place.dart | 80 ++++++++++++++----- .../lib/pages/star_page.dart | 6 +- .../lib/utilerias/FutureBuilder.dart | 10 ++- 6 files changed, 112 insertions(+), 44 deletions(-) diff --git a/fronted/aplicacionrutasturisticas/lib/config/dio.dart b/fronted/aplicacionrutasturisticas/lib/config/dio.dart index fac0678..f523ec8 100644 --- a/fronted/aplicacionrutasturisticas/lib/config/dio.dart +++ b/fronted/aplicacionrutasturisticas/lib/config/dio.dart @@ -4,11 +4,12 @@ import 'package:dio/dio.dart'; final dio = Dio(); +const String localhost = "http://192.168.100.4:3000"; + void Registro_Datos( String nombre, String lastname, String email, String password) async { Response response; - response = - await dio.post("http://192.168.101.13:3000/auth-user/register", data: { + response = await dio.post("$localhost/auth-user/register", data: { "name": nombre, "lastname": lastname, "password": password, @@ -18,8 +19,7 @@ void Registro_Datos( void loginDatos(String email, String password) async { Response responselogin; - responselogin = - await dio.post("http://192.168.101.13:3000/auth-user/login", data: { + responselogin = await dio.post("$localhost/auth-user/login", data: { "email": email, "password": password, }); @@ -29,7 +29,7 @@ void loginDatos(String email, String password) async { //Star page Future datosStartPage(int cityId) async { Response responseCity = await dio.get( - "http://192.168.101.13:3000/city/name", + "$localhost/city/name", queryParameters: {"id": cityId}, ); if (responseCity.statusCode == 200) { @@ -43,7 +43,7 @@ Future datosStartPage(int cityId) async { Future datosTextStartPage(int cityId) async { Response responseCity = await dio.get( - "http://192.168.101.13:3000/city/description", + "$localhost/city/description", queryParameters: {"id": cityId}, ); if (responseCity.statusCode == 200) { @@ -56,22 +56,19 @@ Future datosTextStartPage(int cityId) async { } //Place page -Future> findAllDatPlace( - String placeName, int idCity) async { +Future> findAllDatPlace(String placeName, int idCity) async { try { Response responsePlace = - await dio.get("http://192.168.101.13:3000/place/$idCity/$placeName"); + await dio.get("$localhost/place/$idCity/$placeName"); if (responsePlace.statusCode == 200) { // Si la petición fue exitosa - Map places = responsePlace.data; + List places = responsePlace.data; return places; } else { - // Manejar errores aquí según sea necesario throw Exception('Error al obtener lugares'); } } catch (e) { - // Manejar cualquier error que ocurra durante la solicitud throw Exception('Error en la solicitud HTTP: $e'); } } diff --git a/fronted/aplicacionrutasturisticas/lib/metodos/places/datos_places.dart b/fronted/aplicacionrutasturisticas/lib/metodos/places/datos_places.dart index 5baecb7..0d5a4e6 100644 --- a/fronted/aplicacionrutasturisticas/lib/metodos/places/datos_places.dart +++ b/fronted/aplicacionrutasturisticas/lib/metodos/places/datos_places.dart @@ -1,11 +1,36 @@ import 'package:aplicacionrutasturisticas/config/dio.dart'; class DatosPlaces { - Future> loadCityNameDescription( - String name, int idCity) async { - Map description = await findAllDatPlace(name, idCity); - print("La descripcion es:\n"); - print(description); - return description; + late List description_base; + + Future loadCityNameDescription(String name, int idCity) async { + // Usa await para esperar la carga de datos + List description = await findAllDatPlace(name, idCity); + description_base = description; + } + + String loadNamePlace() { + // Accede al nombre utilizando la clave 'name' + return description_base[0] ?? ''; + } + + String loadDescriptionPlace() { + // Accede a la descripción utilizando la clave 'description' + return description_base[1] ?? ''; + } + + String loadSchedulePlace() { + // Accede al horario utilizando la clave 'schedule' + return description_base[2] ?? ''; + } + + String loadAddressPlace() { + // Accede a la dirección utilizando la clave 'address' + return description_base[3] ?? ''; + } + + String loadCategories() { + // Accede a las categorías utilizando la clave 'categories' + return description_base[4] ?? ''; } } diff --git a/fronted/aplicacionrutasturisticas/lib/pages/login.dart b/fronted/aplicacionrutasturisticas/lib/pages/login.dart index 4d5bae0..a799dd7 100644 --- a/fronted/aplicacionrutasturisticas/lib/pages/login.dart +++ b/fronted/aplicacionrutasturisticas/lib/pages/login.dart @@ -87,7 +87,7 @@ class _TextFielEjemploState extends State { corr = correo.text; pass = password.text; print(corr + " " + pass); - loginDatos(corr, pass); + //loginDatos(corr, pass); context.goNamed("StartPage"); } diff --git a/fronted/aplicacionrutasturisticas/lib/pages/place.dart b/fronted/aplicacionrutasturisticas/lib/pages/place.dart index d83ae79..6255635 100644 --- a/fronted/aplicacionrutasturisticas/lib/pages/place.dart +++ b/fronted/aplicacionrutasturisticas/lib/pages/place.dart @@ -1,6 +1,7 @@ import 'package:aplicacionrutasturisticas/metodos/images/star_page/obtener_imagenes_lista.dart'; import 'package:aplicacionrutasturisticas/utilerias/Carusels.dart'; import 'package:aplicacionrutasturisticas/metodos/places/datos_places.dart'; +import 'package:aplicacionrutasturisticas/utilerias/FutureBuilder.dart'; import 'package:aplicacionrutasturisticas/variables/perfil_variables.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; @@ -17,13 +18,39 @@ class PlaceBase extends StatefulWidget { class _PlaceBaseState extends State { List imgList = []; bool isLoading = true; + String namePlace = ""; + String descriprionPlace = ""; + String schedulePlace = ""; + String adrresPlace = ""; + String categoriesPlace = ""; - @override + @override //Es el contructor que se inicializa al momento de inicar la pagina void initState() { super.initState(); loadImgList(); - print(getIdCity); - DatosPlaces().loadCityNameDescription(widget.place, 1); + loadData(); + } + + //Este metodo manda a llamar a la clase Datos Place para obtener la infomacion del lugar + void loadData() async { + try { + DatosPlaces datos = DatosPlaces(); + await datos.loadCityNameDescription(widget.place, getIdCity); + + setState(() { + namePlace = datos.loadNamePlace(); + descriprionPlace = datos.loadDescriptionPlace(); + schedulePlace = datos.loadSchedulePlace(); + adrresPlace = datos.loadAddressPlace(); + categoriesPlace = datos.loadCategories(); + }); + loadImgList(); + } catch (error) { + print('Error loading data: $error'); + setState(() { + isLoading = false; + }); + } } void loadImgList() async { @@ -41,18 +68,6 @@ class _PlaceBaseState extends State { return Scaffold( body: CustomScrollView( slivers: [ - SliverAppBar( - title: Text('Title: ${widget.place}'), - backgroundColor: Colors.black.withOpacity(0.5), - floating: true, - snap: true, - leading: IconButton( - icon: Icon(Icons.close), - onPressed: () { - Navigator.of(context).pop(); - }, - ), - ), SliverList( delegate: SliverChildListDelegate([ // Aqui se ponen los widgets @@ -65,7 +80,7 @@ class _PlaceBaseState extends State { ), fit: BoxFit.cover, colorFilter: ColorFilter.mode( - Colors.black.withOpacity(0.5), + Colors.white.withOpacity(0.5), BlendMode.darken, ), ), @@ -77,14 +92,41 @@ class _PlaceBaseState extends State { child: Container( height: 3.0, width: 2.0, - color: Colors.white.withOpacity(0.5), + color: Colors.white.withOpacity(0.0), child: Center( child: Column( children: [ + //Aqui van los objetos + SizedBox(height: 50), + Text( + namePlace, + textAlign: TextAlign.center, + style: TextStyle( + color: Colors.white, + fontWeight: FontWeight.bold, + fontSize: 24, + ), + ), isLoading - ? const Center( - child: CupertinoActivityIndicator()) + ? Center(child: CupertinoActivityIndicator()) : carusel_images_list(imgList: imgList), + SizedBox(height: 20), + TextoDinamico( + texto: descriprionPlace, + colors: Colors.white, + ), + TextoDinamico( + texto: 'Horario: $schedulePlace', + colors: Colors.white), + SizedBox(height: 10), + Text( + 'Dirección: $adrresPlace', + style: TextStyle( + fontSize: 16, color: Colors.white), + ), + TextoDinamico( + texto: 'Categorías: $categoriesPlace', + colors: Colors.white) ], ), ), diff --git a/fronted/aplicacionrutasturisticas/lib/pages/star_page.dart b/fronted/aplicacionrutasturisticas/lib/pages/star_page.dart index 4a1ebff..0eebce4 100644 --- a/fronted/aplicacionrutasturisticas/lib/pages/star_page.dart +++ b/fronted/aplicacionrutasturisticas/lib/pages/star_page.dart @@ -102,8 +102,10 @@ class StartedPageState extends State { Center( child: Padding( padding: EdgeInsets.all(20.0), - child: - Container(child: textoDinamico(texto: cityDescription)), + child: Container( + child: TextoDinamico( + texto: cityDescription, + colors: Color.fromARGB(255, 255, 255, 255))), ), ), const SizedBox(height: 80) diff --git a/fronted/aplicacionrutasturisticas/lib/utilerias/FutureBuilder.dart b/fronted/aplicacionrutasturisticas/lib/utilerias/FutureBuilder.dart index 288a6a3..9c33557 100644 --- a/fronted/aplicacionrutasturisticas/lib/utilerias/FutureBuilder.dart +++ b/fronted/aplicacionrutasturisticas/lib/utilerias/FutureBuilder.dart @@ -2,10 +2,12 @@ import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; import 'package:aplicacionrutasturisticas/metodos/cambio_idioma.dart'; -class textoDinamico extends StatelessWidget { +class TextoDinamico extends StatelessWidget { final String texto; + final Color colors; - const textoDinamico({Key? key, required this.texto}) : super(key: key); + const TextoDinamico({Key? key, required this.texto, required this.colors}) + : super(key: key); @override Widget build(BuildContext context) { @@ -19,8 +21,8 @@ class textoDinamico extends StatelessWidget { } else { return Text( snapshot.data ?? 'Cargando...', - style: const TextStyle( - color: Colors.white, + style: TextStyle( + color: colors, fontSize: 15, ), textAlign: TextAlign.justify, -- GitLab