import 'package:flutter/material.dart';

import '../presentation/screens/login/login_page.dart';
import '../presentation/screens/tabbar/tabbar.dart';
import 'route_name.dart';

class Routes {
  static Route buildRoutes(RouteSettings settings) {
    switch (settings.name) {
      case RouteName.loginPage:
        return buildRoute(settings, const LoginPage());
      case RouteName.dashboardPage:
        return buildRoute(settings, TabbarScreen());

      default:
        return _errorRoute();
    }
  }

  static Route login() {
    return PageRouteBuilder(
      pageBuilder: (context, animation, secondaryAnimation) => const LoginPage(),
      transitionsBuilder: (context, animation, secondaryAnimation, child) {
        return child;
      },
      transitionDuration: const Duration(seconds: 0),
    );
  }

  static Route dashboard() {
    return PageRouteBuilder(
      pageBuilder: (context, animation, secondaryAnimation) => TabbarScreen(),
      transitionsBuilder: (context, animation, secondaryAnimation, child) {
        return child;
      },
      transitionDuration: const Duration(seconds: 0),
    );
  }

  static Route homeRoute(RouteSettings settings) {
    return buildRoutes(settings);
  }

  static Route _errorRoute() {
    return MaterialPageRoute(builder: (_) {
      return const Scaffold(
        body: Center(
          child: Text(''),
        ),
      );
    });
  }

  static MaterialPageRoute buildRoute(RouteSettings settings, Widget builder) {
    return MaterialPageRoute(
      settings: settings,
      builder: (BuildContext context) => builder,
    );
  }
}
