cde7505e
吴启风
feat:应用内升级
|
1
2
|
import 'package:flutter/foundation.dart';
|
6d61919a
吴启风
feat:增加过渡页&集成串联游戏
|
3
|
import 'package:flutter/material.dart';
|
cde7505e
吴启风
feat:应用内升级
|
4
5
6
|
import 'package:flutter/services.dart';
import 'package:flutter_app_update/azhon_app_update.dart';
import 'package:flutter_app_update/update_model.dart';
|
6d61919a
吴启风
feat:增加过渡页&集成串联游戏
|
7
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
cde7505e
吴启风
feat:应用内升级
|
8
|
import 'package:url_launcher/url_launcher.dart';
|
28f20da9
吴启风
feat:针对apple审核对支付...
|
9
|
import 'package:wow_english/common/core/app_config_helper.dart';
|
6d61919a
吴启风
feat:增加过渡页&集成串联游戏
|
10
11
12
|
import 'package:wow_english/common/extension/string_extension.dart';
import 'package:wow_english/pages/moduleSelect/state.dart';
import 'package:wow_english/pages/moduleSelect/widgets/BaseHomeHeaderWidget.dart';
|
795fb23f
吴启风
feat:支付成功刷新用户数据
|
13
|
import 'package:wow_english/pages/user/bloc/user_bloc.dart';
|
6d61919a
吴启风
feat:增加过渡页&集成串联游戏
|
14
|
|
278208b8
吴启风
feat:1、用户访问权限调整;2...
|
15
16
|
import '../../common/core/user_util.dart';
import '../../common/dialogs/show_dialog.dart';
|
cde7505e
吴启风
feat:应用内升级
|
17
|
import '../../models/app_config_entity.dart';
|
6d61919a
吴启风
feat:增加过渡页&集成串联游戏
|
18
19
20
21
22
23
24
25
26
27
28
|
import 'bloc.dart';
import 'event.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:wow_english/route/route.dart';
class ModuleSelectPage extends StatelessWidget {
const ModuleSelectPage({super.key});
@override
Widget build(BuildContext context) {
return BlocProvider(
|
cde7505e
吴启风
feat:应用内升级
|
29
30
31
|
create: (BuildContext context) =>
ModuleSelectBloc()
..add(InitEvent()),
|
6d61919a
吴启风
feat:增加过渡页&集成串联游戏
|
32
33
34
35
36
37
38
39
|
child: Builder(builder: (context) => _HomePageView()),
);
}
}
class _HomePageView extends StatelessWidget {
@override
Widget build(BuildContext context) {
|
795fb23f
吴启风
feat:支付成功刷新用户数据
|
40
41
42
43
44
|
return MultiBlocListener(listeners: [
BlocListener<UserBloc, UserState>(listener: (context, state) {
debugPrint('WQF ModuleSelectPage BlocListener state: $state');
}),
BlocListener<ModuleSelectBloc, ModuleSelectState>(
|
cde7505e
吴启风
feat:应用内升级
|
45
46
47
48
49
|
listener: (context, state) {
if (state is UpdateDialogState) {
_showUpdateDialog(context, state.forceUpdate, state.appConfigEntity);
}
},
|
795fb23f
吴启风
feat:支付成功刷新用户数据
|
50
51
|
),
], child: _homeView());
|
6d61919a
吴启风
feat:增加过渡页&集成串联游戏
|
52
53
|
}
|
cde7505e
吴启风
feat:应用内升级
|
54
55
|
Widget _homeView() =>
BlocBuilder<ModuleSelectBloc, ModuleSelectState>(
|
6d61919a
吴启风
feat:增加过渡页&集成串联游戏
|
56
|
builder: (context, state) {
|
cde7505e
吴启风
feat:应用内升级
|
57
58
59
60
61
62
63
64
65
66
67
68
|
return Scaffold(
body: Container(
color: Colors.white,
child: Column(
children: [
const BaseHomeHeaderWidget(),
Expanded(
child: Center(
child: Row(
children: [
Expanded(
child: GestureDetector(
|
795fb23f
吴启风
feat:支付成功刷新用户数据
|
69
|
onTap: () {
|
795fb23f
吴启风
feat:支付成功刷新用户数据
|
70
|
if (UserUtil.isLogined()) {
|
cde7505e
吴启风
feat:应用内升级
|
71
|
pushNamed(AppRouteName.home);
|
795fb23f
吴启风
feat:支付成功刷新用户数据
|
72
73
|
} else {
pushNamed(AppRouteName.login);
|
278208b8
吴启风
feat:1、用户访问权限调整;2...
|
74
|
}
|
795fb23f
吴启风
feat:支付成功刷新用户数据
|
75
76
77
78
79
80
81
82
83
|
},
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Stack(
alignment: AlignmentDirectional.center,
children: [
Image.asset(
'bg_frame_module'.assetPng,
|
cde7505e
吴启风
feat:应用内升级
|
84
85
86
87
88
89
90
|
width: 162.5.w, height: 203.5.h),
Center(
child: Image.asset(
'pic_module_study'.assetPng,
width: 140.5.w,
height: 172.h),
)
|
795fb23f
吴启风
feat:支付成功刷新用户数据
|
91
92
|
]),
10.verticalSpace,
|
cde7505e
吴启风
feat:应用内升级
|
93
|
Image.asset('label_module_study'.assetPng,
|
795fb23f
吴启风
feat:支付成功刷新用户数据
|
94
95
|
width: 124.w, height: 34.h),
],
|
cde7505e
吴启风
feat:应用内升级
|
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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
|
),
),
),
Expanded(
child: BlocBuilder<UserBloc, UserState>(
builder: (context, userState) {
debugPrint(
'WQF ModuleSelectPage BlocBuilder state: $userState');
return GestureDetector(
onTap: () {
//如果没登录先登录
if (UserUtil.isLogined()) {
if (AppConfigHelper
.shouldHidePay()) {
pushNamed(AppRouteName.games);
} else {
if (UserUtil
.hasGamePermission()) {
pushNamed(AppRouteName.games);
} else {
showTwoActionDialog(
'提示', '忽略', '去续费',
'您的课程已到期,请快快续费继续学习吧!',
leftTap: () {
popPage();
}, rightTap: () {
popPage();
pushNamed(AppRouteName.shop);
});
}
}
} else {
pushNamed(AppRouteName.login);
}
},
child: Column(
mainAxisAlignment: MainAxisAlignment
.center,
children: [
Stack(
alignment: AlignmentDirectional
.center,
children: [
Image.asset(
'bg_frame_module'
.assetPng,
width: 162.5.w,
height: 203.5.h),
Image.asset(
'pic_module_game'
.assetPng,
width: 140.5.w,
height: 172.h)
]),
10.verticalSpace,
Image.asset(
'label_module_game'.assetPng,
width: 124.w, height: 34.h),
],
));
}),
),
],
|
6d61919a
吴启风
feat:增加过渡页&集成串联游戏
|
159
|
),
|
cde7505e
吴启风
feat:应用内升级
|
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
|
),
)
],
),
),
);
});
///Flutter侧处理升级对话框
///[forcedUpgrade] 是否强制升级
_showUpdateDialog(BuildContext context, bool forcedUpgrade,
AppConfigEntity appConfigEntity) {
showDialog(
context: context,
// 当我们点击除开对话框内容以外的区域是否关闭对话需用用到barrierDismissible参数 . 这个参数默认值是true ,但不能为null .
barrierDismissible: !forcedUpgrade,
builder: (BuildContext context) {
return WillPopScope(
onWillPop: () => Future.value(!forcedUpgrade),
child: AlertDialog(
title: const Text('发现新版本'),
content: Text(
appConfigEntity.updatePackageDescription ??
'修复了一些已知问题'),
actions: <Widget>[
TextButton(
child: Text(forcedUpgrade ? '退出' : '取消'),
onPressed: () =>
{
if (forcedUpgrade) {
|
258578de
吴启风
feat:修复ios上退出应用失效问题
|
191
|
AppConfigHelper.exitApp()
|
cde7505e
吴启风
feat:应用内升级
|
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
|
} else
{
Navigator.of(context).pop()
}
},
),
TextButton(
child: const Text('升级'),
onPressed: () async {
if (defaultTargetPlatform == TargetPlatform.iOS) {
_launchAppStore("6450870731");
return;
}
final String? apkUrl = appConfigEntity.androidUpdatePackageUrl;
if (apkUrl == null || apkUrl.isEmpty) {
return;
}
UpdateModel model = UpdateModel(
apkUrl,
"wowenglish.apk",
"ic_launcher",
'',
);
AzhonAppUpdate.update(model).then((value) =>
debugPrint('$value'));
if (!forcedUpgrade) {
Navigator.of(context).pop();
}
},
),
],
|
6d61919a
吴启风
feat:增加过渡页&集成串联游戏
|
223
224
|
),
);
|
cde7505e
吴启风
feat:应用内升级
|
225
226
227
228
229
230
231
232
233
234
235
236
|
},
);
}
void _launchAppStore(String appId) async {
final String url = 'https://apps.apple.com/cn/app/wow-english/id$appId';
if (await canLaunchUrl(Uri.parse(url))) {
await launchUrl(Uri.parse(url));
} else {
throw 'Could not launch $url';
}
}
|
6d61919a
吴启风
feat:增加过渡页&集成串联游戏
|
237
|
}
|