feat: pantallas de auth — login rediseñado, registro local y cloud
Login:
- Tema oscuro propio (_kBg, _kPanel, _kAccent) con gradiente top→bottom
- Toggle animado Cuenta local / Cloud con indicador deslizante
- Validación inline, checkbox "Mantener sesión", botón degradado h52
- Links "¿No tienes cuenta?" → /registro y /registro_cloud
Registro local (/registro):
- 7 campos: nombre, correo, teléfono, empresa, RUC, contraseña x2
- Indicador de fortaleza (4 criterios), SHA-256, snackbar + pop al éxito
Registro cloud (/registro_cloud) — flujo 3 pasos + OTP:
- Paso 1: POST /api/auth/pre-register, stepper animado
- Paso 2: OTP 6 dígitos, cooldown 60s, reenvío
- Paso 3: nombre empresa (normalizado a MAYUSCULAS_SNAKE), usuario, contraseña
- Pantalla "Creando" con LinearProgressIndicator y lista de 6 pasos animados
- Pantalla de éxito → pushNamedAndRemoveUntil('/login')
- timeout 120s en POST /api/auth/register (creación de tenant)
AuthService: preRegister(), verifyOtpRegistro(), register(), saveLocalSession()
pubspec: agrega crypto ^3.0.0 para SHA-256
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 4.6
parent
eb081f3ea4
commit
47226f5fa5
+501
-199
@@ -1,7 +1,16 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import '../../providers/app_provider.dart';
|
||||
import '../../theme/app_theme.dart';
|
||||
|
||||
// Paleta exclusiva de pantallas de autenticación (spec estructura_login.md §7)
|
||||
const _kBg = Color(0xFF0A1E3C);
|
||||
const _kTopBar = Color(0xFF0D2D6B);
|
||||
const _kPanel = Color(0xFF0F2A4A);
|
||||
const _kCard = Color(0xFF163558);
|
||||
const _kBorder = Color(0xFF1E4070);
|
||||
const _kAccent = Color(0xFF1976D2);
|
||||
const _kTextMuted = Color(0xFFAABBCC);
|
||||
const _kError = Color(0xFFFF6B6B);
|
||||
|
||||
class LoginScreen extends StatefulWidget {
|
||||
const LoginScreen({Key? key}) : super(key: key);
|
||||
@@ -10,240 +19,533 @@ class LoginScreen extends StatefulWidget {
|
||||
State<LoginScreen> createState() => _LoginScreenState();
|
||||
}
|
||||
|
||||
class _LoginScreenState extends State<LoginScreen> {
|
||||
final _emailCtrl = TextEditingController(text: 'admin@telcotronics.com');
|
||||
final _passCtrl = TextEditingController(text: 'Microbot%');
|
||||
bool _obscure = true;
|
||||
bool _loading = false;
|
||||
String? _error;
|
||||
class _LoginScreenState extends State<LoginScreen>
|
||||
with SingleTickerProviderStateMixin {
|
||||
final _formKey = GlobalKey<FormState>();
|
||||
final _emailCtrl = TextEditingController();
|
||||
final _passCtrl = TextEditingController();
|
||||
|
||||
bool _obscure = true;
|
||||
bool _rememberMe = true;
|
||||
bool _modoCloud = true;
|
||||
|
||||
late final AnimationController _toggleAnim;
|
||||
late final Animation<double> _toggleSlide;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_toggleAnim = AnimationController(
|
||||
vsync: this,
|
||||
duration: const Duration(milliseconds: 240),
|
||||
value: 1.0, // arranca en Cloud (posición derecha)
|
||||
);
|
||||
_toggleSlide = CurvedAnimation(
|
||||
parent: _toggleAnim, curve: Curves.easeInOut);
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_emailCtrl.dispose();
|
||||
_passCtrl.dispose();
|
||||
_toggleAnim.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
Future<void> _login() async {
|
||||
setState(() { _loading = true; _error = null; });
|
||||
final ok = await context.read<AppProvider>().login(
|
||||
_emailCtrl.text.trim(), _passCtrl.text);
|
||||
if (!ok && mounted) {
|
||||
setState(() {
|
||||
_loading = false;
|
||||
_error = context.read<AppProvider>().loginError;
|
||||
});
|
||||
void _switchModo(bool cloud) {
|
||||
if (_modoCloud == cloud) return;
|
||||
setState(() => _modoCloud = cloud);
|
||||
if (cloud) {
|
||||
_toggleAnim.forward();
|
||||
} else {
|
||||
_toggleAnim.reverse();
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> _ingresar() async {
|
||||
if (!(_formKey.currentState?.validate() ?? false)) return;
|
||||
final provider = context.read<AppProvider>();
|
||||
if (_modoCloud) {
|
||||
await provider.login(
|
||||
_emailCtrl.text.trim(),
|
||||
_passCtrl.text,
|
||||
rememberMe: _rememberMe,
|
||||
);
|
||||
} else {
|
||||
await provider.loginLocal(
|
||||
_emailCtrl.text.trim(),
|
||||
_passCtrl.text,
|
||||
rememberMe: _rememberMe,
|
||||
);
|
||||
}
|
||||
// Si ok, el Consumer en main.dart navega a HomeScreen automáticamente
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final provider = context.watch<AppProvider>();
|
||||
return Scaffold(
|
||||
body: Container(
|
||||
decoration: const BoxDecoration(
|
||||
gradient: LinearGradient(
|
||||
colors: [Color(0xFF1E3A8A), Color(0xFF1E40AF), Color(0xFF2563EB)],
|
||||
begin: Alignment.topLeft,
|
||||
end: Alignment.bottomRight,
|
||||
),
|
||||
),
|
||||
child: SafeArea(
|
||||
child: Center(
|
||||
child: SingleChildScrollView(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 28),
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
_buildLogo(),
|
||||
const SizedBox(height: 40),
|
||||
_buildCard(),
|
||||
const SizedBox(height: 24),
|
||||
_buildVersion(),
|
||||
],
|
||||
backgroundColor: _kBg,
|
||||
body: Stack(
|
||||
children: [
|
||||
// Degradado superior
|
||||
Container(
|
||||
height: MediaQuery.of(context).size.height * 0.44,
|
||||
decoration: const BoxDecoration(
|
||||
gradient: LinearGradient(
|
||||
colors: [_kTopBar, _kBg],
|
||||
begin: Alignment.topCenter,
|
||||
end: Alignment.bottomCenter,
|
||||
),
|
||||
),
|
||||
),
|
||||
SafeArea(
|
||||
child: Column(
|
||||
children: [
|
||||
Expanded(child: _buildLogoZone()),
|
||||
_buildFormPanel(provider),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
// ── Zona logo ────────────────────────────────────────────────
|
||||
|
||||
Widget _buildLogoZone() {
|
||||
return Center(
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Container(
|
||||
width: 80,
|
||||
height: 80,
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(20),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: Colors.black.withOpacity(0.38),
|
||||
blurRadius: 18,
|
||||
offset: const Offset(0, 7),
|
||||
),
|
||||
],
|
||||
),
|
||||
child: ClipRRect(
|
||||
borderRadius: BorderRadius.circular(20),
|
||||
child: Image.asset(
|
||||
'assets/icon/icon.png',
|
||||
fit: BoxFit.cover,
|
||||
errorBuilder: (_, __, ___) => Container(
|
||||
color: _kAccent,
|
||||
child: const Icon(Icons.storefront,
|
||||
size: 40, color: Colors.white),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
const Text(
|
||||
'AGENTE VENTAS',
|
||||
style: TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 22,
|
||||
fontWeight: FontWeight.bold,
|
||||
letterSpacing: 5,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 5),
|
||||
const Text(
|
||||
'SIGMAC · Telcotronics',
|
||||
style: TextStyle(
|
||||
color: _kTextMuted,
|
||||
fontSize: 12,
|
||||
letterSpacing: 2,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
// ── Panel formulario ─────────────────────────────────────────
|
||||
|
||||
Widget _buildFormPanel(AppProvider provider) {
|
||||
return Container(
|
||||
decoration: const BoxDecoration(
|
||||
color: _kPanel,
|
||||
borderRadius: BorderRadius.only(
|
||||
topLeft: Radius.circular(32),
|
||||
topRight: Radius.circular(32),
|
||||
),
|
||||
),
|
||||
padding: const EdgeInsets.fromLTRB(24, 28, 24, 36),
|
||||
child: Form(
|
||||
key: _formKey,
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
const Text(
|
||||
'Bienvenido',
|
||||
style: TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 20,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 3),
|
||||
const Text(
|
||||
'Ingresa tus credenciales para continuar',
|
||||
style: TextStyle(color: _kTextMuted, fontSize: 13),
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
_buildToggle(),
|
||||
const SizedBox(height: 18),
|
||||
_buildField(
|
||||
controller: _emailCtrl,
|
||||
label: _modoCloud ? 'Correo electrónico' : 'Usuario',
|
||||
icon: _modoCloud ? Icons.email_outlined : Icons.person_outline,
|
||||
keyboardType: _modoCloud
|
||||
? TextInputType.emailAddress
|
||||
: TextInputType.text,
|
||||
validator: _modoCloud
|
||||
? (v) {
|
||||
if (v == null || v.trim().isEmpty) return 'Ingresa tu correo';
|
||||
if (!v.contains('@') || !v.contains('.')) {
|
||||
return 'Correo inválido';
|
||||
}
|
||||
return null;
|
||||
}
|
||||
: (v) {
|
||||
if (v == null || v.trim().isEmpty) return 'Ingresa tu usuario';
|
||||
return null;
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 13),
|
||||
_buildField(
|
||||
controller: _passCtrl,
|
||||
label: 'Contraseña',
|
||||
icon: Icons.lock_outline,
|
||||
obscure: _obscure,
|
||||
suffix: IconButton(
|
||||
icon: Icon(
|
||||
_obscure
|
||||
? Icons.visibility_outlined
|
||||
: Icons.visibility_off_outlined,
|
||||
color: _kTextMuted,
|
||||
size: 20,
|
||||
),
|
||||
onPressed: () => setState(() => _obscure = !_obscure),
|
||||
),
|
||||
validator: (v) {
|
||||
if (v == null || v.isEmpty) return 'Ingresa tu contraseña';
|
||||
if (v.length < 6) return 'Mínimo 6 caracteres';
|
||||
return null;
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
_buildRememberRow(),
|
||||
if (provider.loginError != null) ...[
|
||||
const SizedBox(height: 12),
|
||||
_buildErrorBox(provider.loginError!),
|
||||
],
|
||||
const SizedBox(height: 16),
|
||||
_buildButton(provider.loading),
|
||||
const SizedBox(height: 12),
|
||||
_buildRegistroLinks(),
|
||||
const SizedBox(height: 12),
|
||||
Center(
|
||||
child: Text(
|
||||
'v1.0.0 · SIGMAC',
|
||||
style: TextStyle(
|
||||
color: _kTextMuted.withOpacity(0.55), fontSize: 11),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
// ── Toggle Local / Cloud ─────────────────────────────────────
|
||||
|
||||
Widget _buildToggle() {
|
||||
return LayoutBuilder(
|
||||
builder: (_, constraints) {
|
||||
final halfW = constraints.maxWidth / 2;
|
||||
return Container(
|
||||
height: 40,
|
||||
decoration: BoxDecoration(
|
||||
color: _kCard,
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
border: Border.all(color: _kBorder),
|
||||
),
|
||||
child: AnimatedBuilder(
|
||||
animation: _toggleSlide,
|
||||
builder: (_, __) => Stack(
|
||||
children: [
|
||||
// Indicador deslizante
|
||||
Positioned(
|
||||
left: _toggleSlide.value * halfW + 3,
|
||||
top: 3,
|
||||
bottom: 3,
|
||||
width: halfW - 6,
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
color: _kAccent,
|
||||
borderRadius: BorderRadius.circular(7),
|
||||
),
|
||||
),
|
||||
),
|
||||
// Labels
|
||||
Row(
|
||||
children: [
|
||||
_toggleOption('Cuenta local', !_modoCloud,
|
||||
onTap: () => _switchModo(false)),
|
||||
_toggleOption('Cloud', _modoCloud,
|
||||
onTap: () => _switchModo(true)),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
Widget _toggleOption(String label, bool active, {required VoidCallback onTap}) {
|
||||
return Expanded(
|
||||
child: GestureDetector(
|
||||
onTap: onTap,
|
||||
behavior: HitTestBehavior.opaque,
|
||||
child: Center(
|
||||
child: Text(
|
||||
label,
|
||||
style: TextStyle(
|
||||
color: active ? Colors.white : _kTextMuted,
|
||||
fontSize: 13,
|
||||
fontWeight: active ? FontWeight.w600 : FontWeight.normal,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildLogo() {
|
||||
return Column(
|
||||
// ── Campo de texto ───────────────────────────────────────────
|
||||
|
||||
Widget _buildField({
|
||||
required TextEditingController controller,
|
||||
required String label,
|
||||
required IconData icon,
|
||||
TextInputType? keyboardType,
|
||||
bool obscure = false,
|
||||
Widget? suffix,
|
||||
String? Function(String?)? validator,
|
||||
}) {
|
||||
return TextFormField(
|
||||
controller: controller,
|
||||
obscureText: obscure,
|
||||
keyboardType: keyboardType,
|
||||
validator: validator,
|
||||
style: const TextStyle(color: Colors.white, fontSize: 14),
|
||||
decoration: InputDecoration(
|
||||
labelText: label,
|
||||
labelStyle: const TextStyle(color: _kTextMuted, fontSize: 13),
|
||||
prefixIcon: Icon(icon, color: _kTextMuted, size: 20),
|
||||
suffixIcon: suffix,
|
||||
filled: true,
|
||||
fillColor: _kCard,
|
||||
contentPadding:
|
||||
const EdgeInsets.symmetric(horizontal: 16, vertical: 14),
|
||||
enabledBorder: OutlineInputBorder(
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
borderSide: const BorderSide(color: _kBorder),
|
||||
),
|
||||
focusedBorder: OutlineInputBorder(
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
borderSide: const BorderSide(color: _kAccent, width: 2),
|
||||
),
|
||||
errorBorder: OutlineInputBorder(
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
borderSide: const BorderSide(color: _kError),
|
||||
),
|
||||
focusedErrorBorder: OutlineInputBorder(
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
borderSide: const BorderSide(color: _kError, width: 2),
|
||||
),
|
||||
errorStyle: const TextStyle(color: _kError, fontSize: 11),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
// ── Fila "Mantener sesión" ───────────────────────────────────
|
||||
|
||||
Widget _buildRememberRow() {
|
||||
return Row(
|
||||
children: [
|
||||
Container(
|
||||
width: 96,
|
||||
height: 96,
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(24),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: Colors.black.withOpacity(0.25),
|
||||
blurRadius: 20,
|
||||
offset: const Offset(0, 8),
|
||||
),
|
||||
],
|
||||
SizedBox(
|
||||
width: 20,
|
||||
height: 20,
|
||||
child: Checkbox(
|
||||
value: _rememberMe,
|
||||
onChanged: (v) => setState(() => _rememberMe = v ?? true),
|
||||
activeColor: _kAccent,
|
||||
side: const BorderSide(color: _kBorder, width: 1.5),
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(4)),
|
||||
),
|
||||
child: ClipRRect(
|
||||
borderRadius: BorderRadius.circular(24),
|
||||
child: Image.asset(
|
||||
'assets/icon/icon.png',
|
||||
width: 96,
|
||||
height: 96,
|
||||
fit: BoxFit.cover,
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
const Text('Mantener sesión',
|
||||
style: TextStyle(color: _kTextMuted, fontSize: 13)),
|
||||
const Spacer(),
|
||||
if (_modoCloud)
|
||||
GestureDetector(
|
||||
onTap: () {},
|
||||
child: const Text(
|
||||
'¿Olvidaste tu contraseña?',
|
||||
style: TextStyle(
|
||||
color: _kAccent,
|
||||
fontSize: 13,
|
||||
fontWeight: FontWeight.w500,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
const Text(
|
||||
'Agente Ventas',
|
||||
style: TextStyle(
|
||||
fontSize: 32,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: Colors.white,
|
||||
letterSpacing: 1.0,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 4),
|
||||
Text(
|
||||
'by SIGMAC',
|
||||
style: TextStyle(
|
||||
fontSize: 13,
|
||||
color: Colors.white.withOpacity(0.65),
|
||||
letterSpacing: 2.0,
|
||||
fontWeight: FontWeight.w500,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 6),
|
||||
Text(
|
||||
'Gestión de rutas y pedidos de campo',
|
||||
style: TextStyle(
|
||||
fontSize: 13,
|
||||
color: Colors.white.withOpacity(0.8),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
// ── Caja de error ────────────────────────────────────────────
|
||||
|
||||
Widget _buildErrorBox(String msg) {
|
||||
return Container(
|
||||
width: double.infinity,
|
||||
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 10),
|
||||
decoration: BoxDecoration(
|
||||
color: _kError.withOpacity(0.10),
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
border: Border.all(color: _kError.withOpacity(0.35)),
|
||||
),
|
||||
child: Row(
|
||||
children: [
|
||||
const Icon(Icons.error_outline, color: _kError, size: 16),
|
||||
const SizedBox(width: 8),
|
||||
Expanded(
|
||||
child: Text(msg,
|
||||
style: const TextStyle(fontSize: 12, color: _kError)),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
// ── Links de registro ────────────────────────────────────────
|
||||
|
||||
Widget _buildRegistroLinks() {
|
||||
return Column(
|
||||
children: [
|
||||
const Divider(color: _kBorder, height: 24),
|
||||
const Text('¿No tienes cuenta?',
|
||||
style: TextStyle(color: _kTextMuted, fontSize: 13)),
|
||||
const SizedBox(height: 10),
|
||||
Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: OutlinedButton.icon(
|
||||
onPressed: () =>
|
||||
Navigator.pushNamed(context, '/registro'),
|
||||
icon: const Icon(Icons.smartphone, size: 16),
|
||||
label: const Text('Cuenta local',
|
||||
style: TextStyle(fontSize: 12)),
|
||||
style: OutlinedButton.styleFrom(
|
||||
primary: _kTextMuted,
|
||||
side: const BorderSide(color: _kBorder),
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(10)),
|
||||
padding: const EdgeInsets.symmetric(vertical: 10),
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 10),
|
||||
Expanded(
|
||||
child: OutlinedButton.icon(
|
||||
onPressed: () =>
|
||||
Navigator.pushNamed(context, '/registro_cloud'),
|
||||
icon: const Icon(Icons.cloud_outlined, size: 16),
|
||||
label: const Text('Nueva Cloud',
|
||||
style: TextStyle(fontSize: 12)),
|
||||
style: OutlinedButton.styleFrom(
|
||||
primary: _kAccent,
|
||||
side: const BorderSide(color: _kAccent),
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(10)),
|
||||
padding: const EdgeInsets.symmetric(vertical: 10),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildCard() {
|
||||
return Container(
|
||||
padding: const EdgeInsets.all(28),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: BorderRadius.circular(20),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: Colors.black.withOpacity(0.2),
|
||||
blurRadius: 20,
|
||||
offset: const Offset(0, 8),
|
||||
),
|
||||
],
|
||||
),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
const Text(
|
||||
'Iniciar sesión',
|
||||
style: TextStyle(
|
||||
fontSize: 20,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: AppTheme.textPrimary,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 6),
|
||||
const Text(
|
||||
'Ingresa tus credenciales para continuar',
|
||||
style: TextStyle(fontSize: 13, color: AppTheme.textSecondary),
|
||||
),
|
||||
const SizedBox(height: 24),
|
||||
TextField(
|
||||
controller: _emailCtrl,
|
||||
keyboardType: TextInputType.emailAddress,
|
||||
decoration: const InputDecoration(
|
||||
labelText: 'Correo electrónico',
|
||||
prefixIcon: Icon(Icons.email_outlined),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 14),
|
||||
TextField(
|
||||
controller: _passCtrl,
|
||||
obscureText: _obscure,
|
||||
decoration: InputDecoration(
|
||||
labelText: 'Contraseña',
|
||||
prefixIcon: const Icon(Icons.lock_outline),
|
||||
suffixIcon: IconButton(
|
||||
icon: Icon(_obscure ? Icons.visibility_outlined : Icons.visibility_off_outlined),
|
||||
onPressed: () => setState(() => _obscure = !_obscure),
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
Align(
|
||||
alignment: Alignment.centerRight,
|
||||
child: TextButton(
|
||||
onPressed: () {},
|
||||
child: const Text('¿Olvidaste tu contraseña?'),
|
||||
),
|
||||
),
|
||||
if (_error != null) ...[
|
||||
Container(
|
||||
width: double.infinity,
|
||||
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 10),
|
||||
decoration: BoxDecoration(
|
||||
color: AppTheme.dangerColor.withOpacity(0.08),
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
border: Border.all(color: AppTheme.dangerColor.withOpacity(0.3)),
|
||||
),
|
||||
child: Row(
|
||||
children: [
|
||||
const Icon(Icons.error_outline, color: AppTheme.dangerColor, size: 16),
|
||||
const SizedBox(width: 8),
|
||||
Expanded(
|
||||
child: Text(
|
||||
_error!,
|
||||
style: const TextStyle(fontSize: 12, color: AppTheme.dangerColor),
|
||||
),
|
||||
// ── Botón ────────────────────────────────────────────────────
|
||||
|
||||
Widget _buildButton(bool loading) {
|
||||
return SizedBox(
|
||||
width: double.infinity,
|
||||
height: 52,
|
||||
child: DecoratedBox(
|
||||
decoration: BoxDecoration(
|
||||
gradient: loading
|
||||
? null
|
||||
: const LinearGradient(
|
||||
colors: [_kTopBar, _kAccent],
|
||||
begin: Alignment.centerLeft,
|
||||
end: Alignment.centerRight,
|
||||
),
|
||||
color: loading ? _kBorder : null,
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
boxShadow: loading
|
||||
? const []
|
||||
: [
|
||||
BoxShadow(
|
||||
color: _kAccent.withOpacity(0.4),
|
||||
blurRadius: 12,
|
||||
offset: const Offset(0, 4),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
],
|
||||
const SizedBox(height: 8),
|
||||
SizedBox(
|
||||
width: double.infinity,
|
||||
height: 50,
|
||||
child: ElevatedButton(
|
||||
onPressed: _loading ? null : _login,
|
||||
child: _loading
|
||||
? const SizedBox(
|
||||
width: 22,
|
||||
height: 22,
|
||||
child: CircularProgressIndicator(
|
||||
strokeWidth: 2.5,
|
||||
color: Colors.white,
|
||||
),
|
||||
)
|
||||
: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: const [
|
||||
Icon(Icons.login, size: 20),
|
||||
SizedBox(width: 8),
|
||||
Text('Ingresar', style: TextStyle(fontSize: 16, fontWeight: FontWeight.w600)),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
child: ElevatedButton(
|
||||
onPressed: loading ? null : _ingresar,
|
||||
style: ElevatedButton.styleFrom(
|
||||
primary: Colors.transparent,
|
||||
onPrimary: Colors.white,
|
||||
shadowColor: Colors.transparent,
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(12)),
|
||||
),
|
||||
],
|
||||
child: loading
|
||||
? const SizedBox(
|
||||
width: 22,
|
||||
height: 22,
|
||||
child: CircularProgressIndicator(
|
||||
strokeWidth: 2.5, color: Colors.white),
|
||||
)
|
||||
: Text(
|
||||
_modoCloud ? 'INGRESAR CON CLOUD' : 'INGRESAR',
|
||||
style: const TextStyle(
|
||||
fontSize: 15,
|
||||
fontWeight: FontWeight.bold,
|
||||
letterSpacing: 1.2,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildVersion() {
|
||||
return Text(
|
||||
'v1.0.0 • SIGMAC • Telcotronics',
|
||||
style: TextStyle(fontSize: 12, color: Colors.white.withOpacity(0.6)),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user