This commit is contained in:
2024-01-04 16:41:51 +08:00
parent 55085ee563
commit 47f82097e2
22 changed files with 483 additions and 645 deletions

View File

@@ -0,0 +1,5 @@
library menu_component;
export './menu_view.dart';
export './menu_state.dart';
export './menu_logic.dart';

View File

@@ -0,0 +1,64 @@
import 'package:get/get.dart';
import 'menu_state.dart';
class MenuLogic extends GetxController {
final MenuState state = MenuState();
final List menuList = [
{
"icon": "https://pic.ziyuan.wang/user/guest/2023/12/ 1_fac68ecc764a6.png",
"title": "商品管理",
"page": "/good",
},
{
"icon": "https://pic.ziyuan.wang/user/guest/2023/12/ 1_fac68ecc764a6.png",
"title": "订单管理",
"page": "/order",
},
{
"icon": "https://pic.ziyuan.wang/user/guest/2023/12/ 1_fac68ecc764a6.png",
"title": "店铺设置",
"page": "/settings"
},
{
"icon": "https://pic.ziyuan.wang/user/guest/2023/12/ 1_fac68ecc764a6.png",
"title": "发布商品",
"page": "/addGood"
},
{
"icon": "https://pic.ziyuan.wang/user/guest/2023/12/ 1_fac68ecc764a6.png",
"title": "数据统计",
"page": "/data"
},
{
"icon":
"https://pic.ziyuan.wang/user/guest/2023/12/%201%20_1__eb4ee5cc67484.png",
"title": "提现管理",
"page": "/cash"
},
{
"icon":
"https://pic.ziyuan.wang/user/guest/2023/12/%201%20_1__eb4ee5cc67484.png",
"title": "员工管理",
"page": "/perm"
}
];
@override
void onReady() {
// TODO: implement onReady
super.onReady();
}
@override
void onClose() {
// TODO: implement onClose
super.onClose();
}
// 跳转页面
void goPage(String page) {
Get.toNamed(page);
}
}

View File

@@ -0,0 +1,5 @@
class MenuState {
MenuState() {
///Initialize variables
}
}

View File

@@ -0,0 +1,66 @@
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'menu_logic.dart';
class MenuComponent extends StatelessWidget {
const MenuComponent({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
final logic = Get.put(MenuLogic());
final state = Get.find<MenuLogic>().state;
// return SizedBox(
// width: double.infinity,
// child: Wrap(
// direction: Axis.horizontal,
// alignment: WrapAlignment.spaceBetween,
// spacing: 15,
// runSpacing: 10,
// children: logic.menuList.map((item) {
// return GestureDetector(
// onTap: () {
// logic.goPage(item["page"]);
// },
// child: Column(
// children: [
// Image(
// image: NetworkImage(item["icon"]),
// width: 65,
// ),
// Text(item["title"],
// style: const TextStyle(fontWeight: FontWeight.w500))
// ],
// ),
// );
// }).toList(),
// ),
// );
return SizedBox(
height: 175.h,
child: GridView(
gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 5, childAspectRatio: 0.8),
children: logic.menuList.map((item) {
return GestureDetector(
onTap: () {
logic.goPage(item["page"]);
},
child: Column(
children: [
Image(
image: NetworkImage(item["icon"]),
width: 65.w,
),
Text(item["title"],
style: const TextStyle(fontWeight: FontWeight.w500))
],
),
);
}).toList()),
);
}
}