/// Configuration centralisée des routes de l'application
/// 
/// Gère toutes les routes et la navigation de l'application UnionFlow
library app_router;

import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import '../../features/authentication/presentation/bloc/auth_bloc.dart';
import '../../features/authentication/presentation/pages/login_page.dart';
import '../../core/navigation/main_navigation_layout.dart';

/// Configuration des routes de l'application
class AppRouter {
  /// Routes principales de l'application
  static Map<String, WidgetBuilder> get routes => {
    '/': (context) => BlocBuilder<AuthBloc, AuthState>(
      builder: (context, state) {
        if (state is AuthLoading) {
          return const Scaffold(
            body: Center(
              child: CircularProgressIndicator(),
            ),
          );
        } else if (state is AuthAuthenticated) {
          return const MainNavigationLayout();
        } else {
          return const LoginPage();
        }
      },
    ),
    '/dashboard': (context) => const MainNavigationLayout(),
    '/login': (context) => const LoginPage(),
  };

  /// Route initiale de l'application
  static const String initialRoute = '/';
}
