1dc46cf7
吴启风
feat:绘本ui
|
1
2
3
4
|
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:wow_english/common/extension/string_extension.dart';
|
2a427e12
吴启风
feat:绘本静态ui基本完成
|
5
|
import 'package:wow_english/pages/reading/widgets/ReadingModeType.dart';
|
065022b7
吴启风
feat:绘本评测反馈弹窗+原音播...
|
6
|
import 'package:wow_english/pages/reading/widgets/reading_dialog_widget.dart';
|
56e2ae5a
liangchengyou
feat:绘本添加回调数据
|
7
|
import 'package:wow_english/route/route.dart';
|
1dc46cf7
吴启风
feat:绘本ui
|
8
|
|
6b0947ca
吴启风
feat:绘本增加initVoic...
|
9
|
import '../../common/core/app_consts.dart';
|
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 {
|
53e9e6db
吴启风
feat:绘本语音评测逻辑
|
19
20
21
|
const ReadingPage({super.key, this.courseLessonId});
final String? courseLessonId;
|
1dc46cf7
吴启风
feat:绘本ui
|
22
23
24
25
|
@override
Widget build(BuildContext context) {
return BlocProvider(
|
82c8633c
biao
音频添加 页面优化
|
26
27
28
29
30
31
32
33
34
35
|
create: (_) =>
ReadingPageBloc(context, PageController(), courseLessonId ?? '')
..add(InitBlocEvent())
..add(RequestDataEvent())
..add(XSVoiceInitEvent({
'appKey': AppConsts.xsAppKey,
'service': AppConsts.xsAppService,
'secretKey': AppConsts.xsAppSecretKey,
'userId': UserUtil.getUser()!.id.toString(),
})),
|
1dc46cf7
吴启风
feat:绘本ui
|
36
37
38
39
40
41
42
43
44
|
child: _ReadingPage(),
);
}
}
class _ReadingPage extends StatelessWidget {
@override
Widget build(BuildContext context) {
return BlocListener<ReadingPageBloc, ReadingPageState>(
|
a506beff
吴启风
feat:先声sdk方法找不到问题...
|
45
|
listener: (context, state) {
|
065022b7
吴启风
feat:绘本评测反馈弹窗+原音播...
|
46
|
Log.d('reading BlocListener=$state');
|
a506beff
吴启风
feat:先声sdk方法找不到问题...
|
47
|
if (state is RequestDataState) {
|
a506beff
吴启风
feat:先声sdk方法找不到问题...
|
48
49
50
|
///刷新页面
context.read<ReadingPageBloc>().add(CurrentPageIndexChangeEvent(0));
}
|
065022b7
吴启风
feat:绘本评测反馈弹窗+原音播...
|
51
52
53
54
55
56
57
58
|
if (state is FeedbackState) {
showDialog<ReadingDialog>(
context: context,
barrierDismissible: false,
builder: (context) {
return const ReadingDialog();
});
}
|
a506beff
吴启风
feat:先声sdk方法找不到问题...
|
59
|
},
|
2a427e12
吴启风
feat:绘本静态ui基本完成
|
60
|
child: _readingPageView(),
|
1dc46cf7
吴启风
feat:绘本ui
|
61
62
63
|
);
}
|
82c8633c
biao
音频添加 页面优化
|
64
65
|
Widget _readingPageView() =>
BlocBuilder<ReadingPageBloc, ReadingPageState>(builder: (context, state) {
|
1dc46cf7
吴启风
feat:绘本ui
|
66
67
68
69
70
|
final bloc = BlocProvider.of<ReadingPageBloc>(context);
return Container(
color: Colors.white,
child: Stack(
children: [
|
2a427e12
吴启风
feat:绘本静态ui基本完成
|
71
|
PageView.builder(
|
a506beff
吴启风
feat:先声sdk方法找不到问题...
|
72
|
itemCount: bloc.dataCount(),
|
2a427e12
吴启风
feat:绘本静态ui基本完成
|
73
74
75
76
77
|
controller: bloc.pageController,
onPageChanged: (int index) {
bloc.add(CurrentPageIndexChangeEvent(index));
},
itemBuilder: (context, int index) {
|
a506beff
吴启风
feat:先声sdk方法找不到问题...
|
78
|
return _readingPagerItem(bloc.entity!.readings![index]);
|
2a427e12
吴启风
feat:绘本静态ui基本完成
|
79
80
81
|
}),
Container(
color: Colors.transparent,
|
5b923179
吴启风
feat:导航栏优化
|
82
|
height: kToolbarHeight,
|
2a427e12
吴启风
feat:绘本静态ui基本完成
|
83
84
85
86
87
|
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Padding(
padding:
|
82c8633c
biao
音频添加 页面优化
|
88
|
EdgeInsets.only(left: ScreenUtil().bottomBarHeight),
|
2a427e12
吴启风
feat:绘本静态ui基本完成
|
89
90
|
child: IconButton(
onPressed: () {
|
82c8633c
biao
音频添加 页面优化
|
91
92
93
94
95
|
popPage(data: {
'currentStep': bloc.currentPage,
'courseLessonId': bloc.courseLessonId,
'isCompleted': bloc.isLastPage(),
});
|
2a427e12
吴启风
feat:绘本静态ui基本完成
|
96
97
98
|
},
icon: Image.asset(
'back_around'.assetPng,
|
5b923179
吴启风
feat:导航栏优化
|
99
100
|
width: 40.w,
height: 40.h,
|
2a427e12
吴启风
feat:绘本静态ui基本完成
|
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
|
)),
),
Container(
height: 32.h,
padding: EdgeInsets.symmetric(horizontal: 27.w),
decoration: BoxDecoration(
color: const Color(0xFF00B6F1),
borderRadius: BorderRadius.circular(15.r),
border: Border.all(
width: 1.0,
color: const Color(0xFF140C10),
),
),
alignment: Alignment.center,
child: Text(
|
a506beff
吴启风
feat:先声sdk方法找不到问题...
|
116
|
'${bloc.currentPage}/${bloc.dataCount()}',
|
2a427e12
吴启风
feat:绘本静态ui基本完成
|
117
118
119
120
121
|
style: TextStyle(fontSize: 20.sp, color: Colors.white),
),
),
Padding(
|
a506beff
吴启风
feat:先声sdk方法找不到问题...
|
122
123
|
padding: EdgeInsets.only(
right: 15.w + ScreenUtil().bottomBarHeight),
|
2a427e12
吴启风
feat:绘本静态ui基本完成
|
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
152
153
154
155
|
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(
|
4d8b0da4
吴启风
feat:绘本跟读底部ui优化
|
156
|
color: const Color(0x80FFFFFF),
|
2a427e12
吴启风
feat:绘本静态ui基本完成
|
157
158
|
child: Row(
children: [
|
5e2bbbd3
biao
添加音频
|
159
|
5.horizontalSpace,
|
b81332ca
吴启风
feat:喇叭组件替换
|
160
161
162
163
164
165
166
167
168
|
SpeakerWidget(
isPlaying:
bloc.voicePlayState == VoicePlayState.playing &&
bloc.isOriginAudioPlaying,
// 控制动画播放
isClickable: !bloc.isRecording,
// 控制是否可点击
width: 42.w,
height: 42.w,
|
a506beff
吴启风
feat:先声sdk方法找不到问题...
|
169
|
onTap: () {
|
a506beff
吴启风
feat:先声sdk方法找不到问题...
|
170
171
|
bloc.add(PlayOriginalAudioEvent(null));
},
|
2a427e12
吴启风
feat:绘本静态ui基本完成
|
172
173
174
175
176
177
|
),
SizedBox(
width: 10.w,
),
Expanded(
child: Text(
|
4d8b0da4
吴启风
feat:绘本跟读底部ui优化
|
178
|
bloc.readingContent(),
|
82c8633c
biao
音频添加 页面优化
|
179
180
181
182
183
|
style: TextStyle(
color: const Color(0xFF333333), fontSize: 21.sp),
maxLines: 2,
overflow: TextOverflow.ellipsis,
)),
|
2a427e12
吴启风
feat:绘本静态ui基本完成
|
184
185
186
|
SizedBox(
width: 10.w,
),
|
c623c7b2
吴启风
feat:语音跟读作答结果动效&语音
|
187
188
|
RecorderWidget(
isPlaying: bloc.isRecording,
|
b81332ca
吴启风
feat:喇叭组件替换
|
189
190
|
isClickable:
bloc.voicePlayState != VoicePlayState.playing,
|
c623c7b2
吴启风
feat:语音跟读作答结果动效&语音
|
191
192
193
194
195
196
|
width: 60.w,
height: 60.w,
onTap: () {
if (bloc.isRecording) {
bloc.add(XSVoiceStopEvent());
} else {
|
b81332ca
吴启风
feat:喇叭组件替换
|
197
198
|
bloc.add(XSVoiceStartEvent(bloc.readingContent(),
'0', UserUtil.getUser()?.id.toString()));
|
c623c7b2
吴启风
feat:语音跟读作答结果动效&语音
|
199
200
201
|
}
},
),
|
2a427e12
吴启风
feat:绘本静态ui基本完成
|
202
203
204
|
SizedBox(
width: 10.w,
),
|
53e9e6db
吴启风
feat:绘本语音评测逻辑
|
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
|
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,
height: 33.h,
width: 33.w,
),
)),
|
2a427e12
吴启风
feat:绘本静态ui基本完成
|
222
|
],
|
1dc46cf7
吴启风
feat:绘本ui
|
223
|
),
|
2a427e12
吴启风
feat:绘本静态ui基本完成
|
224
|
),
|
1dc46cf7
吴启风
feat:绘本ui
|
225
226
227
228
229
230
|
)
],
),
);
});
|
a506beff
吴启风
feat:先声sdk方法找不到问题...
|
231
|
Widget _readingPagerItem(CourseProcessReadings readings) =>
|
2a427e12
吴启风
feat:绘本静态ui基本完成
|
232
233
|
BlocBuilder<ReadingPageBloc, ReadingPageState>(builder: (context, state) {
return Stack(
|
1dc46cf7
吴启风
feat:绘本ui
|
234
|
children: [
|
065022b7
吴启风
feat:绘本评测反馈弹窗+原音播...
|
235
|
Positioned.fill(
|
82c8633c
biao
音频添加 页面优化
|
236
|
child: Image.network(readings.picUrl ?? '', fit: BoxFit.cover),
|
065022b7
吴启风
feat:绘本评测反馈弹窗+原音播...
|
237
|
),
|
1dc46cf7
吴启风
feat:绘本ui
|
238
239
240
241
|
],
);
});
}
|