item_home_last_news.dart 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. import 'package:cpt_main/modules/feedback/feedback_page.dart';
  2. import 'package:cs_resources/theme/app_colors_theme.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 LastNewsItem extends StatelessWidget {
  8. final Map<String, dynamic> lastNews;
  9. void Function() onItemTap;
  10. LastNewsItem({required this.lastNews, required this.onItemTap});
  11. @override
  12. Widget build(BuildContext context) {
  13. return Column(
  14. crossAxisAlignment: CrossAxisAlignment.start,
  15. mainAxisAlignment: MainAxisAlignment.start,
  16. children: [
  17. MyTextView(
  18. lastNews['category_name'],
  19. marginLeft: 9,
  20. marginTop: 9,
  21. fontSize: 14,
  22. isFontMedium: true,
  23. textColor: context.appColors.tabTextUnSelectedPrimary,
  24. ),
  25. const Spacer(),
  26. Row(
  27. mainAxisAlignment: MainAxisAlignment.end, // 对齐到右侧
  28. children: [
  29. Padding(
  30. padding: EdgeInsets.only(right: lastNews['margin_right']), // 控制边距
  31. child: MyAssetImage(
  32. lastNews['category_icon'],
  33. width: (lastNews['icon_width'] as num).toDouble(),
  34. height: (lastNews['icon_height'] as num).toDouble(),
  35. fit: BoxFit.cover, // 调整 fit 参数
  36. ),
  37. ),
  38. ],
  39. ),
  40. ],
  41. // ),
  42. )
  43. .decorated(
  44. color: context.appColors.whiteBG,
  45. borderRadius: BorderRadius.circular(5.0), // 5个圆角
  46. boxShadow: [
  47. BoxShadow(
  48. color: const Color(0xFF656565).withOpacity(0.1), // 阴影颜色,并且设置透明度
  49. offset: const Offset(0, 1.5), // 阴影的偏移量
  50. blurRadius: 2.5, // 模糊半径
  51. spreadRadius: 1.5, // 扩散半径
  52. ),
  53. ],
  54. )
  55. .marginOnly(right: 5)
  56. .constrained(width: 86.5, height: 78.5)
  57. .onTap(onItemTap);
  58. }
  59. }