fix: actualizar la forma de aplicar opacidad en colores de tema y componentes de la interfaz, y se arreglaron errores de interfaz

This commit is contained in:
Moisés Méndez
2026-05-23 03:41:03 -06:00
parent 536f0a1914
commit c91d1f298e
5 changed files with 243 additions and 191 deletions

View File

@@ -8,15 +8,6 @@ import '../bloc/auth_event.dart';
import '../bloc/auth_state.dart';
import '../widgets/privacy_notice_card.dart';
/// Pantalla de inicio de sesión — MVP WasteNotify.
///
/// Diseño: Limpio, institucional, con paleta verde-tierra.
/// Incluye mensajería preventiva integrada de forma no intrusiva.
///
/// Credenciales de demo:
/// Ciudadano: ciudadano@ejemplo.com / password123
/// Operador: operador@ejemplo.com / operador456
/// Teléfono: 5551234567 / pass1234
class LoginScreen extends StatefulWidget {
const LoginScreen({super.key});
@@ -31,6 +22,7 @@ class _LoginScreenState extends State<LoginScreen>
final _passwordController = TextEditingController();
bool _obscurePassword = true;
late final AnimationController _animController;
late final Animation<double> _fadeAnim;
late final Animation<Offset> _slideAnim;
@@ -42,17 +34,9 @@ class _LoginScreenState extends State<LoginScreen>
vsync: this,
duration: const Duration(milliseconds: 700),
);
_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,
));
_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));
_animController.forward();
}
@@ -68,7 +52,7 @@ class _LoginScreenState extends State<LoginScreen>
if (_formKey.currentState?.validate() ?? false) {
context.read<AuthBloc>().add(
AuthLoginRequested(
identifier: _identifierController.text,
identifier: _identifierController.text.trim(),
password: _passwordController.text,
),
);
@@ -113,151 +97,179 @@ class _LoginScreenState extends State<LoginScreen>
const SizedBox(height: 48),
_buildHeader(),
const SizedBox(height: 32),
const ScheduleWarningBanner(),
const SizedBox(height: 32),
_buildForm(context),
const SizedBox(height: 24),
const PrivacyNoticeCard(),
const SizedBox(height: 32),
_buildDemoHint(),
const SizedBox(height: 24),
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),
),
const SizedBox(height: 48),
],
),
),
), 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),
),
const SizedBox(height: 48),
),
),
],
),
),
),
);
}
// --- CAMPO: EMAIL / IDENTIFICADOR ---
TextFormField(
controller: _emailController,
keyboardType: TextInputType.emailAddress,
decoration: const InputDecoration(
labelText: 'Correo Electrónico o Teléfono',
prefixIcon: Icon(Icons.email_outlined),
border: OutlineInputBorder(
borderRadius: BorderRadius.all(Radius.circular(12))),
),
validator: (value) =>
(value == null || value.trim().isEmpty)
? 'Por favor, ingresa tus datos de acceso'
: null,
),
const SizedBox(height: 20),
Widget _buildHeader() {
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: const [
Text(
'Bienvenido a WasteNotify',
style: TextStyle(fontSize: 26, fontWeight: FontWeight.bold),
),
SizedBox(height: 8),
Text(
'Inicia sesión para continuar',
style: TextStyle(fontSize: 14, color: Colors.grey),
),
],
);
}
// --- CAMPO: CONTRASENA ---
TextFormField(
controller: _passwordController,
obscureText: true,
decoration: const InputDecoration(
labelText: 'Contraseña de Acceso',
prefixIcon: Icon(Icons.lock_outline_rounded),
border: OutlineInputBorder(
borderRadius: BorderRadius.all(Radius.circular(12))),
),
validator: (value) => (value == null || value.isEmpty)
? 'Por favor, introduce tu contraseña'
: null,
),
const SizedBox(height: 32),
Widget _buildForm(BuildContext context) {
return Form(
key: _formKey,
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
TextFormField(
controller: _identifierController,
keyboardType: TextInputType.emailAddress,
decoration: const InputDecoration(
labelText: 'Correo Electrónico o Teléfono',
prefixIcon: Icon(Icons.email_outlined),
border: OutlineInputBorder(
borderRadius: BorderRadius.all(Radius.circular(12))),
),
validator: (value) => (value == null || value.trim().isEmpty)
? 'Por favor, ingresa tus datos de acceso'
: null,
),
const SizedBox(height: 20),
// --- CONTENEDOR REACTIVO DE BOTONES (LOGIN & REGISTER) ---
// --- CONTENEDOR REACTIVO DE BOTONES (LOGIN & REGISTER) ---
BlocBuilder<AuthBloc, AuthState>(
builder: (context, state) {
final isLoading = state is AuthLoading;
TextFormField(
controller: _passwordController,
obscureText: _obscurePassword,
decoration: InputDecoration(
labelText: 'Contraseña de Acceso',
prefixIcon: const Icon(Icons.lock_outline_rounded),
border: const OutlineInputBorder(
borderRadius: BorderRadius.all(Radius.circular(12))),
suffixIcon: IconButton(
icon: Icon(
_obscurePassword ? Icons.visibility : Icons.visibility_off),
onPressed: () => setState(() => _obscurePassword = !_obscurePassword),
),
),
validator: (value) => (value == null || value.isEmpty)
? 'Por favor, introduce tu contraseña'
: null,
),
const SizedBox(height: 32),
return Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
AnimatedContainer(
duration: const Duration(milliseconds: 200),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(12),
boxShadow: isLoading
? []
: [
BoxShadow(
color: AppTheme.leafGreen
.withOpacity(0.3),
blurRadius: 16,
offset: const Offset(0, 6),
),
],
BlocBuilder<AuthBloc, AuthState>(
builder: (context, state) {
final isLoading = state is AuthLoading;
return Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
AnimatedContainer(
duration: const Duration(milliseconds: 200),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(12),
boxShadow: isLoading
? []
: [
BoxShadow(
color: AppTheme.leafGreen.withValues(alpha: 0.3),
blurRadius: 16,
offset: const Offset(0, 6),
),
child: ElevatedButton(
onPressed:
isLoading ? null : () => _submit(context),
style: ElevatedButton.styleFrom(
backgroundColor: isLoading
? AppTheme.mintGreen.withOpacity(0.7)
: AppTheme.leafGreen,
disabledBackgroundColor:
AppTheme.mintGreen.withOpacity(0.6),
padding:
const EdgeInsets.symmetric(vertical: 16),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(12)),
),
child: isLoading
? const SizedBox(
height: 22,
width: 22,
child: CircularProgressIndicator(
strokeWidth: 2.5,
valueColor: AlwaysStoppedAnimation(
Colors.white),
),
)
: 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),
),
],
),
),
),
// 📍 ENLACE DE REDIRECCIÓN AL REGISTRO CIUDADANO
const SizedBox(height: 20),
TextButton(
onPressed: () {
// 🚀 Forzamos la navegación limpia usando la ruta de texto directo
context.push('/register');
},
child: const Text(
'¿No tienes una cuenta ciudadana? Regístrate aquí',
style: TextStyle(
color: AppTheme.leafGreen,
fontWeight: FontWeight.w700,
fontSize: 13,
),
],
),
child: ElevatedButton(
onPressed: isLoading ? null : () => _submit(context),
style: ElevatedButton.styleFrom(
backgroundColor: isLoading
? AppTheme.mintGreen.withValues(alpha: 0.7)
: AppTheme.leafGreen,
disabledBackgroundColor:
AppTheme.mintGreen.withValues(alpha: 0.6),
padding: const EdgeInsets.symmetric(vertical: 16),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(12)),
),
child: isLoading
? const SizedBox(
height: 22,
width: 22,
child: CircularProgressIndicator(
strokeWidth: 2.5,
valueColor: AlwaysStoppedAnimation(Colors.white),
),
)
]);
},
: 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),
),
],
),
),
),
], // Fin children de la Column
), // Fin Column
), // Fin Form
), // Fin SingleChildScrollView
), // Fin SafeArea
), // Fin BlocListener
); // Fin Scaffold (Asegúrate de que tenga el punto y coma aquí)
const SizedBox(height: 20),
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,
),
),
)
],
);
},
),
],
),
);
}
Widget _buildDemoHint() {
return const Text(
'Credenciales de demo: ciudadano@ejemplo.com / password123',
style: TextStyle(fontSize: 12, color: Colors.black54),
);
}
}