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:autosos_flutter/const_config.dart';
import 'package:autosos_flutter/pages/home/widgets/number_block.dart';
import 'package:flutter/material.dart';
class HomePage extends StatefulWidget {
@ -15,71 +16,81 @@ class _HomePageState extends State<HomePage> {
@override
Widget build(BuildContext context) {
const AMapWidget map = AMapWidget(
///SDK
privacyStatement: ConstConfig.amapPrivacyStatement,
apiKey: ConstConfig.amapApiKeys,
);
return Scaffold(
appBar: AppBar(
title: const Text("首页"),
actions: const [Text("今日在线时长?小时")],
),
body: Padding(
padding: const EdgeInsets.all(20),
child: Column(
children: [buildTopWidget()],
appBar: AppBar(
title: const Text("首页"),
actions: const [Text("今日在线时长?小时")],
),
)
);
body: Padding(
padding: const EdgeInsets.all(20),
child: Column(
children: [buildTopWidget()],
),
));
}
Widget buildTopWidget() {
return Expanded(
child: Column(
children: [
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("订单")
],
)
],
)
],
)
],
),
return ListView(
shrinkWrap: true,
children: [
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("订单")
],
)
],
)
],
),
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),
),
)
],
);
}
}