d35a4e87
liangchengyou
feat:磨耳朵功能UI
|
1
|
import 'package:flutter/cupertino.dart';
|
8988aa69
liangchengyou
feat:首页+课程列表数据获取
|
2
|
import 'package:flutter/foundation.dart';
|
d35a4e87
liangchengyou
feat:磨耳朵功能UI
|
3
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
2187c85f
吴启风
feat:课程结构调整
|
4
|
import 'package:wow_english/common/request/dao/lesson_dao.dart';
|
13e6d11d
liangchengyou
feat:首页课程模块接口
|
5
|
import 'package:wow_english/common/request/exception.dart';
|
3c1d5c64
liangchengyou
feat:练习功能完成
|
6
7
|
import 'package:wow_english/common/request/dao/listen_dao.dart';
import 'package:wow_english/models/course_process_entity.dart';
|
13e6d11d
liangchengyou
feat:首页课程模块接口
|
8
|
import 'package:wow_english/utils/loading.dart';
|
c61b3c1a
Key
feat: toast_util....
|
9
|
import 'package:wow_english/utils/toast_util.dart';
|
60e47f7c
liangchengyou
feat:课程选择功能
|
10
|
|
2187c85f
吴启风
feat:课程结构调整
|
11
12
|
import '../../../models/course_section_entity.dart';
import '../../../models/course_unit_entity.dart';
|
60e47f7c
liangchengyou
feat:课程选择功能
|
13
|
|
2187c85f
吴启风
feat:课程结构调整
|
14
15
|
part 'section_event.dart';
part 'section_state.dart';
|
8988aa69
liangchengyou
feat:首页+课程列表数据获取
|
16
|
|
2187c85f
吴启风
feat:课程结构调整
|
17
|
class SectionBloc extends Bloc<SectionEvent, SectionState> {
|
c61b3c1a
Key
feat: toast_util....
|
18
|
|
2187c85f
吴启风
feat:课程结构调整
|
19
20
21
22
23
24
25
26
27
28
29
|
CourseUnitEntity _courseUnitEntity;
CourseUnitEntity get courseUnitEntity => _courseUnitEntity;
CourseUnitDetail _courseUnitDetail;
CourseUnitDetail get courseUnitDetail => _courseUnitDetail;
List<CourseSectionEntity>? _courseSectionDatas;
List<CourseSectionEntity>? get courseSectionDatas => _courseSectionDatas;
|
8988aa69
liangchengyou
feat:首页+课程列表数据获取
|
30
|
|
3c1d5c64
liangchengyou
feat:练习功能完成
|
31
32
33
34
|
CourseProcessEntity? _processEntity;
CourseProcessEntity? get processEntity => _processEntity;
|
2187c85f
吴启风
feat:课程结构调整
|
35
|
SectionBloc(this._courseUnitEntity, this._courseUnitDetail) : super(LessonInitial()) {
|
993c1a04
liangchengyou
feat:添加数据模型
|
36
|
on<RequestDataEvent>(_requestData);
|
934e2b47
liangchengyou
feat:权限调整+课程进度接口对接
|
37
38
|
on<RequestExitClassEvent>(_requestExitClass);
on<RequestEnterClassEvent>(_requestEnterClass);
|
3c1d5c64
liangchengyou
feat:练习功能完成
|
39
|
on<RequestVideoLessonEvent>(_requestVideoLesson);
|
60e47f7c
liangchengyou
feat:课程选择功能
|
40
|
}
|
13e6d11d
liangchengyou
feat:首页课程模块接口
|
41
|
|
2187c85f
吴启风
feat:课程结构调整
|
42
|
void _requestData(RequestDataEvent event, Emitter<SectionState> emitter) async {
|
993c1a04
liangchengyou
feat:添加数据模型
|
43
44
|
try {
await loading(() async {
|
2187c85f
吴启风
feat:课程结构调整
|
45
46
|
_courseSectionDatas = await LessonDao.courseSection(courseUnitId: _courseUnitDetail.id!);
emitter(LessonDataLoadState());
|
993c1a04
liangchengyou
feat:添加数据模型
|
47
48
49
|
});
} catch (e) {
if (e is ApiException) {
|
c61b3c1a
Key
feat: toast_util....
|
50
|
showToast(e.message.toString());
|
13e6d11d
liangchengyou
feat:首页课程模块接口
|
51
52
53
|
}
}
}
|
3c1d5c64
liangchengyou
feat:练习功能完成
|
54
|
|
2187c85f
吴启风
feat:课程结构调整
|
55
|
void _requestVideoLesson(RequestVideoLessonEvent event, Emitter<SectionState> emitter) async {
|
3c1d5c64
liangchengyou
feat:练习功能完成
|
56
57
58
|
try {
await loading(() async {
_processEntity = await ListenDao.process(event.courseLessonId);
|
934e2b47
liangchengyou
feat:权限调整+课程进度接口对接
|
59
|
emitter(RequestVideoLessonState(event.courseLessonId,event.courseType));
|
3c1d5c64
liangchengyou
feat:练习功能完成
|
60
61
62
63
64
65
66
|
});
} catch (e) {
if (e is ApiException) {
showToast(e.message??'请求失败,请检查网络连接');
}
}
}
|
934e2b47
liangchengyou
feat:权限调整+课程进度接口对接
|
67
68
|
|
2187c85f
吴启风
feat:课程结构调整
|
69
|
void _requestEnterClass(RequestEnterClassEvent event,Emitter<SectionState> emitter) async {
|
934e2b47
liangchengyou
feat:权限调整+课程进度接口对接
|
70
71
72
73
74
75
76
77
78
79
80
81
|
try {
await loading(() async {
await ListenDao.enterClass(event.courseLessonId);
emitter(RequestEnterClassState(event.courseLessonId,event.courseType));
});
} catch (e) {
if (e is ApiException) {
showToast(e.message??'请求失败,请检查网络连接');
}
}
}
|
2187c85f
吴启风
feat:课程结构调整
|
82
|
void _requestExitClass(RequestExitClassEvent event,Emitter<SectionState> emitter) async {
|
934e2b47
liangchengyou
feat:权限调整+课程进度接口对接
|
83
84
|
await ListenDao.exitClass(event.courseLessonId,event.currentStep,event.currentTime);
}
|
60e47f7c
liangchengyou
feat:课程选择功能
|
85
|
}
|