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';
|
1ebed821
吴启风
feat:修复所有unit解锁态下...
|
11
|
import '../../common/widgets/throttledGesture_gesture_detector.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,
),
|
1ebed821
吴启风
feat:修复所有unit解锁态下...
|
189
190
|
ThrottledGestureDetector(
throttleTime: 1000,
|
a506beff
吴启风
feat:先声sdk方法找不到问题...
|
191
192
|
onTap: () {
if (bloc.isRecording) {
|
53e9e6db
吴启风
feat:绘本语音评测逻辑
|
193
194
195
|
bloc.add(XSVoiceStopEvent());
} else {
bloc.add(XSVoiceStartEvent(
|
4d8b0da4
吴启风
feat:绘本跟读底部ui优化
|
196
|
bloc.readingContent(),
|
53e9e6db
吴启风
feat:绘本语音评测逻辑
|
197
|
'0',
|
dae7f2fd
吴启风
feat:增加android端先声...
|
198
|
UserUtil.getUser()?.id.toString()));
|
a506beff
吴启风
feat:先声sdk方法找不到问题...
|
199
|
}
|
a506beff
吴启风
feat:先声sdk方法找不到问题...
|
200
201
|
},
child: Image.asset(
|
065022b7
吴启风
feat:绘本评测反馈弹窗+原音播...
|
202
203
204
|
bloc.isRecording
? 'micro_phone'.assetGif
: 'micro_phone'.assetPng,
|
a506beff
吴启风
feat:先声sdk方法找不到问题...
|
205
206
207
|
height: 47.h,
width: 47.w,
)),
|
2a427e12
吴启风
feat:绘本静态ui基本完成
|
208
209
210
|
SizedBox(
width: 10.w,
),
|
53e9e6db
吴启风
feat:绘本语音评测逻辑
|
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
|
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基本完成
|
228
|
],
|
1dc46cf7
吴启风
feat:绘本ui
|
229
|
),
|
2a427e12
吴启风
feat:绘本静态ui基本完成
|
230
|
),
|
1dc46cf7
吴启风
feat:绘本ui
|
231
232
233
234
235
236
|
)
],
),
);
});
|
a506beff
吴启风
feat:先声sdk方法找不到问题...
|
237
|
Widget _readingPagerItem(CourseProcessReadings readings) =>
|
2a427e12
吴启风
feat:绘本静态ui基本完成
|
238
239
|
BlocBuilder<ReadingPageBloc, ReadingPageState>(builder: (context, state) {
return Stack(
|
1dc46cf7
吴启风
feat:绘本ui
|
240
|
children: [
|
065022b7
吴启风
feat:绘本评测反馈弹窗+原音播...
|
241
|
Positioned.fill(
|
82c8633c
biao
音频添加 页面优化
|
242
|
child: Image.network(readings.picUrl ?? '', fit: BoxFit.cover),
|
065022b7
吴启风
feat:绘本评测反馈弹窗+原音播...
|
243
|
),
|
1dc46cf7
吴启风
feat:绘本ui
|
244
245
246
247
|
],
);
});
}
|