import 'package:flutter/material.dart';
import 'package:surface_tension_calculator/routes/routes.dart';

import '../screens/home_screen.dart';

class RouteGenerator {
  static Route<dynamic> generateRoute(RouteSettings settings) {
    // Getting arguments passed in while calling Navigator.pushNamed
    final args = settings.arguments;

    switch (settings.name) {
      case MainUIRoutes.homeScreen:
        return MaterialPageRoute<dynamic>(
          settings: settings,
          builder: (_) => const HomeScreen(),
        );
      case MainUIRoutes.resultsScreen:
        // if (args is Map && args['student'] is Student) {
        //   return MaterialPageRoute(
        //       settings: settings,
        //       builder: (_) => DashboardScreen(student: args['student']));
        // } else {
        return _errorRoute();
      // }

      default:
        // If there is no such named route in the switch statement
        return _errorRoute();
    }
  }

  static Route<dynamic> _errorRoute() {
    return MaterialPageRoute(
      builder: (_) {
        return Scaffold(
          appBar: AppBar(title: const Text('Error')),
          body: const Column(
            mainAxisAlignment: MainAxisAlignment.center,
            crossAxisAlignment: CrossAxisAlignment.stretch,
            children: [
              Icon(Icons.construction_rounded, size: 65),
              Center(child: Text('This page is under construction.')),
            ],
          ),
        );
      },
    );
  }
}
