| 1 | import 'package:flutter/material.dart'; |
| 2 | import 'package:flutter_riverpod/flutter_riverpod.dart'; |
| 3 | import 'package:hugeicons/hugeicons.dart'; |
| 4 | import 'package:go_router/go_router.dart'; |
| 5 | import 'package:localmind/core/routes/app_routes.dart'; |
| 6 | import 'package:localmind/core/theme/colors.dart'; |
| 7 | import 'package:localmind/features/conversations/providers/conversation_providers.dart'; |
| 8 | |
| 9 | class SidebarSearchButton extends ConsumerWidget { |
| 10 | const SidebarSearchButton({super.key}); |
| 11 | |
| 12 | @override |
| 13 | Widget build(BuildContext context, WidgetRef ref) { |
| 14 | final isDark = Theme.of(context).brightness == Brightness.dark; |
| 15 | |
| 16 | return Padding( |
| 17 | padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 8), |
| 18 | child: InkWell( |
| 19 | onTap: () { |
| 20 | if (Scaffold.maybeOf(context)?.isDrawerOpen ?? false) { |
| 21 | Navigator.pop(context); |
| 22 | } |
| 23 | context.go(AppRoutes.chatHistory); |
| 24 | WidgetsBinding.instance.addPostFrameCallback((_) { |
| 25 | ref.read(focusHistorySearchProvider.notifier).requestFocus(); |
| 26 | }); |
| 27 | }, |
| 28 | borderRadius: BorderRadius.circular(8), |
| 29 | child: Container( |
| 30 | padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 10), |
| 31 | decoration: BoxDecoration( |
| 32 | color: isDark ? AppColors.darkSurfaceInput : AppColors.lightSurface, |
| 33 | borderRadius: BorderRadius.circular(8), |
| 34 | border: Border.all( |
| 35 | color: isDark ? AppColors.darkBorder : AppColors.lightBorder, |
| 36 | ), |
| 37 | ), |
| 38 | child: Row( |
| 39 | children: [ |
| 40 | HugeIcon( |
| 41 | icon: HugeIcons.strokeRoundedSearch01, |
| 42 | size: 18, |
| 43 | color: isDark |
| 44 | ? AppColors.darkMutedText |
| 45 | : AppColors.lightMutedText, |
| 46 | ), |
| 47 | const SizedBox(width: 10), |
| 48 | Expanded( |
| 49 | child: Text( |
| 50 | 'Search conversations...', |
| 51 | style: TextStyle( |
| 52 | fontSize: 13, |
| 53 | color: isDark |
| 54 | ? AppColors.darkMutedText |
| 55 | : AppColors.lightMutedText, |
| 56 | ), |
| 57 | overflow: TextOverflow.ellipsis, |
| 58 | ), |
| 59 | ), |
| 60 | Text( |
| 61 | '⌘K', |
| 62 | style: TextStyle( |
| 63 | fontSize: 11, |
| 64 | fontWeight: FontWeight.w500, |
| 65 | color: isDark |
| 66 | ? AppColors.darkMutedText |
| 67 | : AppColors.lightMutedText, |
| 68 | letterSpacing: 0.5, |
| 69 | ), |
| 70 | ), |
| 71 | ], |
| 72 | ), |
| 73 | ), |
| 74 | ), |
| 75 | ); |
| 76 | } |
| 77 | } |