Commit d1ab5cb2c18b4e9964006ef6c8a9ed3e96032807
1 parent
a0bbff8c
feat:绘本跟读页上方进度信息改成进度条呈现
Showing
4 changed files
with
44 additions
and
37 deletions
lib/pages/reading/bloc/reading_bloc.dart
| @@ -89,7 +89,9 @@ class ReadingPageBloc | @@ -89,7 +89,9 @@ class ReadingPageBloc | ||
| 89 | 89 | ||
| 90 | final BuildContext context; | 90 | final BuildContext context; | 
| 91 | 91 | ||
| 92 | - ReadingPageBloc(this.context, this.pageController, this.courseLessonId) | 92 | + final Color? moduleColor; | 
| 93 | + | ||
| 94 | + ReadingPageBloc(this.context, this.pageController, this.courseLessonId, this.moduleColor) | ||
| 93 | : super(ReadingPageInitial()) { | 95 | : super(ReadingPageInitial()) { | 
| 94 | on<CurrentPageIndexChangeEvent>(_pageControllerChange); | 96 | on<CurrentPageIndexChangeEvent>(_pageControllerChange); | 
| 95 | on<CurrentModeChangeEvent>(_playModeChange); | 97 | on<CurrentModeChangeEvent>(_playModeChange); | 
lib/pages/reading/reading_page.dart
| 1 | import 'package:flutter/material.dart'; | 1 | import 'package:flutter/material.dart'; | 
| 2 | import 'package:flutter_bloc/flutter_bloc.dart'; | 2 | import 'package:flutter_bloc/flutter_bloc.dart'; | 
| 3 | import 'package:flutter_screenutil/flutter_screenutil.dart'; | 3 | import 'package:flutter_screenutil/flutter_screenutil.dart'; | 
| 4 | +import 'package:percent_indicator/linear_percent_indicator.dart'; | ||
| 4 | import 'package:wow_english/common/extension/string_extension.dart'; | 5 | import 'package:wow_english/common/extension/string_extension.dart'; | 
| 5 | import 'package:wow_english/pages/reading/widgets/ReadingModeType.dart'; | 6 | import 'package:wow_english/pages/reading/widgets/ReadingModeType.dart'; | 
| 6 | import 'package:wow_english/pages/reading/widgets/reading_dialog_widget.dart'; | 7 | import 'package:wow_english/pages/reading/widgets/reading_dialog_widget.dart'; | 
| @@ -8,7 +9,6 @@ import 'package:wow_english/route/route.dart'; | @@ -8,7 +9,6 @@ import 'package:wow_english/route/route.dart'; | ||
| 8 | 9 | ||
| 9 | import '../../common/core/app_consts.dart'; | 10 | import '../../common/core/app_consts.dart'; | 
| 10 | import '../../common/core/user_util.dart'; | 11 | import '../../common/core/user_util.dart'; | 
| 11 | -import '../../common/widgets/record_playback_widget.dart'; | ||
| 12 | import '../../common/widgets/recorder_widget.dart'; | 12 | import '../../common/widgets/recorder_widget.dart'; | 
| 13 | import '../../common/widgets/speaker_widget.dart'; | 13 | import '../../common/widgets/speaker_widget.dart'; | 
| 14 | import '../../models/course_process_entity.dart'; | 14 | import '../../models/course_process_entity.dart'; | 
| @@ -17,23 +17,25 @@ import 'bloc/reading_bloc.dart'; | @@ -17,23 +17,25 @@ import 'bloc/reading_bloc.dart'; | ||
| 17 | 17 | ||
| 18 | ///绘本页 | 18 | ///绘本页 | 
| 19 | class ReadingPage extends StatelessWidget { | 19 | class ReadingPage extends StatelessWidget { | 
| 20 | - const ReadingPage({super.key, this.courseLessonId}); | 20 | + const ReadingPage({super.key, this.courseLessonId, this.moduleColor}); | 
| 21 | 21 | ||
| 22 | final String? courseLessonId; | 22 | final String? courseLessonId; | 
| 23 | 23 | ||
| 24 | + final Color? moduleColor; | ||
| 25 | + | ||
| 24 | @override | 26 | @override | 
| 25 | Widget build(BuildContext context) { | 27 | Widget build(BuildContext context) { | 
| 26 | return BlocProvider( | 28 | return BlocProvider( | 
| 27 | - create: (_) => | ||
| 28 | - ReadingPageBloc(context, PageController(), courseLessonId ?? '') | ||
| 29 | - ..add(InitBlocEvent()) | ||
| 30 | - ..add(RequestDataEvent()) | ||
| 31 | - ..add(XSVoiceInitEvent({ | ||
| 32 | - 'appKey': AppConsts.xsAppKey, | ||
| 33 | - 'service': AppConsts.xsAppService, | ||
| 34 | - 'secretKey': AppConsts.xsAppSecretKey, | ||
| 35 | - 'userId': UserUtil.getUser()!.id.toString(), | ||
| 36 | - })), | 29 | + create: (_) => ReadingPageBloc( | 
| 30 | + context, PageController(), courseLessonId ?? '', moduleColor) | ||
| 31 | + ..add(InitBlocEvent()) | ||
| 32 | + ..add(RequestDataEvent()) | ||
| 33 | + ..add(XSVoiceInitEvent({ | ||
| 34 | + 'appKey': AppConsts.xsAppKey, | ||
| 35 | + 'service': AppConsts.xsAppService, | ||
| 36 | + 'secretKey': AppConsts.xsAppSecretKey, | ||
| 37 | + 'userId': UserUtil.getUser()!.id.toString(), | ||
| 38 | + })), | ||
| 37 | child: _ReadingPage(), | 39 | child: _ReadingPage(), | 
| 38 | ); | 40 | ); | 
| 39 | } | 41 | } | 
| @@ -102,20 +104,20 @@ class _ReadingPage extends StatelessWidget { | @@ -102,20 +104,20 @@ class _ReadingPage extends StatelessWidget { | ||
| 102 | )), | 104 | )), | 
| 103 | ), | 105 | ), | 
| 104 | Container( | 106 | Container( | 
| 105 | - height: 32.h, | ||
| 106 | - padding: EdgeInsets.symmetric(horizontal: 27.w), | ||
| 107 | - decoration: BoxDecoration( | ||
| 108 | - color: const Color(0xFF00B6F1), | ||
| 109 | - borderRadius: BorderRadius.circular(15.r), | ||
| 110 | - border: Border.all( | ||
| 111 | - width: 1.0, | ||
| 112 | - color: const Color(0xFF140C10), | ||
| 113 | - ), | ||
| 114 | - ), | 107 | + height: 10.h, | 
| 108 | + width: 150.w, | ||
| 115 | alignment: Alignment.center, | 109 | alignment: Alignment.center, | 
| 116 | - child: Text( | ||
| 117 | - '${bloc.currentPage}/${bloc.dataCount()}', | ||
| 118 | - style: TextStyle(fontSize: 20.sp, color: Colors.white), | 110 | + child: LinearPercentIndicator( | 
| 111 | + animation: true, | ||
| 112 | + lineHeight: 10.h, | ||
| 113 | + animationDuration: 250, | ||
| 114 | + animateFromLastPercent: true, | ||
| 115 | + percent: bloc.dataCount() > 0 | ||
| 116 | + ? bloc.currentPage / bloc.dataCount() | ||
| 117 | + : 0, | ||
| 118 | + // center: Text('$progress/$total}'), | ||
| 119 | + barRadius: const Radius.circular(5), | ||
| 120 | + progressColor: bloc.moduleColor, | ||
| 119 | ), | 121 | ), | 
| 120 | ), | 122 | ), | 
| 121 | 123 | ||
| @@ -175,14 +177,14 @@ class _ReadingPage extends StatelessWidget { | @@ -175,14 +177,14 @@ class _ReadingPage extends StatelessWidget { | ||
| 175 | width: 10.w, | 177 | width: 10.w, | 
| 176 | ), | 178 | ), | 
| 177 | Expanded( | 179 | Expanded( | 
| 178 | - child: RichText( | ||
| 179 | - text: TextSpan( | ||
| 180 | - style: DefaultTextStyle.of(context).style, | ||
| 181 | - children: bloc.displayContent(), | ||
| 182 | - ), | ||
| 183 | - maxLines: 2, | ||
| 184 | - overflow: TextOverflow.ellipsis, | 180 | + child: RichText( | 
| 181 | + text: TextSpan( | ||
| 182 | + style: DefaultTextStyle.of(context).style, | ||
| 183 | + children: bloc.displayContent(), | ||
| 185 | ), | 184 | ), | 
| 185 | + maxLines: 2, | ||
| 186 | + overflow: TextOverflow.ellipsis, | ||
| 187 | + ), | ||
| 186 | ), | 188 | ), | 
| 187 | SizedBox( | 189 | SizedBox( | 
| 188 | width: 10.w, | 190 | width: 10.w, | 
lib/pages/section/section_page.dart
| @@ -111,9 +111,10 @@ class _SectionPageView extends StatelessWidget { | @@ -111,9 +111,10 @@ class _SectionPageView extends StatelessWidget { | ||
| 111 | await clickController.playMusicAndPerformAction( | 111 | await clickController.playMusicAndPerformAction( | 
| 112 | context, AudioPlayerUtilType.readingTime, () async { | 112 | context, AudioPlayerUtilType.readingTime, () async { | 
| 113 | await bloc.requestEnterClass(courseLessonId, () { | 113 | await bloc.requestEnterClass(courseLessonId, () { | 
| 114 | - pushNamed(AppRouteName.reading, | ||
| 115 | - arguments: {'courseLessonId': courseLessonId}) | ||
| 116 | - .then((value) { | 114 | + pushNamed(AppRouteName.reading, arguments: { | 
| 115 | + 'courseLessonId': courseLessonId, | ||
| 116 | + 'moduleColor': ModuleCache.instance.getCurrentThemeColor() | ||
| 117 | + }).then((value) { | ||
| 117 | if (value != null) { | 118 | if (value != null) { | 
| 118 | Map<String, dynamic> dataMap = | 119 | Map<String, dynamic> dataMap = | 
| 119 | value as Map<String, dynamic>; | 120 | value as Map<String, dynamic>; | 
lib/route/route.dart
| @@ -247,12 +247,14 @@ class AppRouter { | @@ -247,12 +247,14 @@ class AppRouter { | ||
| 247 | transitionsBuilder: (_, __, ___, child) => child); | 247 | transitionsBuilder: (_, __, ___, child) => child); | 
| 248 | case AppRouteName.reading: | 248 | case AppRouteName.reading: | 
| 249 | var courseLessonId = ''; | 249 | var courseLessonId = ''; | 
| 250 | + Color? moduleColor; | ||
| 250 | if (settings.arguments != null) { | 251 | if (settings.arguments != null) { | 
| 251 | courseLessonId = | 252 | courseLessonId = | 
| 252 | (settings.arguments as Map)['courseLessonId'] as String; | 253 | (settings.arguments as Map)['courseLessonId'] as String; | 
| 254 | + moduleColor = (settings.arguments as Map)['moduleColor'] as Color?; | ||
| 253 | } | 255 | } | 
| 254 | return CupertinoPageRoute( | 256 | return CupertinoPageRoute( | 
| 255 | - builder: (_) => ReadingPage(courseLessonId: courseLessonId)); | 257 | + builder: (_) => ReadingPage(courseLessonId: courseLessonId, moduleColor: moduleColor)); | 
| 256 | default: | 258 | default: | 
| 257 | return CupertinoPageRoute( | 259 | return CupertinoPageRoute( | 
| 258 | builder: (_) => Scaffold( | 260 | builder: (_) => Scaffold( | 
