import 'package:flutter/material.dart';
import 'package:tugas_akhir_supabase/screens/auth/forgot_password_screen.dart';
import 'package:tugas_akhir_supabase/screens/auth/login_screen.dart';
import 'package:tugas_akhir_supabase/screens/auth/otp_screen.dart';
import 'package:tugas_akhir_supabase/screens/auth/register_screen.dart';
import 'package:tugas_akhir_supabase/screens/auth/reset_password_otp_screen.dart';
import 'package:tugas_akhir_supabase/screens/auth/reset_password_screen.dart';
import 'package:tugas_akhir_supabase/screens/calendar/calendar_screen.dart';
import 'package:tugas_akhir_supabase/screens/calendar/field_management_screen.dart';
import 'package:tugas_akhir_supabase/screens/calendar/schedule_detail_screen.dart';
import 'package:tugas_akhir_supabase/screens/calendar/schedule_list_screen.dart';
import 'package:tugas_akhir_supabase/screens/community/community_screen.dart';
import 'package:tugas_akhir_supabase/screens/home_screen.dart';
import 'package:tugas_akhir_supabase/screens/image_processing/plant_scanner_screen.dart';
import 'package:tugas_akhir_supabase/screens/intro/animation_splash_screen.dart';
import 'package:tugas_akhir_supabase/screens/intro/intro_page_screen.dart';
import 'package:tugas_akhir_supabase/screens/panen/analisis_panen_screen.dart';
import 'package:tugas_akhir_supabase/screens/profile_screen.dart';

/// Defines all routes used in the application
class AppRoutes {
  /// Map of all routes in the application
  static final Map<String, WidgetBuilder> routes = {
    '/': (context) => const SplashScreen(),
    '/intro': (context) => const AnimatedIntroScreen(),
    '/login': (context) => const LoginScreen(),
    '/register': (context) => const RegisterScreen(),
    '/otp': (context) {
      final args =
          ModalRoute.of(context)?.settings.arguments as Map<String, dynamic>;
      return OtpScreen(
        email: args['email'] as String,
        userId: args['userId'] as String,
      );
    },
    '/forgot-password': (context) => const ForgotPasswordScreen(),
    '/reset-password': (context) => const ResetPasswordScreen(),
    '/reset-password-otp': (context) {
      final args =
          ModalRoute.of(context)?.settings.arguments as Map<String, dynamic>;
      return ResetPasswordOtpScreen(email: args['email'] as String);
    },
    '/home': (context) => const HomeScreen(),
    '/profile': (context) => const ProfileScreen(),
    '/kalender': (context) => const KalenderTanamScreen(),
    '/add-field': (context) => const FieldManagementScreen(),
    '/schedule-list': (context) => const ScheduleListScreen(),

    '/kalender-detail': (context) {
      final args =
          ModalRoute.of(context)?.settings.arguments as Map<String, dynamic>;
      return ScheduleDetailScreen(scheduleId: args['scheduleId'] as String);
    },
    '/analisis': (context) {
      final args =
          ModalRoute.of(context)?.settings.arguments as Map<String, dynamic>;
      return HarvestAnalysisScreen(userId: args['userId'] as String);
    },
    '/komunitas': (context) => const CommunityScreen(),
    '/scan': (context) => const PlantScannerScreen(),
  };
}
