feat:implementacion grafica

This commit is contained in:
25030248hasel
2026-05-22 18:06:11 -06:00
parent 83be5a1a40
commit ffb5bdb346
16 changed files with 1819 additions and 98 deletions

View File

@@ -0,0 +1,121 @@
import 'dart:async';
import 'package:flutter/material.dart';
import 'package:go_router/go_router.dart';
import '../../features/auth/presentation/bloc/auth_bloc.dart';
import '../../features/auth/presentation/bloc/auth_state.dart';
import '../../features/auth/presentation/screens/login_screen.dart';
import '../../features/auth/presentation/screens/home_screen_placeholder.dart';
/// Rutas nombradas de la aplicación.
abstract final class AppRoutes {
static const String splash = '/';
static const String login = '/login';
static const String home = '/home';
}
/// Configuración central de navegación con go_router.
///
/// La redirección basada en estado de autenticación garantiza que
/// rutas protegidas sean inaccesibles sin sesión válida.
GoRouter createRouter(AuthBloc authBloc) {
return GoRouter(
initialLocation: AppRoutes.splash,
refreshListenable: GoRouterAuthNotifier(authBloc),
redirect: (BuildContext context, GoRouterState state) {
final authState = authBloc.state;
final isAuthenticated = authState is AuthAuthenticated;
final isCheckingSession = authState is AuthCheckingSession ||
authState is AuthInitial;
final currentLocation = state.uri.path;
// Mientras se verifica la sesión, mostrar splash.
if (isCheckingSession) {
return currentLocation == AppRoutes.splash ? null : AppRoutes.splash;
}
// Si no está autenticado, ir a login.
if (!isAuthenticated) {
return currentLocation == AppRoutes.login ? null : AppRoutes.login;
}
// Si está autenticado y en splash o login, ir a home.
if (isAuthenticated &&
(currentLocation == AppRoutes.login ||
currentLocation == AppRoutes.splash)) {
return AppRoutes.home;
}
return null; // Sin redirección.
},
routes: [
GoRoute(
path: AppRoutes.splash,
builder: (context, state) => const _SplashScreen(),
),
GoRoute(
path: AppRoutes.login,
builder: (context, state) => const LoginScreen(),
),
GoRoute(
path: AppRoutes.home,
builder: (context, state) => const HomeScreenPlaceholder(),
),
],
);
}
/// Pantalla de splash mínima mientras se verifica la sesión.
class _SplashScreen extends StatelessWidget {
const _SplashScreen();
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: const Color(0xFF2E7D32),
body: Center(
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
const Icon(
Icons.recycling_rounded,
size: 72,
color: Colors.white,
),
const SizedBox(height: 24),
Text(
'WasteNotify',
style: Theme.of(context).textTheme.headlineMedium?.copyWith(
color: Colors.white,
fontWeight: FontWeight.bold,
letterSpacing: 1.2,
),
),
const SizedBox(height: 48),
const CircularProgressIndicator(
valueColor: AlwaysStoppedAnimation<Color>(Colors.white70),
),
],
),
),
);
}
}
/// Notificador que conecta el estado del BLoC con go_router.
/// Permite que el router reaccione automáticamente a cambios de sesión.
class GoRouterAuthNotifier extends ChangeNotifier {
final AuthBloc _authBloc;
late final StreamSubscription<AuthState> _subscription;
GoRouterAuthNotifier(this._authBloc) {
_subscription = _authBloc.stream.listen((_) => notifyListeners());
}
@override
void dispose() {
_subscription.cancel();
super.dispose();
}
}

View File

@@ -0,0 +1,110 @@
import 'package:flutter/material.dart';
/// Paleta y tema central de WasteNotify.
/// Inspirado en materiales naturales: verde bosque + tierra + blanco hueso.
/// Transmite confianza institucional y respeto ambiental.
abstract final class AppTheme {
// --- Paleta de color ---
static const Color forestGreen = Color(0xFF1B5E20);
static const Color leafGreen = Color(0xFF2E7D32);
static const Color mintGreen = Color(0xFF43A047);
static const Color lightMint = Color(0xFFE8F5E9);
static const Color earthBrown = Color(0xFF4E342E);
static const Color sandBeige = Color(0xFFFFF8E1);
static const Color warmWhite = Color(0xFFFAFAF7);
static const Color charcoal = Color(0xFF212121);
static const Color midGray = Color(0xFF757575);
static const Color lightGray = Color(0xFFEEEEEE);
static const Color alertAmber = Color(0xFFF57C00);
static const Color errorRed = Color(0xFFC62828);
static ThemeData get light {
const colorScheme = ColorScheme(
brightness: Brightness.light,
primary: leafGreen,
onPrimary: Colors.white,
primaryContainer: lightMint,
onPrimaryContainer: forestGreen,
secondary: earthBrown,
onSecondary: Colors.white,
secondaryContainer: sandBeige,
onSecondaryContainer: earthBrown,
error: errorRed,
onError: Colors.white,
surface: warmWhite,
onSurface: charcoal,
);
return ThemeData(
useMaterial3: true,
colorScheme: colorScheme,
fontFamily: 'Georgia', // Serifed: transmite solidez institucional
scaffoldBackgroundColor: warmWhite,
appBarTheme: const AppBarTheme(
backgroundColor: warmWhite,
foregroundColor: charcoal,
elevation: 0,
scrolledUnderElevation: 1,
),
elevatedButtonTheme: ElevatedButtonThemeData(
style: ElevatedButton.styleFrom(
backgroundColor: leafGreen,
foregroundColor: Colors.white,
minimumSize: const Size(double.infinity, 54),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(12),
),
elevation: 3,
shadowColor: leafGreen.withOpacity(0.4),
textStyle: const TextStyle(
fontSize: 16,
fontWeight: FontWeight.w700,
letterSpacing: 0.5,
),
),
),
inputDecorationTheme: InputDecorationTheme(
filled: true,
fillColor: Colors.white,
contentPadding:
const EdgeInsets.symmetric(horizontal: 16, vertical: 16),
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(12),
borderSide: const BorderSide(color: lightGray, width: 1.5),
),
enabledBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(12),
borderSide: const BorderSide(color: lightGray, width: 1.5),
),
focusedBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(12),
borderSide: const BorderSide(color: leafGreen, width: 2),
),
errorBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(12),
borderSide: const BorderSide(color: errorRed, width: 1.5),
),
focusedErrorBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(12),
borderSide: const BorderSide(color: errorRed, width: 2),
),
labelStyle: const TextStyle(color: midGray),
hintStyle: TextStyle(color: midGray.withOpacity(0.7)),
),
cardTheme: CardThemeData(
color: Colors.white,
elevation: 2,
shadowColor: Colors.black.withOpacity(0.08),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(16),
),
),
snackBarTheme: SnackBarThemeData(
backgroundColor: charcoal,
contentTextStyle: const TextStyle(color: Colors.white, fontSize: 14),
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(8)),
behavior: SnackBarBehavior.floating,
),
);
}
}