Commit 1ebed821195a57428c6b63d3bbd8c8ba07e00fe6
1 parent
ae77d87f
feat:修复所有unit解锁态下page页数
Showing
2 changed files
with
28 additions
and
19 deletions
lib/pages/reading/reading_page.dart
... | ... | @@ -8,6 +8,7 @@ import 'package:wow_english/route/route.dart'; |
8 | 8 | |
9 | 9 | import '../../common/core/app_consts.dart'; |
10 | 10 | import '../../common/core/user_util.dart'; |
11 | +import '../../common/widgets/throttledGesture_gesture_detector.dart'; | |
11 | 12 | import '../../models/course_process_entity.dart'; |
12 | 13 | import '../../utils/log_util.dart'; |
13 | 14 | import 'bloc/reading_bloc.dart'; |
... | ... | @@ -187,7 +188,8 @@ class _ReadingPage extends StatelessWidget { |
187 | 188 | SizedBox( |
188 | 189 | width: 10.w, |
189 | 190 | ), |
190 | - GestureDetector( | |
191 | + ThrottledGestureDetector( | |
192 | + throttleTime: 1000, | |
191 | 193 | onTap: () { |
192 | 194 | if (bloc.isRecording) { |
193 | 195 | bloc.add(XSVoiceStopEvent()); | ... | ... |
lib/pages/section/bloc/section_bloc.dart
... | ... | @@ -37,14 +37,15 @@ class SectionBloc extends Bloc<SectionEvent, SectionState> { |
37 | 37 | ///courseUnitId与课程环节列表的映射 |
38 | 38 | final Map<int, List<CourseSectionEntity>?> _courseSectionDatasMap = {}; |
39 | 39 | |
40 | - Map<int, List<CourseSectionEntity>?> get courseSectionDatasMap => _courseSectionDatasMap; | |
40 | + Map<int, List<CourseSectionEntity>?> get courseSectionDatasMap => | |
41 | + _courseSectionDatasMap; | |
41 | 42 | |
42 | 43 | CourseProcessEntity? _processEntity; |
43 | 44 | |
44 | 45 | CourseProcessEntity? get processEntity => _processEntity; |
45 | 46 | |
46 | - SectionBloc(this._courseUnitEntity, this._currentPage, | |
47 | - this._pageController, this._listController) | |
47 | + SectionBloc(this._courseUnitEntity, this._currentPage, this._pageController, | |
48 | + this._listController) | |
48 | 49 | : super(LessonInitial()) { |
49 | 50 | on<RequestDataEvent>(_requestSectionsData); |
50 | 51 | on<RequestEndClassEvent>(_requestEndClass); |
... | ... | @@ -101,20 +102,18 @@ class SectionBloc extends Bloc<SectionEvent, SectionState> { |
101 | 102 | RequestEndClassEvent event, Emitter<SectionState> emitter) async { |
102 | 103 | if (event.isCompleted) { |
103 | 104 | await await ListenDao.endClass(event.courseLessonId, |
104 | - currentStep: event.currentStep, | |
105 | - currentTime: event.currentTime); | |
105 | + currentStep: event.currentStep, currentTime: event.currentTime); | |
106 | 106 | } else { |
107 | 107 | await await ListenDao.exitClass(event.courseLessonId, |
108 | - currentStep: event.currentStep, | |
109 | - currentTime: event.currentTime); | |
108 | + currentStep: event.currentStep, currentTime: event.currentTime); | |
110 | 109 | } |
111 | 110 | if (event.autoNextSection) { |
112 | 111 | final nextCourseSection = |
113 | - await getNextCourseSection(int.parse(event.courseLessonId)); | |
112 | + await getNextCourseSection(int.parse(event.courseLessonId), emitter); | |
114 | 113 | if (nextCourseSection != null) { |
115 | 114 | ///进入课堂 |
116 | - add(RequestEnterClassEvent(nextCourseSection.id.toString(), | |
117 | - nextCourseSection.courseType)); | |
115 | + add(RequestEnterClassEvent( | |
116 | + nextCourseSection.id.toString(), nextCourseSection.courseType)); | |
118 | 117 | } |
119 | 118 | } |
120 | 119 | } |
... | ... | @@ -129,7 +128,8 @@ class SectionBloc extends Bloc<SectionEvent, SectionState> { |
129 | 128 | int unlockPageCount() { |
130 | 129 | return _courseUnitEntity.courseUnitVOList |
131 | 130 | ?.indexWhereOrNull((element) => element.lock == true) ?? |
132 | - 1; | |
131 | + _courseUnitEntity.courseUnitVOList?.length ?? | |
132 | + 0; | |
133 | 133 | } |
134 | 134 | |
135 | 135 | ///当前页的课程详情 |
... | ... | @@ -171,33 +171,40 @@ class SectionBloc extends Bloc<SectionEvent, SectionState> { |
171 | 171 | CourseUnitDetail? findCourseUnitDetailById(int courseLessonId) { |
172 | 172 | final curCourseSectionEntity = findCourseSectionById(courseLessonId); |
173 | 173 | if (curCourseSectionEntity != null) { |
174 | - final curCourseUnitDetail = _courseUnitEntity.courseUnitVOList?.firstWhere((element) => | |
175 | - element.id == curCourseSectionEntity.courseUnitId); | |
174 | + final curCourseUnitDetail = _courseUnitEntity.courseUnitVOList | |
175 | + ?.firstWhere( | |
176 | + (element) => element.id == curCourseSectionEntity.courseUnitId); | |
176 | 177 | return curCourseUnitDetail; |
177 | 178 | } |
178 | 179 | return null; |
179 | 180 | } |
180 | 181 | |
181 | 182 | ///根据courseLessonId查找下一个courseSection |
182 | - Future<CourseSectionEntity?> getNextCourseSection(int courseLessonId) async { | |
183 | + Future<CourseSectionEntity?> getNextCourseSection( | |
184 | + int courseLessonId, Emitter<SectionState> emitter) async { | |
183 | 185 | final curCourseSectionEntity = findCourseSectionById(courseLessonId); |
184 | 186 | final curSectionSort = curCourseSectionEntity?.sortOrder ?? 0; |
187 | + | |
188 | + ///查找下一个section | |
185 | 189 | final nextCourseSectionEntity = findCourseSectionBySort(curSectionSort + 1); |
186 | 190 | if (nextCourseSectionEntity != null) { |
187 | 191 | return nextCourseSectionEntity; |
188 | 192 | } else { |
189 | - ///跨unit选lesson | |
193 | + ///section为空说明当前unit学完了,找下一个unit。(跨unit选lesson) | |
194 | + ///先根据courseLessonId找出当前的unit | |
190 | 195 | final curCourseUnitDetail = findCourseUnitDetailById(courseLessonId); |
191 | 196 | if (curCourseUnitDetail != null) { |
197 | + ///再根据当前unit找出下一个unit | |
192 | 198 | final nextCourseUnitDetail = _courseUnitEntity.courseUnitVOList |
193 | - ?.firstWhere((element) => element.sortOrder == (curCourseUnitDetail.sortOrder! + 1)); | |
199 | + ?.firstWhere((element) => | |
200 | + element.sortOrder == (curCourseUnitDetail.sortOrder! + 1)); | |
194 | 201 | if (nextCourseUnitDetail != null) { |
195 | 202 | final courseUnitId = nextCourseUnitDetail.id!; |
196 | 203 | try { |
197 | 204 | await loading(() async { |
198 | 205 | _courseSectionDatasMap[courseUnitId] = |
199 | - await LessonDao.courseSection(courseUnitId: courseUnitId); | |
200 | - emit(LessonDataLoadState()); | |
206 | + await LessonDao.courseSection(courseUnitId: courseUnitId); | |
207 | + emitter(LessonDataLoadState()); | |
201 | 208 | }); |
202 | 209 | _pageController.nextPage( |
203 | 210 | duration: const Duration(milliseconds: 500), | ... | ... |