Blame view

lib/route/route.dart 9.79 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';
07599105   吴启风   feat:商品列表请求&路由
5
  import 'package:wow_english/models/product_entity.dart';
6d61919a   吴启风   feat:增加过渡页&集成串联游戏
6
  import 'package:wow_english/pages/games/view.dart';
4b358e22   liangchengyou   feat:调整文件结构
7
8
9
10
11
12
  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';
6d61919a   吴启风   feat:增加过渡页&集成串联游戏
13
  import 'package:wow_english/pages/moduleSelect/view.dart';
842b7132   liangchengyou   feat:磨耳朵/练习页面调整
14
  import 'package:wow_english/pages/practice/topic_picture_page.dart';
4b358e22   liangchengyou   feat:调整文件结构
15
  import 'package:wow_english/pages/repeatafter/repeat_after_page.dart';
08a0f5a8   liangchengyou   feat:路由方式更新
16
  import 'package:wow_english/pages/repeataftercontent/repeat_after_content_page.dart';
4b358e22   liangchengyou   feat:调整文件结构
17
18
19
20
  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...
21
  import 'package:wow_english/pages/user/information/user_information_page.dart';
c948a9ea   liangchengyou   feat:个人信息更改模块功能
22
  import 'package:wow_english/pages/user/modify/modify_user_avatar_page.dart';
c9df43c8   Key   feat: 修改个人信息、接口
23
  import 'package:wow_english/pages/user/modify/modify_user_information_page.dart';
3840b7fe   liangchengyou   feat:更新设置页面
24
  import 'package:wow_english/pages/user/setting/setting_page.dart';
4b358e22   liangchengyou   feat:调整文件结构
25
26
  import 'package:wow_english/pages/user/user_page.dart';
  import 'package:wow_english/pages/video/lookvideo/look_video_page.dart';
4b358e22   liangchengyou   feat:调整文件结构
27
  
2a427e12   吴启风   feat:绘本静态ui基本完成
28
  import '../pages/reading/reading_page.dart';
4224b3f8   吴启风   feat:支付详情页ui
29
  import '../pages/shopping/view.dart';
3840b7fe   liangchengyou   feat:更新设置页面
30
31
  import '../pages/user/setting/delete_account_page.dart';
  import '../pages/user/setting/reback_page.dart';
07599105   吴启风   feat:商品列表请求&路由
32
  import '../utils/log_util.dart';
2a427e12   吴启风   feat:绘本静态ui基本完成
33
  
