From 8fcae8949f5c0a1979a8ec01df10cb012134a0b8 Mon Sep 17 00:00:00 2001 From: 18631081161 <2088094923@qq.com> Date: Sat, 23 Nov 2024 15:35:46 +0800 Subject: [PATCH] =?UTF-8?q?=E9=80=82=E9=85=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/tools/game/game_page.dart | 56 +++++++++++++++---------- lib/tools/game/game_play_time_page.dart | 2 +- 2 files changed, 36 insertions(+), 22 deletions(-) diff --git a/lib/tools/game/game_page.dart b/lib/tools/game/game_page.dart index cffb7ed..33b8b4d 100644 --- a/lib/tools/game/game_page.dart +++ b/lib/tools/game/game_page.dart @@ -58,6 +58,9 @@ class _GamePageState extends State { @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 { 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 { 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 { ); } - _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 { _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 { ), 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 { ); } - _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 { 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), ), diff --git a/lib/tools/game/game_play_time_page.dart b/lib/tools/game/game_play_time_page.dart index 1fe7634..a2c1c2c 100644 --- a/lib/tools/game/game_play_time_page.dart +++ b/lib/tools/game/game_play_time_page.dart @@ -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 createState() => _GamePlaytimeState();