mobile_skt/lib/screens/workbench/workbench.dart

121 lines
4.2 KiB
Dart
Raw Normal View History

2024-03-27 11:06:01 +08:00
import 'package:collection/collection.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter/widgets.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';
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';
class WorkBenchModel {
final String title;
final String route;
2024-03-27 11:06:01 +08:00
WorkBenchModel({required this.title, required this.route});
}
class WorkBenchPage extends StatelessWidget {
WorkBenchPage({super.key});
List<WorkBenchModel> works = [
2024-03-27 11:06:01 +08:00
WorkBenchModel(title: '库存', route: '/inventory'),
WorkBenchModel(title: '产品', route: '/product'),
WorkBenchModel(title: '合同', route: '/contract'),
WorkBenchModel(title: '人事', route: '/personnel'),
WorkBenchModel(title: '公车', route: '/finance'),
WorkBenchModel(title: '任务', route: '/task_manage'),
WorkBenchModel(title: '报表', route: '/report'),
];
@override
Widget build(BuildContext context) {
2024-03-21 14:09:49 +08:00
return Scaffold(
appBar: AppBar(
leading: const SizedBox(),
title: const Text(
'工作台',
),
2024-03-21 14:09:49 +08:00
),
body: SingleChildScrollView(
child: Column(children: [
Container(
padding: EdgeInsets.all(ScreenAdaper.width(20)),
child: GridView.builder(
shrinkWrap: true,
physics: const NeverScrollableScrollPhysics(),
itemCount: works.length,
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: Get.width > 800 ? 5 : 3,
crossAxisSpacing: ScreenAdaper.width(20),
mainAxisSpacing: ScreenAdaper.height(20),
childAspectRatio: 1.0),
itemBuilder: (BuildContext context, int index) {
return buildCard(index);
},
),
)
])),
);
}
Widget buildCard(int index) {
2024-03-27 11:06:01 +08:00
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: LinearGradient(
begin: Alignment.centerLeft,
end: Alignment.centerRight,
colors: [AppTheme.primaryColorLight, AppTheme.primaryColor]),
boxShadow: [
BoxShadow(
color: AppTheme.black.withOpacity(0.5),
offset: Offset(0, 0),
blurRadius: 5,
spreadRadius: 2)
],
),
child: Stack(
children: [
// Image.asset(works[index].icon),
Center(
child: Stack(
alignment: Alignment.center,
children: [
Text(
works[index].title,
style: TextStyle(
2024-03-28 15:13:27 +08:00
letterSpacing: ScreenAdaper.width(10),
2024-03-27 11:06:01 +08:00
fontSize: ScreenAdaper.sp(40),
fontWeight: FontWeight.bold,
foreground: Paint()
..style = PaintingStyle.stroke
..strokeWidth = 5
..color = Colors.black),
),
Text(
works[index].title,
style: TextStyle(
2024-03-28 15:13:27 +08:00
letterSpacing: ScreenAdaper.width(10),
2024-03-27 11:06:01 +08:00
color: Colors.white,
fontSize: ScreenAdaper.sp(40),
fontWeight: FontWeight.bold),
),
],
),
2024-03-27 11:06:01 +08:00
)
],
)));
}
}