home_page.dart
4.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
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
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
115
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter_easyloading/flutter_easyloading.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:wow_english/common/extension/string_extension.dart';
import 'package:wow_english/home/bloc/home_bloc.dart';
import 'package:wow_english/home/widgets/home_lesson_item_widget.dart';
import 'package:wow_english/home/widgets/home_tab_header_widget.dart';
import 'package:wow_english/route/route.dart';
class HomePage extends StatelessWidget {
const HomePage({super.key});
@override
Widget build(BuildContext context) {
return BlocProvider(
create: (context) => HomeBloc(PageController(
initialPage: 0,
)),
child: _HomePageView(),
);
}
}
class _HomePageView extends StatelessWidget {
void _headerActionEvent(HeaderActionType type) {
if (type == HeaderActionType.video) {
Navigator.of(AppRouter.context).pushNamed(AppRouteName.reAfter);
} else if (type == HeaderActionType.phase) {
Navigator.of(AppRouter.context).pushNamed(AppRouteName.lesson);
} else if (type == HeaderActionType.listen) {
Navigator.of(AppRouter.context).pushNamed(AppRouteName.listen);
} else if (type == HeaderActionType.shop) {
Navigator.of(AppRouter.context).pushNamed(AppRouteName.shop);
} else {
}
}
@override
Widget build(BuildContext context) {
return BlocListener<HomeBloc,HomeState>(
listener: (context, state){},
child: _homeView(),
);
}
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();
})
,
),
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,
),
],
),
),
)
],
),
),
),
);
});
}