import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:get/get.dart';
import 'package:intl/date_symbol_data_local.dart';
import 'package:prosappco/src/authentication/authentication_repository.dart';
import 'package:prosappco/src/screens/calendar.dart';
import 'package:prosappco/src/screens/city.dart';
import 'package:prosappco/src/screens/login.dart';
import 'package:firebase_core/firebase_core.dart';
import 'package:prosappco/src/screens/login_email.dart';
import 'package:prosappco/src/screens/my_services.dart';
import 'package:prosappco/src/screens/my_services_pro.dart';
import 'package:prosappco/src/screens/new_number.dart';
import 'package:prosappco/src/screens/new_password.dart';
import 'package:prosappco/src/screens/profession.dart';
import 'package:prosappco/src/screens/professional_profile.dart';
import 'package:prosappco/src/screens/professional_revision.dart';
import 'package:prosappco/src/screens/profile.dart';
import 'package:prosappco/src/screens/profile_pro.dart';
import 'package:prosappco/src/screens/register.dart';
import 'package:prosappco/src/screens/request_sent.dart';
import 'package:prosappco/src/screens/service.dart';
import 'package:prosappco/src/screens/solicitudes.dart';
import 'package:prosappco/src/services/local_notifications.dart';
import 'firebase_options.dart';

void main() async {
  WidgetsFlutterBinding.ensureInitialized();

  await initNotifications();

  await initializeDateFormatting('es_MX', null);

  SystemChrome.setPreferredOrientations([
    DeviceOrientation.portraitUp,
    DeviceOrientation.portraitDown,
  ]);
  await Firebase.initializeApp(
    options: DefaultFirebaseOptions.currentPlatform,
  ).then((value) => Get.put(AuthenticationRepository()));
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return GetMaterialApp(
      theme: ThemeData(fontFamily: 'Poppins'),
      debugShowCheckedModeBanner: false,
      title: 'ProsApp',
      initialRoute: '/',
      routes: {
        '/': (context) => const LoginScreen(),
        '/login': (context) => const LoginEmailScreen(),
        '/profile': (context) => const ProfileScreen(),
        '/register': (context) => const RegisterScreen(),
        '/city': (context) => const CityScreen(),
        '/profession': (context) => const ProfessionScreen(),
        '/newNumber': (context) => const NewNumberScreen(),
        '/profesionalRevision': (context) => const ProfessionalRevisionScreen(),
        '/profesionalProfile': (context) => const ProfessionalProfileScreen(),
        '/solicitudEnviada': (context) => const RequestSentScreen(),
        '/nuevaPassword': (context) => NewPasswordScreen(),
        '/servicio': (context) => const ServiceScreen(),
        '/profilePro': (context) => const ProfilePro(),
        '/calendar': (context) => const CalendarScreen(),
        '/solicitud': (context) => SolicitudScreen(),
        '/misserviciospro': (context) => const MyServicesProScreen(),
        '/misservicios': (context) => MyServicesScreen(),
      },
      onGenerateRoute: (settings) {
        throw Exception('Ruta desconocida: ${settings.name}');
      },
    );
  }
}
