2024-03-27 11:06:01 +08:00
|
|
|
import 'package:collection/collection.dart';
|
2024-03-20 09:37:20 +08:00
|
|
|
import 'package:flutter/material.dart';
|
2024-04-01 08:41:52 +08:00
|
|
|
import 'package:flutter_staggered_grid_view/flutter_staggered_grid_view.dart';
|
|
|
|
import 'package:flutter_svg/svg.dart';
|
2024-03-20 09:37:20 +08:00
|
|
|
import 'package:get/get.dart';
|
2024-04-10 11:04:27 +08:00
|
|
|
import 'package:sk_base_mobile/app_theme.dart';
|
2024-04-10 17:38:23 +08:00
|
|
|
import 'package:sk_base_mobile/router/router.dart';
|
2024-04-01 08:41:52 +08:00
|
|
|
import 'package:sk_base_mobile/screens/workbench/workbench_controller.dart';
|
2024-04-10 17:38:23 +08:00
|
|
|
import 'package:sk_base_mobile/router/router.util.dart';
|
2024-03-20 09:37:20 +08:00
|
|
|
import 'package:sk_base_mobile/util/screen_adaper_util.dart';
|
2024-03-27 11:06:01 +08:00
|
|
|
import 'package:sk_base_mobile/util/snack_bar.util.dart';
|
2024-04-09 08:31:17 +08:00
|
|
|
import 'package:sk_base_mobile/widgets/core/sk_appbar.dart';
|
2024-03-20 09:37:20 +08:00
|
|
|
|
|
|
|
class WorkBenchPage extends StatelessWidget {
|
|
|
|
WorkBenchPage({super.key});
|
2024-04-01 08:41:52 +08:00
|
|
|
final controller = Get.put(WorkBenchController());
|
2024-03-20 09:37:20 +08:00
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
2024-03-21 14:09:49 +08:00
|
|
|
return Scaffold(
|
2024-04-10 11:04:27 +08:00
|
|
|
backgroundColor: AppTheme.nearlyWhite,
|
2024-04-07 17:32:46 +08:00
|
|
|
appBar: const SkAppbar(title: '工作台', hideLeading: true),
|
|
|
|
body: buildList());
|
2024-04-01 08:41:52 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
Widget buildList() {
|
|
|
|
return MasonryGridView.count(
|
|
|
|
padding: EdgeInsets.only(top: ScreenAdaper.width(20)),
|
|
|
|
crossAxisCount: Get.width > 800 ? 6 : 4,
|
|
|
|
itemCount: controller.menus.length,
|
|
|
|
itemBuilder: (context, index) {
|
|
|
|
return buildItem(
|
|
|
|
index,
|
|
|
|
);
|
|
|
|
},
|
2024-03-21 14:09:49 +08:00
|
|
|
);
|
2024-03-20 09:37:20 +08:00
|
|
|
}
|
|
|
|
|
2024-04-01 08:41:52 +08:00
|
|
|
Widget buildItem(int index) {
|
2024-03-27 11:06:01 +08:00
|
|
|
return InkWell(
|
2024-04-01 08:41:52 +08:00
|
|
|
onTap: () {
|
|
|
|
final route = RouteConfig.getPages
|
|
|
|
.map((e) => e.name)
|
|
|
|
.firstWhereOrNull((name) => name == controller.menus[index].route);
|
|
|
|
if (route != null) {
|
2024-04-12 09:56:00 +08:00
|
|
|
RouterUtil.toNamed(controller.menus[index].route!);
|
2024-04-01 08:41:52 +08:00
|
|
|
} else {
|
2024-04-10 17:38:23 +08:00
|
|
|
SnackBarUtil().info('您没有权限,请联系管理员。后期会隐藏没有权限的功能');
|
2024-04-01 08:41:52 +08:00
|
|
|
}
|
|
|
|
},
|
|
|
|
child: Container(
|
|
|
|
alignment: Alignment.center,
|
|
|
|
padding: EdgeInsets.only(
|
|
|
|
top: ScreenAdaper.height(20), bottom: ScreenAdaper.height(20)),
|
|
|
|
child: Column(
|
|
|
|
children: [
|
|
|
|
SvgPicture.asset(
|
|
|
|
'assets/icons/${controller.menus[index].icon}',
|
|
|
|
width: ScreenAdaper.width(100),
|
|
|
|
height: ScreenAdaper.width(100),
|
|
|
|
),
|
|
|
|
SizedBox(
|
|
|
|
height: ScreenAdaper.height(10),
|
2024-03-27 11:06:01 +08:00
|
|
|
),
|
2024-04-01 08:41:52 +08:00
|
|
|
Text(controller.menus[index].title)
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
2024-03-20 09:37:20 +08:00
|
|
|
}
|
2024-04-01 08:41:52 +08:00
|
|
|
// Widget buildCard(int index) {
|
|
|
|
// return InkWell(
|
|
|
|
// onTap: () {
|
|
|
|
// final route = RouteConfig.getPages
|
|
|
|
// .map((e) => e.name)
|
|
|
|
// .firstWhereOrNull((name) => name == works[index].route);
|
|
|
|
// if (route != null) {
|
|
|
|
// Get.toNamed(works[index].route);
|
|
|
|
// } else {
|
|
|
|
// SnackBarUtil().info('功能待开发。');
|
|
|
|
// }
|
|
|
|
// },
|
|
|
|
// child: Container(
|
|
|
|
// clipBehavior: Clip.antiAlias,
|
|
|
|
// decoration: BoxDecoration(
|
|
|
|
// borderRadius: BorderRadius.circular(10),
|
|
|
|
// gradient: const LinearGradient(
|
|
|
|
// begin: Alignment.centerLeft,
|
|
|
|
// end: Alignment.centerRight,
|
|
|
|
// colors: [AppTheme.primaryColorLight, AppTheme.primaryColor]),
|
|
|
|
// boxShadow: [
|
|
|
|
// BoxShadow(
|
|
|
|
// color: AppTheme.black.withOpacity(0.4),
|
|
|
|
// offset: const Offset(0, 0),
|
|
|
|
// blurRadius: 1,
|
|
|
|
// spreadRadius: 1)
|
|
|
|
// ],
|
|
|
|
// ),
|
|
|
|
// child: Stack(
|
|
|
|
// children: [
|
|
|
|
// // Image.asset(works[index].icon),
|
|
|
|
// Center(
|
|
|
|
// child: Stack(
|
|
|
|
// alignment: Alignment.center,
|
|
|
|
// children: [
|
|
|
|
// Text(
|
|
|
|
// works[index].title,
|
|
|
|
// style: TextStyle(
|
|
|
|
// letterSpacing: ScreenAdaper.width(10),
|
|
|
|
// fontSize: ScreenAdaper.height(40),
|
|
|
|
// fontWeight: FontWeight.bold,
|
|
|
|
// foreground: Paint()
|
|
|
|
// ..style = PaintingStyle.stroke
|
|
|
|
// ..strokeWidth = 5
|
|
|
|
// ..color = Colors.black),
|
|
|
|
// ),
|
|
|
|
// Text(
|
|
|
|
// works[index].title,
|
|
|
|
// style: TextStyle(
|
|
|
|
// letterSpacing: ScreenAdaper.width(10),
|
|
|
|
// color: Colors.white,
|
|
|
|
// fontSize: ScreenAdaper.height(40),
|
|
|
|
// fontWeight: FontWeight.bold),
|
|
|
|
// ),
|
|
|
|
// ],
|
|
|
|
// ),
|
|
|
|
// )
|
|
|
|
// ],
|
|
|
|
// )));
|
|
|
|
// }
|
2024-03-20 09:37:20 +08:00
|
|
|
}
|