NumberBlock

main
zhuce 2024-02-22 18:31:34 +08:00
parent 3e6a3c7883
commit 8bd99d02f1
2 changed files with 99 additions and 56 deletions

View File

@ -1,5 +1,6 @@
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/number_block.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
class HomePage extends StatefulWidget { class HomePage extends StatefulWidget {
@ -15,71 +16,81 @@ class _HomePageState extends State<HomePage> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
const AMapWidget map = AMapWidget( const AMapWidget map = AMapWidget(
///SDK ///SDK
privacyStatement: ConstConfig.amapPrivacyStatement, privacyStatement: ConstConfig.amapPrivacyStatement,
apiKey: ConstConfig.amapApiKeys, apiKey: ConstConfig.amapApiKeys,
); );
return Scaffold( return Scaffold(
appBar: AppBar( appBar: AppBar(
title: const Text("首页"), title: const Text("首页"),
actions: const [Text("今日在线时长?小时")], actions: const [Text("今日在线时长?小时")],
),
body: Padding(
padding: const EdgeInsets.all(20),
child: Column(
children: [buildTopWidget()],
), ),
) body: Padding(
); padding: const EdgeInsets.all(20),
child: Column(
children: [buildTopWidget()],
),
));
} }
Widget buildTopWidget() { Widget buildTopWidget() {
return Expanded( return ListView(
child: Column( shrinkWrap: true,
children: [ children: [
Row( Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween, mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [ children: [
const Row( const Row(
children: [ children: [
Text( Text(
"接单中", "接单中",
style: TextStyle( style: TextStyle(
fontSize: 23, fontSize: 23,
fontWeight: FontWeight.bold, fontWeight: FontWeight.bold,
color: Colors.black), color: Colors.black),
) )
], ],
), ),
Row( Row(
children: [ children: [
Switch( Switch(
value: enabled, value: enabled,
onChanged: (value) => setState(() { onChanged: (value) =>
enabled = value; setState(() {
}), enabled = value;
activeColor: Colors.red, }),
), activeColor: Colors.red,
Container( ),
margin: const EdgeInsets.only(left: 10, right: 10), Container(
width: 1, margin: const EdgeInsets.only(left: 10, right: 10),
height: 20, width: 1,
color: Colors.grey, height: 20,
), color: Colors.grey,
Column( ),
children: [ Column(
enabled children: [
? Image.asset("images/3.0x/order_receiving_star.png") enabled
: Image.asset("images/3.0x/order_receiving_end.png"), ? Image.asset("images/3.0x/order_receiving_star.png")
const Text("订单") : Image.asset("images/3.0x/order_receiving_end.png"),
], const Text("订单")
) ],
], )
) ],
], )
) ],
], ),
), Padding(padding:const EdgeInsets.only(top:20), child: GridView.count(
shrinkWrap: true,
crossAxisCount: 3,
childAspectRatio: 1.0,
children: const [
NumberBlock(title: "钱包(元)", number: "111"),
NumberBlock(title: "总订单数", number: "111"),
NumberBlock(title: "总金额(元)", number: "111"),
],
),)
],
); );
} }
} }

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 ListView(
shrinkWrap: true,
children: [
Center(
child: Text(
"$number",
style: const TextStyle(
fontSize: 23,
fontWeight: FontWeight.bold,
),
),
),
Center(
child: Text(
title,
style: const TextStyle(fontSize: 12, color: Colors.grey),
),
)
],
);
}
}