From d1b4fb344ef8f83fddf222a3dd709d34f505f1b1 Mon Sep 17 00:00:00 2001 From: MAGESHWARAN Date: Fri, 17 Apr 2026 10:24:14 +0530 Subject: [PATCH] Update 2026-04-17 --- lib/consts/download_helper.dart | 10 ++++++ lib/view/Mahi_chat/comman_input_button.dart | 2 ++ lib/view/Mahi_chat/file_images_screen.dart | 6 +++- lib/view/screens/serivce_request_screen.dart | 35 +++++++++++++------- pubspec.lock | 2 +- pubspec.yaml | 1 + 6 files changed, 42 insertions(+), 14 deletions(-) diff --git a/lib/consts/download_helper.dart b/lib/consts/download_helper.dart index c515d9d..b23ac3c 100644 --- a/lib/consts/download_helper.dart +++ b/lib/consts/download_helper.dart @@ -498,9 +498,18 @@ class DownloadHelper { 'pptx', 'rtf', 'odt', + 'rar', + 'zip', + '7z', ].contains(ext); } + /// Check if file is an archive + static bool isArchiveFile(String path) { + final ext = getFileExtension(path); + return ['zip', 'rar', '7z', 'tar', 'gz'].contains(ext); + } + /// Check if file is video static bool isVideoFile(String path) { final ext = getFileExtension(path); @@ -524,6 +533,7 @@ class DownloadHelper { if (['doc', 'docx'].contains(ext)) return '📝'; if (['xls', 'xlsx'].contains(ext)) return '📊'; if (['ppt', 'pptx'].contains(ext)) return '📽️'; + if (isArchiveFile(path)) return '📦'; } return '📎'; } diff --git a/lib/view/Mahi_chat/comman_input_button.dart b/lib/view/Mahi_chat/comman_input_button.dart index 5819023..c24a285 100644 --- a/lib/view/Mahi_chat/comman_input_button.dart +++ b/lib/view/Mahi_chat/comman_input_button.dart @@ -229,6 +229,8 @@ class _ChatInputBoxState extends ConsumerState { return Icons.description; } else if (['xls', 'xlsx'].contains(ext)) { return Icons.table_chart; + } else if (['zip', 'rar', '7z'].contains(ext)) { + return Icons.folder_zip; } else { return Icons.insert_drive_file; } diff --git a/lib/view/Mahi_chat/file_images_screen.dart b/lib/view/Mahi_chat/file_images_screen.dart index 7ab9096..a9f6f13 100644 --- a/lib/view/Mahi_chat/file_images_screen.dart +++ b/lib/view/Mahi_chat/file_images_screen.dart @@ -582,7 +582,11 @@ class SwipeableMessageBubbleState extends State child: Row( children: [ Icon( - Icons.insert_drive_file, + ['xls', 'xlsx'].contains(doc.fileType.toLowerCase()) + ? Icons.table_chart + : ['zip', 'rar', '7z'].contains(doc.fileType.toLowerCase()) + ? Icons.folder_zip + : Icons.insert_drive_file, color: Colors.grey[600], ), const SizedBox(width: 8), diff --git a/lib/view/screens/serivce_request_screen.dart b/lib/view/screens/serivce_request_screen.dart index 218730f..ac0a51e 100644 --- a/lib/view/screens/serivce_request_screen.dart +++ b/lib/view/screens/serivce_request_screen.dart @@ -142,14 +142,9 @@ class _ServiceRequestScreenState extends ConsumerState { onTap: () => Navigator.pop(ctx, 'gallery'), ), ListTile( - leading: const Icon(Icons.picture_as_pdf, color: Colors.red), - title: const Text('Select PDF'), - onTap: () => Navigator.pop(ctx, 'pdf'), - ), - ListTile( - leading: const Icon(Icons.folder_zip, color: Colors.orange), - title: const Text('Select ZIP'), - onTap: () => Navigator.pop(ctx, 'zip'), + leading: const Icon(Icons.insert_drive_file, color: Colors.blue), + title: const Text('Files'), + onTap: () => Navigator.pop(ctx, 'any'), ), ], ), @@ -183,11 +178,10 @@ class _ServiceRequestScreenState extends ConsumerState { _isFileError = false; }); } - } else if (choice == 'pdf' || choice == 'zip') { + } else if (choice == 'any') { final result = await FilePicker.platform.pickFiles( allowMultiple: true, - type: FileType.custom, - allowedExtensions: choice == 'pdf' ? ['pdf'] : ['zip', 'rar', '7z'], + type: FileType.any, ); if (result != null && result.files.isNotEmpty) { for (var file in result.files) { @@ -284,6 +278,9 @@ class _ServiceRequestScreenState extends ConsumerState { bool _isZip(String pathStr) => ['.zip', '.rar', '.7z'].contains(path.extension(pathStr).toLowerCase()); + bool _isExcel(String pathStr) => + ['.xls', '.xlsx'].contains(path.extension(pathStr).toLowerCase()); + @override Widget build(BuildContext context) { final r = ResponsiveUtils(context); @@ -418,6 +415,13 @@ class _ServiceRequestScreenState extends ConsumerState { widget.icon, width: serviceIconSize, height: serviceIconSize, + errorBuilder: (context, error, stackTrace) { + return Icon( + Icons.error_outline, + color: Colors.red.shade300, + size: serviceIconSize * 0.8, + ); + }, ), ), SizedBox(height: spacingMD), @@ -616,7 +620,7 @@ class _ServiceRequestScreenState extends ConsumerState { child: Column( children: [ Text( - "Upload PDF, IMG, JPG, ZIP", + "Upload Documents or Images", style: AppTextStyles.semiBold.copyWith( fontSize: fontSize, height: 25.56 / 12.78, @@ -778,6 +782,13 @@ class _ServiceRequestScreenState extends ConsumerState { size: iconSize, color: Colors.orange.shade600, ); + } else if (_isExcel(pathStr)) { + bgColor = Colors.green.shade50; + preview = Icon( + Icons.table_chart, + size: iconSize, + color: Colors.green.shade600, + ); } else { bgColor = Colors.blue.shade50; preview = Icon( diff --git a/pubspec.lock b/pubspec.lock index b9af59f..b0949c7 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -569,7 +569,7 @@ packages: source: hosted version: "3.2.2" http_parser: - dependency: transitive + dependency: "direct main" description: name: http_parser sha256: "178d74305e7866013777bab2c3d8726205dc5a4dd935297175b19a23a2e66571" diff --git a/pubspec.yaml b/pubspec.yaml index 677c539..4751d7d 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -40,6 +40,7 @@ dependencies: web_socket_channel: ^3.0.2 flutter_local_notifications: ^18.0.1 curved_labeled_navigation_bar: ^2.0.6 + http_parser: ^4.1.2