95edef4f
liangchengyou
feat:更新适配代码
|
1
|
import 'package:flutter/material.dart';
|
60e47f7c
liangchengyou
feat:课程选择功能
|
2
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
d35a4e87
liangchengyou
feat:磨耳朵功能UI
|
3
4
|
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:wow_english/common/extension/string_extension.dart';
|
8988aa69
liangchengyou
feat:首页+课程列表数据获取
|
5
6
|
import 'package:wow_english/models/course_entity.dart';
import 'package:wow_english/pages/home/widgets/home_bouns_item.dart';
|
4b358e22
liangchengyou
feat:调整文件结构
|
7
|
import 'package:wow_english/pages/home/widgets/home_tab_header_widget.dart';
|
8988aa69
liangchengyou
feat:首页+课程列表数据获取
|
8
|
import 'package:wow_english/pages/home/widgets/home_vidoe_item.dart';
|
60e47f7c
liangchengyou
feat:课程选择功能
|
9
|
import 'package:wow_english/route/route.dart';
|
95edef4f
liangchengyou
feat:更新适配代码
|
10
|
|
4b358e22
liangchengyou
feat:调整文件结构
|
11
12
|
import 'bloc/home_bloc.dart';
|
95edef4f
liangchengyou
feat:更新适配代码
|
13
|
class HomePage extends StatelessWidget {
|
8988aa69
liangchengyou
feat:首页+课程列表数据获取
|
14
15
16
17
|
const HomePage({super.key, this.moduleId});
/// 模块id
final String? moduleId;
|
95edef4f
liangchengyou
feat:更新适配代码
|
18
19
20
|
@override
Widget build(BuildContext context) {
|
60e47f7c
liangchengyou
feat:课程选择功能
|
21
|
return BlocProvider(
|
8988aa69
liangchengyou
feat:首页+课程列表数据获取
|
22
|
create: (context) => HomeBloc(moduleId)..requestData(),
|
60e47f7c
liangchengyou
feat:课程选择功能
|
23
24
25
26
27
28
29
30
|
child: _HomePageView(),
);
}
}
class _HomePageView extends StatelessWidget {
void _headerActionEvent(HeaderActionType type) {
if (type == HeaderActionType.video) {
|
9d080046
liangchengyou
feat:视频跟读逻辑
|
31
|
Navigator.of(AppRouter.context).pushNamed(AppRouteName.reAfter);
|
60e47f7c
liangchengyou
feat:课程选择功能
|
32
33
34
|
} else if (type == HeaderActionType.phase) {
Navigator.of(AppRouter.context).pushNamed(AppRouteName.lesson);
} else if (type == HeaderActionType.listen) {
|
d35a4e87
liangchengyou
feat:磨耳朵功能UI
|
35
36
|
Navigator.of(AppRouter.context).pushNamed(AppRouteName.listen);
} else if (type == HeaderActionType.shop) {
|
d1d32220
liangchengyou
feat:兑换课程+购买记录
|
37
|
Navigator.of(AppRouter.context).pushNamed(AppRouteName.shop);
|
056970d8
Key
feat: api
|
38
39
|
} else if (type == HeaderActionType.user) {
Navigator.of(AppRouter.context).pushNamed(AppRouteName.user);
|
60e47f7c
liangchengyou
feat:课程选择功能
|
40
|
} else {
|
624214d0
liangchengyou
feat:看题选字/选图UI和部分逻辑
|
41
|
// Navigator.of(AppRouter.context).pushNamed(AppRouteName.topicPic);
|
119ba920
liangchengyou
feat:视频播放器
|
42
|
// Navigator.of(AppRouter.context).pushNamed(AppRouteName.topicWord);
|
95e3448c
liangchengyou
feat:听音选图/选字
|
43
44
|
// Navigator.of(AppRouter.context).pushNamed(AppRouteName.lookVideo);
// Navigator.of(AppRouter.context).pushNamed(AppRouteName.voicePic);
|
725dc3f2
liangchengyou
feat:语音问答界面UI
|
45
46
|
// Navigator.of(AppRouter.context).pushNamed(AppRouteName.voiceWord);
Navigator.of(AppRouter.context).pushNamed(AppRouteName.voiceAnswer);
|
60e47f7c
liangchengyou
feat:课程选择功能
|
47
48
49
50
51
52
53
|
}
}
@override
Widget build(BuildContext context) {
return BlocListener<HomeBloc,HomeState>(
listener: (context, state){},
|
d35a4e87
liangchengyou
feat:磨耳朵功能UI
|
54
|
child: _homeView(),
|
95edef4f
liangchengyou
feat:更新适配代码
|
55
56
|
);
}
|
d35a4e87
liangchengyou
feat:磨耳朵功能UI
|
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
|
Widget _homeView() => BlocBuilder<HomeBloc,HomeState>(
builder: (context, state){
final bloc = BlocProvider.of<HomeBloc>(context);
return Scaffold(
body: Container(
color: Colors.white,
child: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
HomeTabHeaderWidget(
actionTap: (HeaderActionType type) {
_headerActionEvent(type);
},
),
Expanded(
|
65e33ae8
liangchengyou
feat:更新代码
|
74
|
child: ListView.builder(
|
ad8454ca
liangchengyou
feat:调整模型
|
75
|
itemCount: bloc.modelData?.totalCourseLesson,
|
65e33ae8
liangchengyou
feat:更新代码
|
76
77
|
scrollDirection: Axis.horizontal,
itemBuilder: (BuildContext context, int index){
|
8988aa69
liangchengyou
feat:首页+课程列表数据获取
|
78
79
80
81
82
83
84
85
86
87
88
|
String? title = bloc.modelData?.courseLessons?[index]?.name;
CourseCourseLessons? data = bloc.modelData?.courseLessons?[index];
if (data?.courseType == 5) {//彩蛋
return HomeBoundsItem(
imageUrl: data?.coverUrl,
);
} else {
return HomeVideoItem(
lessons: data,
);
}
|
d35a4e87
liangchengyou
feat:磨耳朵功能UI
|
89
|
})
|
d35a4e87
liangchengyou
feat:磨耳朵功能UI
|
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
|
),
SafeArea(
child: Padding(
padding: EdgeInsets.symmetric(horizontal: 13.w),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
SizedBox(
height: 47.h,
width: 80.w,
),
Container(
decoration: BoxDecoration(
color: Colors.blue,
borderRadius: BorderRadius.circular(14.5.r),
),
padding: EdgeInsets.symmetric(vertical: 8.h,horizontal: 24.w),
child: Text(
|
8988aa69
liangchengyou
feat:首页+课程列表数据获取
|
108
|
'${(bloc.modelData?.nowCourseLesson)}/${bloc.modelData?.totalCourseLesson}',
|
d35a4e87
liangchengyou
feat:磨耳朵功能UI
|
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
|
style: TextStyle(
color: Colors.white,
fontSize: 12.sp
),
),
),
Image.asset(
'blue-positive'.assetPng,
height: 47.h,
width: 80.w,
),
],
),
),
)
],
),
),
),
);
});
|
056970d8
Key
feat: api
|
130
|
}
|