Blame view

lib/route/route.dart 2.21 KB
2a29701f   liangchengyou   feat:提交代码
1
2
  import 'package:flutter/cupertino.dart';
  import 'package:flutter/material.dart';
a117a5a3   liangchengyou   feat:更新代码
3
  import 'package:wow_english/app/splash_page.dart';
95edef4f   liangchengyou   feat:更新适配代码
4
  import 'package:wow_english/home/home_page.dart';
1d5315dd   liangchengyou   feat:添加字体,调整文件结构
5
6
7
  import 'package:wow_english/login/forgetpwd/forget_password_home_page.dart';
  import 'package:wow_english/login/loginpage/login_page.dart';
  import 'package:wow_english/login/setpwd/set_pwd_page.dart';
2a29701f   liangchengyou   feat:提交代码
8
9
10
11
12
13
  import 'package:wow_english/tab/tab_page.dart';
  
  
  class AppRouteName {
    static const String splash = 'splash';
    static const String login = 'login';
95edef4f   liangchengyou   feat:更新适配代码
14
    static const String home = 'home';
4bf67b91   liangchengyou   feat:设置密码
15
    static const String fogPwd = 'fogPwd';
1d5315dd   liangchengyou   feat:添加字体,调整文件结构
16
    static const String setPwd = 'setPwd';
2a29701f   liangchengyou   feat:提交代码
17
18
19
20
21
22
23
24
25
26
27
28
29
    static const String tab = '/';
  }
  
  class AppRouter {
    static final navigatorKey = GlobalKey<NavigatorState>();
    // App 根节点Context
    static BuildContext get context => navigatorKey.currentContext!;
    
    static Route<dynamic> generateRoute(RouteSettings settings) {
      switch (settings.name) {
        case AppRouteName.splash:
          return PageRouteBuilder(
              opaque: false,
a117a5a3   liangchengyou   feat:更新代码
30
              pageBuilder: (_,__,___) => const SplashPage(),
2a29701f   liangchengyou   feat:提交代码
31
32
33
              transitionDuration: Duration.zero,
              transitionsBuilder: (_, __, ___, child) => child);
        case AppRouteName.login:
062f0df2   liangchengyou   feat:登录模块代码提交
34
          return CupertinoPageRoute(builder: (_) =>  const LoginPage());
95edef4f   liangchengyou   feat:更新适配代码
35
36
        case AppRouteName.home:
          return CupertinoPageRoute(builder: (_) =>  const HomePage());
4bf67b91   liangchengyou   feat:设置密码
37
        case AppRouteName.fogPwd:
1d5315dd   liangchengyou   feat:添加字体,调整文件结构
38
39
          return CupertinoPageRoute(builder: (_) =>  const ForgetPasswordHomePage());
        case AppRouteName.setPwd:
4bf67b91   liangchengyou   feat:设置密码
40
          final phoneNum = (settings.arguments as Map)['phoneNumber'] as String;
1d5315dd   liangchengyou   feat:添加字体,调整文件结构
41
          return CupertinoPageRoute(builder: (_) =>  SetPassWordPage(phoneNum: phoneNum));
2a29701f   liangchengyou   feat:提交代码
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
        case AppRouteName.tab:
          return PageRouteBuilder(
              opaque: false,
              settings: const RouteSettings(name: AppRouteName.tab),
              transitionDuration: Duration.zero,
              pageBuilder: (_,__,___) => const TabPage(),
              transitionsBuilder: (_, __, ___, child) => child);
        default:
          return CupertinoPageRoute(
              builder: (_) => Scaffold(
                  body: Center(
                      child: Text('No route defined for ${settings.name}'))));
      }
    }
  }