diff --git a/fronted/aplicacionrutasturisticas/lib/config/router.dart b/fronted/aplicacionrutasturisticas/lib/config/router.dart index 5003afec0ae23d0145a39a835d30a058f489868d..67485c3e069d8abd7c05014313a80943a72859bf 100644 --- a/fronted/aplicacionrutasturisticas/lib/config/router.dart +++ b/fronted/aplicacionrutasturisticas/lib/config/router.dart @@ -1,12 +1,21 @@ import 'package:aplicacionrutasturisticas/pages/login.dart'; +import 'package:aplicacionrutasturisticas/pages/register.dart'; import 'package:flutter/cupertino.dart'; import 'package:go_router/go_router.dart'; final GoRouter router = GoRouter(routes: [ GoRoute( - path: 'pages', - builder: (BuildContext context, GoRouterState state) { - return LoginPage(); - }, - ) + name: "LoginPage", + path: '/', + builder: (BuildContext context, GoRouterState state) { + return const TextFielEjemploLogin(); + }, + routes: [ + GoRoute( + name: "RegisterPage", + path: "/registerlogin", + builder: (BuildContext context, GoRouterState state) { + return const RegistroPage(); + }) + ]) ]); diff --git a/fronted/aplicacionrutasturisticas/lib/main.dart b/fronted/aplicacionrutasturisticas/lib/main.dart index 0e3b85c7f699bb0fd651aa481e142c246d793282..65f821a43081444e5b1e0814897c1d3a49177ac2 100644 --- a/fronted/aplicacionrutasturisticas/lib/main.dart +++ b/fronted/aplicacionrutasturisticas/lib/main.dart @@ -2,11 +2,11 @@ import 'package:flutter/material.dart'; import 'package:aplicacionrutasturisticas/pages/login.dart'; import 'package:aplicacionrutasturisticas/pages/register.dart'; -void main(){ +void main() { runApp(MyApp()); } -class MyApp extends StatelessWidget{ +class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { return MaterialApp( diff --git a/fronted/aplicacionrutasturisticas/lib/pages/login.dart b/fronted/aplicacionrutasturisticas/lib/pages/login.dart index a92228718ad56b97078c540dc398970a6524404a..e19a4c272ba199a60736f20796932736bb7723d6 100644 --- a/fronted/aplicacionrutasturisticas/lib/pages/login.dart +++ b/fronted/aplicacionrutasturisticas/lib/pages/login.dart @@ -11,6 +11,11 @@ class TextFielEjemploLogin extends StatefulWidget { } class _TextFielEjemploState extends State { + final correo = TextEditingController(); + final password = TextEditingController(); + + String corr = "", pass = ""; + @override Widget build(BuildContext context) { return MaterialApp( @@ -20,11 +25,9 @@ class _TextFielEjemploState extends State { child: Center( child: Text("Inicia Sesión", style: const TextStyle(fontWeight: FontWeight.bold), - selectionColor: Colors.black) - ) - ), + selectionColor: Colors.black))), ), - body: const Center( + body: Center( child: SingleChildScrollView( child: Column( mainAxisAlignment: MainAxisAlignment.center, @@ -33,22 +36,27 @@ class _TextFielEjemploState extends State { SizedBox( height: 20.0, ), - hacerTextField(texto: "Correo electronico", ocultar: false), + hacerTextField( + controller: correo, + texto: "Correo electronico", + ocultar: false), SizedBox(height: 20), Row( mainAxisAlignment: MainAxisAlignment.center, children: [ hacerTextField( + controller: password, texto: "Contraseña", - ocultar: false, + ocultar: true, ), ], ), SizedBox(height: 20), ColoredBox( - color: Colors.white, + color: Colors.white, child: boton_Escribir( texto: "Iniciar sesión", + onPression: botonIniciaSesion, )) ], ), @@ -57,4 +65,10 @@ class _TextFielEjemploState extends State { ), ); } + + void botonIniciaSesion() { + corr = correo.text; + pass = password.text; + print(corr + " " + pass); + } } diff --git a/fronted/aplicacionrutasturisticas/lib/pages/register.dart b/fronted/aplicacionrutasturisticas/lib/pages/register.dart index 932ec8b447020c4ae6ec5539d46f980d83b8247c..b7e35ca1f2771d5d02c08498185e8a03f9a6b434 100644 --- a/fronted/aplicacionrutasturisticas/lib/pages/register.dart +++ b/fronted/aplicacionrutasturisticas/lib/pages/register.dart @@ -7,14 +7,23 @@ import 'package:flutter/material.dart'; import 'package:flutter/widgets.dart'; import 'package:flutter/services.dart'; -class TextFielEjemplo extends StatefulWidget { - const TextFielEjemplo({super.key}); +class RegistroPage extends StatefulWidget { + const RegistroPage({super.key}); static String id = "register_page"; @override - _TextFielEjemploState createState() => _TextFielEjemploState(); + RegistroPageState createState() => RegistroPageState(); } -class _TextFielEjemploState extends State { +class RegistroPageState extends State { + final nombre = TextEditingController(); + final apellido = TextEditingController(); + final email = TextEditingController(); + final phone = TextEditingController(); + final pasword = TextEditingController(); + final passwordConfirmed = TextEditingController(); + + String nom = "", ape = "", ema = "", pho = "", pass = "", passc = ""; + @override Widget build(BuildContext context) { return MaterialApp( @@ -28,30 +37,33 @@ class _TextFielEjemploState extends State { textScaleFactor: lerpDouble(2, 2, 3)))), ), //backgroundColor: Colors.black, - body: const Center( + body: Center( child: SingleChildScrollView( child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ - iconButton(), - SizedBox( + const iconButton(), + const SizedBox( height: 20.0, ), - hacerTextField(texto: "Nombre/s", ocultar: false), + hacerTextField( + controller: nombre, texto: "Nombre/s", ocultar: false), SizedBox(height: 20), Row( mainAxisAlignment: MainAxisAlignment.center, children: [ hacerTextField( + controller: apellido, texto: "Apellidos", ocultar: false, ), ], ), - SizedBox(height: 20), + const SizedBox(height: 20), ColoredBox( color: Colors.white, child: hacerTextField( + controller: email, texto: "Email", ocultar: false, ), @@ -62,22 +74,30 @@ class _TextFielEjemploState extends State { ColoredBox( color: Colors.white, child: hacerTextField( - texto: "Numero de teléfono", ocultar: false)), + controller: phone, + texto: "Numero de teléfono", + ocultar: false)), SizedBox(height: 20), ColoredBox( color: Colors.white, - child: hacerTextField(texto: "Contraseña", ocultar: true)), + child: hacerTextField( + controller: pasword, + texto: "Contraseña", + ocultar: true)), SizedBox(height: 20), ColoredBox( color: Colors.white, child: hacerTextField( - texto: "Confirma contraseña", ocultar: true), + controller: passwordConfirmed, + texto: "Confirma contraseña", + ocultar: true), ), SizedBox(height: 20), ColoredBox( color: Colors.white, child: boton_Escribir( texto: "Registro", + onPression: precionaRegistro, )) ], ), @@ -86,4 +106,27 @@ class _TextFielEjemploState extends State { ), ); } + + void precionaRegistro() { + nom = nombre.text; + ape = apellido.text; + ema = email.text; + pho = phone.text; + pass = pasword.text; + passc = passwordConfirmed.text; + + print("Haaz precionado el boton \n"); + print(nom + + " " + + ape + + ' ' + + ema + + ' ' + + pho + + ' ' + + pass + + ' ' + + passc + + " \n "); + } } diff --git a/fronted/aplicacionrutasturisticas/lib/utilerias/Buttons.dart b/fronted/aplicacionrutasturisticas/lib/utilerias/Buttons.dart index 3743a2955d74926ebca630d3e63e5b305d9db458..2a02b966118f7591c783623123e94ad370c0e294 100644 --- a/fronted/aplicacionrutasturisticas/lib/utilerias/Buttons.dart +++ b/fronted/aplicacionrutasturisticas/lib/utilerias/Buttons.dart @@ -4,8 +4,10 @@ import 'package:flutter/widgets.dart'; class boton_Escribir extends StatefulWidget { final String texto; - - const boton_Escribir({Key? key, required this.texto}) : super(key: key); + final VoidCallback? onPression; + const boton_Escribir( + {Key? key, required this.texto, required this.onPression}) + : super(key: key); @override _BotonEscribirState createState() => _BotonEscribirState(); @@ -17,10 +19,11 @@ class _BotonEscribirState extends State { @override Widget build(BuildContext context) { return OutlinedButton( - onPressed: () { - debugPrint("Acabas de hacer click"); - //objectoX; - }, + onPressed: widget.onPression ?? + () { + debugPrint("Acabas de hacer click"); + //objectoX; + }, child: Text(widget.texto), style: ButtonStyle( //fixedSize: MaterialStateProperty.all(Size(200, 10)), diff --git a/fronted/aplicacionrutasturisticas/lib/utilerias/Textfields.dart b/fronted/aplicacionrutasturisticas/lib/utilerias/Textfields.dart index f580b5ed55b42bb84ad973e18b600159f6f437f7..b1e4deb9dcb309fa1368642ffce97331ce175236 100644 --- a/fronted/aplicacionrutasturisticas/lib/utilerias/Textfields.dart +++ b/fronted/aplicacionrutasturisticas/lib/utilerias/Textfields.dart @@ -7,13 +7,19 @@ import 'package:flutter/widgets.dart'; class hacerTextField extends StatelessWidget { final String texto; final bool ocultar; - const hacerTextField({Key? key, required this.texto, required this.ocultar}) + final TextEditingController? controller; + const hacerTextField( + {Key? key, + required this.controller, + required this.texto, + required this.ocultar}) : super(key: key); @override Widget build(BuildContext context) { return SizedBox( width: 250, child: TextField( + controller: controller, cursorColor: Colors.purple, style: const TextStyle( color: Color.fromARGB(255, 0, 0, 0),