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';
|
1dc46cf7
吴启风
feat:绘本ui
|
6
|
|
a506beff
吴启风
feat:先声sdk方法找不到问题...
|
7
8
|
import '../../common/core/user_util.dart';
import '../../models/course_process_entity.dart';
|
1dc46cf7
吴启风
feat:绘本ui
|
9
10
|
import 'bloc/reading_bloc.dart';
|
2a427e12
吴启风
feat:绘本静态ui基本完成
|
11
|
class ReadingPage extends StatelessWidget {
|
53e9e6db
吴启风
feat:绘本语音评测逻辑
|
12
13
14
|
const ReadingPage({super.key, this.courseLessonId});
final String? courseLessonId;
|
1dc46cf7
吴启风
feat:绘本ui
|
15
16
17
18
|
@override
Widget build(BuildContext context) {
return BlocProvider(
|
53e9e6db
吴启风
feat:绘本语音评测逻辑
|
19
20
21
|
create: (_) => ReadingPageBloc(PageController(), courseLessonId ?? '')
..add(InitBlocEvent())
..add(RequestDataEvent()),
|
1dc46cf7
吴启风
feat:绘本ui
|
22
23
24
25
26
27
28
29
30
|
child: _ReadingPage(),
);
}
}
class _ReadingPage extends StatelessWidget {
@override
Widget build(BuildContext context) {
return BlocListener<ReadingPageBloc, ReadingPageState>(
|
a506beff
吴启风
feat:先声sdk方法找不到问题...
|
31
32
33
34
35
36
37
38
39
|
listener: (context, state) {
if (state is RequestDataState) {
// context.read<TopicPictureBloc>().add(CurrentPageIndexChangeEvent(0));
print('reading RequestDataState=$state');
///刷新页面
context.read<ReadingPageBloc>().add(CurrentPageIndexChangeEvent(0));
}
},
|
2a427e12
吴启风
feat:绘本静态ui基本完成
|
40
|
child: _readingPageView(),
|
1dc46cf7
吴启风
feat:绘本ui
|
41
42
43
|
);
}
|
2a427e12
吴启风
feat:绘本静态ui基本完成
|
44
45
46
|
Widget _readingPageView() => BlocBuilder<ReadingPageBloc, ReadingPageState>(
buildWhen: (_, s) => s is CurrentPageIndexState,
builder: (context, state) {
|
1dc46cf7
吴启风
feat:绘本ui
|
47
48
49
50
51
|
final bloc = BlocProvider.of<ReadingPageBloc>(context);
return Container(
color: Colors.white,
child: Stack(
children: [
|
2a427e12
吴启风
feat:绘本静态ui基本完成
|
52
|
PageView.builder(
|
a506beff
吴启风
feat:先声sdk方法找不到问题...
|
53
|
itemCount: bloc.dataCount(),
|
2a427e12
吴启风
feat:绘本静态ui基本完成
|
54
55
56
57
58
|
controller: bloc.pageController,
onPageChanged: (int index) {
bloc.add(CurrentPageIndexChangeEvent(index));
},
itemBuilder: (context, int index) {
|
a506beff
吴启风
feat:先声sdk方法找不到问题...
|
59
|
return _readingPagerItem(bloc.entity!.readings![index]);
|
2a427e12
吴启风
feat:绘本静态ui基本完成
|
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
|
}),
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方法找不到问题...
|
93
|
'${bloc.currentPage}/${bloc.dataCount()}',
|
2a427e12
吴启风
feat:绘本静态ui基本完成
|
94
95
96
97
98
|
style: TextStyle(fontSize: 20.sp, color: Colors.white),
),
),
Padding(
|
a506beff
吴启风
feat:先声sdk方法找不到问题...
|
99
100
|
padding: EdgeInsets.only(
right: 15.w + ScreenUtil().bottomBarHeight),
|
2a427e12
吴启风
feat:绘本静态ui基本完成
|
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
|
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方法找不到问题...
|
137
138
139
140
141
|
GestureDetector(
onTap: () {
if (bloc.isRecording) {
return;
}
|
a506beff
吴启风
feat:先声sdk方法找不到问题...
|
142
143
144
|
bloc.add(PlayOriginalAudioEvent(null));
},
child: Image.asset(
|
53e9e6db
吴启风
feat:绘本语音评测逻辑
|
145
146
147
148
|
bloc.voicePlayState == VoicePlayState.playing &&
bloc.isOriginAudioPlaying
? 'reade_answer'.assetGif
: 'voice'.assetPng,
|
a506beff
吴启风
feat:先声sdk方法找不到问题...
|
149
150
151
|
height: 40.h,
width: 45.w,
),
|
2a427e12
吴启风
feat:绘本静态ui基本完成
|
152
153
154
155
156
157
|
),
SizedBox(
width: 10.w,
),
Expanded(
child: Text(
|
a506beff
吴启风
feat:先声sdk方法找不到问题...
|
158
|
bloc.currentPageData()?.word ?? '',
|
2a427e12
吴启风
feat:绘本静态ui基本完成
|
159
160
161
162
163
164
165
166
|
style: TextStyle(
color: const Color(0xFF333333), fontSize: 21.sp),
maxLines: 2,
overflow: TextOverflow.ellipsis,
)),
SizedBox(
width: 10.w,
),
|
a506beff
吴启风
feat:先声sdk方法找不到问题...
|
167
168
169
|
GestureDetector(
onTap: () {
if (bloc.isRecording) {
|
53e9e6db
吴启风
feat:绘本语音评测逻辑
|
170
171
172
173
174
175
|
bloc.add(XSVoiceStopEvent());
} else {
bloc.add(XSVoiceStartEvent(
bloc.currentPageData()?.word ?? '',
'0',
UserUtil.getUser()!.id.toString()));
|
a506beff
吴启风
feat:先声sdk方法找不到问题...
|
176
|
}
|
a506beff
吴启风
feat:先声sdk方法找不到问题...
|
177
178
179
180
181
182
|
},
child: Image.asset(
'micro_phone'.assetPng,
height: 47.h,
width: 47.w,
)),
|
2a427e12
吴启风
feat:绘本静态ui基本完成
|
183
184
185
|
SizedBox(
width: 10.w,
),
|
53e9e6db
吴启风
feat:绘本语音评测逻辑
|
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
|
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基本完成
|
203
|
],
|
1dc46cf7
吴启风
feat:绘本ui
|
204
|
),
|
2a427e12
吴启风
feat:绘本静态ui基本完成
|
205
|
),
|
1dc46cf7
吴启风
feat:绘本ui
|
206
207
208
209
210
211
|
)
],
),
);
});
|
a506beff
吴启风
feat:先声sdk方法找不到问题...
|
212
|
Widget _readingPagerItem(CourseProcessReadings readings) =>
|
2a427e12
吴启风
feat:绘本静态ui基本完成
|
213
214
|
BlocBuilder<ReadingPageBloc, ReadingPageState>(builder: (context, state) {
return Stack(
|
1dc46cf7
吴启风
feat:绘本ui
|
215
|
children: [
|
a506beff
吴启风
feat:先声sdk方法找不到问题...
|
216
217
|
Image.network(readings.picUrl ?? '',
height: double.infinity, width: double.infinity),
|
1dc46cf7
吴启风
feat:绘本ui
|
218
219
220
221
|
],
);
});
}
|