FIX: VIEW REGISTER
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import '../../../../core/router/app_router.dart'; // 📍 Importación de rutas verificada
|
||||
|
||||
import '../../../../core/theme/app_theme.dart';
|
||||
import '../bloc/auth_bloc.dart';
|
||||
@@ -36,7 +37,8 @@ class _LoginScreenState extends State<LoginScreen>
|
||||
);
|
||||
_fadeAnim = CurvedAnimation(parent: _animController, curve: Curves.easeOut);
|
||||
_slideAnim = Tween<Offset>(begin: const Offset(0, 0.06), end: Offset.zero)
|
||||
.animate(CurvedAnimation(parent: _animController, curve: Curves.easeOutCubic));
|
||||
.animate(CurvedAnimation(
|
||||
parent: _animController, curve: Curves.easeOutCubic));
|
||||
_animController.forward();
|
||||
}
|
||||
|
||||
@@ -68,7 +70,8 @@ class _LoginScreenState extends State<LoginScreen>
|
||||
SnackBar(
|
||||
content: Row(
|
||||
children: [
|
||||
const Icon(Icons.error_outline, color: Colors.white, size: 18),
|
||||
const Icon(Icons.error_outline,
|
||||
color: Colors.white, size: 18),
|
||||
const SizedBox(width: 10),
|
||||
Expanded(child: Text(state.message)),
|
||||
],
|
||||
@@ -104,13 +107,15 @@ class _LoginScreenState extends State<LoginScreen>
|
||||
_buildDemoHint(),
|
||||
const Spacer(),
|
||||
const SizedBox(height: 8),
|
||||
Text(
|
||||
'Sistema Municipal de Recolección Residencial\nCelaya, Guanajuato',
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(
|
||||
fontSize: 12,
|
||||
color: Colors.grey.shade600,
|
||||
height: 1.3),
|
||||
Center(
|
||||
child: Text(
|
||||
'Sistema Municipal de Recolección Residencial\nCelaya, Guanajuato',
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(
|
||||
fontSize: 12,
|
||||
color: Colors.grey.shade600,
|
||||
height: 1.3),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 48),
|
||||
],
|
||||
@@ -163,7 +168,6 @@ class _LoginScreenState extends State<LoginScreen>
|
||||
: null,
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
|
||||
TextFormField(
|
||||
controller: _passwordController,
|
||||
obscureText: _obscurePassword,
|
||||
@@ -175,7 +179,8 @@ class _LoginScreenState extends State<LoginScreen>
|
||||
suffixIcon: IconButton(
|
||||
icon: Icon(
|
||||
_obscurePassword ? Icons.visibility : Icons.visibility_off),
|
||||
onPressed: () => setState(() => _obscurePassword = !_obscurePassword),
|
||||
onPressed: () =>
|
||||
setState(() => _obscurePassword = !_obscurePassword),
|
||||
),
|
||||
),
|
||||
validator: (value) => (value == null || value.isEmpty)
|
||||
@@ -183,7 +188,6 @@ class _LoginScreenState extends State<LoginScreen>
|
||||
: null,
|
||||
),
|
||||
const SizedBox(height: 32),
|
||||
|
||||
BlocBuilder<AuthBloc, AuthState>(
|
||||
builder: (context, state) {
|
||||
final isLoading = state is AuthLoading;
|
||||
@@ -200,7 +204,8 @@ class _LoginScreenState extends State<LoginScreen>
|
||||
? []
|
||||
: [
|
||||
BoxShadow(
|
||||
color: AppTheme.leafGreen.withValues(alpha: 0.3),
|
||||
color:
|
||||
AppTheme.leafGreen.withValues(alpha: 0.3),
|
||||
blurRadius: 16,
|
||||
offset: const Offset(0, 6),
|
||||
),
|
||||
@@ -220,43 +225,26 @@ class _LoginScreenState extends State<LoginScreen>
|
||||
),
|
||||
child: isLoading
|
||||
? const SizedBox(
|
||||
height: 22,
|
||||
width: 22,
|
||||
height: 20,
|
||||
width: 20,
|
||||
child: CircularProgressIndicator(
|
||||
strokeWidth: 2.5,
|
||||
valueColor: AlwaysStoppedAnimation(Colors.white),
|
||||
),
|
||||
color: Colors.white, strokeWidth: 2),
|
||||
)
|
||||
: const Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Icon(Icons.login_rounded,
|
||||
size: 20, color: Colors.white),
|
||||
SizedBox(width: 10),
|
||||
Text(
|
||||
'Ingresar de forma segura',
|
||||
style: TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 15,
|
||||
fontWeight: FontWeight.bold),
|
||||
),
|
||||
],
|
||||
),
|
||||
: const Text('Iniciar Sesión',
|
||||
style: TextStyle(color: Colors.white)),
|
||||
),
|
||||
),
|
||||
|
||||
const SizedBox(height: 20),
|
||||
const SizedBox(height: 16),
|
||||
// 📍 BOTÓN DE REGISTRO CORREGIDO (child al final)
|
||||
TextButton(
|
||||
onPressed: () => context.push('/register'),
|
||||
child: const Text(
|
||||
'¿No tienes una cuenta ciudadana? Regístrate aquí',
|
||||
style: TextStyle(
|
||||
color: AppTheme.leafGreen,
|
||||
fontWeight: FontWeight.w700,
|
||||
fontSize: 13,
|
||||
),
|
||||
onPressed: () => context.push(AppRoutes.register),
|
||||
style: TextButton.styleFrom(
|
||||
foregroundColor: AppTheme.leafGreen,
|
||||
textStyle: const TextStyle(
|
||||
fontSize: 14, fontWeight: FontWeight.w500),
|
||||
),
|
||||
)
|
||||
child: const Text('¿No tienes cuenta? Regístrate aquí'),
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
@@ -266,10 +254,6 @@ class _LoginScreenState extends State<LoginScreen>
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildDemoHint() {
|
||||
return const Text(
|
||||
'Credenciales de demo: ciudadano@ejemplo.com / password123',
|
||||
style: TextStyle(fontSize: 12, color: Colors.black54),
|
||||
);
|
||||
}
|
||||
// Placeholders para evitar errores si no están definidos
|
||||
Widget _buildDemoHint() => const SizedBox.shrink();
|
||||
}
|
||||
|
||||
@@ -11,11 +11,31 @@ class RegisterScreen extends StatefulWidget {
|
||||
|
||||
class _RegisterScreenState extends State<RegisterScreen> {
|
||||
final _formKey = GlobalKey<FormState>();
|
||||
String _selectedColonia = 'Centro';
|
||||
late String _selectedColonia; // 📍 Se mantiene late pero se inicializa abajo
|
||||
final _nameController = TextEditingController();
|
||||
final _emailController = TextEditingController();
|
||||
final _passwordController = TextEditingController();
|
||||
|
||||
// 📍 CORRECCIÓN CRÍTICA: Asignar el valor inicial antes del método build
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
if (MockWasteData.schedules.isNotEmpty) {
|
||||
// Evita problemas de aserción tomando el primer valor real de tus mocks
|
||||
_selectedColonia = MockWasteData.schedules.first.colonia;
|
||||
} else {
|
||||
_selectedColonia = ''; // Respaldo por si la lista estuviera vacía
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_nameController.dispose();
|
||||
_emailController.dispose();
|
||||
_passwordController.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
@@ -38,26 +58,26 @@ class _RegisterScreenState extends State<RegisterScreen> {
|
||||
TextFormField(
|
||||
controller: _nameController,
|
||||
decoration: const InputDecoration(labelText: 'Nombre Completo', border: OutlineInputBorder()),
|
||||
validator: (v) => v!.isEmpty ? 'Ingresa tu nombre' : null,
|
||||
validator: (v) => v == null || v.isEmpty ? 'Ingresa tu nombre' : null,
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
TextFormField(
|
||||
controller: _emailController,
|
||||
decoration: const InputDecoration(labelText: 'Correo o Teléfono', border: OutlineInputBorder()),
|
||||
validator: (v) => v!.isEmpty ? 'Ingresa tus datos' : null,
|
||||
validator: (v) => v == null || v.isEmpty ? 'Ingresa tus datos' : null,
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
TextFormField(
|
||||
controller: _passwordController,
|
||||
obscureText: true,
|
||||
decoration: const InputDecoration(labelText: 'Contraseña', border: OutlineInputBorder()),
|
||||
validator: (v) => v!.length < 6 ? 'Mínimo 6 caracteres' : null,
|
||||
validator: (v) => v == null || v.length < 6 ? 'Mínimo 6 caracteres' : null,
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
|
||||
// Dropdown para seleccionar la Colonia (Requisito MVP)
|
||||
// Dropdown para seleccionar la Colonia
|
||||
DropdownButtonFormField<String>(
|
||||
initialValue: _selectedColonia,
|
||||
value: _selectedColonia,
|
||||
decoration: const InputDecoration(labelText: 'Selecciona tu Colonia / Domicilio', border: OutlineInputBorder()),
|
||||
items: MockWasteData.schedules.map((zone) {
|
||||
return DropdownMenuItem(value: zone.colonia, child: Text(zone.colonia));
|
||||
@@ -82,7 +102,6 @@ class _RegisterScreenState extends State<RegisterScreen> {
|
||||
style: ElevatedButton.styleFrom(padding: const EdgeInsets.symmetric(vertical: 16), backgroundColor: Colors.green),
|
||||
onPressed: () {
|
||||
if (_formKey.currentState!.validate()) {
|
||||
// Simulación de Registro Exitoso: Navega al Home enviando la colonia elegida
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
const SnackBar(content: Text('Cuenta creada con éxito (Modo Simulación)')),
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user