import 'package:flutter/cupertino.dart';
import 'package:go_router/go_router.dart';
import 'package:{{#snakeCase}}{{project_name}}{{/snakeCase}}/presentation/features/counter/counter.dart';
import 'package:{{#snakeCase}}{{project_name}}{{/snakeCase}}/presentation/features/home/home.dart';

abstract class AppRouter {
  /// Default transition for all pages
  static Page<void> defaultTransition(
    BuildContext context,
    GoRouterState state,
    Widget child,
  ) =>
      CupertinoPage<void>(
        key: state.pageKey,
        child: child,
      );

  /// Disable transition animation
  static Page<void> noTransition(
    BuildContext context,
    GoRouterState state,
    Widget child,
  ) =>
      CustomTransitionPage<void>(
        key: state.pageKey,
        transitionsBuilder: (_, __, ___, child) => child,
        child: child,
      );

  /// Defines public routes (no authentication needed).
  ///
  /// Example:
  /// ```dart
  /// static final publicRoutes = [
  /// '/',
  /// '/sign_in',
  /// '/sign_up',
  /// ];
  /// ```
  static final List<String> publicRoutes = [];

  /// Defines GoRoute routes.
  static final List<GoRoute> routes = [
    GoRoute(
      path: '/',
      name: Home.pageName,
      pageBuilder: (context, state) =>
          defaultTransition(context, state, const Home()),
    ),
    GoRoute(
      path: '/counter',
      name: Counter.pageName,
      pageBuilder: (context, state) =>
          defaultTransition(context, state, const Counter()),
    ),
  ];

  /// Router
  static GoRouter router = GoRouter(
    initialLocation: '/',
    routes: AppRouter.routes,
    debugLogDiagnostics: true,
    redirect: (context, state) => null,
  );
}
