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
5
|
import 'package:flutter_easyloading/flutter_easyloading.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:wow_english/common/extension/string_extension.dart';
|
60e47f7c
liangchengyou
feat:课程选择功能
|
6
|
import 'package:wow_english/home/bloc/home_bloc.dart';
|
d35a4e87
liangchengyou
feat:磨耳朵功能UI
|
7
|
import 'package:wow_english/home/widgets/home_lesson_item_widget.dart';
|
95edef4f
liangchengyou
feat:更新适配代码
|
8
|
import 'package:wow_english/home/widgets/home_tab_header_widget.dart';
|
60e47f7c
liangchengyou
feat:课程选择功能
|
9
|
import 'package:wow_english/route/route.dart';
|
95edef4f
liangchengyou
feat:更新适配代码
|
10
11
12
13
14
15
|
class HomePage extends StatelessWidget {
const HomePage({super.key});
@override
Widget build(BuildContext context) {
|
60e47f7c
liangchengyou
feat:课程选择功能
|
16
|
return BlocProvider(
|
d35a4e87
liangchengyou
feat:磨耳朵功能UI
|
17
18
19
|
create: (context) => HomeBloc(PageController(
initialPage: 0,
)),
|
60e47f7c
liangchengyou
feat:课程选择功能
|
20
21
22
23
24
25
26
27
|
child: _HomePageView(),
);
}
}
class _HomePageView extends StatelessWidget {
void _headerActionEvent(HeaderActionType type) {
if (type == HeaderActionType.video) {
|
9d080046
liangchengyou
feat:视频跟读逻辑
|
28
|
Navigator.of(AppRouter.context).pushNamed(AppRouteName.reAfter);
|
60e47f7c
liangchengyou
feat:课程选择功能
|
29
30
31
|
} else if (type == HeaderActionType.phase) {
Navigator.of(AppRouter.context).pushNamed(AppRouteName.lesson);
} else if (type == HeaderActionType.listen) {
|
d35a4e87
liangchengyou
feat:磨耳朵功能UI
|
32
33
|
Navigator.of(AppRouter.context).pushNamed(AppRouteName.listen);
} else if (type == HeaderActionType.shop) {
|
d1d32220
liangchengyou
feat:兑换课程+购买记录
|
34
|
Navigator.of(AppRouter.context).pushNamed(AppRouteName.shop);
|
60e47f7c
liangchengyou
feat:课程选择功能
|
35
36
37
38
39
40
41
42
43
|
} else {
}
}
@override
Widget build(BuildContext context) {
return BlocListener<HomeBloc,HomeState>(
listener: (context, state){},
|
d35a4e87
liangchengyou
feat:磨耳朵功能UI
|
44
|
child: _homeView(),
|
95edef4f
liangchengyou
feat:更新适配代码
|
45
46
|
);
}
|
d35a4e87
liangchengyou
feat:磨耳朵功能UI
|
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
|
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(
child: PageView.builder(
itemCount: 10,
controller: bloc.pageController,
pageSnapping: false,
onPageChanged: (int index) {
EasyLoading.showToast(index.toString());
},
itemBuilder: (BuildContext context,int index){
return const HomeLessonItem();
|
d35a4e87
liangchengyou
feat:磨耳朵功能UI
|
73
74
75
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
109
110
111
112
113
114
|
})
,
),
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(
'3/67',
style: TextStyle(
color: Colors.white,
fontSize: 12.sp
),
),
),
Image.asset(
'blue-positive'.assetPng,
height: 47.h,
width: 80.w,
),
],
),
),
)
],
),
),
),
);
});
|
95edef4f
liangchengyou
feat:更新适配代码
|
115
|
}
|