2a29701f   liangchengyou   feat:提交代码
34
35
36
  class AppRouteName {
    static const String splash = 'splash';
    static const String login = 'login';
6d61919a   吴启风   feat:增加过渡页&集成串联游戏
37
38
    static const String moduleSelect = 'moduleSelect';
    static const String games = 'games';
95edef4f   liangchengyou   feat:更新适配代码
39
    static const String home = 'home';
4bf67b91   liangchengyou   feat:设置密码
40
    static const String fogPwd = 'fogPwd';
c61b3c1a   Key   feat: toast_util....
41
  
c9df43c8   Key   feat: 修改个人信息、接口
42
43
    /// 设置密码,修改密码;不要自己调用,使用[SetPassWordPage.push]方法,隐藏这种实现
    //static const String setPwd = 'setPwd';
bfb40cd0   liangchengyou   feat:忘记密码获取验证码
44
    static const String webView = 'webView';
60e47f7c   liangchengyou   feat:课程选择功能
45
    static const String lesson = 'lesson';
d35a4e87   liangchengyou   feat:磨耳朵功能UI
46
    static const String listen = 'listen';
d1d32220   liangchengyou   feat:兑换课程+购买记录
47
48
49
    static const String shop = 'shop';
    static const String exLesson = 'exLesson';
    static const String exList = 'exList';
9d080046   liangchengyou   feat:视频跟读逻辑
50
    static const String reAfter = 'reAfter';
624214d0   liangchengyou   feat:看题选字/选图UI和部分逻辑
51
    static const String topicPic = 'topicPic';
22b7d4da   Key   feat: user, api path
52
    static const String user = 'user';
4224b3f8   吴启风   feat:支付详情页ui
53
    static const String pay = 'pay';
da82bd70   Key   feat: user_inform...
54
55
56
  
    /// 用户详细信息页
    static const String userInformation = 'userInformation';
c948a9ea   liangchengyou   feat:个人信息更改模块功能
57
58
    /// 修改用户头像
    static const String userAvatar = 'userAvatar';
c9df43c8   Key   feat: 修改个人信息、接口
59
60
61
  
    /// 用户修改信息页,不要自己调用,使用[ModifyUserInformationPage.push]方法,隐藏这种实现
    //static const String userModifyInformation = 'userModifyInformation';
08a0f5a8   liangchengyou   feat:路由方式更新
62
    ///看视频
119ba920   liangchengyou   feat:视频播放器
63
    static const String lookVideo = 'lookVideo';
08a0f5a8   liangchengyou   feat:路由方式更新
64
    ///绘本
c61b3c1a   Key   feat: toast_util....
65
    static const String reading = 'reading';
08a0f5a8   liangchengyou   feat:路由方式更新
66
67
68
    ///视频跟读详情
    static const String readAfterContent = 'readAfterContent';
  
3840b7fe   liangchengyou   feat:更新设置页面
69
70
71
72
73
74
75
    ///设置
    static const String setting = 'setting';
    ///注销账号
    static const String deleteAccount = 'deleteAccount';
    ///帮助与反馈
    static const String reBack = 'reBack';
  
2a29701f   liangchengyou   feat:提交代码
76
77
78
79
80
    static const String tab = '/';
  }
  
  class AppRouter {
    static final navigatorKey = GlobalKey<NavigatorState>();
94342c3f   Key   feat: user util
81
  
2a29701f   liangchengyou   feat:提交代码
82
83
    // App 根节点Context
    static BuildContext get context => navigatorKey.currentContext!;
22b7d4da   Key   feat: user, api path
84
  
2a29701f   liangchengyou   feat:提交代码
85
86
87
88
89
    static Route<dynamic> generateRoute(RouteSettings settings) {
      switch (settings.name) {
        case AppRouteName.splash:
          return PageRouteBuilder(
              opaque: false,
94342c3f   Key   feat: user util
90
              pageBuilder: (_, __, ___) => const SplashPage(),
2a29701f   liangchengyou   feat:提交代码
91
92
93
              transitionDuration: Duration.zero,
              transitionsBuilder: (_, __, ___, child) => child);
        case AppRouteName.login:
94342c3f   Key   feat: user util
94
          return CupertinoPageRoute(builder: (_) => const LoginPage());
6d61919a   吴启风   feat:增加过渡页&集成串联游戏
95
96
97
98
        case AppRouteName.moduleSelect:
          return CupertinoPageRoute(builder: (_) => const ModuleSelectPage());
        case AppRouteName.games:
          return CupertinoPageRoute(builder: (_) => const GamesPage());
95edef4f   liangchengyou   feat:更新适配代码
99
        case AppRouteName.home:
8988aa69   liangchengyou   feat:首页+课程列表数据获取
100
101
102
103
          var moduleId = '';
          if (settings.arguments != null) {
            moduleId = (settings.arguments as Map)['moduleId'] as String;
          }
c61b3c1a   Key   feat: toast_util....
104
105
          return CupertinoPageRoute(
              builder: (_) => HomePage(
e55bbdf3   Key   fixed: aliyun oss...
106
107
                    moduleId: moduleId,
                  ));
4bf67b91   liangchengyou   feat:设置密码
108
        case AppRouteName.fogPwd:
94342c3f   Key   feat: user util
109
          return CupertinoPageRoute(builder: (_) => const ForgetPasswordHomePage());
60e47f7c   liangchengyou   feat:课程选择功能
110
        case AppRouteName.lesson:
94342c3f   Key   feat: user util
111
          return CupertinoPageRoute(builder: (_) => const LessonPage());
d35a4e87   liangchengyou   feat:磨耳朵功能UI
112
        case AppRouteName.listen:
94342c3f   Key   feat: user util
113
          return CupertinoPageRoute(builder: (_) => const ListenPage());
d1d32220   liangchengyou   feat:兑换课程+购买记录
114
        case AppRouteName.shop:
94342c3f   Key   feat: user util
115
          return CupertinoPageRoute(builder: (_) => const ShopHomePage());
4224b3f8   吴启风   feat:支付详情页ui
116
        case AppRouteName.pay:
07599105   吴启风   feat:商品列表请求&路由
117
118
119
120
121
          var productEntity = ProductEntity();
          if (settings.arguments != null && settings.arguments is ProductEntity) {
            productEntity = settings.arguments as ProductEntity;
          }
          return CupertinoPageRoute(builder: (_) => ShoppingPage(productEntity: productEntity));
d1d32220   liangchengyou   feat:兑换课程+购买记录
122
        case AppRouteName.exLesson:
94342c3f   Key   feat: user util
123
          return CupertinoPageRoute(builder: (_) => const ExchangeLessonPage());
d1d32220   liangchengyou   feat:兑换课程+购买记录
124
        case AppRouteName.exList:
94342c3f   Key   feat: user util
125
          return CupertinoPageRoute(builder: (_) => const ExchangeLessonListPage());
9d080046   liangchengyou   feat:视频跟读逻辑
126
        case AppRouteName.reAfter:
94342c3f   Key   feat: user util
127
          return CupertinoPageRoute(builder: (_) => const RepeatAfterPage());
22b7d4da   Key   feat: user, api path
128
        case AppRouteName.user:
94342c3f   Key   feat: user util
129
          return CupertinoPageRoute(builder: (_) => const UserPage());
da82bd70   Key   feat: user_inform...
130
131
        case AppRouteName.userInformation:
          return CupertinoPageRoute(builder: (_) => const UserInformationPage());
c948a9ea   liangchengyou   feat:个人信息更改模块功能
132
133
134
        case AppRouteName.userAvatar:
          var pageType = 0;
          if (settings.arguments != null) {
934e2b47   liangchengyou   feat:权限调整+课程进度接口对接
135
            final content = (settings.arguments as Map)['pageType'] as String;
c948a9ea   liangchengyou   feat:个人信息更改模块功能
136
137
            pageType = int.parse(content);
          }
e55bbdf3   Key   fixed: aliyun oss...
138
139
140
141
142
          return CupertinoPageRoute(
              builder: (_) => ModifyUserAvatarPage(
                    pageType: pageType,
                  ));
        /*case AppRouteName.userModifyInformation:
c9df43c8   Key   feat: 修改个人信息、接口
143
144
145
146
147
148
149
          return CupertinoPageRoute(builder: (_) {
            ModifyUserInformationType argument = ModifyUserInformationType.name;
            if (settings.arguments != null) {
              argument = settings.arguments as ModifyUserInformationType;
            }
            return ModifyUserInformationPage(type: argument);
          });*/
624214d0   liangchengyou   feat:看题选字/选图UI和部分逻辑
150
        case AppRouteName.topicPic:
608c05b4   liangchengyou   feat:兑换课程
151
152
          var courseLessonId = '';
          if (settings.arguments != null) {
934e2b47   liangchengyou   feat:权限调整+课程进度接口对接
153
            courseLessonId = (settings.arguments as Map)['courseLessonId'] as String;
608c05b4   liangchengyou   feat:兑换课程
154
          }
e55bbdf3   Key   fixed: aliyun oss...
155
          return CupertinoPageRoute(builder: (_) => TopicPicturePage(courseLessonId: courseLessonId));
119ba920   liangchengyou   feat:视频播放器
156
        case AppRouteName.lookVideo:
993c1a04   liangchengyou   feat:添加数据模型
157
          final videoUrl = (settings.arguments as Map)['videoUrl'] as String;
842b7132   liangchengyou   feat:磨耳朵/练习页面调整
158
          final title = (settings.arguments as Map)['title'] as String?;
934e2b47   liangchengyou   feat:权限调整+课程进度接口对接
159
          final courseLessonId = (settings.arguments as Map)['courseLessonId'] as String?;
c61b3c1a   Key   feat: toast_util....
160
161
          return CupertinoPageRoute(
              builder: (_) => LookVideoPage(
934e2b47   liangchengyou   feat:权限调整+课程进度接口对接
162
163
164
165
                videoUrl: videoUrl,
                typeTitle: title,
                courseLessonId: courseLessonId,
              ));
e55bbdf3   Key   fixed: aliyun oss...
166
        /*case AppRouteName.setPwd:
cb38bc90   liangchengyou   feat:视频跟读逻辑处理
167
        case AppRouteName.setPwd:
c61b3c1a   Key   feat: toast_util....
168
169
170
                    phoneNum: phoneNum,
                    smsCode: smsCode,
                    pageType: pageType,
c9df43c8   Key   feat: 修改个人信息、接口
171
                  ));*/
bfb40cd0   liangchengyou   feat:忘记密码获取验证码
172
173
174
        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
175
176
          return CupertinoPageRoute(
              builder: (_) => WowWebViewPage(
e55bbdf3   Key   fixed: aliyun oss...
177
178
179
                    urlStr: urlStr,
                    webViewTitle: webViewTitle,
                  ));
08a0f5a8   liangchengyou   feat:路由方式更新
180
        case AppRouteName.readAfterContent:
cb38bc90   liangchengyou   feat:视频跟读逻辑处理
181
182
          var videoFollowReadId = '';
          if (settings.arguments != null) {
934e2b47   liangchengyou   feat:权限调整+课程进度接口对接
183
            videoFollowReadId = (settings.arguments as Map)['videoFollowReadId'] as String;
cb38bc90   liangchengyou   feat:视频跟读逻辑处理
184
          }
e55bbdf3   Key   fixed: aliyun oss...
185
          return CupertinoPageRoute(builder: (_) => RepeatAfterContentPage(videoFollowReadId: videoFollowReadId));
3840b7fe   liangchengyou   feat:更新设置页面
186
187
188
189
190
191
        case AppRouteName.setting:
          return  CupertinoPageRoute(builder: (_) => const SettingPage());
        case AppRouteName.deleteAccount:
          return  CupertinoPageRoute(builder: (_) => const DeleteAccountPage());
        case AppRouteName.reBack:
          return CupertinoPageRoute(builder: (_) => const ReBackPage());
2a29701f   liangchengyou   feat:提交代码
192
193
194
195
196
        case AppRouteName.tab:
          return PageRouteBuilder(
              opaque: false,
              settings: const RouteSettings(name: AppRouteName.tab),
              transitionDuration: Duration.zero,
94342c3f   Key   feat: user util
197
              pageBuilder: (_, __, ___) => const TabPage(),
2a29701f   liangchengyou   feat:提交代码
198
              transitionsBuilder: (_, __, ___, child) => child);
2a427e12   吴启风   feat:绘本静态ui基本完成
199
        case AppRouteName.reading:
53e9e6db   吴启风   feat:绘本语音评测逻辑
200
201
          var courseLessonId = '';
          if (settings.arguments != null) {
934e2b47   liangchengyou   feat:权限调整+课程进度接口对接
202
            courseLessonId = (settings.arguments as Map)['courseLessonId'] as String;
53e9e6db   吴启风   feat:绘本语音评测逻辑
203
204
          }
          return CupertinoPageRoute(builder: (_) => ReadingPage(courseLessonId: courseLessonId));
2a29701f   liangchengyou   feat:提交代码
205
206
        default:
          return CupertinoPageRoute(
94342c3f   Key   feat: user util
207
              builder: (_) => Scaffold(body: Center(child: Text('No route defined for ${settings.name}'))));
2a29701f   liangchengyou   feat:提交代码
208
209
      }
    }
22b7d4da   Key   feat: user, api path
210
  }
08a0f5a8   liangchengyou   feat:路由方式更新
211
  
934e2b47   liangchengyou   feat:权限调整+课程进度接口对接
212
213
214
215
  Future pushNamed(String routeName, {Object? arguments}) {
    return Navigator.of(AppRouter.context).pushNamed(routeName, arguments: arguments).then((value) {
      return value;
    });
08a0f5a8   liangchengyou   feat:路由方式更新
216
217
  }
  
934e2b47   liangchengyou   feat:权限调整+课程进度接口对接
218
219
  Future pushNamedAndRemoveUntil(String routeName, RoutePredicate predicate, {Object? arguments}) {
    return Navigator.of(AppRouter.context).pushNamedAndRemoveUntil(routeName, predicate, arguments: arguments);
08a0f5a8   liangchengyou   feat:路由方式更新
220
221
  }
  
934e2b47   liangchengyou   feat:权限调整+课程进度接口对接
222
223
  void popPage({dynamic data}) {
     Navigator.of(AppRouter.context).pop(data);
08a0f5a8   liangchengyou   feat:路由方式更新
224
  }