import 'package:collection/collection.dart'; import 'package:flutter/material.dart'; 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/constants/router.dart'; import 'package:sk_base_mobile/screens/workbench/workbench_controller.dart'; import 'package:sk_base_mobile/util/screen_adaper_util.dart'; import 'package:sk_base_mobile/util/snack_bar.util.dart'; import 'package:sk_base_mobile/widgets/sk_appbar.dart'; class WorkBenchPage extends StatelessWidget { WorkBenchPage({super.key}); final controller = Get.put(WorkBenchController()); @override Widget build(BuildContext context) { return Scaffold( appBar: const SkAppbar(title: '工作台', hideLeading: true), body: buildList()); } 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, ); }, ); } Widget buildItem(int index) { return InkWell( 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), ), Text(controller.menus[index].title) ], ), ), ); } // 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), // ), // ], // ), // ) // ], // ))); // } }