fix: soporte siempre visible + perfil mejorado
- Setting: lee support_title/description/days/hours/email/phone - SettingsProvider: fallback a Setting vacio si no hay datos en DB - SupportView: guard para settings null - Avatar: ui-avatars.com como imagen por defecto (con nombre) - Perfil: seccion correo como ExpansionTile (acordeon) paso 1: email+contrasena+confirmar → Enviar codigo paso 2: ingresar codigo de 6 digitos → Verificar (verde) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 4.6
parent
8372e19d9f
commit
aeeeeb47fb
@@ -55,13 +55,13 @@ class Setting {
|
|||||||
versionIos: _s(doc['version_ios']),
|
versionIos: _s(doc['version_ios']),
|
||||||
versionAndroid: _s(doc['version_android']),
|
versionAndroid: _s(doc['version_android']),
|
||||||
horaNotificacion: _s(doc['hora_notificacion']),
|
horaNotificacion: _s(doc['hora_notificacion']),
|
||||||
tituloSoporte: _s(doc['titulo_soporte'], 'Soporte ProsApp'),
|
tituloSoporte: _s(doc['support_title'] ?? doc['titulo_soporte'], 'Soporte ProsApp'),
|
||||||
parrafoSoporte: _s(doc['parrafo_soporte'],
|
parrafoSoporte: _s(doc['support_description'] ?? doc['parrafo_soporte'],
|
||||||
'Estamos aquí para ayudarte. Contáctanos por cualquiera de estos canales.'),
|
'Estamos aquí para ayudarte. Contáctanos por cualquiera de estos canales.'),
|
||||||
numeroSoporte: _s(doc['numero_soporte'] ?? doc['support_phone']),
|
numeroSoporte: _s(doc['support_phone'] ?? doc['numero_soporte']),
|
||||||
emailSoporte: _s(doc['email_soporte'] ?? doc['support_email']),
|
emailSoporte: _s(doc['support_email'] ?? doc['email_soporte']),
|
||||||
diasSoporte: _s(doc['dias_soporte'] ?? doc['support_days'], 'Lunes a Viernes'),
|
diasSoporte: _s(doc['support_days'] ?? doc['dias_soporte'], 'Lunes a Viernes'),
|
||||||
horasSoporte: _s(doc['horas_soporte'] ?? doc['support_hours'], '8:00 am - 6:00 pm'),
|
horasSoporte: _s(doc['support_hours'] ?? doc['horas_soporte'], '8:00 am – 6:00 pm'),
|
||||||
politicasPrivacidad: _s(doc['politicas_privacidad']),
|
politicasPrivacidad: _s(doc['politicas_privacidad']),
|
||||||
politicasPrivacidadTitle: _s(doc['politicas_privacidad_title']),
|
politicasPrivacidadTitle: _s(doc['politicas_privacidad_title']),
|
||||||
politicasPrivacidadBody: _s(doc['politicas_privacidad_body']),
|
politicasPrivacidadBody: _s(doc['politicas_privacidad_body']),
|
||||||
|
|||||||
@@ -11,6 +11,10 @@ class NavbarAvatar extends StatelessWidget {
|
|||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final user = Provider.of<AuthProvider>(context).user!;
|
final user = Provider.of<AuthProvider>(context).user!;
|
||||||
final hasPicture = user.picture != null && user.picture!.isNotEmpty;
|
final hasPicture = user.picture != null && user.picture!.isNotEmpty;
|
||||||
|
final encoded = Uri.encodeComponent(user.name.isEmpty ? 'U' : user.name);
|
||||||
|
final fallbackUrl =
|
||||||
|
'https://ui-avatars.com/api/?name=$encoded&background=42A4EF&color=fff&size=80&bold=true&rounded=true';
|
||||||
|
final imageUrl = hasPicture ? user.picture! : fallbackUrl;
|
||||||
|
|
||||||
return MouseRegion(
|
return MouseRegion(
|
||||||
cursor: SystemMouseCursors.click,
|
cursor: SystemMouseCursors.click,
|
||||||
@@ -20,13 +24,12 @@ class NavbarAvatar extends StatelessWidget {
|
|||||||
width: 36,
|
width: 36,
|
||||||
height: 36,
|
height: 36,
|
||||||
child: ClipOval(
|
child: ClipOval(
|
||||||
child: hasPicture
|
child: Image.network(
|
||||||
? Image.network(
|
imageUrl,
|
||||||
user.picture!,
|
fit: BoxFit.cover,
|
||||||
fit: BoxFit.cover,
|
errorBuilder: (_, __, ___) =>
|
||||||
errorBuilder: (_, __, ___) => _InitialsAvatar(name: user.name),
|
Image.network(fallbackUrl, fit: BoxFit.cover),
|
||||||
)
|
),
|
||||||
: _InitialsAvatar(name: user.name),
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -34,46 +37,3 @@ class NavbarAvatar extends StatelessWidget {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class _InitialsAvatar extends StatelessWidget {
|
|
||||||
final String name;
|
|
||||||
const _InitialsAvatar({required this.name});
|
|
||||||
|
|
||||||
String get _initials {
|
|
||||||
final parts = name.trim().split(RegExp(r'\s+'));
|
|
||||||
if (parts.isEmpty || parts.first.isEmpty) return '?';
|
|
||||||
if (parts.length == 1) return parts.first[0].toUpperCase();
|
|
||||||
return (parts.first[0] + parts.last[0]).toUpperCase();
|
|
||||||
}
|
|
||||||
|
|
||||||
Color get _bgColor {
|
|
||||||
final colors = [
|
|
||||||
const Color(0xFF6366F1), // indigo
|
|
||||||
const Color(0xFF8B5CF6), // violet
|
|
||||||
const Color(0xFFEC4899), // pink
|
|
||||||
const Color(0xFF14B8A6), // teal
|
|
||||||
const Color(0xFFF59E0B), // amber
|
|
||||||
const Color(0xFF10B981), // emerald
|
|
||||||
const Color(0xFFEF4444), // red
|
|
||||||
const Color(0xFF3B82F6), // blue
|
|
||||||
];
|
|
||||||
final index = name.isEmpty ? 0 : name.codeUnitAt(0) % colors.length;
|
|
||||||
return colors[index];
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
return Container(
|
|
||||||
color: _bgColor,
|
|
||||||
child: Center(
|
|
||||||
child: Text(
|
|
||||||
_initials,
|
|
||||||
style: const TextStyle(
|
|
||||||
color: Colors.white,
|
|
||||||
fontSize: 13,
|
|
||||||
fontWeight: FontWeight.bold,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
+157
-206
@@ -253,25 +253,9 @@ class _ProfileViewForm extends StatelessWidget {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget _buildInitials(String name) {
|
String _uiAvatarUrl(String name) {
|
||||||
final parts = name.trim().split(RegExp(r'\s+'));
|
final encoded = Uri.encodeComponent(name.isEmpty ? 'Usuario' : name);
|
||||||
final initials = parts.length >= 2
|
return 'https://ui-avatars.com/api/?name=$encoded&background=42A4EF&color=fff&size=200&bold=true&rounded=true';
|
||||||
? '${parts.first[0]}${parts.last[0]}'.toUpperCase()
|
|
||||||
: (parts.first.isEmpty ? '?' : parts.first[0].toUpperCase());
|
|
||||||
final colors = [
|
|
||||||
const Color(0xFF6366F1), const Color(0xFF8B5CF6),
|
|
||||||
const Color(0xFFEC4899), const Color(0xFF14B8A6),
|
|
||||||
const Color(0xFFF59E0B), const Color(0xFF10B981),
|
|
||||||
const Color(0xFFEF4444), const Color(0xFF3B82F6),
|
|
||||||
];
|
|
||||||
final bg = name.isEmpty ? colors[0] : colors[name.codeUnitAt(0) % colors.length];
|
|
||||||
return Container(
|
|
||||||
color: bg,
|
|
||||||
child: Center(
|
|
||||||
child: Text(initials,
|
|
||||||
style: const TextStyle(color: Colors.white, fontSize: 48, fontWeight: FontWeight.bold)),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class _AvatarContainer extends StatelessWidget {
|
class _AvatarContainer extends StatelessWidget {
|
||||||
@@ -287,15 +271,9 @@ class _AvatarContainer extends StatelessWidget {
|
|||||||
final picUrl = profileFormProvider.user!.picture;
|
final picUrl = profileFormProvider.user!.picture;
|
||||||
final hasPicture = picUrl != null && picUrl.isNotEmpty;
|
final hasPicture = picUrl != null && picUrl.isNotEmpty;
|
||||||
final userName = profileFormProvider.user!.name;
|
final userName = profileFormProvider.user!.name;
|
||||||
|
final imageUrl = hasPicture ? picUrl! : _uiAvatarUrl(userName);
|
||||||
Widget avatarImage;
|
final image = Image.network(imageUrl, fit: BoxFit.cover,
|
||||||
if (hasPicture) {
|
errorBuilder: (_, __, ___) => Image.network(_uiAvatarUrl(userName), fit: BoxFit.cover));
|
||||||
avatarImage = Image.network(picUrl, fit: BoxFit.cover,
|
|
||||||
errorBuilder: (_, __, ___) => _buildInitials(userName));
|
|
||||||
} else {
|
|
||||||
avatarImage = _buildInitials(userName);
|
|
||||||
}
|
|
||||||
final image = avatarImage;
|
|
||||||
|
|
||||||
return WhiteCard(
|
return WhiteCard(
|
||||||
width: containerFull ? null : 250,
|
width: containerFull ? null : 250,
|
||||||
@@ -378,7 +356,6 @@ class _AvatarContainer extends StatelessWidget {
|
|||||||
|
|
||||||
class _EmailLinkCard extends StatefulWidget {
|
class _EmailLinkCard extends StatefulWidget {
|
||||||
const _EmailLinkCard();
|
const _EmailLinkCard();
|
||||||
|
|
||||||
@override
|
@override
|
||||||
State<_EmailLinkCard> createState() => _EmailLinkCardState();
|
State<_EmailLinkCard> createState() => _EmailLinkCardState();
|
||||||
}
|
}
|
||||||
@@ -389,20 +366,12 @@ class _EmailLinkCardState extends State<_EmailLinkCard> {
|
|||||||
final _confirmCtrl = TextEditingController();
|
final _confirmCtrl = TextEditingController();
|
||||||
final _codeCtrl = TextEditingController();
|
final _codeCtrl = TextEditingController();
|
||||||
|
|
||||||
bool _enabled = false;
|
bool _expanded = false;
|
||||||
bool _codeSent = false;
|
bool _codeSent = false;
|
||||||
bool _loading = false;
|
bool _loading = false;
|
||||||
bool _obscurePass = true;
|
bool _obscurePass = true;
|
||||||
bool _obscureConfirm = true;
|
bool _obscureConfirm = true;
|
||||||
|
|
||||||
@override
|
|
||||||
void initState() {
|
|
||||||
super.initState();
|
|
||||||
final user = context.read<AuthProvider>().user!;
|
|
||||||
_enabled = user.email != null && user.email!.isNotEmpty;
|
|
||||||
if (_enabled) _emailCtrl.text = user.email!;
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void dispose() {
|
void dispose() {
|
||||||
_emailCtrl.dispose();
|
_emailCtrl.dispose();
|
||||||
@@ -415,27 +384,21 @@ class _EmailLinkCardState extends State<_EmailLinkCard> {
|
|||||||
Future<void> _sendCode() async {
|
Future<void> _sendCode() async {
|
||||||
final email = _emailCtrl.text.trim();
|
final email = _emailCtrl.text.trim();
|
||||||
final pass = _passCtrl.text;
|
final pass = _passCtrl.text;
|
||||||
final confirm = _confirmCtrl.text;
|
|
||||||
|
|
||||||
if (!RegExp(r'^[\w.+-]+@[\w-]+\.\w+$').hasMatch(email)) {
|
if (!RegExp(r'^[\w.+-]+@[\w-]+\.\w+$').hasMatch(email)) {
|
||||||
_snack('Ingresa un correo válido', error: true);
|
_snack('Ingresa un correo válido', error: true); return;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
if (pass.length < 6) {
|
if (pass.length < 6) {
|
||||||
_snack('La contraseña debe tener al menos 6 caracteres', error: true);
|
_snack('La contraseña debe tener al menos 6 caracteres', error: true); return;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
if (pass != confirm) {
|
if (pass != _confirmCtrl.text) {
|
||||||
_snack('Las contraseñas no coinciden', error: true);
|
_snack('Las contraseñas no coinciden', error: true); return;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
setState(() => _loading = true);
|
setState(() => _loading = true);
|
||||||
try {
|
try {
|
||||||
await ApiService.instance.post('/auth/send-email-otp', {'email': email});
|
await ApiService.instance.post('/auth/send-email-otp', {'email': email});
|
||||||
setState(() => _codeSent = true);
|
setState(() => _codeSent = true);
|
||||||
_snack('Código enviado a $email');
|
_snack('Código enviado a $email');
|
||||||
} catch (e) {
|
} catch (_) {
|
||||||
_snack('Error al enviar el código', error: true);
|
_snack('Error al enviar el código', error: true);
|
||||||
} finally {
|
} finally {
|
||||||
setState(() => _loading = false);
|
setState(() => _loading = false);
|
||||||
@@ -444,10 +407,7 @@ class _EmailLinkCardState extends State<_EmailLinkCard> {
|
|||||||
|
|
||||||
Future<void> _verify() async {
|
Future<void> _verify() async {
|
||||||
final code = _codeCtrl.text.trim();
|
final code = _codeCtrl.text.trim();
|
||||||
if (code.length != 6) {
|
if (code.length != 6) { _snack('Ingresa el código de 6 dígitos', error: true); return; }
|
||||||
_snack('Ingresa el código de 6 dígitos', error: true);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
setState(() => _loading = true);
|
setState(() => _loading = true);
|
||||||
try {
|
try {
|
||||||
await ApiService.instance.post('/auth/link-email-otp', {
|
await ApiService.instance.post('/auth/link-email-otp', {
|
||||||
@@ -456,174 +416,177 @@ class _EmailLinkCardState extends State<_EmailLinkCard> {
|
|||||||
'code': code,
|
'code': code,
|
||||||
});
|
});
|
||||||
await context.read<AuthProvider>().refreshUser();
|
await context.read<AuthProvider>().refreshUser();
|
||||||
setState(() { _codeSent = false; _codeCtrl.clear(); });
|
setState(() { _codeSent = false; _expanded = false; _codeCtrl.clear(); });
|
||||||
_snack('Correo vinculado exitosamente');
|
_snack('Correo vinculado correctamente');
|
||||||
} catch (e) {
|
} catch (_) {
|
||||||
_snack('Código incorrecto o expirado', error: true);
|
_snack('Código incorrecto o expirado', error: true);
|
||||||
} finally {
|
} finally {
|
||||||
setState(() => _loading = false);
|
setState(() => _loading = false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void _snack(String msg, {bool error = false}) {
|
void _snack(String m, {bool error = false}) => error
|
||||||
if (error) {
|
? NotificationsService.showSnackBarError(m)
|
||||||
NotificationsService.showSnackBarError(msg);
|
: NotificationsService.showSnackbar(m);
|
||||||
} else {
|
|
||||||
NotificationsService.showSnackbar(msg);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final user = context.watch<AuthProvider>().user!;
|
final user = context.watch<AuthProvider>().user!;
|
||||||
final hasEmail = user.email != null && user.email!.isNotEmpty;
|
final hasEmail = user.email != null && user.email!.isNotEmpty;
|
||||||
final isDark = Theme.of(context).brightness == Brightness.dark;
|
final isDark = Theme.of(context).brightness == Brightness.dark;
|
||||||
final fillColor = isDark ? const Color(0xFF0F172A) : const Color(0xFFF5F8FF);
|
final fillColor = isDark ? const Color(0xFF0F172A) : const Color(0xFFF8FAFF);
|
||||||
final borderColor = isDark ? const Color(0xFF334155) : const Color(0xFFE0E7FF);
|
final borderColor = isDark ? const Color(0xFF334155) : const Color(0xFFE0E7FF);
|
||||||
|
|
||||||
InputDecoration _fieldDeco(String label, String hint, IconData icon) =>
|
InputDecoration fd(String label, String hint, IconData icon) => InputDecoration(
|
||||||
InputDecoration(
|
|
||||||
labelText: label,
|
labelText: label,
|
||||||
hintText: hint,
|
hintText: hint,
|
||||||
prefixIcon: Icon(icon, size: 20),
|
prefixIcon: Icon(icon, size: 20),
|
||||||
filled: true,
|
filled: true,
|
||||||
fillColor: fillColor,
|
fillColor: fillColor,
|
||||||
border: OutlineInputBorder(
|
contentPadding: const EdgeInsets.symmetric(horizontal: 16, vertical: 14),
|
||||||
borderRadius: BorderRadius.circular(10), borderSide: BorderSide.none),
|
border: OutlineInputBorder(borderRadius: BorderRadius.circular(10), borderSide: BorderSide.none),
|
||||||
enabledBorder: OutlineInputBorder(
|
enabledBorder: OutlineInputBorder(borderRadius: BorderRadius.circular(10), borderSide: BorderSide(color: borderColor)),
|
||||||
borderRadius: BorderRadius.circular(10),
|
focusedBorder: OutlineInputBorder(borderRadius: BorderRadius.circular(10), borderSide: const BorderSide(color: Color(0xFF42A4EF), width: 2)),
|
||||||
borderSide: BorderSide(color: borderColor)),
|
|
||||||
focusedBorder: OutlineInputBorder(
|
|
||||||
borderRadius: BorderRadius.circular(10),
|
|
||||||
borderSide: const BorderSide(color: Color(0xFF42A4EF), width: 2)),
|
|
||||||
);
|
);
|
||||||
|
|
||||||
return WhiteCard(
|
return WhiteCard(
|
||||||
title: 'Acceso con correo',
|
child: Theme(
|
||||||
child: Column(
|
data: Theme.of(context).copyWith(dividerColor: Colors.transparent),
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
child: ExpansionTile(
|
||||||
children: [
|
initiallyExpanded: hasEmail,
|
||||||
Row(
|
onExpansionChanged: (v) { if (!hasEmail) setState(() => _expanded = v); },
|
||||||
children: [
|
tilePadding: EdgeInsets.zero,
|
||||||
Expanded(
|
childrenPadding: EdgeInsets.zero,
|
||||||
child: Text(
|
leading: Container(
|
||||||
hasEmail
|
width: 36, height: 36,
|
||||||
? 'Correo vinculado: ${user.email}'
|
decoration: BoxDecoration(
|
||||||
: 'Vincula un correo para iniciar sesión también con email y contraseña.',
|
color: hasEmail
|
||||||
style: TextStyle(
|
? const Color(0xFF10B981).withOpacity(0.12)
|
||||||
fontSize: 13,
|
: const Color(0xFF42A4EF).withOpacity(0.12),
|
||||||
color: isDark ? Colors.white54 : Colors.black54,
|
shape: BoxShape.circle,
|
||||||
),
|
),
|
||||||
),
|
child: Icon(
|
||||||
),
|
hasEmail ? Icons.mark_email_read_outlined : Icons.email_outlined,
|
||||||
Switch(
|
color: hasEmail ? const Color(0xFF10B981) : const Color(0xFF42A4EF),
|
||||||
value: _enabled,
|
size: 18,
|
||||||
activeColor: const Color(0xFF42A4EF),
|
),
|
||||||
onChanged: (val) {
|
|
||||||
if (hasEmail) return; // ya vinculado, no desactivar desde aquí
|
|
||||||
setState(() {
|
|
||||||
_enabled = val;
|
|
||||||
_codeSent = false;
|
|
||||||
_codeCtrl.clear();
|
|
||||||
});
|
|
||||||
},
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
),
|
||||||
|
title: Text(
|
||||||
if (_enabled && !hasEmail) ...[
|
hasEmail ? 'Correo vinculado' : 'Vincular correo electrónico',
|
||||||
const SizedBox(height: 16),
|
style: TextStyle(
|
||||||
|
fontSize: 14,
|
||||||
if (!_codeSent) ...[
|
fontWeight: FontWeight.w600,
|
||||||
TextField(
|
color: isDark ? Colors.white : Colors.black87,
|
||||||
controller: _emailCtrl,
|
),
|
||||||
keyboardType: TextInputType.emailAddress,
|
),
|
||||||
decoration: _fieldDeco('Correo electrónico', 'tu@correo.com', Icons.email_outlined),
|
subtitle: Text(
|
||||||
),
|
hasEmail
|
||||||
const SizedBox(height: 12),
|
? user.email!
|
||||||
TextField(
|
: 'Agrega un correo y contraseña para iniciar sesión sin SMS',
|
||||||
controller: _passCtrl,
|
style: TextStyle(fontSize: 12, color: isDark ? Colors.white38 : Colors.black45),
|
||||||
obscureText: _obscurePass,
|
),
|
||||||
decoration: _fieldDeco('Contraseña', 'Mínimo 6 caracteres', Icons.lock_outline).copyWith(
|
trailing: hasEmail
|
||||||
suffixIcon: IconButton(
|
? const Icon(Icons.verified, color: Color(0xFF10B981), size: 20)
|
||||||
icon: Icon(_obscurePass ? Icons.visibility_off_outlined : Icons.visibility_outlined, size: 20),
|
: null,
|
||||||
onPressed: () => setState(() => _obscurePass = !_obscurePass),
|
children: [
|
||||||
),
|
if (!hasEmail) ...[
|
||||||
),
|
const Divider(height: 1),
|
||||||
),
|
|
||||||
const SizedBox(height: 12),
|
|
||||||
TextField(
|
|
||||||
controller: _confirmCtrl,
|
|
||||||
obscureText: _obscureConfirm,
|
|
||||||
decoration: _fieldDeco('Confirmar contraseña', 'Repite la contraseña', Icons.lock_outline).copyWith(
|
|
||||||
suffixIcon: IconButton(
|
|
||||||
icon: Icon(_obscureConfirm ? Icons.visibility_off_outlined : Icons.visibility_outlined, size: 20),
|
|
||||||
onPressed: () => setState(() => _obscureConfirm = !_obscureConfirm),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
const SizedBox(height: 16),
|
const SizedBox(height: 16),
|
||||||
SizedBox(
|
|
||||||
width: double.infinity,
|
if (!_codeSent) ...[
|
||||||
child: ElevatedButton(
|
TextField(
|
||||||
onPressed: _loading ? null : _sendCode,
|
controller: _emailCtrl,
|
||||||
style: ElevatedButton.styleFrom(
|
keyboardType: TextInputType.emailAddress,
|
||||||
backgroundColor: const Color(0xFF42A4EF),
|
decoration: fd('Correo electrónico', 'tu@correo.com', Icons.email_outlined),
|
||||||
foregroundColor: Colors.white,
|
|
||||||
padding: const EdgeInsets.symmetric(vertical: 14),
|
|
||||||
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(10)),
|
|
||||||
elevation: 0,
|
|
||||||
),
|
|
||||||
child: _loading
|
|
||||||
? const SizedBox(width: 18, height: 18, child: CircularProgressIndicator(color: Colors.white, strokeWidth: 2))
|
|
||||||
: const Text('Enviar código de verificación', style: TextStyle(fontWeight: FontWeight.w600)),
|
|
||||||
),
|
),
|
||||||
),
|
const SizedBox(height: 10),
|
||||||
] else ...[
|
TextField(
|
||||||
Container(
|
controller: _passCtrl,
|
||||||
padding: const EdgeInsets.all(12),
|
obscureText: _obscurePass,
|
||||||
decoration: BoxDecoration(
|
decoration: fd('Contraseña', 'Mínimo 6 caracteres', Icons.lock_outline).copyWith(
|
||||||
color: const Color(0xFF42A4EF).withOpacity(0.1),
|
suffixIcon: IconButton(
|
||||||
borderRadius: BorderRadius.circular(10),
|
icon: Icon(_obscurePass ? Icons.visibility_off_outlined : Icons.visibility_outlined, size: 18),
|
||||||
border: Border.all(color: const Color(0xFF42A4EF).withOpacity(0.3)),
|
onPressed: () => setState(() => _obscurePass = !_obscurePass),
|
||||||
),
|
|
||||||
child: Row(
|
|
||||||
children: [
|
|
||||||
const Icon(Icons.email_outlined, color: Color(0xFF42A4EF), size: 18),
|
|
||||||
const SizedBox(width: 8),
|
|
||||||
Expanded(
|
|
||||||
child: Text(
|
|
||||||
'Código enviado a ${_emailCtrl.text.trim()}',
|
|
||||||
style: const TextStyle(fontSize: 13, color: Color(0xFF42A4EF)),
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
],
|
),
|
||||||
),
|
),
|
||||||
),
|
const SizedBox(height: 10),
|
||||||
const SizedBox(height: 12),
|
TextField(
|
||||||
TextField(
|
controller: _confirmCtrl,
|
||||||
controller: _codeCtrl,
|
obscureText: _obscureConfirm,
|
||||||
keyboardType: TextInputType.number,
|
decoration: fd('Confirmar contraseña', 'Repite la contraseña', Icons.lock_outline).copyWith(
|
||||||
textAlign: TextAlign.center,
|
suffixIcon: IconButton(
|
||||||
maxLength: 6,
|
icon: Icon(_obscureConfirm ? Icons.visibility_off_outlined : Icons.visibility_outlined, size: 18),
|
||||||
style: const TextStyle(fontSize: 26, fontWeight: FontWeight.bold, letterSpacing: 10),
|
onPressed: () => setState(() => _obscureConfirm = !_obscureConfirm),
|
||||||
decoration: _fieldDeco('', '------', Icons.pin_outlined).copyWith(
|
),
|
||||||
counterText: '',
|
),
|
||||||
hintStyle: const TextStyle(letterSpacing: 10, color: Colors.grey),
|
|
||||||
),
|
),
|
||||||
),
|
const SizedBox(height: 14),
|
||||||
const SizedBox(height: 16),
|
SizedBox(
|
||||||
Row(
|
width: double.infinity,
|
||||||
children: [
|
child: ElevatedButton.icon(
|
||||||
|
onPressed: _loading ? null : _sendCode,
|
||||||
|
icon: _loading
|
||||||
|
? const SizedBox(width: 16, height: 16, child: CircularProgressIndicator(color: Colors.white, strokeWidth: 2))
|
||||||
|
: const Icon(Icons.send_outlined, size: 18),
|
||||||
|
label: Text(_loading ? 'Enviando...' : 'Enviar código de verificación'),
|
||||||
|
style: ElevatedButton.styleFrom(
|
||||||
|
backgroundColor: const Color(0xFF42A4EF),
|
||||||
|
foregroundColor: Colors.white,
|
||||||
|
padding: const EdgeInsets.symmetric(vertical: 14),
|
||||||
|
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(10)),
|
||||||
|
elevation: 0,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
] else ...[
|
||||||
|
// Paso 2: ingresar código
|
||||||
|
Container(
|
||||||
|
padding: const EdgeInsets.symmetric(horizontal: 14, vertical: 10),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: const Color(0xFF42A4EF).withOpacity(0.08),
|
||||||
|
borderRadius: BorderRadius.circular(10),
|
||||||
|
border: Border.all(color: const Color(0xFF42A4EF).withOpacity(0.25)),
|
||||||
|
),
|
||||||
|
child: Row(children: [
|
||||||
|
const Icon(Icons.mark_email_read_outlined, color: Color(0xFF42A4EF), size: 18),
|
||||||
|
const SizedBox(width: 8),
|
||||||
|
Expanded(child: Text(
|
||||||
|
'Código enviado a ${_emailCtrl.text.trim()}',
|
||||||
|
style: const TextStyle(fontSize: 13, color: Color(0xFF42A4EF)),
|
||||||
|
)),
|
||||||
|
]),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 14),
|
||||||
|
TextField(
|
||||||
|
controller: _codeCtrl,
|
||||||
|
keyboardType: TextInputType.number,
|
||||||
|
textAlign: TextAlign.center,
|
||||||
|
maxLength: 6,
|
||||||
|
autofocus: true,
|
||||||
|
style: const TextStyle(fontSize: 28, fontWeight: FontWeight.bold, letterSpacing: 12),
|
||||||
|
decoration: InputDecoration(
|
||||||
|
counterText: '',
|
||||||
|
hintText: '······',
|
||||||
|
hintStyle: const TextStyle(letterSpacing: 12, color: Colors.grey),
|
||||||
|
filled: true,
|
||||||
|
fillColor: fillColor,
|
||||||
|
border: OutlineInputBorder(borderRadius: BorderRadius.circular(10), borderSide: BorderSide.none),
|
||||||
|
enabledBorder: OutlineInputBorder(borderRadius: BorderRadius.circular(10), borderSide: BorderSide(color: borderColor)),
|
||||||
|
focusedBorder: OutlineInputBorder(borderRadius: BorderRadius.circular(10), borderSide: const BorderSide(color: Color(0xFF42A4EF), width: 2)),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 14),
|
||||||
|
Row(children: [
|
||||||
Expanded(
|
Expanded(
|
||||||
child: OutlinedButton(
|
child: OutlinedButton(
|
||||||
onPressed: _loading ? null : () => setState(() { _codeSent = false; _codeCtrl.clear(); }),
|
onPressed: _loading ? null : () => setState(() { _codeSent = false; _codeCtrl.clear(); }),
|
||||||
style: OutlinedButton.styleFrom(
|
style: OutlinedButton.styleFrom(
|
||||||
padding: const EdgeInsets.symmetric(vertical: 14),
|
padding: const EdgeInsets.symmetric(vertical: 13),
|
||||||
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(10)),
|
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(10)),
|
||||||
side: const BorderSide(color: Color(0xFF42A4EF)),
|
side: BorderSide(color: borderColor),
|
||||||
),
|
),
|
||||||
child: const Text('← Cambiar datos', style: TextStyle(color: Color(0xFF42A4EF))),
|
child: const Text('← Volver'),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
const SizedBox(width: 10),
|
const SizedBox(width: 10),
|
||||||
@@ -631,35 +594,23 @@ class _EmailLinkCardState extends State<_EmailLinkCard> {
|
|||||||
child: ElevatedButton(
|
child: ElevatedButton(
|
||||||
onPressed: _loading ? null : _verify,
|
onPressed: _loading ? null : _verify,
|
||||||
style: ElevatedButton.styleFrom(
|
style: ElevatedButton.styleFrom(
|
||||||
backgroundColor: const Color(0xFF42A4EF),
|
backgroundColor: const Color(0xFF10B981),
|
||||||
foregroundColor: Colors.white,
|
foregroundColor: Colors.white,
|
||||||
padding: const EdgeInsets.symmetric(vertical: 14),
|
padding: const EdgeInsets.symmetric(vertical: 13),
|
||||||
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(10)),
|
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(10)),
|
||||||
elevation: 0,
|
elevation: 0,
|
||||||
),
|
),
|
||||||
child: _loading
|
child: _loading
|
||||||
? const SizedBox(width: 18, height: 18, child: CircularProgressIndicator(color: Colors.white, strokeWidth: 2))
|
? const SizedBox(width: 16, height: 16, child: CircularProgressIndicator(color: Colors.white, strokeWidth: 2))
|
||||||
: const Text('Verificar', style: TextStyle(fontWeight: FontWeight.w600)),
|
: const Text('Verificar', style: TextStyle(fontWeight: FontWeight.w600)),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
]),
|
||||||
),
|
],
|
||||||
|
const SizedBox(height: 8),
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
|
),
|
||||||
if (hasEmail) ...[
|
|
||||||
const SizedBox(height: 12),
|
|
||||||
Row(
|
|
||||||
children: [
|
|
||||||
const Icon(Icons.verified, color: Color(0xFF10B981), size: 18),
|
|
||||||
const SizedBox(width: 6),
|
|
||||||
Text('Correo verificado', style: TextStyle(color: isDark ? Colors.white70 : Colors.black87, fontSize: 13)),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
],
|
|
||||||
|
|
||||||
const SizedBox(height: 4),
|
|
||||||
],
|
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user