From 1f968e3a677f2f16543f218d6ef16dc8c60bc182 Mon Sep 17 00:00:00 2001 From: Angel David Carlos Silva Date: Thu, 25 Apr 2024 11:43:07 -0600 Subject: [PATCH] login y password modo chido --- .../lib/config/router.dart | 19 ++++-- .../aplicacionrutasturisticas/lib/main.dart | 4 +- .../lib/pages/login.dart | 28 ++++++-- .../lib/pages/register.dart | 67 +++++++++++++++---- .../lib/utilerias/Buttons.dart | 15 +++-- .../lib/utilerias/Textfields.dart | 8 ++- 6 files changed, 108 insertions(+), 33 deletions(-) diff --git a/fronted/aplicacionrutasturisticas/lib/config/router.dart b/fronted/aplicacionrutasturisticas/lib/config/router.dart index 5003afe..67485c3 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 0e3b85c..65f821a 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 a922287..e19a4c2 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 932ec8b..b7e35ca 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 3743a29..2a02b96 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 f580b5e..b1e4deb 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), -- GitLab