// Copyright (C) 2022 WYATT GROUP
// Please see the AUTHORS file for details.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.

import 'package:example_router/presentation/features/edit_profile/edit_profile_page.dart';
import 'package:example_router/presentation/features/home/home_page.dart';
import 'package:example_router/presentation/features/sign_in/sign_in_page.dart';
import 'package:example_router/presentation/features/sign_up/sign_up_page.dart';
import 'package:example_router/presentation/features/sub/sub_page.dart';
import 'package:example_router/presentation/features/welcome/welcome_page.dart';
import 'package:flutter/cupertino.dart';
import 'package:go_router/go_router.dart';

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

  static final publicRoutes = ['/', '/sign_in', '/sign_up'];

  static final List<GoRoute> routes = [
    GoRoute(
      path: '/',
      name: WelcomePage.pageName,
      pageBuilder: (context, state) => defaultTransition(
        context,
        state,
        const WelcomePage(),
      ),
    ),
    GoRoute(
      path: '/sign_in',
      name: SignInPage.pageName,
      pageBuilder: (context, state) => defaultTransition(
        context,
        state,
        const SignInPage(),
      ),
    ),
    GoRoute(
      path: '/sign_up',
      name: SignUpPage.pageName,
      pageBuilder: (context, state) => defaultTransition(
        context,
        state,
        const SignUpPage(),
      ),
    ),
    GoRoute(
      path: '/home',
      name: HomePage.pageName,
      pageBuilder: (context, state) => defaultTransition(
        context,
        state,
        const HomePage(),
      ),
    ),
    GoRoute(
      path: '/home/sub',
      name: SubPage.pageName,
      pageBuilder: (context, state) => defaultTransition(
        context,
        state,
        const SubPage(),
      ),
    ),
    GoRoute(
      path: '/home/edit',
      name: EditProfilePage.pageName,
      pageBuilder: (context, state) => defaultTransition(
        context,
        state,
        const EditProfilePage(),
      ),
    ),
  ];
}
