import 'package:flutter/material.dart';
import '../Tab.dart';
import '../views/palRoom/PalRoom.dart';
import '../views/createRoom/CreateRoom.dart';
import '../views/login/Login.dart';

final routes = {
  '/': (context) => Tabs(),
  'PalRoom': (context) => PalRoomPage(),
  'CreateRoom': (context) => CreateRoomPage(),
  'Login': (context) => LoginPage(),
};

var onGenerateRoute = (RouteSettings settings) {
  // 统一处理
  final String? name = settings.name;
  final Function? pageContentBuilder = routes[name];
  if (pageContentBuilder != null) {
    if (settings.arguments != null) {
      final Route route = MaterialPageRoute(
          builder: (context) =>
              pageContentBuilder(context, arguments: settings.arguments));
      return route;
    } else {
      final Route route =
          MaterialPageRoute(builder: (context) => pageContentBuilder(context));
      return route;
    }
  }
};
