适配
This commit is contained in:
parent
4e8d51f186
commit
8fcae8949f
|
|
@ -58,6 +58,9 @@ class _GamePageState extends State<GamePage> {
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final size = MediaQuery.of(context).size;
|
final size = MediaQuery.of(context).size;
|
||||||
|
|
||||||
|
final w96 = size.width / 3.75;
|
||||||
|
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
backgroundColor: Color(0xFF17181A),
|
backgroundColor: Color(0xFF17181A),
|
||||||
body: Column(
|
body: Column(
|
||||||
|
|
@ -131,13 +134,13 @@ class _GamePageState extends State<GamePage> {
|
||||||
children: [
|
children: [
|
||||||
///游戏分类
|
///游戏分类
|
||||||
Container(
|
Container(
|
||||||
width: 96,
|
width: w96,
|
||||||
color: Colors.black26,
|
color: Colors.black26,
|
||||||
child: ListView.builder(
|
child: ListView.builder(
|
||||||
itemCount: typeList.length,
|
itemCount: typeList.length,
|
||||||
padding: EdgeInsets.zero,
|
padding: EdgeInsets.zero,
|
||||||
itemBuilder: (BuildContext context, int index) {
|
itemBuilder: (BuildContext context, int index) {
|
||||||
return _typeItem(index);
|
return _typeItem(index, context);
|
||||||
}),
|
}),
|
||||||
),
|
),
|
||||||
|
|
||||||
|
|
@ -149,17 +152,17 @@ class _GamePageState extends State<GamePage> {
|
||||||
|
|
||||||
Expanded(
|
Expanded(
|
||||||
child: Container(
|
child: Container(
|
||||||
margin: EdgeInsets.only(left: 14, right: 14),
|
margin: const EdgeInsets.only(left: 14, right: 14),
|
||||||
child: GridView.builder(
|
child: GridView.builder(
|
||||||
itemCount: gameList.length,
|
itemCount: gameList.length,
|
||||||
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
|
gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(
|
||||||
crossAxisCount: 2, // 两列
|
crossAxisCount: 2, // 两列
|
||||||
mainAxisSpacing: 18.0,
|
mainAxisSpacing: 18.0,
|
||||||
crossAxisSpacing: 10.0,
|
crossAxisSpacing: 10.0,
|
||||||
childAspectRatio: 0.57837,
|
childAspectRatio: 0.57837,
|
||||||
),
|
),
|
||||||
itemBuilder: (context, index) {
|
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(
|
return GestureDetector(
|
||||||
behavior: HitTestBehavior.opaque,
|
behavior: HitTestBehavior.opaque,
|
||||||
onTap: () {
|
onTap: () {
|
||||||
|
|
@ -181,8 +189,8 @@ class _GamePageState extends State<GamePage> {
|
||||||
_viewModel.getGameList(typeList[index].id);
|
_viewModel.getGameList(typeList[index].id);
|
||||||
},
|
},
|
||||||
child: Container(
|
child: Container(
|
||||||
height: 35,
|
height: h35,
|
||||||
margin: EdgeInsets.only(top: 20),
|
margin: EdgeInsets.only(top: t20),
|
||||||
child: Column(
|
child: Column(
|
||||||
children: [
|
children: [
|
||||||
Text(
|
Text(
|
||||||
|
|
@ -191,7 +199,7 @@ class _GamePageState extends State<GamePage> {
|
||||||
),
|
),
|
||||||
currentTypeIndex == index
|
currentTypeIndex == index
|
||||||
? Container(
|
? Container(
|
||||||
width: 21,
|
width: w21,
|
||||||
height: 3,
|
height: 3,
|
||||||
color: Colors.white,
|
color: Colors.white,
|
||||||
margin: EdgeInsets.only(top: 5),
|
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(
|
return GestureDetector(
|
||||||
onTap: () {
|
onTap: () {
|
||||||
Navigator.push(
|
Navigator.push(
|
||||||
|
|
@ -218,31 +232,31 @@ class _GamePageState extends State<GamePage> {
|
||||||
child: Column(
|
child: Column(
|
||||||
children: [
|
children: [
|
||||||
CachedNetworkImage(
|
CachedNetworkImage(
|
||||||
width: 107,
|
width: w107,
|
||||||
height: 107,
|
height: w107,
|
||||||
imageUrl: '${data.gameIconImage}',
|
imageUrl: '${data.gameIconImage}',
|
||||||
errorWidget: (context, url, error) => const Icon(Icons.error),
|
errorWidget: (context, url, error) => const Icon(Icons.error),
|
||||||
),
|
),
|
||||||
Container(
|
Container(
|
||||||
width: 107,
|
width: w107,
|
||||||
margin: EdgeInsets.only(top: 11),
|
margin: const EdgeInsets.only(top: 11),
|
||||||
alignment: Alignment.center,
|
alignment: Alignment.center,
|
||||||
child: Text(
|
child: Text(
|
||||||
'${data.gameName}',
|
'${data.gameName}',
|
||||||
overflow: TextOverflow.ellipsis,
|
overflow: TextOverflow.ellipsis,
|
||||||
style: TextStyle(fontSize: 14, color: Color(0xFFD6D6D7)),
|
style: const TextStyle(fontSize: 14, color: Color(0xFFD6D6D7)),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
Container(
|
Container(
|
||||||
width: 75,
|
width: w75,
|
||||||
height: 32,
|
height: h32,
|
||||||
alignment: Alignment.center,
|
alignment: Alignment.center,
|
||||||
margin: EdgeInsets.only(top: 11),
|
margin: const EdgeInsets.only(top: 11),
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: Color(0xFF074CE7),
|
color: const Color(0xFF074CE7),
|
||||||
borderRadius: BorderRadius.all(Radius.circular(18)),
|
borderRadius: BorderRadius.all(Radius.circular(c18)),
|
||||||
),
|
),
|
||||||
child: Text(
|
child: const Text(
|
||||||
"打开",
|
"打开",
|
||||||
style: TextStyle(color: Colors.white, fontSize: 13),
|
style: TextStyle(color: Colors.white, fontSize: 13),
|
||||||
),
|
),
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@ import 'game_model.dart';
|
||||||
class GamePlayTimePage extends StatefulWidget {
|
class GamePlayTimePage extends StatefulWidget {
|
||||||
final String gameId;
|
final String gameId;
|
||||||
|
|
||||||
GamePlayTimePage({super.key, required this.gameId});
|
const GamePlayTimePage({super.key, required this.gameId});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
State<GamePlayTimePage> createState() => _GamePlaytimeState();
|
State<GamePlayTimePage> createState() => _GamePlaytimeState();
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user