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