Blame view

lib/route/route.dart 6.06 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';
bfb40cd0   liangchengyou   feat:忘记密码获取验证码
4
  import 'package:wow_english/common/pages/wow_web_page.dart';
4b358e22   liangchengyou   feat:调整文件结构
5
6
7
8
9
10
  import 'package:wow_english/pages/home/home_page.dart';
  import 'package:wow_english/pages/lessons/lesson_page.dart';
  import 'package:wow_english/pages/listen/listen_page.dart';
  import 'package:wow_english/pages/login/forgetpwd/forget_password_home_page.dart';
  import 'package:wow_english/pages/login/loginpage/login_page.dart';
  import 'package:wow_english/pages/login/setpwd/set_pwd_page.dart';
842b7132   liangchengyou   feat:磨耳朵/练习页面调整
11
  import 'package:wow_english/pages/practice/topic_picture_page.dart';
4b358e22   liangchengyou   feat:调整文件结构
12
13
14
15
16
  import 'package:wow_english/pages/repeatafter/repeat_after_page.dart';
  import 'package:wow_english/pages/shop/exchane/exchange_lesson_page.dart';
  import 'package:wow_english/pages/shop/exchangelist/exchange_lesson_list_page.dart';
  import 'package:wow_english/pages/shop/home/shop_home_page.dart';
  import 'package:wow_english/pages/tab/tab_page.dart';
da82bd70   Key   feat: user_inform...
17
  import 'package:wow_english/pages/user/information/user_information_page.dart';
4b358e22   liangchengyou   feat:调整文件结构
18
19
  import 'package:wow_english/pages/user/user_page.dart';
  import 'package:wow_english/pages/video/lookvideo/look_video_page.dart';
4b358e22   liangchengyou   feat:调整文件结构
20
  
2a427e12   吴启风   feat:绘本静态ui基本完成
21
22
  import '../pages/reading/reading_page.dart';
  
