main_item_module.dart 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. // 自定义的模块项 Widget
  2. import 'package:domain/entity/home_module.dart';
  3. import 'package:flutter/material.dart';
  4. import 'package:widgets/ext/ex_widget.dart';
  5. import 'package:widgets/my_load_image.dart';
  6. import 'package:widgets/my_text_view.dart';
  7. class ModuleItem extends StatelessWidget {
  8. final HomeModule item;
  9. final VoidCallback onTap;
  10. ModuleItem(this.item, this.onTap);
  11. @override
  12. Widget build(BuildContext context) {
  13. return GestureDetector(
  14. onTap: onTap,
  15. child: Container(
  16. decoration: BoxDecoration(
  17. color: const Color(0xFF4DCFF6).withOpacity(0.2), // 设置背景颜色和不透明度
  18. borderRadius: BorderRadius.circular(7.5), // 设置圆角
  19. ),
  20. child: Column(
  21. crossAxisAlignment: CrossAxisAlignment.start,
  22. children: [
  23. // 模块的名称
  24. MyTextView(
  25. item.moduleName,
  26. textColor: Colors.white,
  27. isTextEllipsis: true,
  28. maxLines: 2,
  29. isFontBold: true,
  30. marginLeft: 20,
  31. marginRight: 20,
  32. marginTop: 20,
  33. fontSize: 17,
  34. ),
  35. Center(
  36. child: MyAssetImage(item.moduleIconPath, width: item.iconWidth, height: item.iconHeight),
  37. ).expanded(),
  38. ],
  39. ),
  40. ),
  41. );
  42. }
  43. }