mobile_skt/lib/screens/workbench/workbench.dart

131 lines
4.6 KiB
Dart
Raw Normal View History

2024-03-27 11:06:01 +08:00
import 'package:collection/collection.dart';
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';
import 'package:get/get.dart';
import 'package:sk_base_mobile/app_theme.dart';
2024-03-27 11:06:01 +08:00
import 'package:sk_base_mobile/constants/router.dart';
2024-04-01 08:41:52 +08:00
import 'package:sk_base_mobile/screens/workbench/workbench_controller.dart';
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';
class WorkBenchPage extends StatelessWidget {
WorkBenchPage({super.key});
2024-04-01 08:41:52 +08:00
final controller = Get.put(WorkBenchController());
@override
Widget build(BuildContext context) {
2024-03-21 14:09:49 +08:00
return Scaffold(
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-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) {
Get.toNamed(controller.menus[index].route);
} else {
SnackBarUtil().info('功能待开发。');
}
},
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-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),
// ),
// ],
// ),
// )
// ],
// )));
// }
}