Commit d1ab5cb2c18b4e9964006ef6c8a9ed3e96032807

Authored by 吴启风
1 parent a0bbff8c

feat:绘本跟读页上方进度信息改成进度条呈现

lib/pages/reading/bloc/reading_bloc.dart
... ... @@ -89,7 +89,9 @@ class ReadingPageBloc
89 89  
90 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 95 : super(ReadingPageInitial()) {
94 96 on<CurrentPageIndexChangeEvent>(_pageControllerChange);
95 97 on<CurrentModeChangeEvent>(_playModeChange);
... ...
lib/pages/reading/reading_page.dart
1 1 import 'package:flutter/material.dart';
2 2 import 'package:flutter_bloc/flutter_bloc.dart';
3 3 import 'package:flutter_screenutil/flutter_screenutil.dart';
  4 +import 'package:percent_indicator/linear_percent_indicator.dart';
4 5 import 'package:wow_english/common/extension/string_extension.dart';
5 6 import 'package:wow_english/pages/reading/widgets/ReadingModeType.dart';
6 7 import 'package:wow_english/pages/reading/widgets/reading_dialog_widget.dart';
... ... @@ -8,7 +9,6 @@ import &#39;package:wow_english/route/route.dart&#39;;
8 9  
9 10 import '../../common/core/app_consts.dart';
10 11 import '../../common/core/user_util.dart';
11   -import '../../common/widgets/record_playback_widget.dart';
12 12 import '../../common/widgets/recorder_widget.dart';
13 13 import '../../common/widgets/speaker_widget.dart';
14 14 import '../../models/course_process_entity.dart';
... ... @@ -17,23 +17,25 @@ import &#39;bloc/reading_bloc.dart&#39;;
17 17  
18 18 ///绘本页
19 19 class ReadingPage extends StatelessWidget {
20   - const ReadingPage({super.key, this.courseLessonId});
  20 + const ReadingPage({super.key, this.courseLessonId, this.moduleColor});
21 21  
22 22 final String? courseLessonId;
23 23  
  24 + final Color? moduleColor;
  25 +
24 26 @override
25 27 Widget build(BuildContext context) {
26 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 39 child: _ReadingPage(),
38 40 );
39 41 }
... ... @@ -102,20 +104,20 @@ class _ReadingPage extends StatelessWidget {
102 104 )),
103 105 ),
104 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 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 177 width: 10.w,
176 178 ),
177 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 189 SizedBox(
188 190 width: 10.w,
... ...
lib/pages/section/section_page.dart
... ... @@ -111,9 +111,10 @@ class _SectionPageView extends StatelessWidget {
111 111 await clickController.playMusicAndPerformAction(
112 112 context, AudioPlayerUtilType.readingTime, () async {
113 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 118 if (value != null) {
118 119 Map<String, dynamic> dataMap =
119 120 value as Map<String, dynamic>;
... ...
lib/route/route.dart
... ... @@ -247,12 +247,14 @@ class AppRouter {
247 247 transitionsBuilder: (_, __, ___, child) => child);
248 248 case AppRouteName.reading:
249 249 var courseLessonId = '';
  250 + Color? moduleColor;
250 251 if (settings.arguments != null) {
251 252 courseLessonId =
252 253 (settings.arguments as Map)['courseLessonId'] as String;
  254 + moduleColor = (settings.arguments as Map)['moduleColor'] as Color?;
253 255 }
254 256 return CupertinoPageRoute(
255   - builder: (_) => ReadingPage(courseLessonId: courseLessonId));
  257 + builder: (_) => ReadingPage(courseLessonId: courseLessonId, moduleColor: moduleColor));
256 258 default:
257 259 return CupertinoPageRoute(
258 260 builder: (_) => Scaffold(
... ...