import 'package:farm_tpf/presentation/screens/tabbar/tabbar.dart';
import 'package:flutter/material.dart';
import '../presentation/screens/login/login_page.dart';
import '../presentation/screens/splash/view/splash_page.dart';
import 'route_name.dart';

class Routes {
  static Route buildRoutes(RouteSettings settings) {
    switch (settings.name) {
      case RouteName.splashPage:
        return buildRoute(settings, SplashPage());
      case RouteName.login:
        return buildRoute(settings, LoginPage());
      case RouteName.home:
        return buildRoute(settings, TabbarScreen());
      default:
        return _errorRoute();
    }
  }

  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,
    );
  }
}
