| 1 | import 'package:flutter/material.dart'; |
| 2 | import 'package:hugeicons/hugeicons.dart'; |
| 3 | import 'package:localmind/core/theme/colors.dart'; |
| 4 | |
| 5 | class DrawerNavItem extends StatelessWidget { |
| 6 | const DrawerNavItem({ |
| 7 | super.key, |
| 8 | required this.iconData, |
| 9 | required this.label, |
| 10 | required this.isSelected, |
| 11 | required this.onTap, |
| 12 | this.badgeText, |
| 13 | this.trailing, |
| 14 | }); |
| 15 | |
| 16 | final List<List<dynamic>> iconData; |
| 17 | final String label; |
| 18 | final bool isSelected; |
| 19 | final VoidCallback onTap; |
| 20 | final String? badgeText; |
| 21 | final Widget? trailing; |
| 22 | |
| 23 | @override |
| 24 | Widget build(BuildContext context) { |
| 25 | final theme = Theme.of(context); |
| 26 | final isDark = theme.brightness == Brightness.dark; |
| 27 | final accent = isDark ? AppColors.darkAccent : AppColors.lightAccent; |
| 28 | |
| 29 | return Padding( |
| 30 | padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 2), |
| 31 | child: InkWell( |
| 32 | onTap: onTap, |
| 33 | borderRadius: BorderRadius.circular(8), |
| 34 | child: Container( |
| 35 | padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 10), |
| 36 | decoration: BoxDecoration( |
| 37 | color: isSelected ? accent.withAlpha(30) : Colors.transparent, |
| 38 | borderRadius: BorderRadius.circular(8), |
| 39 | ), |
| 40 | child: Row( |
| 41 | children: [ |
| 42 | HugeIcon( |
| 43 | icon: iconData, |
| 44 | size: 20, |
| 45 | color: isSelected |
| 46 | ? accent |
| 47 | : (isDark |
| 48 | ? AppColors.darkPrimaryText |
| 49 | : AppColors.lightPrimaryText), |
| 50 | ), |
| 51 | const SizedBox(width: 12), |
| 52 | Expanded( |
| 53 | child: Text( |
| 54 | label, |
| 55 | style: TextStyle( |
| 56 | fontSize: 14, |
| 57 | fontWeight: isSelected ? FontWeight.w600 : FontWeight.w500, |
| 58 | color: isSelected |
| 59 | ? accent |
| 60 | : (isDark |
| 61 | ? AppColors.darkPrimaryText |
| 62 | : AppColors.lightPrimaryText), |
| 63 | ), |
| 64 | overflow: TextOverflow.ellipsis, |
| 65 | ), |
| 66 | ), |
| 67 | if (badgeText != null && badgeText!.isNotEmpty) ...[ |
| 68 | const SizedBox(width: 8), |
| 69 | Container( |
| 70 | padding: const EdgeInsets.symmetric( |
| 71 | horizontal: 8, |
| 72 | vertical: 2, |
| 73 | ), |
| 74 | decoration: BoxDecoration( |
| 75 | color: accent.withAlpha(45), |
| 76 | borderRadius: BorderRadius.circular(999), |
| 77 | ), |
| 78 | child: Text( |
| 79 | badgeText!, |
| 80 | style: TextStyle( |
| 81 | fontSize: 10, |
| 82 | fontWeight: FontWeight.w700, |
| 83 | letterSpacing: 0.3, |
| 84 | color: isSelected |
| 85 | ? accent |
| 86 | : (isDark ? AppColors.darkPrimaryText : accent), |
| 87 | ), |
| 88 | ), |
| 89 | ), |
| 90 | ], |
| 91 | if (trailing != null) ...[const SizedBox(width: 8), trailing!], |
| 92 | ], |
| 93 | ), |
| 94 | ), |
| 95 | ), |
| 96 | ); |
| 97 | } |
| 98 | } |