profile_menu_item.dart 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. import '../../core/theme/app_colors.dart';
  2. import 'package:flutter/material.dart';
  3. import '../../core/theme/app_colors_extension.dart';
  4. /// Pencil Component/ProfileMenuItem — 个人中心菜单项
  5. ///
  6. /// 左侧图标(22x22, primary色)+文字(14号),右侧箭头图标。
  7. /// 高度56,圆角10,背景bgCard,padding (0,16),gap 12。
  8. class ProfileMenuItem extends StatelessWidget {
  9. final IconData icon;
  10. final String label;
  11. final String? trailing;
  12. final Widget? trailingWidget;
  13. final VoidCallback? onTap;
  14. const ProfileMenuItem({
  15. super.key,
  16. required this.icon,
  17. required this.label,
  18. this.trailing,
  19. this.trailingWidget,
  20. this.onTap,
  21. });
  22. @override
  23. Widget build(BuildContext context) {
  24. final colors = Theme.of(context).extension<AppColorsExtension>()!;
  25. return GestureDetector(
  26. onTap: onTap,
  27. child: Container(
  28. height: 56,
  29. padding: const EdgeInsets.symmetric(horizontal: 16),
  30. decoration: BoxDecoration(
  31. color: colors.bgCard,
  32. borderRadius: BorderRadius.circular(10),
  33. ),
  34. child: Row(
  35. children: [
  36. SizedBox(
  37. width: 22,
  38. height: 22,
  39. child: Icon(icon, size: 22, color: colors.primary),
  40. ),
  41. const SizedBox(width: 12),
  42. Expanded(
  43. child: Text(
  44. label,
  45. style: TextStyle(
  46. fontSize: AppFontSizes.body,
  47. color: colors.textPrimary,
  48. ),
  49. ),
  50. ),
  51. if (trailingWidget != null) ...[
  52. trailingWidget!,
  53. const SizedBox(width: 4),
  54. ] else if (trailing != null) ...[
  55. Text(
  56. trailing!,
  57. style: TextStyle(
  58. fontSize: AppFontSizes.body,
  59. color: colors.textPlaceholder,
  60. ),
  61. ),
  62. const SizedBox(width: 4),
  63. ],
  64. Icon(
  65. Icons.chevron_right,
  66. size: 18,
  67. color: colors.textPlaceholder,
  68. ),
  69. ],
  70. ),
  71. ),
  72. );
  73. }
  74. }