import 'package:recomendagro/src/app/auth/screens/cadastro.dart';
import 'package:recomendagro/src/app/auth/screens/codigoverifica.dart';
import 'package:recomendagro/src/app/auth/screens/login.dart';
import 'package:recomendagro/src/app/base/screens/splash.dart';
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:go_router/go_router.dart';

final GlobalKey<NavigatorState> _rootNavigatorKey = GlobalKey<NavigatorState>(debugLabel: 'root');
final GlobalKey<NavigatorState> _shellNavigatorKey = GlobalKey<NavigatorState>(debugLabel: 'shell');

final routerProvider = Provider<GoRouter>((ref) {
  return GoRouter(
    initialLocation: SlapshScreen.path,
    navigatorKey: _rootNavigatorKey,
    debugLogDiagnostics: false,
    routes: [
      GoRoute(
        path: SlapshScreen.path,
        parentNavigatorKey: _rootNavigatorKey,
        builder: (_, state) => const SlapshScreen()
      ),
      GoRoute(
        path: LoginScreen.path,
        parentNavigatorKey: _rootNavigatorKey,
        builder: (_, state) => const LoginScreen()
      ),
      GoRoute(
        path: CadastroScreen.path,
        parentNavigatorKey: _rootNavigatorKey,
        builder: (_, state) => const CadastroScreen()
      ),
      GoRoute(
        path: CodigoVerificacaoScreen.path,
        parentNavigatorKey: _rootNavigatorKey,
        builder: (_, state) => const CodigoVerificacaoScreen()
      ),
      // GoRoute(
      //   path: RecuperarContaScreen.path,
      //   parentNavigatorKey: _rootNavigatorKey,
      //   builder: (_, state) => const RecuperarContaScreen()
      // ),
      // GoRoute(
      //   path: ComponentScreen.path,
      //   parentNavigatorKey: _rootNavigatorKey,
      //   builder: (_, state) => const ComponentScreen()
      // ),
      // GoRoute(
      //   parentNavigatorKey: _rootNavigatorKey,
      //   path: '${HomeSignScreen.pathDoc}/:id',
      //   pageBuilder: (_, state)  => transitionScreen(
      //     state.pageKey,
      //     child: HomeSignScreen(urlState: state)
      //   )
      // ),
      // ShellRoute(
      //   navigatorKey: _shellNavigatorKey,
      //   builder: (context, state, child) {
      //     return BaseHomeDash(
      //       child: child
      //     );
      //   },
      //   routes:  <RouteBase>[
      //     GoRoute(
      //       path: ListDocumentosScreen.path,
      //       pageBuilder: (_, state) => transitionScreen(
      //         state.pageKey,
      //         child: const ListDocumentosScreen()
      //       )
      //     ),
      //     GoRoute(
      //       path: DocumentosSolicitadosScreen.path,
      //       pageBuilder: (_, state) => transitionScreen(
      //         state.pageKey,
      //         child: const DocumentosSolicitadosScreen(),
      //       )
      //     ),
      //     GoRoute(
      //       path: DocumentosArquivadoScreen.path,
      //       pageBuilder: (_, state) => transitionScreen(
      //         state.pageKey,
      //         child: const DocumentosArquivadoScreen(),
      //       )
      //     ),
      //     GoRoute(
      //       path: DocumentosLixeiraScreen.path,
      //       pageBuilder: (_, state) => transitionScreen(
      //         state.pageKey,
      //         child: const DocumentosLixeiraScreen(),
      //       )
      //     ),
      //     GoRoute(
      //       path: DocumentosVencidosScreen.path,
      //       pageBuilder: (_, state) => transitionScreen(
      //         state.pageKey,
      //         child: const DocumentosVencidosScreen(),
      //       )
      //     ),
      //     GoRoute(
      //       path: BaseProfileScreen.path,
      //       pageBuilder: (_, state) => transitionScreen(
      //         state.pageKey,
      //         child: const BaseProfileScreen(),
      //       )
      //     )
      ]
  );
});


CustomTransitionPage transitionScreen(LocalKey key, {required Widget child}){
  return CustomTransitionPage(
    key: key,
    child: child,
    transitionsBuilder: (context, animation, secondaryAnimation, child) {
      return FadeTransition(
        opacity: CurveTween(
          curve: Curves.ease
          // curve: Curves.easeInOutCirc
        ).animate(animation),
        child: child,
      );
    }
  );
}