modificaciones en el sistema

This commit is contained in:
Kimberly
2026-05-23 05:54:34 -06:00
parent 32fe398f4b
commit cca83f0012
8 changed files with 867 additions and 533 deletions

View File

@@ -1,5 +1,5 @@
import 'package:flutter/material.dart';
import 'domicilios.dart'; // Para navegar aquí tras el login
import 'domicilios.dart';
class LoginScreen extends StatefulWidget {
const LoginScreen({super.key});
@@ -8,45 +8,35 @@ class LoginScreen extends StatefulWidget {
State<LoginScreen> createState() => _LoginScreenState();
}
class _LoginScreenState extends State<LoginScreen> with SingleTickerProviderStateMixin {
class _LoginScreenState extends State<LoginScreen> {
final _formKey = GlobalKey<FormState>();
// Controladores para capturar el texto
final _usuarioController = TextEditingController();
final _passwordController = TextEditingController();
final TextEditingController emailController =
TextEditingController();
bool _obscurePassword = true; // Ocultar/mostrar contraseña
late TabController _tabController; // Controla si inicia con Email o Teléfono
final TextEditingController passwordController =
TextEditingController();
@override
void initState() {
super.initState();
_tabController = TabController(length: 2, vsync: this);
}
bool ocultarPassword = true;
@override
void dispose() {
_usuarioController.dispose();
_passwordController.dispose();
_tabController.dispose();
super.dispose();
}
void _iniciarSesion() {
void iniciarSesion() {
if (_formKey.currentState!.validate()) {
// Aquí irá tu lógica futura con Firebase/Supabase
// Simulación de login exitoso
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(
content: Text('¡Ingreso exitoso!'),
content: Text('Inicio de sesión exitoso'),
backgroundColor: Colors.green,
),
);
// Navegamos directamente a tu pantalla de Gestión de Domicilios
// Navegar a la pantalla principal
Navigator.pushReplacement(
context,
MaterialPageRoute(builder: (context) => const GestionDomiciliosScreen()),
MaterialPageRoute(
builder: (context) =>
const GestionDomiciliosScreen(),
),
);
}
}
@@ -55,165 +45,180 @@ class _LoginScreenState extends State<LoginScreen> with SingleTickerProviderStat
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Colors.white,
body: SafeArea(
body: Center(
child: SingleChildScrollView(
padding: const EdgeInsets.symmetric(horizontal: 24.0, vertical: 16.0),
padding: const EdgeInsets.all(25),
child: Form(
key: _formKey,
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.center,
children: [
const SizedBox(height: 40),
// Icono e Identidad de la App
// Logo
CircleAvatar(
radius: 45,
backgroundColor: Colors.green[50],
child: Icon(Icons.recycling_rounded, size: 55, color: Colors.green[700]),
),
const SizedBox(height: 16),
Text(
'EcoRecolección',
style: Theme.of(context).textTheme.headlineMedium?.copyWith(
fontWeight: FontWeight.bold,
color: Colors.green[800],
radius: 50,
backgroundColor: Colors.green.shade100,
child: Icon(
Icons.recycling,
size: 60,
color: Colors.green.shade700,
),
),
Text(
'Por una comunidad más limpia y educada',
style: TextStyle(color: Colors.grey[600], fontSize: 14),
const SizedBox(height: 20),
const Text(
'EcoRecolección',
style: TextStyle(
fontSize: 28,
fontWeight: FontWeight.bold,
),
),
const SizedBox(height: 10),
Text(
'Inicia sesión para continuar',
style: TextStyle(
color: Colors.grey.shade600,
fontSize: 16,
),
),
const SizedBox(height: 40),
// Selector de tipo de ingreso (Email / Teléfono)
Container(
decoration: BoxDecoration(
color: Colors.grey[100],
borderRadius: BorderRadius.circular(12),
),
child: TabBar(
controller: _tabController,
indicatorSize: TabBarIndicatorSize.tab,
dividerColor: Colors.transparent,
indicator: BoxDecoration(
color: Colors.green[700],
borderRadius: BorderRadius.circular(12),
),
labelColor: Colors.white,
unselectedLabelColor: Colors.grey[600],
labelStyle: const TextStyle(fontWeight: FontWeight.bold),
tabs: const [
Tab(text: 'Correo Electrónico'),
Tab(text: 'Teléfono'),
],
onTap: (index) {
_usuarioController.clear(); // Limpia al cambiar de pestaña
},
),
),
const SizedBox(height: 24),
// Contenedor dinámico según el Tab activo
AnimatedBuilder(
animation: _tabController,
builder: (context, child) {
bool esEmail = _tabController.index == 0;
return TextFormField(
controller: _usuarioController,
keyboardType: esEmail ? TextInputType.emailAddress : TextInputType.phone,
decoration: InputDecoration(
labelText: esEmail ? 'Correo Electrónico' : 'Número de Teléfono',
hintText: esEmail ? 'ejemplo@correo.com' : '10 dígitos',
prefixIcon: Icon(esEmail ? Icons.email_outlined : Icons.phone_android_rounded, color: Colors.green[700]),
border: OutlineInputBorder(borderRadius: BorderRadius.circular(12)),
focusedBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(12),
borderSide: BorderSide(color: Colors.green[700]!, width: 2),
),
),
validator: (value) {
if (value == null || value.trim().isEmpty) {
return esEmail ? 'Ingresa tu correo' : 'Ingresa tu teléfono';
}
if (esEmail && !RegExp(r'^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$').hasMatch(value)) {
return 'Introduce un correo válido';
}
return null;
},
);
},
),
const SizedBox(height: 16),
// Campo de Contraseña
// Campo correo
TextFormField(
controller: _passwordController,
obscureText: _obscurePassword,
controller: emailController,
decoration: InputDecoration(
labelText: 'Contraseña',
prefixIcon: Icon(Icons.lock_outline_rounded, color: Colors.green[700]),
suffixIcon: IconButton(
icon: Icon(_obscurePassword ? Icons.visibility_off_outlined : Icons.visibility_outlined, color: Colors.grey),
onPressed: () {
setState(() {
_obscurePassword = !_obscurePassword;
});
},
),
border: OutlineInputBorder(borderRadius: BorderRadius.circular(12)),
focusedBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(12),
borderSide: BorderSide(color: Colors.green[700]!, width: 2),
labelText: 'Correo Electrónico',
hintText: 'ejemplo@correo.com',
prefixIcon: const Icon(Icons.email),
border: OutlineInputBorder(
borderRadius:
BorderRadius.circular(15),
),
),
validator: (value) {
if (value == null || value.isEmpty) {
return 'Ingresa tu contraseña';
return 'Ingresa tu correo';
}
if (value.length < 6) {
return 'Debe tener al menos 6 caracteres';
if (!value.contains('@')) {
return 'Correo inválido';
}
return null;
},
),
// Olvidé mi contraseña
Align(
alignment: Alignment.centerRight,
child: TextButton(
onPressed: () {},
child: Text('¿Olvidaste tu contraseña?', style: TextStyle(color: Colors.green[800], fontWeight: FontWeight.w600)),
),
),
const SizedBox(height: 16),
const SizedBox(height: 20),
// Botón Ingresar
// Campo contraseña
TextFormField(
controller: passwordController,
obscureText: ocultarPassword,
decoration: InputDecoration(
labelText: 'Contraseña',
prefixIcon:
const Icon(Icons.lock),
suffixIcon: IconButton(
icon: Icon(
ocultarPassword
? Icons.visibility_off
: Icons.visibility,
),
onPressed: () {
setState(() {
ocultarPassword =
!ocultarPassword;
});
},
),
border: OutlineInputBorder(
borderRadius:
BorderRadius.circular(15),
),
),
validator: (value) {
if (value == null || value.isEmpty) {
return 'Ingresa tu contraseña';
}
if (value.length < 6) {
return 'Mínimo 6 caracteres';
}
return null;
},
),
const SizedBox(height: 30),
// Botón iniciar sesión
SizedBox(
width: double.infinity,
height: 52,
height: 55,
child: ElevatedButton(
onPressed: iniciarSesion,
style: ElevatedButton.styleFrom(
backgroundColor: Colors.green[700],
backgroundColor: Colors.green,
foregroundColor: Colors.white,
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(12)),
elevation: 1,
shape: RoundedRectangleBorder(
borderRadius:
BorderRadius.circular(15),
),
),
child: const Text(
'Iniciar Sesión',
style: TextStyle(
fontSize: 18,
fontWeight: FontWeight.bold,
),
),
onPressed: _iniciarSesion,
child: const Text('Iniciar Sesión', style: TextStyle(fontSize: 16, fontWeight: FontWeight.bold)),
),
),
const SizedBox(height: 24),
// Crear cuenta nueva
const SizedBox(height: 20),
// Registro
Row(
mainAxisAlignment: MainAxisAlignment.center,
mainAxisAlignment:
MainAxisAlignment.center,
children: [
Text('¿No tienes una cuenta? ', style: TextStyle(color: Colors.grey[600])),
GestureDetector(
onTap: () {}, // Aquí abrirías la pantalla de registro
child: Text(
'Regístrate',
style: TextStyle(color: Colors.green[800], fontWeight: FontWeight.bold, decoration: TextDecoration.underline),
const Text(
'¿No tienes cuenta?',
),
TextButton(
onPressed: () {},
child: const Text(
'Registrarse',
style: TextStyle(
color: Colors.green,
fontWeight: FontWeight.bold,
),
),
),
],