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>
70 lines
2.2 KiB
Dart
70 lines
2.2 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:provider/provider.dart';
|
|
import 'providers/app_provider.dart';
|
|
import 'theme/app_theme.dart';
|
|
import 'screens/login/login_screen.dart';
|
|
import 'screens/login/registro_screen.dart';
|
|
import 'screens/login/registro_cloud_screen.dart';
|
|
import 'screens/main_shell.dart';
|
|
|
|
class PedidosApp extends StatelessWidget {
|
|
final GlobalKey<NavigatorState> navigatorKey;
|
|
|
|
const PedidosApp({Key? key, required this.navigatorKey}) : super(key: key);
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return MaterialApp(
|
|
title: 'Agente Ventas SIGMAC',
|
|
debugShowCheckedModeBanner: false,
|
|
theme: AppTheme.light,
|
|
navigatorKey: navigatorKey,
|
|
routes: {
|
|
'/login': (_) => const LoginScreen(),
|
|
'/registro': (_) => const RegistroScreen(),
|
|
'/registro_cloud': (_) => const RegistroCloudScreen(),
|
|
},
|
|
home: Consumer<AppProvider>(
|
|
builder: (_, provider, __) {
|
|
if (provider.loading) return const _LoadingScreen();
|
|
return provider.isLoggedIn ? const MainShell() : const LoginScreen();
|
|
},
|
|
),
|
|
);
|
|
}
|
|
}
|
|
|
|
class _LoadingScreen extends StatelessWidget {
|
|
const _LoadingScreen({Key? key}) : super(key: key);
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Scaffold(
|
|
backgroundColor: AppTheme.primaryColor,
|
|
body: Center(
|
|
child: Column(
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
children: [
|
|
ClipRRect(
|
|
borderRadius: BorderRadius.circular(22),
|
|
child: Image.asset('assets/icon/icon.png', width: 80, height: 80),
|
|
),
|
|
const SizedBox(height: 20),
|
|
const Text(
|
|
'Agente Ventas',
|
|
style: TextStyle(fontSize: 26, fontWeight: FontWeight.bold, color: Colors.white),
|
|
),
|
|
const SizedBox(height: 4),
|
|
Text(
|
|
'by SIGMAC',
|
|
style: TextStyle(fontSize: 12, color: Colors.white.withOpacity(0.6), letterSpacing: 2.0),
|
|
),
|
|
const SizedBox(height: 40),
|
|
const Text('Cargando datos...', style: TextStyle(color: Colors.white70, fontSize: 13)),
|
|
],
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|