2a29701f   liangchengyou   feat:提交代码
23
24
25
  class AppRouteName {
    static const String splash = 'splash';
    static const String login = 'login';
95edef4f   liangchengyou   feat:更新适配代码
26
    static const String home = 'home';
4bf67b91   liangchengyou   feat:设置密码
27
    static const String fogPwd = 'fogPwd';
c61b3c1a   Key   feat: toast_util....
28
29
  
    /// 设置密码,修改密码;不要自己调用,使用[SetPassWordPage.push]方法
1d5315dd   liangchengyou   feat:添加字体,调整文件结构
30
    static const String setPwd = 'setPwd';
bfb40cd0   liangchengyou   feat:忘记密码获取验证码
31
    static const String webView = 'webView';
60e47f7c   liangchengyou   feat:课程选择功能
32
    static const String lesson = 'lesson';
d35a4e87   liangchengyou   feat:磨耳朵功能UI
33
    static const String listen = 'listen';
d1d32220   liangchengyou   feat:兑换课程+购买记录
34
35
36
    static const String shop = 'shop';
    static const String exLesson = 'exLesson';
    static const String exList = 'exList';
9d080046   liangchengyou   feat:视频跟读逻辑
37
    static const String reAfter = 'reAfter';
624214d0   liangchengyou   feat:看题选字/选图UI和部分逻辑
38
39
    static const String topicPic = 'topicPic';
    static const String topicWord = 'topicWord';
95e3448c   liangchengyou   feat:听音选图/选字
40
41
    static const String voicePic = 'voicePic';
    static const String voiceWord = 'voiceWord';
725dc3f2   liangchengyou   feat:语音问答界面UI
42
    static const String voiceAnswer = 'voiceAnswer';
da82bd70   Key   feat: user_inform...
43
44
  
    /// 用户个人主页
22b7d4da   Key   feat: user, api path
45
    static const String user = 'user';
da82bd70   Key   feat: user_inform...
46
47
48
  
    /// 用户详细信息页
    static const String userInformation = 'userInformation';
119ba920   liangchengyou   feat:视频播放器
49
    static const String lookVideo = 'lookVideo';
c61b3c1a   Key   feat: toast_util....
50
51
52
    static const String reading = 'reading';
  
    ///绘本
2a29701f   liangchengyou   feat:提交代码
53
54
55
56
57
    static const String tab = '/';
  }
  
  class AppRouter {
    static final navigatorKey = GlobalKey<NavigatorState>();
94342c3f   Key   feat: user util
58
  
2a29701f   liangchengyou   feat:提交代码
59
60
    // App 根节点Context
    static BuildContext get context => navigatorKey.currentContext!;
22b7d4da   Key   feat: user, api path
61
  
2a29701f   liangchengyou   feat:提交代码
62
63
64
65
66
    static Route<dynamic> generateRoute(RouteSettings settings) {
      switch (settings.name) {
        case AppRouteName.splash:
          return PageRouteBuilder(
              opaque: false,
94342c3f   Key   feat: user util
67
              pageBuilder: (_, __, ___) => const SplashPage(),
2a29701f   liangchengyou   feat:提交代码
68
69
70
              transitionDuration: Duration.zero,
              transitionsBuilder: (_, __, ___, child) => child);
        case AppRouteName.login:
94342c3f   Key   feat: user util
71
          return CupertinoPageRoute(builder: (_) => const LoginPage());
95edef4f   liangchengyou   feat:更新适配代码
72
        case AppRouteName.home:
8988aa69   liangchengyou   feat:首页+课程列表数据获取
73
74
75
76
          var moduleId = '';
          if (settings.arguments != null) {
            moduleId = (settings.arguments as Map)['moduleId'] as String;
          }
c61b3c1a   Key   feat: toast_util....
77
78
79
80
          return CupertinoPageRoute(
              builder: (_) => HomePage(
                    moduleId: moduleId,
                  ));
4bf67b91   liangchengyou   feat:设置密码
81
        case AppRouteName.fogPwd:
94342c3f   Key   feat: user util
82
          return CupertinoPageRoute(builder: (_) => const ForgetPasswordHomePage());
60e47f7c   liangchengyou   feat:课程选择功能
83
        case AppRouteName.lesson:
94342c3f   Key   feat: user util
84
          return CupertinoPageRoute(builder: (_) => const LessonPage());
d35a4e87   liangchengyou   feat:磨耳朵功能UI
85
        case AppRouteName.listen:
94342c3f   Key   feat: user util
86
          return CupertinoPageRoute(builder: (_) => const ListenPage());
d1d32220   liangchengyou   feat:兑换课程+购买记录
87
        case AppRouteName.shop:
94342c3f   Key   feat: user util
88
          return CupertinoPageRoute(builder: (_) => const ShopHomePage());
d1d32220   liangchengyou   feat:兑换课程+购买记录
89
        case AppRouteName.exLesson:
94342c3f   Key   feat: user util
90
          return CupertinoPageRoute(builder: (_) => const ExchangeLessonPage());
d1d32220   liangchengyou   feat:兑换课程+购买记录
91
        case AppRouteName.exList:
94342c3f   Key   feat: user util
92
          return CupertinoPageRoute(builder: (_) => const ExchangeLessonListPage());
9d080046   liangchengyou   feat:视频跟读逻辑
93
        case AppRouteName.reAfter:
94342c3f   Key   feat: user util
94
          return CupertinoPageRoute(builder: (_) => const RepeatAfterPage());
22b7d4da   Key   feat: user, api path
95
        case AppRouteName.user:
94342c3f   Key   feat: user util
96
          return CupertinoPageRoute(builder: (_) => const UserPage());
da82bd70   Key   feat: user_inform...
97
98
        case AppRouteName.userInformation:
          return CupertinoPageRoute(builder: (_) => const UserInformationPage());
624214d0   liangchengyou   feat:看题选字/选图UI和部分逻辑
99
        case AppRouteName.topicPic:
94342c3f   Key   feat: user util
100
          return CupertinoPageRoute(builder: (_) => const TopicPicturePage());
119ba920   liangchengyou   feat:视频播放器
101
        case AppRouteName.lookVideo:
993c1a04   liangchengyou   feat:添加数据模型
102
          final videoUrl = (settings.arguments as Map)['videoUrl'] as String;
842b7132   liangchengyou   feat:磨耳朵/练习页面调整
103
          final title = (settings.arguments as Map)['title'] as String?;
c61b3c1a   Key   feat: toast_util....
104
105
106
107
108
          return CupertinoPageRoute(
              builder: (_) => LookVideoPage(
                    videoUrl: videoUrl,
                    typeTitle: title,
                  ));
1d5315dd   liangchengyou   feat:添加字体,调整文件结构
109
        case AppRouteName.setPwd:
c61b3c1a   Key   feat: toast_util....
110
111
112
113
114
115
116
117
118
119
          var map = settings.arguments as Map;
          final phoneNum = map['phoneNumber'] as String?;
          final smsCode = map['smsCode'] as String?;
          final pageType = map['pageType'] as SetPwdPageType;
          return CupertinoPageRoute(
              builder: (_) => SetPassWordPage(
                    phoneNum: phoneNum,
                    smsCode: smsCode,
                    pageType: pageType,
                  ));
bfb40cd0   liangchengyou   feat:忘记密码获取验证码
120
121
122
        case AppRouteName.webView:
          final urlStr = (settings.arguments as Map)['urlStr'] as String;
          final webViewTitle = (settings.arguments as Map)['webViewTitle'] as String;
94342c3f   Key   feat: user util
123
124
125
126
127
          return CupertinoPageRoute(
              builder: (_) => WowWebViewPage(
                    urlStr: urlStr,
                    webViewTitle: webViewTitle,
                  ));
2a29701f   liangchengyou   feat:提交代码
128
129
130
131
132
        case AppRouteName.tab:
          return PageRouteBuilder(
              opaque: false,
              settings: const RouteSettings(name: AppRouteName.tab),
              transitionDuration: Duration.zero,
94342c3f   Key   feat: user util
133
              pageBuilder: (_, __, ___) => const TabPage(),
2a29701f   liangchengyou   feat:提交代码
134
              transitionsBuilder: (_, __, ___, child) => child);
2a427e12   吴启风   feat:绘本静态ui基本完成
135
136
        case AppRouteName.reading:
          return CupertinoPageRoute(builder: (_) => const ReadingPage());
2a29701f   liangchengyou   feat:提交代码
137
138
        default:
          return CupertinoPageRoute(
94342c3f   Key   feat: user util
139
              builder: (_) => Scaffold(body: Center(child: Text('No route defined for ${settings.name}'))));
2a29701f   liangchengyou   feat:提交代码
140
141
      }
    }
22b7d4da   Key   feat: user, api path
142
  }