route.dart
5.75 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:wow_english/app/splash_page.dart';
import 'package:wow_english/common/pages/wow_web_page.dart';
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';
import 'package:wow_english/pages/practice/topic_picture_page.dart';
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';
import 'package:wow_english/pages/user/user_page.dart';
import 'package:wow_english/pages/video/lookvideo/look_video_page.dart';
import '../pages/reading/reading_page.dart';
class AppRouteName {
static const String splash = 'splash';
static const String login = 'login';
static const String home = 'home';
static const String fogPwd = 'fogPwd';
/// 设置密码,修改密码;不要自己调用,使用[SetPassWordPage.push]方法
static const String setPwd = 'setPwd';
static const String webView = 'webView';
static const String lesson = 'lesson';
static const String listen = 'listen';
static const String shop = 'shop';
static const String exLesson = 'exLesson';
static const String exList = 'exList';
static const String reAfter = 'reAfter';
static const String topicPic = 'topicPic';
static const String topicWord = 'topicWord';
static const String voicePic = 'voicePic';
static const String voiceWord = 'voiceWord';
static const String voiceAnswer = 'voiceAnswer';
static const String user = 'user';
static const String lookVideo = 'lookVideo';
static const String reading = 'reading';
///绘本
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,
pageBuilder: (_, __, ___) => const SplashPage(),
transitionDuration: Duration.zero,
transitionsBuilder: (_, __, ___, child) => child);
case AppRouteName.login:
return CupertinoPageRoute(builder: (_) => const LoginPage());
case AppRouteName.home:
var moduleId = '';
if (settings.arguments != null) {
moduleId = (settings.arguments as Map)['moduleId'] as String;
}
return CupertinoPageRoute(
builder: (_) => HomePage(
moduleId: moduleId,
));
case AppRouteName.fogPwd:
return CupertinoPageRoute(builder: (_) => const ForgetPasswordHomePage());
case AppRouteName.lesson:
return CupertinoPageRoute(builder: (_) => const LessonPage());
case AppRouteName.listen:
return CupertinoPageRoute(builder: (_) => const ListenPage());
case AppRouteName.shop:
return CupertinoPageRoute(builder: (_) => const ShopHomePage());
case AppRouteName.exLesson:
return CupertinoPageRoute(builder: (_) => const ExchangeLessonPage());
case AppRouteName.exList:
return CupertinoPageRoute(builder: (_) => const ExchangeLessonListPage());
case AppRouteName.reAfter:
return CupertinoPageRoute(builder: (_) => const RepeatAfterPage());
case AppRouteName.user:
return CupertinoPageRoute(builder: (_) => const UserPage());
case AppRouteName.topicPic:
return CupertinoPageRoute(builder: (_) => const TopicPicturePage());
case AppRouteName.lookVideo:
final videoUrl = (settings.arguments as Map)['videoUrl'] as String;
final title = (settings.arguments as Map)['title'] as String?;
return CupertinoPageRoute(
builder: (_) => LookVideoPage(
videoUrl: videoUrl,
typeTitle: title,
));
case AppRouteName.setPwd:
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,
));
case AppRouteName.webView:
final urlStr = (settings.arguments as Map)['urlStr'] as String;
final webViewTitle = (settings.arguments as Map)['webViewTitle'] as String;
return CupertinoPageRoute(
builder: (_) => WowWebViewPage(
urlStr: urlStr,
webViewTitle: webViewTitle,
));
case AppRouteName.tab:
return PageRouteBuilder(
opaque: false,
settings: const RouteSettings(name: AppRouteName.tab),
transitionDuration: Duration.zero,
pageBuilder: (_, __, ___) => const TabPage(),
transitionsBuilder: (_, __, ___, child) => child);
case AppRouteName.reading:
return CupertinoPageRoute(builder: (_) => const ReadingPage());
default:
return CupertinoPageRoute(
builder: (_) => Scaffold(body: Center(child: Text('No route defined for ${settings.name}'))));
}
}
}