This commit is contained in:
18631081161 2024-11-23 15:35:46 +08:00
parent 4e8d51f186
commit 8fcae8949f
2 changed files with 36 additions and 22 deletions

View File

@ -58,6 +58,9 @@ class _GamePageState extends State<GamePage> {
@override
Widget build(BuildContext context) {
final size = MediaQuery.of(context).size;
final w96 = size.width / 3.75;
return Scaffold(
backgroundColor: Color(0xFF17181A),
body: Column(
@ -131,13 +134,13 @@ class _GamePageState extends State<GamePage> {
children: [
///
Container(
width: 96,
width: w96,
color: Colors.black26,
child: ListView.builder(
itemCount: typeList.length,
padding: EdgeInsets.zero,
itemBuilder: (BuildContext context, int index) {
return _typeItem(index);
return _typeItem(index, context);
}),
),
@ -149,17 +152,17 @@ class _GamePageState extends State<GamePage> {
Expanded(
child: Container(
margin: EdgeInsets.only(left: 14, right: 14),
margin: const EdgeInsets.only(left: 14, right: 14),
child: GridView.builder(
itemCount: gameList.length,
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 2, //
mainAxisSpacing: 18.0,
crossAxisSpacing: 10.0,
childAspectRatio: 0.57837,
),
itemBuilder: (context, index) {
return _gameItem(index, gameList[index]);
return _gameItem(index, gameList[index], context);
}),
),
)
@ -171,7 +174,12 @@ class _GamePageState extends State<GamePage> {
);
}
_typeItem(index) {
_typeItem(index, context) {
final size = MediaQuery.of(context).size;
final h35 = size.width / 10.285714285714;
final t20 = size.width / 18;
final w21 = size.width / 17.142857142857;
return GestureDetector(
behavior: HitTestBehavior.opaque,
onTap: () {
@ -181,8 +189,8 @@ class _GamePageState extends State<GamePage> {
_viewModel.getGameList(typeList[index].id);
},
child: Container(
height: 35,
margin: EdgeInsets.only(top: 20),
height: h35,
margin: EdgeInsets.only(top: t20),
child: Column(
children: [
Text(
@ -191,7 +199,7 @@ class _GamePageState extends State<GamePage> {
),
currentTypeIndex == index
? Container(
width: 21,
width: w21,
height: 3,
color: Colors.white,
margin: EdgeInsets.only(top: 5),
@ -203,7 +211,13 @@ class _GamePageState extends State<GamePage> {
);
}
_gameItem(index, GameListBean data) {
_gameItem(index, GameListBean data, context) {
final size = MediaQuery.of(context).size;
final w107 = size.width / 3.3644859813084;
final w75 = size.width / 6.3157894736842;
final h32 = size.width / 11.25;
final c18 = size.width / 20;
return GestureDetector(
onTap: () {
Navigator.push(
@ -218,31 +232,31 @@ class _GamePageState extends State<GamePage> {
child: Column(
children: [
CachedNetworkImage(
width: 107,
height: 107,
width: w107,
height: w107,
imageUrl: '${data.gameIconImage}',
errorWidget: (context, url, error) => const Icon(Icons.error),
),
Container(
width: 107,
margin: EdgeInsets.only(top: 11),
width: w107,
margin: const EdgeInsets.only(top: 11),
alignment: Alignment.center,
child: Text(
'${data.gameName}',
overflow: TextOverflow.ellipsis,
style: TextStyle(fontSize: 14, color: Color(0xFFD6D6D7)),
style: const TextStyle(fontSize: 14, color: Color(0xFFD6D6D7)),
),
),
Container(
width: 75,
height: 32,
width: w75,
height: h32,
alignment: Alignment.center,
margin: EdgeInsets.only(top: 11),
margin: const EdgeInsets.only(top: 11),
decoration: BoxDecoration(
color: Color(0xFF074CE7),
borderRadius: BorderRadius.all(Radius.circular(18)),
color: const Color(0xFF074CE7),
borderRadius: BorderRadius.all(Radius.circular(c18)),
),
child: Text(
child: const Text(
"打开",
style: TextStyle(color: Colors.white, fontSize: 13),
),

View File

@ -10,7 +10,7 @@ import 'game_model.dart';
class GamePlayTimePage extends StatefulWidget {
final String gameId;
GamePlayTimePage({super.key, required this.gameId});
const GamePlayTimePage({super.key, required this.gameId});
@override
State<GamePlayTimePage> createState() => _GamePlaytimeState();