import 'package:collection/collection.dart'; import 'package:flutter/material.dart'; import 'package:get/get.dart'; import 'package:sk_base_mobile/app_theme.dart'; import 'package:sk_base_mobile/constants/router.dart'; import 'package:sk_base_mobile/util/screen_adaper_util.dart'; import 'package:sk_base_mobile/util/snack_bar.util.dart'; class WorkBenchModel { final String title; final String route; WorkBenchModel({required this.title, required this.route}); } class WorkBenchPage extends StatelessWidget { WorkBenchPage({super.key}); final List works = [ 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) { return Scaffold( appBar: AppBar( leading: const SizedBox(), title: const Text( '工作台', ), ), 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) { 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), ), ], ), ) ], ))); } }