1dc46cf7
吴启风
feat:绘本ui
|
1
2
3
|
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
d1ab5cb2
吴启风
feat:绘本跟读页上方进度信息改...
|
4
|
import 'package:percent_indicator/linear_percent_indicator.dart';
|
1dc46cf7
吴启风
feat:绘本ui
|
5
|
import 'package:wow_english/common/extension/string_extension.dart';
|
2a427e12
吴启风
feat:绘本静态ui基本完成
|
6
|
import 'package:wow_english/pages/reading/widgets/ReadingModeType.dart';
|
065022b7
吴启风
feat:绘本评测反馈弹窗+原音播...
|
7
|
import 'package:wow_english/pages/reading/widgets/reading_dialog_widget.dart';
|
56e2ae5a
liangchengyou
feat:绘本添加回调数据
|
8
|
import 'package:wow_english/route/route.dart';
|
1dc46cf7
吴启风
feat:绘本ui
|
9
|
|
a506beff
吴启风
feat:先声sdk方法找不到问题...
|
10
|
import '../../common/core/user_util.dart';
|
c623c7b2
吴启风
feat:语音跟读作答结果动效&语音
|
11
|
import '../../common/widgets/recorder_widget.dart';
|
b81332ca
吴启风
feat:喇叭组件替换
|
12
|
import '../../common/widgets/speaker_widget.dart';
|
a506beff
吴启风
feat:先声sdk方法找不到问题...
|
13
|
import '../../models/course_process_entity.dart';
|
065022b7
吴启风
feat:绘本评测反馈弹窗+原音播...
|
14
|
import '../../utils/log_util.dart';
|
1dc46cf7
吴启风
feat:绘本ui
|
15
16
|
import 'bloc/reading_bloc.dart';
|
4d8b0da4
吴启风
feat:绘本跟读底部ui优化
|
17
|
///绘本页
|
2a427e12
吴启风
feat:绘本静态ui基本完成
|
18
|
class ReadingPage extends StatelessWidget {
|
d1ab5cb2
吴启风
feat:绘本跟读页上方进度信息改...
|
19
|
const ReadingPage({super.key, this.courseLessonId, this.moduleColor});
|
53e9e6db
吴启风
feat:绘本语音评测逻辑
|
20
21
|
final String? courseLessonId;
|
1dc46cf7
吴启风
feat:绘本ui
|
22
|
|
d1ab5cb2
吴启风
feat:绘本跟读页上方进度信息改...
|
23
24
|
final Color? moduleColor;
|
1dc46cf7
吴启风
feat:绘本ui
|
25
26
27
|
@override
Widget build(BuildContext context) {
return BlocProvider(
|
d1ab5cb2
吴启风
feat:绘本跟读页上方进度信息改...
|
28
29
30
|
create: (_) => ReadingPageBloc(
context, PageController(), courseLessonId ?? '', moduleColor)
..add(InitBlocEvent())
|
0fa4e405
吴启风
feat: 将语音评测从先声迁移至驰声
|
31
|
..add(RequestDataEvent()),
|
1dc46cf7
吴启风
feat:绘本ui
|
32
33
34
35
36
37
38
39
40
|
child: _ReadingPage(),
);
}
}
class _ReadingPage extends StatelessWidget {
@override
Widget build(BuildContext context) {
return BlocListener<ReadingPageBloc, ReadingPageState>(
|
a506beff
吴启风
feat:先声sdk方法找不到问题...
|
41
|
listener: (context, state) {
|
065022b7
吴启风
feat:绘本评测反馈弹窗+原音播...
|
42
|
Log.d('reading BlocListener=$state');
|
a506beff
吴启风
feat:先声sdk方法找不到问题...
|
43
|
if (state is RequestDataState) {
|
a506beff
吴启风
feat:先声sdk方法找不到问题...
|
44
45
46
|
///刷新页面
context.read<ReadingPageBloc>().add(CurrentPageIndexChangeEvent(0));
}
|
065022b7
吴启风
feat:绘本评测反馈弹窗+原音播...
|
47
48
49
50
51
52
53
54
|
if (state is FeedbackState) {
showDialog<ReadingDialog>(
context: context,
barrierDismissible: false,
builder: (context) {
return const ReadingDialog();
});
}
|
a506beff
吴启风
feat:先声sdk方法找不到问题...
|
55
|
},
|
2a427e12
吴启风
feat:绘本静态ui基本完成
|
56
|
child: _readingPageView(),
|
1dc46cf7
吴启风
feat:绘本ui
|
57
58
59
|
);
}
|
82c8633c
biao
音频添加 页面优化
|
60
61
|
Widget _readingPageView() =>
BlocBuilder<ReadingPageBloc, ReadingPageState>(builder: (context, state) {
|
1dc46cf7
吴启风
feat:绘本ui
|
62
63
64
65
66
|
final bloc = BlocProvider.of<ReadingPageBloc>(context);
return Container(
color: Colors.white,
child: Stack(
children: [
|
2a427e12
吴启风
feat:绘本静态ui基本完成
|
67
|
PageView.builder(
|
a506beff
吴启风
feat:先声sdk方法找不到问题...
|
68
|
itemCount: bloc.dataCount(),
|
2a427e12
吴启风
feat:绘本静态ui基本完成
|
69
70
71
72
73
|
controller: bloc.pageController,
onPageChanged: (int index) {
bloc.add(CurrentPageIndexChangeEvent(index));
},
itemBuilder: (context, int index) {
|
a506beff
吴启风
feat:先声sdk方法找不到问题...
|
74
|
return _readingPagerItem(bloc.entity!.readings![index]);
|
2a427e12
吴启风
feat:绘本静态ui基本完成
|
75
76
77
|
}),
Container(
color: Colors.transparent,
|
5b923179
吴启风
feat:导航栏优化
|
78
|
height: kToolbarHeight,
|
2a427e12
吴启风
feat:绘本静态ui基本完成
|
79
80
81
82
83
|
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Padding(
padding:
|
82c8633c
biao
音频添加 页面优化
|
84
|
EdgeInsets.only(left: ScreenUtil().bottomBarHeight),
|
2a427e12
吴启风
feat:绘本静态ui基本完成
|
85
86
|
child: IconButton(
onPressed: () {
|
82c8633c
biao
音频添加 页面优化
|
87
88
89
90
91
|
popPage(data: {
'currentStep': bloc.currentPage,
'courseLessonId': bloc.courseLessonId,
'isCompleted': bloc.isLastPage(),
});
|
2a427e12
吴启风
feat:绘本静态ui基本完成
|
92
93
94
|
},
icon: Image.asset(
'back_around'.assetPng,
|
5b923179
吴启风
feat:导航栏优化
|
95
96
|
width: 40.w,
height: 40.h,
|
2a427e12
吴启风
feat:绘本静态ui基本完成
|
97
98
99
|
)),
),
Container(
|
d1ab5cb2
吴启风
feat:绘本跟读页上方进度信息改...
|
100
101
|
height: 10.h,
width: 150.w,
|
2a427e12
吴启风
feat:绘本静态ui基本完成
|
102
|
alignment: Alignment.center,
|
d1ab5cb2
吴启风
feat:绘本跟读页上方进度信息改...
|
103
104
105
106
107
108
109
110
111
112
113
|
child: LinearPercentIndicator(
animation: true,
lineHeight: 10.h,
animationDuration: 250,
animateFromLastPercent: true,
percent: bloc.dataCount() > 0
? bloc.currentPage / bloc.dataCount()
: 0,
// center: Text('$progress/$total}'),
barRadius: const Radius.circular(5),
progressColor: bloc.moduleColor,
|
2a427e12
吴启风
feat:绘本静态ui基本完成
|
114
115
116
117
|
),
),
Padding(
|
a506beff
吴启风
feat:先声sdk方法找不到问题...
|
118
119
|
padding: EdgeInsets.only(
right: 15.w + ScreenUtil().bottomBarHeight),
|
2a427e12
吴启风
feat:绘本静态ui基本完成
|
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
|
child: GestureDetector(
onTap: () {
bloc.add(CurrentModeChangeEvent());
},
child: SizedBox(
height: 40.h,
child: Container(
decoration: BoxDecoration(
image: DecorationImage(
image: AssetImage('bg_reading_mode'.assetPng),
fit: BoxFit.fill),
),
alignment: Alignment.center,
padding: EdgeInsets.symmetric(horizontal: 10.w),
child: Text(
bloc.currentMode == ReadingModeType.auto
? '设为手动'
: '设为自动',
style: TextStyle(fontSize: 14.5.sp),
),
),
),
),
),
// ScreenUtil().bottomBarHeight.horizontalSpace,
],
),
),
Align(
alignment: Alignment.bottomLeft,
child: Container(
|
fd737d6a
吴启风
feat:绘本作答结果以单词为单位...
|
152
|
color: const Color(0xCCFFFFFF),
|
2a427e12
吴启风
feat:绘本静态ui基本完成
|
153
154
|
child: Row(
children: [
|
5e2bbbd3
biao
添加音频
|
155
|
5.horizontalSpace,
|
b81332ca
吴启风
feat:喇叭组件替换
|
156
157
158
159
160
161
162
163
164
|
SpeakerWidget(
isPlaying:
bloc.voicePlayState == VoicePlayState.playing &&
bloc.isOriginAudioPlaying,
// 控制动画播放
isClickable: !bloc.isRecording,
// 控制是否可点击
width: 42.w,
height: 42.w,
|
a506beff
吴启风
feat:先声sdk方法找不到问题...
|
165
|
onTap: () {
|
a506beff
吴启风
feat:先声sdk方法找不到问题...
|
166
167
|
bloc.add(PlayOriginalAudioEvent(null));
},
|
2a427e12
吴启风
feat:绘本静态ui基本完成
|
168
169
170
171
172
|
),
SizedBox(
width: 10.w,
),
Expanded(
|
d1ab5cb2
吴启风
feat:绘本跟读页上方进度信息改...
|
173
174
175
176
|
child: RichText(
text: TextSpan(
style: DefaultTextStyle.of(context).style,
children: bloc.displayContent(),
|
fd737d6a
吴启风
feat:绘本作答结果以单词为单位...
|
177
|
),
|
d1ab5cb2
吴启风
feat:绘本跟读页上方进度信息改...
|
178
179
180
|
maxLines: 2,
overflow: TextOverflow.ellipsis,
),
|
fd737d6a
吴启风
feat:绘本作答结果以单词为单位...
|
181
|
),
|
2a427e12
吴启风
feat:绘本静态ui基本完成
|
182
183
184
|
SizedBox(
width: 10.w,
),
|
c623c7b2
吴启风
feat:语音跟读作答结果动效&语音
|
185
186
|
RecorderWidget(
isPlaying: bloc.isRecording,
|
457ac447
吴启风
feat:代码优化-空条件调用
|
187
188
|
width: 54.w,
height: 54.w,
|
c623c7b2
吴启风
feat:语音跟读作答结果动效&语音
|
189
190
191
192
|
onTap: () {
if (bloc.isRecording) {
bloc.add(XSVoiceStopEvent());
} else {
|
b81332ca
吴启风
feat:喇叭组件替换
|
193
194
|
bloc.add(XSVoiceStartEvent(bloc.readingContent(),
'0', UserUtil.getUser()?.id.toString()));
|
c623c7b2
吴启风
feat:语音跟读作答结果动效&语音
|
195
196
197
|
}
},
),
|
1de82c6c
吴启风
feat:绘本跟读录音播放组件用回...
|
198
199
200
201
202
203
204
205
206
207
208
209
210
|
GestureDetector(
onTap: () {
if (bloc.isRecording) {
return;
}
bloc.add(PlayRecordAudioEvent());
},
child: Visibility(
visible: bloc.currentPageData()?.recordUrl != null,
child: Image.asset(
bloc.isRecordAudioPlaying
? 'record_pause'.assetWebp
: 'record_play'.assetWebp,
|
457ac447
吴启风
feat:代码优化-空条件调用
|
211
212
|
height: 35.h,
width: 35.h,
|
1de82c6c
吴启风
feat:绘本跟读录音播放组件用回...
|
213
214
215
216
217
218
219
220
221
222
223
|
),
)),
// RecorderPlaybackWidget(
// isClickable: !bloc.isRecording && bloc.currentPageData()?.recordUrl != null,
// isPlaying: bloc.isRecordAudioPlaying,
// width: 42.w,
// height: 42.w,
// onTap: () {
// bloc.add(PlayRecordAudioEvent());
// },
// )
|
457ac447
吴启风
feat:代码优化-空条件调用
|
224
225
226
|
SizedBox(
width: 10.w,
)
|
2a427e12
吴启风
feat:绘本静态ui基本完成
|
227
|
],
|
1dc46cf7
吴启风
feat:绘本ui
|
228
|
),
|
2a427e12
吴启风
feat:绘本静态ui基本完成
|
229
|
),
|
1dc46cf7
吴启风
feat:绘本ui
|
230
231
232
233
234
235
|
)
],
),
);
});
|
a506beff
吴启风
feat:先声sdk方法找不到问题...
|
236
|
Widget _readingPagerItem(CourseProcessReadings readings) =>
|
2a427e12
吴启风
feat:绘本静态ui基本完成
|
237
238
|
BlocBuilder<ReadingPageBloc, ReadingPageState>(builder: (context, state) {
return Stack(
|
1dc46cf7
吴启风
feat:绘本ui
|
239
|
children: [
|
065022b7
吴启风
feat:绘本评测反馈弹窗+原音播...
|
240
|
Positioned.fill(
|
82c8633c
biao
音频添加 页面优化
|
241
|
child: Image.network(readings.picUrl ?? '', fit: BoxFit.cover),
|
065022b7
吴启风
feat:绘本评测反馈弹窗+原音播...
|
242
|
),
|
1dc46cf7
吴启风
feat:绘本ui
|
243
244
245
246
|
],
);
});
}
|