a4c3106a
吴启风
feat:游戏列表页
|
1
2
3
4
|
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
a4c3106a
吴启风
feat:游戏列表页
|
5
6
7
8
9
10
|
import 'package:wow_english/common/widgets/we_app_bar.dart';
import 'package:wow_english/pages/games/state.dart';
import '../games/event.dart';
import 'bloc.dart';
|
a4c3106a
吴启风
feat:游戏列表页
|
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
class GamesPage extends StatelessWidget {
const GamesPage({super.key});
@override
Widget build(BuildContext context) {
return BlocProvider(
create: (BuildContext context) => GamesBloc()..add(InitEvent()),
child: Builder(builder: (context) => _GamesPageView()),
);
}
}
class _GamesPageView extends StatelessWidget {
@override
Widget build(BuildContext context) {
return BlocListener<GamesBloc, GamesState>(
|
2879454a
吴启风
feat:调通支付宝支付&游戏列表页
|
27
|
listener: (context, state) {},
|
a4c3106a
吴启风
feat:游戏列表页
|
28
29
|
child: Scaffold(
appBar: const WEAppBar(
|
2879454a
吴启风
feat:调通支付宝支付&游戏列表页
|
30
|
titleText: '游戏专区',
|
a4c3106a
吴启风
feat:游戏列表页
|
31
32
33
34
35
36
37
|
centerTitle: false,
),
body: _gamesView(),
),
);
}
|
2879454a
吴启风
feat:调通支付宝支付&游戏列表页
|
38
39
|
Widget _gamesView() =>
BlocBuilder<GamesBloc, GamesState>(builder: (context, state) {
|
a4c3106a
吴启风
feat:游戏列表页
|
40
|
final bloc = BlocProvider.of<GamesBloc>(context);
|
2879454a
吴启风
feat:调通支付宝支付&游戏列表页
|
41
|
return Container(
|
e62c1a97
吴启风
feat:1、游戏列表页优化;2、...
|
42
43
|
alignment: Alignment.center,
margin: EdgeInsets.symmetric(horizontal: 40.0.w),
|
2879454a
吴启风
feat:调通支付宝支付&游戏列表页
|
44
45
|
child: GridView.builder(
padding: EdgeInsets.zero,
|
e62c1a97
吴启风
feat:1、游戏列表页优化;2、...
|
46
47
|
// 让 GridView 只占用所需的空间
shrinkWrap: true,
|
2879454a
吴启风
feat:调通支付宝支付&游戏列表页
|
48
49
|
// physics: const NeverScrollableScrollPhysics(),
gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(
|
e62c1a97
吴启风
feat:1、游戏列表页优化;2、...
|
50
|
crossAxisCount: 4,
|
2879454a
吴启风
feat:调通支付宝支付&游戏列表页
|
51
52
|
crossAxisSpacing: 10,
mainAxisSpacing: 10,
|
e62c1a97
吴启风
feat:1、游戏列表页优化;2、...
|
53
|
childAspectRatio: 0.75,
|
a4c3106a
吴启风
feat:游戏列表页
|
54
|
),
|
2879454a
吴启风
feat:调通支付宝支付&游戏列表页
|
55
56
57
58
59
60
61
62
|
itemCount: bloc.listData.length,
itemBuilder: (BuildContext context, int index) {
final gameEntity = bloc.listData[index];
return GestureDetector(
onTap: () {
bloc.add(GotoGamePageEvent(gameEntity.id));
},
child: Column(
|
e62c1a97
吴启风
feat:1、游戏列表页优化;2、...
|
63
|
mainAxisAlignment: MainAxisAlignment.center,
|
2879454a
吴启风
feat:调通支付宝支付&游戏列表页
|
64
|
children: [
|
e62c1a97
吴启风
feat:1、游戏列表页优化;2、...
|
65
66
67
68
69
70
|
//图片增加圆角
ClipRRect(
borderRadius: BorderRadius.circular(10),
child: Image.asset(gameEntity.imageName,
width: 150, height: 150)),
10.verticalSpace,
|
2879454a
吴启风
feat:调通支付宝支付&游戏列表页
|
71
72
|
Text(gameEntity.name,
style: TextStyle(
|
e62c1a97
吴启风
feat:1、游戏列表页优化;2、...
|
73
|
fontSize: 16.sp,
|
2879454a
吴启风
feat:调通支付宝支付&游戏列表页
|
74
75
76
77
78
|
color: const Color(0xFF140C10)))
],
),
);
}));
|
a4c3106a
吴启风
feat:游戏列表页
|
79
|
});
|
a4c3106a
吴启风
feat:游戏列表页
|
80
|
}
|