Compare commits

...

4 Commits

Author SHA1 Message Date
zhuce b53e42a43f 背景 2024-02-22 19:36:35 +08:00
zhuce c9ca6ac6e3 ImageBlock 2024-02-22 19:22:03 +08:00
zhuce 8bd99d02f1 NumberBlock 2024-02-22 18:31:34 +08:00
zhuce 3e6a3c7883 首页topWidget第一行 2024-02-22 18:04:03 +08:00
4 changed files with 151 additions and 2 deletions

View File

@ -1,5 +1,7 @@
import 'package:amap_flutter_map/amap_flutter_map.dart'; import 'package:amap_flutter_map/amap_flutter_map.dart';
import 'package:autosos_flutter/const_config.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'; import 'package:flutter/material.dart';
class HomePage extends StatefulWidget { class HomePage extends StatefulWidget {
@ -10,6 +12,8 @@ class HomePage extends StatefulWidget {
} }
class _HomePageState extends State<HomePage> { class _HomePageState extends State<HomePage> {
bool enabled = false;
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
const AMapWidget map = AMapWidget( const AMapWidget map = AMapWidget(
@ -18,9 +22,95 @@ class _HomePageState extends State<HomePage> {
apiKey: ConstConfig.amapApiKeys, apiKey: ConstConfig.amapApiKeys,
); );
return Scaffold( return Scaffold(
body: Column( appBar: AppBar(
title: const Text(
"首页",
style: TextStyle(color: Colors.white),
),
actions: const [
Text("今日在线时长?小时", style: TextStyle(color: Colors.white))
],
flexibleSpace: Container(
decoration: const BoxDecoration(
image: DecorationImage(
image: AssetImage("images/4.0x/home_top_bg.png"),
fit: BoxFit.cover)),
)),
backgroundColor: const Color(0xFFF3F3F3),
body: Padding(
padding: const EdgeInsets.all(10),
child: Column(
children: [buildTopWidget()],
),
));
}
Widget buildTopWidget() {
return Container(
padding: const EdgeInsets.all(20),
decoration: const BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.all(Radius.circular(5))),
child: Column(
mainAxisSize: MainAxisSize.min,
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [ children: [
Text("hello world") Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
const Row(
children: [
Text(
"接单中",
style: TextStyle(
fontSize: 23,
fontWeight: FontWeight.bold,
color: Colors.black),
)
],
),
Row(
children: [
Switch(
value: enabled,
onChanged: (value) => setState(() {
enabled = value;
}),
activeColor: Colors.red,
),
Container(
margin: const EdgeInsets.only(left: 10, right: 10),
width: 1,
height: 20,
color: Colors.grey,
),
Column(
children: [
enabled
? Image.asset("images/3.0x/order_receiving_star.png")
: Image.asset("images/3.0x/order_receiving_end.png"),
const Text("订单")
],
)
],
)
],
),
GridView.count(
physics: const NeverScrollableScrollPhysics(),
shrinkWrap: true,
crossAxisCount: 3,
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"),
],
),
], ],
), ),
); );

View File

@ -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),
)
],
);
}
}

View File

@ -0,0 +1,32 @@
import 'package:flutter/material.dart';
class NumberBlock extends StatelessWidget {
final String title;
final String number;
const NumberBlock({super.key, required this.title, required this.number});
@override
Widget build(BuildContext context) {
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,
),
),
Text(
title,
style: const TextStyle(fontSize: 12, color: Colors.grey),
),
],
),
);
}
}

View File

@ -63,6 +63,10 @@ flutter:
# To add assets to your application, add an assets section, like this: # To add assets to your application, add an assets section, like this:
assets: assets:
- images/ - images/
- images/1.5x/
- images/2.0x/
- images/3.0x/
- images/4.0x/
# An image asset can refer to one or more resolution-specific "variants", see # An image asset can refer to one or more resolution-specific "variants", see
# https://flutter.dev/assets-and-images/#resolution-aware # https://flutter.dev/assets-and-images/#resolution-aware