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