From 28b7820641389e6b1d485a35652a2e11a78b7222 Mon Sep 17 00:00:00 2001 From: imlildud Date: Fri, 22 May 2026 18:42:58 -0600 Subject: [PATCH] feat: login window added --- lib/main.dart | 15 ++--- lib/src/views/login.dart | 130 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 138 insertions(+), 7 deletions(-) create mode 100644 lib/src/views/login.dart diff --git a/lib/main.dart b/lib/main.dart index f272b45..7d144fd 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -1,6 +1,8 @@ +// main.dart import 'package:flutter/material.dart'; import 'src/views/rutas.dart'; -import 'src/views/main_screen.dart'; // Importar la pantalla principal +import 'src/views/main_screen.dart'; +import 'src/views/login.dart'; // Importar LoginView void main() { runApp(const MyApp()); @@ -59,7 +61,7 @@ class RegistroView extends StatelessWidget { shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(15)) ), onPressed: () { - // ✅ Navegar a la pantalla principal con todas las vistas + // Navegar a MainScreen (app principal) Navigator.pushReplacement( context, MaterialPageRoute(builder: (context) => const MainScreen()), @@ -74,14 +76,13 @@ class RegistroView extends StatelessWidget { shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(15)) ), onPressed: () { - // TODO: Implementar inicio de sesión - // Por ahora también navega a MainScreen - Navigator.pushReplacement( + // Navegar a LoginView + Navigator.push( context, - MaterialPageRoute(builder: (context) => const MainScreen()), + MaterialPageRoute(builder: (context) => const LoginView()), ); }, - child: const Text('Iniciar Sesion', style: TextStyle(color: Colors.white, fontSize: 18)), + child: const Text('¿Tienes cuenta?', style: TextStyle(color: Colors.white, fontSize: 18)), ), ], ) diff --git a/lib/src/views/login.dart b/lib/src/views/login.dart new file mode 100644 index 0000000..43a34ca --- /dev/null +++ b/lib/src/views/login.dart @@ -0,0 +1,130 @@ +import 'package:flutter/material.dart'; +import 'rutas.dart'; +import 'main_screen.dart'; + +class LoginView extends StatelessWidget { + const LoginView({super.key}); + + final Color colorAzul = const Color(0xFF0F0D38); + final Color colorVerde = const Color(0xFF2E4D31); + + @override + Widget build(BuildContext context) { + return Scaffold( + backgroundColor: Colors.white, + appBar: AppBar( + backgroundColor: colorAzul, + title: const Text('Iniciar Sesión', + style: TextStyle(color: Colors.white, fontWeight: FontWeight.bold, fontSize: 28)), + centerTitle: true, + leading: IconButton( + icon: const Icon(Icons.arrow_back, color: Colors.white, size: 30), + onPressed: () { + Navigator.pop(context); // Regresar al registro + }, + ), + ), + body: SingleChildScrollView( + padding: const EdgeInsets.all(30.0), + child: Column( + children: [ + const SizedBox(height: 50), + // Icono de usuario grande + Container( + padding: const EdgeInsets.all(20), + decoration: BoxDecoration( + shape: BoxShape.circle, + color: colorAzul.withOpacity(0.1), + border: Border.all(color: colorVerde, width: 3), + ), + child: const Icon(Icons.person, size: 80, color: colorAzul), + ), + const SizedBox(height: 50), + // Campo de Correo + _buildInput(Icons.email_outlined, 'Correo electrónico', obscureText: false), + const SizedBox(height: 20), + // Campo de Contraseña + _buildInput(Icons.lock_outline, 'Contraseña', obscureText: true), + const SizedBox(height: 50), + // Botones + Column( + children: [ + // Botón Iniciar Sesión + ElevatedButton( + style: ElevatedButton.styleFrom( + backgroundColor: colorVerde, + minimumSize: const Size(double.infinity, 55), + shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(15)), + ), + onPressed: () { + // Validaciones básicas + // Por ahora navega directamente a MainScreen + Navigator.pushReplacement( + context, + MaterialPageRoute(builder: (context) => const MainScreen()), + ); + }, + child: const Text( + 'Iniciar Sesión', + style: TextStyle(color: Colors.white, fontSize: 20, fontWeight: FontWeight.bold), + ), + ), + const SizedBox(height: 20), + // Botón Crear Cuenta + OutlinedButton( + style: OutlinedButton.styleFrom( + minimumSize: const Size(double.infinity, 55), + side: BorderSide(color: colorAzul, width: 2), + shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(15)), + ), + onPressed: () { + // Regresar al registro + Navigator.pop(context); + }, + child: Text( + 'Crear Cuenta', + style: TextStyle(color: colorAzul, fontSize: 20, fontWeight: FontWeight.bold), + ), + ), + ], + ), + ], + ), + ), + ); + } + + Widget _buildInput(IconData icon, String hint, {bool obscureText = false}) { + return Row( + children: [ + Container( + padding: const EdgeInsets.all(10), + decoration: BoxDecoration( + shape: BoxShape.circle, + border: Border.all(color: Colors.black, width: 2), + ), + child: Icon(icon, size: 40, color: Colors.black), + ), + const SizedBox(width: 15), + Expanded( + child: TextField( + obscureText: obscureText, + decoration: InputDecoration( + hintText: hint, + hintStyle: TextStyle(color: colorVerde.withOpacity(0.5), fontWeight: FontWeight.bold, fontSize: 22), + contentPadding: const EdgeInsets.symmetric(horizontal: 20, vertical: 15), + enabledBorder: OutlineInputBorder( + borderRadius: BorderRadius.circular(30), + borderSide: BorderSide(color: colorVerde, width: 4), + ), + focusedBorder: OutlineInputBorder( + borderRadius: BorderRadius.circular(30), + borderSide: BorderSide(color: colorAzul, width: 4), + ), + ), + ), + ), + ], + ); + } +} \ No newline at end of file