import 'package:flutter/material.dart';
import 'package:afterwork/presentation/screens/login/login_screen.dart';
import 'package:afterwork/presentation/screens/story/story_screen.dart';
import 'package:afterwork/presentation/screens/profile/profile_screen.dart';
import 'package:afterwork/presentation/screens/settings/settings_screen.dart';
import 'package:afterwork/presentation/screens/home/home_screen.dart';
import 'package:afterwork/presentation/screens/event/event_screen.dart';
import 'package:afterwork/data/datasources/event_remote_data_source.dart';
import '../presentation/reservations/reservations_screen.dart';

/// Router personnalisé pour gérer la navigation dans l'application.
/// Les logs permettent de tracer chaque navigation dans la console.
class AppRouter {
  final EventRemoteDataSource eventRemoteDataSource;
  final String userId;
  final String userName;
  final String userLastName;

  /// Initialisation des informations utilisateur et source de données
  AppRouter({
    required this.eventRemoteDataSource,
    required this.userId,
    required this.userName,
    required this.userLastName,
  }) {
    print("AppRouter initialisé avec les infos utilisateur : $userId, $userName, $userLastName");
  }

  /// Génération des routes pour l'application
  Route<dynamic> generateRoute(RouteSettings settings) {
    print("Navigation vers la route : ${settings.name}");

    switch (settings.name) {
      case '/':
        return MaterialPageRoute(builder: (_) => const LoginScreen());

      case '/home':
        return MaterialPageRoute(
          builder: (_) => HomeScreen(
            eventRemoteDataSource: eventRemoteDataSource,
            userId: userId,
            userName: userName,
            userLastName: userLastName,
            userProfileImage: 'lib/assets/images/profile_picture.png',
          ),
        );

      case '/event':
        return MaterialPageRoute(
          builder: (_) => EventScreen(
            userId: userId,
            userName: userName,
            userLastName: userLastName,
          ),
        );

      case '/story':
        return MaterialPageRoute(builder: (_) => const StoryScreen());

      case '/profile':
        return MaterialPageRoute(builder: (_) => const ProfileScreen());

      case '/settings':
        return MaterialPageRoute(builder: (_) => const SettingsScreen());

      case '/reservations':
        return MaterialPageRoute(builder: (_) => const ReservationsScreen());

      default:
        return MaterialPageRoute(
          builder: (_) => const Scaffold(
            body: Center(child: Text('Page non trouvée')),
          ),
        );
    }
  }
}
