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