import 'package:flutter/material.dart';
import 'package:flutter_habit/pages/home_page.dart';
import 'package:flutter_habit/pages/splash_page.dart';

/// Description: routes
/// Time       : 08/18/2023 Friday
/// Author     : liuyuqi.gov@msn.cn
class Routes {
  static const String home = "/home";
  static const String splash = "/splash";
  
  static MaterialPageRoute<dynamic> onGenerateRoute(RouteSettings settings) {
    switch (settings.name) {
      case splash:
        return MaterialPageRoute(builder: (_) => SplashPage());
      case home:
        return MaterialPageRoute(builder: (_) => HomePage());
      default:
        return MaterialPageRoute(builder: (_) => SplashPage());
    }
  }

  /// 路由跳转,是否返回  replace: true 为不返回
  static void go(context, String routeName, {bool replace = false}) {
    if (replace) {
      Navigator.pushReplacementNamed(context, routeName);
      // Navigator.pushAndRemoveUntil(context, newRoute, (route) => false);
      return;
    }
    Navigator.pushNamed(context, routeName);
  }
}
