From c9ca6ac6e3bd08c66d0774ebcf5009abd44c55ba Mon Sep 17 00:00:00 2001 From: zhuce <821293938@qq.com> Date: Thu, 22 Feb 2024 19:22:03 +0800 Subject: [PATCH] ImageBlock --- lib/pages/home/home_page.dart | 12 ++++++++---- lib/pages/home/widgets/image_block.dart | 23 +++++++++++++++++++++++ lib/pages/home/widgets/number_block.dart | 22 +++++++++++----------- 3 files changed, 42 insertions(+), 15 deletions(-) create mode 100644 lib/pages/home/widgets/image_block.dart diff --git a/lib/pages/home/home_page.dart b/lib/pages/home/home_page.dart index 86be8b3..63d4799 100644 --- a/lib/pages/home/home_page.dart +++ b/lib/pages/home/home_page.dart @@ -1,5 +1,6 @@ import 'package:amap_flutter_map/amap_flutter_map.dart'; import 'package:autosos_flutter/const_config.dart'; +import 'package:autosos_flutter/pages/home/widgets/image_block.dart'; import 'package:autosos_flutter/pages/home/widgets/number_block.dart'; import 'package:flutter/material.dart'; @@ -35,8 +36,7 @@ class _HomePageState extends State { } Widget buildTopWidget() { - return ListView( - shrinkWrap: true, + return Column( children: [ Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, @@ -80,14 +80,18 @@ class _HomePageState extends State { ) ], ), - Padding(padding:const EdgeInsets.only(top:20), child: GridView.count( + Padding(padding:const EdgeInsets.only(top:0), child: GridView.count( + physics: const NeverScrollableScrollPhysics(), shrinkWrap: true, crossAxisCount: 3, - childAspectRatio: 1.0, + childAspectRatio: 1.5, children: const [ NumberBlock(title: "钱包(元)", number: "111"), NumberBlock(title: "总订单数", number: "111"), NumberBlock(title: "总金额(元)", number: "111"), + ImageBlock(title: "提现",imgUrl: "images/3.0x/tixian_ic.png"), + ImageBlock(title: "个人中心",imgUrl: "images/3.0x/gerenzhongxin_ic.png"), + ImageBlock(title: "设置",imgUrl: "images/3.0x/shezhi_ic.png"), ], ),) ], diff --git a/lib/pages/home/widgets/image_block.dart b/lib/pages/home/widgets/image_block.dart new file mode 100644 index 0000000..e1a6c76 --- /dev/null +++ b/lib/pages/home/widgets/image_block.dart @@ -0,0 +1,23 @@ +import 'package:flutter/material.dart'; + +class ImageBlock extends StatelessWidget { + final String title; + final String imgUrl; + + const ImageBlock({super.key, required this.title, required this.imgUrl}); + + @override + Widget build(BuildContext context) { + return Column( + mainAxisAlignment: MainAxisAlignment.center, + mainAxisSize: MainAxisSize.min, + children: [ + Image.asset(imgUrl), + Text( + title, + style: const TextStyle(fontSize: 14, color: Colors.black), + ) + ], + ); + } +} diff --git a/lib/pages/home/widgets/number_block.dart b/lib/pages/home/widgets/number_block.dart index abd8e17..02f669a 100644 --- a/lib/pages/home/widgets/number_block.dart +++ b/lib/pages/home/widgets/number_block.dart @@ -8,25 +8,25 @@ class NumberBlock extends StatelessWidget { @override Widget build(BuildContext context) { - return ListView( - shrinkWrap: true, - children: [ - Center( - child: Text( - "$number", + return Padding( + padding: const EdgeInsets.all(0), + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + mainAxisSize: MainAxisSize.min, + children: [ + Text( + number, style: const TextStyle( fontSize: 23, fontWeight: FontWeight.bold, ), ), - ), - Center( - child: Text( + Text( title, style: const TextStyle(fontSize: 12, color: Colors.grey), ), - ) - ], + ], + ), ); } }