82c8633c
biao
音频添加 页面优化
|
1
|
import 'package:audioplayers/audioplayers.dart';
|
3ba925a9
吴启风
feat:环节页增加翻页切换单元效果
|
2
|
import 'package:flutter/cupertino.dart';
|
95edef4f
liangchengyou
feat:更新适配代码
|
3
|
import 'package:flutter/material.dart';
|
60e47f7c
liangchengyou
feat:课程选择功能
|
4
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
d35a4e87
liangchengyou
feat:磨耳朵功能UI
|
5
|
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
3ba925a9
吴启风
feat:环节页增加翻页切换单元效果
|
6
|
import 'package:nested_scroll_views/material.dart';
|
f5fc01c1
liangchengyou
feat:修复首页进入个人信息页闪退问题
|
7
|
import 'package:wow_english/common/core/user_util.dart';
|
d35a4e87
liangchengyou
feat:磨耳朵功能UI
|
8
|
import 'package:wow_english/common/extension/string_extension.dart';
|
2187c85f
吴启风
feat:课程结构调整
|
9
|
import 'package:wow_english/models/course_unit_entity.dart';
|
46675a89
吴启风
feat:过渡页-视频环节
|
10
|
import 'package:wow_english/pages/section/section_type.dart';
|
e620143b
吴启风
feat:单元&课程解锁状态蒙层ui
|
11
|
import 'package:wow_english/pages/section/widgets/section_item.dart';
|
2187c85f
吴启风
feat:课程结构调整
|
12
13
|
import 'package:wow_english/pages/section/widgets/section_bouns_item.dart';
import 'package:wow_english/pages/section/widgets/section_header_widget.dart';
|
60e47f7c
liangchengyou
feat:课程选择功能
|
14
|
import 'package:wow_english/route/route.dart';
|
b1869cf8
biao
背景音乐添加
|
15
16
|
import 'package:wow_english/utils/audioplayer_util.dart';
import 'package:wow_english/utils/log_util.dart';
|
c61b3c1a
Key
feat: toast_util....
|
17
|
import 'package:wow_english/utils/toast_util.dart';
|
95edef4f
liangchengyou
feat:更新适配代码
|
18
|
|
2187c85f
吴启风
feat:课程结构调整
|
19
20
|
import '../../models/course_section_entity.dart';
import 'bloc/section_bloc.dart';
|
68dd7ba8
liangchengyou
feat:首页主题颜色+已知问题修改
|
21
|
import 'courese_module_model.dart';
|
4b358e22
liangchengyou
feat:调整文件结构
|
22
|
|
2187c85f
吴启风
feat:课程结构调整
|
23
24
|
/// 环节列表页
class SectionPage extends StatelessWidget {
|
3ba925a9
吴启风
feat:环节页增加翻页切换单元效果
|
25
|
const SectionPage(
|
66a7e3e7
吴启风
feat:退出课堂和结束课堂优化
|
26
|
{super.key, required this.courseUnitEntity, required this.courseUnitId});
|
8988aa69
liangchengyou
feat:首页+课程列表数据获取
|
27
|
|
2187c85f
吴启风
feat:课程结构调整
|
28
29
30
|
final CourseUnitEntity courseUnitEntity;
/// unitId
|
66a7e3e7
吴启风
feat:退出课堂和结束课堂优化
|
31
|
final int courseUnitId;
|
95edef4f
liangchengyou
feat:更新适配代码
|
32
33
34
|
@override
Widget build(BuildContext context) {
|
66a7e3e7
吴启风
feat:退出课堂和结束课堂优化
|
35
36
37
|
int initialPage = courseUnitEntity.courseUnitVOList
?.indexWhere((element) => element.id == courseUnitId) ??
0;
|
60e47f7c
liangchengyou
feat:课程选择功能
|
38
|
return BlocProvider(
|
8df5fbf9
吴启风
feat:单元列表页由于ios嵌套...
|
39
40
41
42
43
|
create: (context) => SectionBloc(
courseUnitEntity,
initialPage,
PageController(initialPage: initialPage),
ScrollController(),
|
5e2bbbd3
biao
添加音频
|
44
45
|
ScrollController())
..add(InitEvent()),
|
8df5fbf9
吴启风
feat:单元列表页由于ios嵌套...
|
46
|
//为了触发指示器进入后计算位置
|
0cbdbb34
吴启风
feat:环节列表页返回单元列表页...
|
47
|
// ..add(CurrentUnitIndexChangeEvent(initialPage)),
|
2187c85f
吴启风
feat:课程结构调整
|
48
|
child: _SectionPageView(context),
|
60e47f7c
liangchengyou
feat:课程选择功能
|
49
50
51
52
|
);
}
}
|
2187c85f
吴启风
feat:课程结构调整
|
53
54
|
class _SectionPageView extends StatelessWidget {
const _SectionPageView(this.context);
|
454dc387
吴启风
feat:原阶段选择页(首页)增加...
|
55
56
57
|
final BuildContext context;
|
60e47f7c
liangchengyou
feat:课程选择功能
|
58
59
|
@override
Widget build(BuildContext context) {
|
2187c85f
吴启风
feat:课程结构调整
|
60
61
|
final bloc = BlocProvider.of<SectionBloc>(context);
return BlocListener<SectionBloc, SectionState>(
|
3c1d5c64
liangchengyou
feat:练习功能完成
|
62
63
|
listener: (context, state) {
if (state is RequestVideoLessonState) {
|
2187c85f
吴启风
feat:课程结构调整
|
64
|
final videoUrl = bloc.processEntity?.videos?.videoUrl ?? '';
|
3c1d5c64
liangchengyou
feat:练习功能完成
|
65
|
var title = '';
|
46675a89
吴启风
feat:过渡页-视频环节
|
66
|
if (state.type == SectionType.song.value) {
|
3c1d5c64
liangchengyou
feat:练习功能完成
|
67
68
69
|
title = 'song';
}
|
46675a89
吴启风
feat:过渡页-视频环节
|
70
|
if (state.type == SectionType.video.value) {
|
3c1d5c64
liangchengyou
feat:练习功能完成
|
71
72
73
|
title = 'video';
}
|
46675a89
吴启风
feat:过渡页-视频环节
|
74
|
if (state.type == SectionType.bouns.value) {
|
3c1d5c64
liangchengyou
feat:练习功能完成
|
75
76
|
title = 'bonus';
}
|
997ea0d6
liangchengyou
feat:绘本闪退问题修复
|
77
|
|
934e2b47
liangchengyou
feat:权限调整+课程进度接口对接
|
78
79
80
|
if (videoUrl.isEmpty || !videoUrl.contains('http')) {
return;
}
|
2187c85f
吴启风
feat:课程结构调整
|
81
82
83
|
pushNamed(AppRouteName.lookVideo, arguments: {
'videoUrl': videoUrl,
'title': title,
|
46675a89
吴启风
feat:过渡页-视频环节
|
84
85
|
'courseLessonId': state.courseLessonId,
'isTopic': true
|
2187c85f
吴启风
feat:课程结构调整
|
86
|
}).then((value) {
|
934e2b47
liangchengyou
feat:权限调整+课程进度接口对接
|
87
|
if (value != null) {
|
46675a89
吴启风
feat:过渡页-视频环节
|
88
|
Map<String, dynamic> dataMap = value as Map<String, dynamic>;
|
66a7e3e7
吴启风
feat:退出课堂和结束课堂优化
|
89
90
91
92
|
bloc.add(RequestEndClassEvent(
dataMap['courseLessonId']!, dataMap['isCompleted'],
currentTime: dataMap['currentTime'],
autoNextSection: dataMap['nextSection']));
|
934e2b47
liangchengyou
feat:权限调整+课程进度接口对接
|
93
|
}
|
b1869cf8
biao
背景音乐添加
|
94
95
|
AudioPlayerUtil.getInstance()
.playAudio(AudioPlayerUtilType.countWithMe);
|
934e2b47
liangchengyou
feat:权限调整+课程进度接口对接
|
96
97
98
99
100
|
});
return;
}
if (state is RequestEnterClassState) {
|
66a7e3e7
吴启风
feat:退出课堂和结束课堂优化
|
101
102
|
if (state.courseType != SectionType.practice.value &&
state.courseType != SectionType.pictureBook.value) {
|
2187c85f
吴启风
feat:课程结构调整
|
103
|
///视频类型
|
934e2b47
liangchengyou
feat:权限调整+课程进度接口对接
|
104
|
///获取视频课程内容
|
82c8633c
biao
音频添加 页面优化
|
105
|
if (state.courseType == 1) {
|
b1869cf8
biao
背景音乐添加
|
106
107
|
AudioPlayerUtil.getInstance()
.playAudio(AudioPlayerUtilType.musicTime);
|
82c8633c
biao
音频添加 页面优化
|
108
|
} else {
|
b1869cf8
biao
背景音乐添加
|
109
110
|
AudioPlayerUtil.getInstance()
.playAudio(AudioPlayerUtilType.videoTime);
|
82c8633c
biao
音频添加 页面优化
|
111
|
}
|
5e2bbbd3
biao
添加音频
|
112
113
114
115
116
|
Future.delayed(const Duration(seconds: 1), () {
bloc.add(RequestVideoLessonEvent(
state.courseLessonId, state.courseType));
});
|
934e2b47
liangchengyou
feat:权限调整+课程进度接口对接
|
117
118
119
|
return;
}
|
46675a89
吴启风
feat:过渡页-视频环节
|
120
|
if (state.courseType == SectionType.pictureBook.value) {
|
b1869cf8
biao
背景音乐添加
|
121
122
|
AudioPlayerUtil.getInstance()
.playAudio(AudioPlayerUtilType.readingTime);
|
5e2bbbd3
biao
添加音频
|
123
124
125
126
127
128
129
130
131
132
133
134
135
|
Future.delayed(const Duration(seconds: 1), () {
//绘本
pushNamed(AppRouteName.reading,
arguments: {'courseLessonId': state.courseLessonId})
.then((value) {
if (value != null) {
Map<String, dynamic> dataMap = value as Map<String, dynamic>;
bloc.add(RequestEndClassEvent(
dataMap['courseLessonId']!,
dataMap['isCompleted'],
currentStep: dataMap['currentStep'],
autoNextSection: dataMap['nextSection'],
));
|
b1869cf8
biao
背景音乐添加
|
136
137
|
AudioPlayerUtil.getInstance()
.playAudio(AudioPlayerUtilType.countWithMe);
|
5e2bbbd3
biao
添加音频
|
138
139
|
}
});
|
934e2b47
liangchengyou
feat:权限调整+课程进度接口对接
|
140
|
});
|
5e2bbbd3
biao
添加音频
|
141
|
|
934e2b47
liangchengyou
feat:权限调整+课程进度接口对接
|
142
143
144
|
return;
}
|
46675a89
吴启风
feat:过渡页-视频环节
|
145
|
if (state.courseType == SectionType.practice.value) {
|
2187c85f
吴启风
feat:课程结构调整
|
146
|
//练习
|
b1869cf8
biao
背景音乐添加
|
147
148
|
AudioPlayerUtil.getInstance()
.playAudio(AudioPlayerUtilType.quizTime);
|
5e2bbbd3
biao
添加音频
|
149
150
151
152
153
154
155
156
157
158
159
|
Future.delayed(const Duration(seconds: 1), () {
pushNamed(AppRouteName.topicPic,
arguments: {'courseLessonId': state.courseLessonId})
.then((value) {
if (value != null) {
Map<String, dynamic> dataMap = value as Map<String, dynamic>;
bloc.add(RequestEndClassEvent(
dataMap['courseLessonId']!, dataMap['isCompleted'],
currentStep: dataMap['currentStep'],
autoNextSection: dataMap['nextSection']));
}
|
b1869cf8
biao
背景音乐添加
|
160
161
|
AudioPlayerUtil.getInstance()
.playAudio(AudioPlayerUtilType.countWithMe);
|
5e2bbbd3
biao
添加音频
|
162
|
});
|
934e2b47
liangchengyou
feat:权限调整+课程进度接口对接
|
163
|
});
|
3c1d5c64
liangchengyou
feat:练习功能完成
|
164
165
|
return;
}
|
3c1d5c64
liangchengyou
feat:练习功能完成
|
166
167
|
}
},
|
3ba925a9
吴启风
feat:环节页增加翻页切换单元效果
|
168
|
child: _sectionView(),
|
95edef4f
liangchengyou
feat:更新适配代码
|
169
170
|
);
}
|
d35a4e87
liangchengyou
feat:磨耳朵功能UI
|
171
|
|
3ba925a9
吴启风
feat:环节页增加翻页切换单元效果
|
172
|
Widget _sectionView() =>
|
2187c85f
吴启风
feat:课程结构调整
|
173
174
|
BlocBuilder<SectionBloc, SectionState>(builder: (context, state) {
final bloc = BlocProvider.of<SectionBloc>(context);
|
68dd7ba8
liangchengyou
feat:首页主题颜色+已知问题修改
|
175
176
177
178
179
180
181
|
return Scaffold(
body: Container(
color: Colors.white,
child: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
|
2187c85f
吴启风
feat:课程结构调整
|
182
|
SectionHeaderWidget(
|
66a7e3e7
吴启风
feat:退出课堂和结束课堂优化
|
183
|
title: bloc.getCourseUnitDetail().name,
|
0cbdbb34
吴启风
feat:环节列表页返回单元列表页...
|
184
185
186
187
188
189
|
courseModuleCode: bloc.courseUnitEntity.courseModuleCode,
onBack: () {
popPage(data: {
'needRefresh': bloc.courseUnitEntityChanged,
});
}),
|
68dd7ba8
liangchengyou
feat:首页主题颜色+已知问题修改
|
190
|
Expanded(
|
8df5fbf9
吴启风
feat:单元列表页由于ios嵌套...
|
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
|
child: Padding(
padding: EdgeInsets.symmetric(horizontal: 10.w),
child: NestedPageView.builder(
itemCount: bloc.unlockPageCount(),
controller: bloc.pageController,
onPageChanged: (int index) {
bloc.add(CurrentUnitIndexChangeEvent(index));
},
itemBuilder: (context, index) {
return ScrollConfiguration(
///去掉 Android 上默认的边缘拖拽效果
behavior: ScrollConfiguration.of(context)
.copyWith(overscroll: false),
child: _itemTransCard(
bloc.getCourseUnitDetail(pageIndex: index),
index,
context),
);
}),
)),
|
3ba925a9
吴启风
feat:环节页增加翻页切换单元效果
|
211
|
SafeArea(
|
8df5fbf9
吴启风
feat:单元列表页由于ios嵌套...
|
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
|
child: SizedBox(
width: 210.w,
height: 40.h,
// child: OverflowBox(
// maxWidth: 300, // 允许内容超出容器宽度
child: ListView.builder(
controller: bloc.indicatorSrollController,
scrollDirection: Axis.horizontal,
itemCount: bloc.unlockPageCount(),
itemBuilder: (context, index) {
bool isSelected = index == bloc.currentPage;
// 计算透明度,使得当前页的指示器不透明,两侧逐渐透明
double opacity = 0.25 +
(1 - ((bloc.currentPage - index).abs() / 2)) *
0.5;
// 限制透明度在 0.5 到 1.0 之间
opacity = opacity.clamp(0.25, 1.0);
return GestureDetector(
onTap: () => bloc.pageController.animateToPage(
index,
duration: const Duration(milliseconds: 60),
curve: Curves.ease),
child: SizedBox(
width: 30.0.w,
height: 30.0.h,
child: Padding(
padding:
EdgeInsets.all(isSelected ? 0.w : 5.w),
child: Opacity(
opacity: opacity,
child: Container(
alignment: Alignment.center,
decoration: BoxDecoration(
color: isSelected
? Colors.blue
: Colors.grey,
shape: BoxShape.circle,
),
child: Text("${index + 1}",
textAlign: TextAlign.center,
style: TextStyle(
color: Colors.white,
fontSize:
isSelected ? 12.sp : 8.sp)),
),
),
),
),
);
})),
),
// )
|
68dd7ba8
liangchengyou
feat:首页主题颜色+已知问题修改
|
264
265
266
|
],
),
),
|
d35a4e87
liangchengyou
feat:磨耳朵功能UI
|
267
|
),
|
68dd7ba8
liangchengyou
feat:首页主题颜色+已知问题修改
|
268
269
|
);
});
|
056970d8
Key
feat: api
|
270
|
}
|
3ba925a9
吴启风
feat:环节页增加翻页切换单元效果
|
271
|
|
66a7e3e7
吴启风
feat:退出课堂和结束课堂优化
|
272
273
|
Widget _itemTransCard(
CourseUnitDetail courseUnitDetail, int pageIndex, BuildContext context) {
|
3ba925a9
吴启风
feat:环节页增加翻页切换单元效果
|
274
|
final bloc = BlocProvider.of<SectionBloc>(context);
|
66a7e3e7
吴启风
feat:退出课堂和结束课堂优化
|
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
|
List<CourseSectionEntity>? courseSectionEntities =
bloc.courseSectionDatasMap[courseUnitDetail.id];
if (courseSectionEntities == null) {
bloc.add(RequestDataEvent(courseUnitDetail.id!));
return Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
const Text(
'暂无数据',
style: TextStyle(fontSize: 24.0),
),
const SizedBox(height: 16.0),
// 间距
CircularProgressIndicator(
color: CourseModuleModel(
bloc.courseUnitEntity.courseModuleCode ?? 'Phase-1')
.color),
// 加载动画
],
),
);
} else {
|
8df5fbf9
吴启风
feat:单元列表页由于ios嵌套...
|
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
|
return NestedListView.builder(
itemCount: bloc.courseSectionDatasMap[courseUnitDetail.id]?.length ?? 0,
scrollDirection: Axis.horizontal,
itemBuilder: (BuildContext context, int index) {
CourseSectionEntity sectionData = courseSectionEntities[index];
if (sectionData.courseType == SectionType.bouns.value) {
//彩蛋
return GestureDetector(
onTap: () {
if (!UserUtil.isLogined()) {
pushNamed(AppRouteName.login);
return;
}
if (sectionData.lock == true) {
showToast('当前课程暂未解锁');
return;
}
|
3ba925a9
吴启风
feat:环节页增加翻页切换单元效果
|
315
|
|
8df5fbf9
吴启风
feat:单元列表页由于ios嵌套...
|
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
|
///进入课堂
bloc.add(RequestEnterClassEvent(
sectionData.id.toString(), sectionData.courseType));
},
child: SectionBoundsItem(
imageUrl: sectionData.coverUrl,
),
);
} else {
return GestureDetector(
onTap: () {
if (!UserUtil.isLogined()) {
pushNamed(AppRouteName.login);
return;
}
if (sectionData.lock == true) {
showToast('当前课程暂未解锁');
return;
}
|
3ba925a9
吴启风
feat:环节页增加翻页切换单元效果
|
335
|
|
8df5fbf9
吴启风
feat:单元列表页由于ios嵌套...
|
336
337
338
339
340
341
342
343
344
345
346
|
///进入课堂
bloc.add(RequestEnterClassEvent(
sectionData.id.toString(), sectionData.courseType));
},
child: SectionItem(
courseModuleId: bloc.courseUnitEntity.courseModuleCode,
lessons: sectionData,
),
);
}
});
|
66a7e3e7
吴启风
feat:退出课堂和结束课堂优化
|
347
|
}
|
3ba925a9
吴启风
feat:环节页增加翻页切换单元效果
|
348
|
}
|