From 6dedc1924c1d87b5d4d84202c7a69c9c92b768c3 Mon Sep 17 00:00:00 2001 From: cogwheel0 <172976095+cogwheel0@users.noreply.github.com> Date: Thu, 21 Aug 2025 16:15:27 +0530 Subject: [PATCH] refactor: ux --- ios/Podfile.lock | 6 + lib/features/chat/views/chat_page.dart | 214 +----------------- .../widgets/assistant_message_widget.dart | 51 +++-- .../widgets/enhanced_image_attachment.dart | 5 +- .../chat/widgets/message_batch_widget.dart | 94 +------- .../chat/widgets/modern_chat_input.dart | 2 + .../chat/widgets/tag_management_dialog.dart | 30 +-- .../navigation/views/chats_list_page.dart | 119 +--------- 8 files changed, 76 insertions(+), 445 deletions(-) diff --git a/ios/Podfile.lock b/ios/Podfile.lock index 8935d94..ea11de5 100644 --- a/ios/Podfile.lock +++ b/ios/Podfile.lock @@ -50,6 +50,8 @@ PODS: - SDWebImage (5.21.1): - SDWebImage/Core (= 5.21.1) - SDWebImage/Core (5.21.1) + - share_plus (0.0.1): + - Flutter - shared_preferences_foundation (0.0.1): - Flutter - FlutterMacOS @@ -71,6 +73,7 @@ DEPENDENCIES: - package_info_plus (from `.symlinks/plugins/package_info_plus/ios`) - path_provider_foundation (from `.symlinks/plugins/path_provider_foundation/darwin`) - record_ios (from `.symlinks/plugins/record_ios/ios`) + - share_plus (from `.symlinks/plugins/share_plus/ios`) - shared_preferences_foundation (from `.symlinks/plugins/shared_preferences_foundation/darwin`) - sqflite_darwin (from `.symlinks/plugins/sqflite_darwin/darwin`) - url_launcher_ios (from `.symlinks/plugins/url_launcher_ios/ios`) @@ -100,6 +103,8 @@ EXTERNAL SOURCES: :path: ".symlinks/plugins/path_provider_foundation/darwin" record_ios: :path: ".symlinks/plugins/record_ios/ios" + share_plus: + :path: ".symlinks/plugins/share_plus/ios" shared_preferences_foundation: :path: ".symlinks/plugins/shared_preferences_foundation/darwin" sqflite_darwin: @@ -121,6 +126,7 @@ SPEC CHECKSUMS: path_provider_foundation: 080d55be775b7414fd5a5ef3ac137b97b097e564 record_ios: fee1c924aa4879b882ebca2b4bce6011bcfc3d8b SDWebImage: f29024626962457f3470184232766516dee8dfea + share_plus: 50da8cb520a8f0f65671c6c6a99b3617ed10a58a shared_preferences_foundation: 9e1978ff2562383bd5676f64ec4e9aa8fa06a6f7 sqflite_darwin: 20b2a3a3b70e43edae938624ce550a3cbf66a3d0 SwiftyGif: 706c60cf65fa2bc5ee0313beece843c8eb8194d4 diff --git a/lib/features/chat/views/chat_page.dart b/lib/features/chat/views/chat_page.dart index 25c702c..1b1ae8f 100644 --- a/lib/features/chat/views/chat_page.dart +++ b/lib/features/chat/views/chat_page.dart @@ -9,7 +9,6 @@ import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_animate/flutter_animate.dart'; import 'dart:io' show Platform, File; import 'dart:async'; -import 'package:path/path.dart' as path; import '../../../core/providers/app_providers.dart'; import '../providers/chat_providers.dart'; import '../../../core/utils/debug_logger.dart'; @@ -247,11 +246,6 @@ class _ChatPageState extends ConsumerState { if (selectedModel == null) { debugPrint('DEBUG: No model selected'); - if (mounted) { - ScaffoldMessenger.of(context).showSnackBar( - const SnackBar(content: Text('Please select a model first')), - ); - } return; } @@ -262,16 +256,6 @@ class _ChatPageState extends ConsumerState { ); if (!isOnline && !isReviewerMode) { debugPrint('DEBUG: Offline - cannot send message'); - if (mounted) { - ScaffoldMessenger.of(context).showSnackBar( - SnackBar( - content: const Text( - 'You\'re offline. Message will be sent when connection is restored.', - ), - backgroundColor: context.conduitTheme.warning, - ), - ); - } return; } @@ -328,22 +312,6 @@ class _ChatPageState extends ConsumerState { }); } catch (e) { debugPrint('DEBUG: Message send error: $e'); - if (mounted) { - ScaffoldMessenger.of(context).showSnackBar( - SnackBar( - content: const Text( - 'Message failed to send. Check your connection and try again.', - ), - backgroundColor: context.conduitTheme.error, - action: SnackBarAction( - label: 'Retry', - textColor: Colors.white, - onPressed: () => _handleMessageSend(text, selectedModel), - ), - duration: const Duration(seconds: 6), - ), - ); - } } } @@ -353,12 +321,6 @@ class _ChatPageState extends ConsumerState { if (!isAvailable) { if (!mounted) return; - ScaffoldMessenger.of(context).showSnackBar( - SnackBar( - content: const Text('Voice input unavailable. Check permissions.'), - backgroundColor: context.conduitTheme.warning, - ), - ); return; } @@ -386,20 +348,11 @@ class _ChatPageState extends ConsumerState { final fileUploadCapableModels = ref.read(fileUploadCapableModelsProvider); if (fileUploadCapableModels.isEmpty) { if (!mounted) return; - ScaffoldMessenger.of(context).showSnackBar( - SnackBar( - content: const Text('Selected model does not support file upload'), - backgroundColor: context.conduitTheme.error, - ), - ); return; } final fileService = ref.read(fileAttachmentServiceProvider); if (fileService == null) { - ScaffoldMessenger.of( - context, - ).showSnackBar(const SnackBar(content: Text('File service unavailable'))); return; } @@ -411,12 +364,6 @@ class _ChatPageState extends ConsumerState { final currentFiles = ref.read(attachedFilesProvider); if (!validateFileCount(currentFiles.length, files.length, 10)) { if (!mounted) return; - ScaffoldMessenger.of(context).showSnackBar( - SnackBar( - content: const Text('Maximum 10 files allowed'), - backgroundColor: context.conduitTheme.error, - ), - ); return; } @@ -425,14 +372,6 @@ class _ChatPageState extends ConsumerState { final fileSize = await file.length(); if (!validateFileSize(fileSize, 20)) { if (!mounted) return; - ScaffoldMessenger.of(context).showSnackBar( - SnackBar( - content: Text( - 'File ${path.basename(file.path)} exceeds 20MB limit', - ), - backgroundColor: context.conduitTheme.error, - ), - ); return; } } @@ -451,23 +390,13 @@ class _ChatPageState extends ConsumerState { }, onError: (error) { if (!mounted) return; - ScaffoldMessenger.of(context).showSnackBar( - SnackBar( - content: Text('Upload failed: $error'), - backgroundColor: context.conduitTheme.error, - ), - ); + debugPrint('Upload failed: $error'); }, ); } } catch (e) { if (!mounted) return; - ScaffoldMessenger.of(context).showSnackBar( - SnackBar( - content: Text('File selection failed: $e'), - backgroundColor: context.conduitTheme.error, - ), - ); + debugPrint('File selection failed: $e'); } } @@ -480,21 +409,12 @@ class _ChatPageState extends ConsumerState { final visionCapableModels = ref.read(visionCapableModelsProvider); if (visionCapableModels.isEmpty) { if (!mounted) return; - ScaffoldMessenger.of(context).showSnackBar( - SnackBar( - content: const Text('Selected model does not support image inputs'), - backgroundColor: context.conduitTheme.error, - ), - ); return; } final fileService = ref.read(fileAttachmentServiceProvider); if (fileService == null) { debugPrint('DEBUG: File service is null - cannot proceed'); - ScaffoldMessenger.of( - context, - ).showSnackBar(const SnackBar(content: Text('File service unavailable'))); return; } @@ -515,12 +435,6 @@ class _ChatPageState extends ConsumerState { // Validate file size (default 20MB limit like OpenWebUI) if (!validateFileSize(imageSize, 20)) { if (!mounted) return; - ScaffoldMessenger.of(context).showSnackBar( - SnackBar( - content: const Text('Image size exceeds 20MB limit'), - backgroundColor: context.conduitTheme.error, - ), - ); return; } @@ -528,12 +442,6 @@ class _ChatPageState extends ConsumerState { final currentFiles = ref.read(attachedFilesProvider); if (!validateFileCount(currentFiles.length, 1, 10)) { if (!mounted) return; - ScaffoldMessenger.of(context).showSnackBar( - SnackBar( - content: const Text('Maximum 10 files allowed'), - backgroundColor: context.conduitTheme.error, - ), - ); return; } @@ -556,23 +464,11 @@ class _ChatPageState extends ConsumerState { onError: (error) { debugPrint('DEBUG: Image upload error: $error'); if (!mounted) return; - ScaffoldMessenger.of(context).showSnackBar( - SnackBar( - content: Text('Image upload failed: $error'), - backgroundColor: context.conduitTheme.error, - ), - ); }, ); } catch (e) { debugPrint('DEBUG: Image attachment error: $e'); if (!mounted) return; - ScaffoldMessenger.of(context).showSnackBar( - SnackBar( - content: Text('Image attachment failed: $e'), - backgroundColor: context.conduitTheme.error, - ), - ); } } @@ -586,14 +482,6 @@ class _ChatPageState extends ConsumerState { _showScrollToBottom = false; }); } - - // Show success message - ScaffoldMessenger.of(context).showSnackBar( - const SnackBar( - content: Text('New chat started'), - duration: Duration(seconds: 2), - ), - ); } void _showChatsListOverlay() { @@ -1029,20 +917,11 @@ class _ChatPageState extends ConsumerState { void _copyMessage(String content) { Clipboard.setData(ClipboardData(text: content)); - ScaffoldMessenger.of(context).showSnackBar( - const SnackBar( - content: Text('Copied to clipboard'), - duration: Duration(seconds: 2), - ), - ); } void _regenerateMessage(dynamic message) async { final selectedModel = ref.read(selectedModelProvider); if (selectedModel == null) { - ScaffoldMessenger.of(context).showSnackBar( - const SnackBar(content: Text('Please select a model first')), - ); return; } @@ -1051,9 +930,6 @@ class _ChatPageState extends ConsumerState { final messageIndex = messages.indexOf(message); if (messageIndex <= 0 || messages[messageIndex - 1].role != 'user') { - ScaffoldMessenger.of(context).showSnackBar( - const SnackBar(content: Text('Cannot regenerate this message')), - ); return; } @@ -1068,40 +944,13 @@ class _ChatPageState extends ConsumerState { userMessage.content, userMessage.attachmentIds, ); - - if (mounted) { - ScaffoldMessenger.of(context).showSnackBar( - const SnackBar( - content: Text('Regenerating...'), - duration: Duration(seconds: 2), - ), - ); - } } catch (e) { - if (mounted) { - ScaffoldMessenger.of(context).showSnackBar( - SnackBar( - content: Text( - 'Failed to regenerate message. Try again or check your connection.', - ), - backgroundColor: context.conduitTheme.error, - action: SnackBarAction( - label: 'Retry', - textColor: Colors.white, - onPressed: () => _regenerateMessage(message), - ), - duration: const Duration(seconds: 6), - ), - ); - } + debugPrint('Regenerate failed: $e'); } } void _editMessage(dynamic message) async { if (message.role != 'user') { - ScaffoldMessenger.of(context).showSnackBar( - const SnackBar(content: Text('Only user messages can be edited')), - ); return; } @@ -1170,25 +1019,11 @@ class _ChatPageState extends ConsumerState { if (selectedModel != null) { await sendMessage(ref, result, null); - if (mounted) { - ScaffoldMessenger.of(context).showSnackBar( - const SnackBar( - content: Text('Message updated'), - duration: Duration(seconds: 2), - ), - ); - } + if (mounted) {} } } } catch (e) { - if (mounted) { - ScaffoldMessenger.of(context).showSnackBar( - SnackBar( - content: Text('Failed to edit message: $e'), - backgroundColor: context.conduitTheme.error, - ), - ); - } + if (mounted) {} } } @@ -1197,16 +1032,10 @@ class _ChatPageState extends ConsumerState { void _likeMessage(dynamic message) { // TODO: Implement message liking - ScaffoldMessenger.of( - context, - ).showSnackBar(const SnackBar(content: Text('Message liked!'))); } void _dislikeMessage(dynamic message) { // TODO: Implement message disliking - ScaffoldMessenger.of( - context, - ).showSnackBar(const SnackBar(content: Text('Message disliked!'))); } Widget _buildEmptyState(ThemeData theme) { @@ -1755,14 +1584,7 @@ class _ChatPageState extends ConsumerState { // ref.read(chatMessagesProvider.notifier).removeMessage(selectedMessage.id); // } _clearSelection(); - if (mounted) { - ScaffoldMessenger.of(context).showSnackBar( - const SnackBar( - content: Text('Messages removed'), - duration: Duration(seconds: 2), - ), - ); - } + if (mounted) {} } }); } @@ -2249,28 +2071,14 @@ class _VoiceInputSheetState extends ConsumerState<_VoiceInputSheet> { _isListening = false; }); _elapsedTimer?.cancel(); - if (mounted) { - ScaffoldMessenger.of(context).showSnackBar( - SnackBar( - content: Text('Voice input error: $error'), - backgroundColor: context.conduitTheme.error, - ), - ); - } + if (mounted) {} }, ); } catch (e) { setState(() { _isListening = false; }); - if (mounted) { - ScaffoldMessenger.of(context).showSnackBar( - SnackBar( - content: Text('Failed to start voice input: $e'), - backgroundColor: context.conduitTheme.error, - ), - ); - } + if (mounted) {} } } @@ -2304,12 +2112,6 @@ class _VoiceInputSheetState extends ConsumerState<_VoiceInputSheet> { setState(() => _isListening = false); } catch (e) { if (!mounted) return; - ScaffoldMessenger.of(context).showSnackBar( - SnackBar( - content: Text('Transcription failed: $e'), - backgroundColor: context.conduitTheme.error, - ), - ); setState(() => _isListening = false); } finally { if (mounted) setState(() => _isTranscribing = false); diff --git a/lib/features/chat/widgets/assistant_message_widget.dart b/lib/features/chat/widgets/assistant_message_widget.dart index 4000a14..58bbc45 100644 --- a/lib/features/chat/widgets/assistant_message_widget.dart +++ b/lib/features/chat/widgets/assistant_message_widget.dart @@ -313,9 +313,11 @@ class _AssistantMessageWidgetState extends ConsumerState ), ), - // Action buttons below the message content (always visible) - const SizedBox(height: Spacing.sm), - _buildActionButtons(), + // Action buttons below the message content (only after streaming completes) + if (!widget.isStreaming) ...[ + const SizedBox(height: Spacing.sm), + _buildActionButtons(), + ], ], ), ) @@ -387,15 +389,23 @@ class _AssistantMessageWidgetState extends ConsumerState child: EnhancedImageAttachment( attachmentId: widget.message.attachmentIds![0], isMarkdownFormat: true, - constraints: const BoxConstraints(maxWidth: 500, maxHeight: 400), - disableAnimation: widget.isStreaming, // Disable animation during streaming + constraints: const BoxConstraints( + maxWidth: 500, + maxHeight: 400, + ), + disableAnimation: + widget.isStreaming, // Disable animation during streaming ), ) : Wrap( - key: ValueKey('multi_images_${widget.message.attachmentIds!.join('_')}'), + key: ValueKey( + 'multi_images_${widget.message.attachmentIds!.join('_')}', + ), spacing: Spacing.sm, runSpacing: Spacing.sm, - children: widget.message.attachmentIds!.map((attachmentId) { + children: widget.message.attachmentIds!.map(( + attachmentId, + ) { return EnhancedImageAttachment( key: ValueKey('attachment_$attachmentId'), attachmentId: attachmentId, @@ -404,7 +414,8 @@ class _AssistantMessageWidgetState extends ConsumerState maxWidth: imageCount == 2 ? 245 : 160, maxHeight: imageCount == 2 ? 245 : 160, ), - disableAnimation: widget.isStreaming, // Disable animation during streaming + disableAnimation: + widget.isStreaming, // Disable animation during streaming ); }).toList(), ), @@ -415,7 +426,7 @@ class _AssistantMessageWidgetState extends ConsumerState if (widget.message.files == null || widget.message.files!.isEmpty) { return const SizedBox.shrink(); } - + // Filter for image files final imageFiles = widget.message.files! .where((file) => file['type'] == 'image') @@ -439,24 +450,31 @@ class _AssistantMessageWidgetState extends ConsumerState builder: (context) { final imageUrl = imageFiles[0]['url'] as String?; if (imageUrl == null) return const SizedBox.shrink(); - + return EnhancedImageAttachment( - attachmentId: imageUrl, // Pass URL directly as it handles URLs + attachmentId: + imageUrl, // Pass URL directly as it handles URLs isMarkdownFormat: true, - constraints: const BoxConstraints(maxWidth: 500, maxHeight: 400), - disableAnimation: widget.isStreaming, // Disable animation during streaming + constraints: const BoxConstraints( + maxWidth: 500, + maxHeight: 400, + ), + disableAnimation: widget + .isStreaming, // Disable animation during streaming ); }, ), ) : Wrap( - key: ValueKey('gen_multi_${imageFiles.map((f) => f['url']).join('_')}'), + key: ValueKey( + 'gen_multi_${imageFiles.map((f) => f['url']).join('_')}', + ), spacing: Spacing.sm, runSpacing: Spacing.sm, children: imageFiles.map((file) { final imageUrl = file['url'] as String?; if (imageUrl == null) return const SizedBox.shrink(); - + return EnhancedImageAttachment( key: ValueKey('gen_attachment_$imageUrl'), attachmentId: imageUrl, // Pass URL directly @@ -465,7 +483,8 @@ class _AssistantMessageWidgetState extends ConsumerState maxWidth: imageCount == 2 ? 245 : 160, maxHeight: imageCount == 2 ? 245 : 160, ), - disableAnimation: widget.isStreaming, // Disable animation during streaming + disableAnimation: + widget.isStreaming, // Disable animation during streaming ); }).toList(), ), diff --git a/lib/features/chat/widgets/enhanced_image_attachment.dart b/lib/features/chat/widgets/enhanced_image_attachment.dart index fa07103..32194d4 100644 --- a/lib/features/chat/widgets/enhanced_image_attachment.dart +++ b/lib/features/chat/widgets/enhanced_image_attachment.dart @@ -725,9 +725,8 @@ class FullScreenImageViewer extends ConsumerWidget { await SharePlus.instance.share(ShareParams(files: [XFile(file.path)])); } catch (e) { - ScaffoldMessenger.of( - context, - ).showSnackBar(const SnackBar(content: Text('Failed to share image'))); + // Swallowing UI feedback per requirements; keep a log for debugging + debugPrint('Failed to share image: $e'); } } } diff --git a/lib/features/chat/widgets/message_batch_widget.dart b/lib/features/chat/widgets/message_batch_widget.dart index 86ca099..99c4291 100644 --- a/lib/features/chat/widgets/message_batch_widget.dart +++ b/lib/features/chat/widgets/message_batch_widget.dart @@ -307,36 +307,13 @@ class CopyOptionsSheet extends ConsumerWidget { if (content != null) { await Clipboard.setData(ClipboardData(text: content)); - if (context.mounted) { - ScaffoldMessenger.of(context).showSnackBar( - SnackBar( - content: Text( - '${messages.length} messages copied to clipboard', - ), - backgroundColor: AppTheme.success, - ), - ); - } + if (context.mounted) {} } } else { - if (context.mounted) { - ScaffoldMessenger.of(context).showSnackBar( - SnackBar( - content: Text('Failed to copy messages: ${result.error}'), - backgroundColor: AppTheme.error, - ), - ); - } + if (context.mounted) {} } } catch (e) { - if (context.mounted) { - ScaffoldMessenger.of(context).showSnackBar( - SnackBar( - content: Text('Error copying messages: $e'), - backgroundColor: AppTheme.error, - ), - ); - } + if (context.mounted) {} } } } @@ -652,21 +629,10 @@ class MoreOptionsSheet extends ConsumerWidget { controller.clear(); setState(() {}); // Refresh the dialog - if (context.mounted) { - ScaffoldMessenger.of(context).showSnackBar( - SnackBar(content: Text('Tag "$tag" added')), - ); - } + if (context.mounted) {} } } catch (e) { - if (context.mounted) { - ScaffoldMessenger.of(context).showSnackBar( - SnackBar( - content: Text('Failed to add tag: $e'), - backgroundColor: AppTheme.error, - ), - ); - } + if (context.mounted) {} } } }, @@ -730,28 +696,10 @@ class MoreOptionsSheet extends ConsumerWidget { ); setState(() {}); // Refresh the dialog - if (context.mounted) { - ScaffoldMessenger.of( - context, - ).showSnackBar( - SnackBar( - content: Text('Tag "$tag" removed'), - ), - ); - } + if (context.mounted) {} } } catch (e) { - if (context.mounted) { - ScaffoldMessenger.of(context).showSnackBar( - SnackBar( - content: Text( - 'Failed to remove tag: $e', - ), - backgroundColor: - context.conduitTheme.error, - ), - ); - } + if (context.mounted) {} } }, ), @@ -818,23 +766,12 @@ class MoreOptionsSheet extends ConsumerWidget { ref.invalidate(archivedConversationsProvider); if (context.mounted) { - ScaffoldMessenger.of(context).showSnackBar( - const SnackBar(content: Text('Conversation archived')), - ); - // Navigate back or clear current conversation Navigator.of(context).popUntil((route) => route.isFirst); } } } catch (e) { - if (context.mounted) { - ScaffoldMessenger.of(context).showSnackBar( - SnackBar( - content: Text('Failed to archive conversation: $e'), - backgroundColor: AppTheme.error, - ), - ); - } + if (context.mounted) {} } } } @@ -848,7 +785,7 @@ class MoreOptionsSheet extends ConsumerWidget { confirmText: 'Delete', isDestructive: true, ); - + if (confirmed == true && context.mounted) { _deleteMessages(context, ref); } @@ -880,23 +817,12 @@ class MoreOptionsSheet extends ConsumerWidget { ref.read(chatMessagesProvider.notifier).clearMessages(); if (context.mounted) { - ScaffoldMessenger.of(context).showSnackBar( - const SnackBar(content: Text('Conversation deleted')), - ); - // Navigate back to conversation list Navigator.of(context).popUntil((route) => route.isFirst); } } } catch (e) { - if (context.mounted) { - ScaffoldMessenger.of(context).showSnackBar( - SnackBar( - content: Text('Failed to delete conversation: $e'), - backgroundColor: AppTheme.error, - ), - ); - } + if (context.mounted) {} } } } diff --git a/lib/features/chat/widgets/modern_chat_input.dart b/lib/features/chat/widgets/modern_chat_input.dart index a80a00e..4ad579d 100644 --- a/lib/features/chat/widgets/modern_chat_input.dart +++ b/lib/features/chat/widgets/modern_chat_input.dart @@ -280,6 +280,8 @@ class _ModernChatInputState extends ConsumerState autofocus: false, maxLines: _isExpanded ? null : 1, keyboardType: TextInputType.multiline, + textCapitalization: + TextCapitalization.sentences, textInputAction: TextInputAction.newline, showCursor: true, cursorColor: context.conduitTheme.inputText, diff --git a/lib/features/chat/widgets/tag_management_dialog.dart b/lib/features/chat/widgets/tag_management_dialog.dart index 23888b1..54f8807 100644 --- a/lib/features/chat/widgets/tag_management_dialog.dart +++ b/lib/features/chat/widgets/tag_management_dialog.dart @@ -213,20 +213,9 @@ class _TagManagementDialogState extends ConsumerState { ref.invalidate(conversationsProvider); _tagController.clear(); - if (mounted) { - ScaffoldMessenger.of( - context, - ).showSnackBar(SnackBar(content: Text('Tag "$tag" added'))); - } + if (mounted) {} } catch (e) { - if (mounted) { - ScaffoldMessenger.of(context).showSnackBar( - SnackBar( - content: Text('Error adding tag: $e'), - backgroundColor: Theme.of(context).colorScheme.error, - ), - ); - } + if (mounted) {} } finally { setState(() => _isAdding = false); } @@ -240,20 +229,9 @@ class _TagManagementDialogState extends ConsumerState { await api.removeTagFromConversation(widget.conversation.id, tag); ref.invalidate(conversationsProvider); - if (mounted) { - ScaffoldMessenger.of( - context, - ).showSnackBar(SnackBar(content: Text('Tag "$tag" removed'))); - } + if (mounted) {} } catch (e) { - if (mounted) { - ScaffoldMessenger.of(context).showSnackBar( - SnackBar( - content: Text('Error removing tag: $e'), - backgroundColor: Theme.of(context).colorScheme.error, - ), - ); - } + if (mounted) {} } } } diff --git a/lib/features/navigation/views/chats_list_page.dart b/lib/features/navigation/views/chats_list_page.dart index feaec95..dc148b4 100644 --- a/lib/features/navigation/views/chats_list_page.dart +++ b/lib/features/navigation/views/chats_list_page.dart @@ -1295,12 +1295,7 @@ class _ChatsListPageState extends ConsumerState String name, BuildContext dialogContext, ) async { - // Store theme values and messenger before async operation - final theme = context.conduitTheme; - final textInverseColor = theme.textInverse; - final successColor = theme.success; - final errorColor = theme.error; - final messenger = ScaffoldMessenger.of(context); + // Begin async operation try { final api = ref.read(apiServiceProvider); @@ -1312,33 +1307,9 @@ class _ChatsListPageState extends ConsumerState if (mounted && dialogContext.mounted) { Navigator.pop(dialogContext); } - if (context.mounted) { - messenger.showSnackBar( - SnackBar( - content: Text( - 'Folder "$name" created', - style: AppTypography.bodyMediumStyle.copyWith( - color: textInverseColor, - ), - ), - backgroundColor: successColor, - ), - ); - } + if (context.mounted) {} } catch (e) { - if (context.mounted) { - messenger.showSnackBar( - SnackBar( - content: Text( - 'Failed to create folder: $e', - style: AppTypography.bodyMediumStyle.copyWith( - color: textInverseColor, - ), - ), - backgroundColor: errorColor, - ), - ); - } + if (context.mounted) {} } } @@ -1352,35 +1323,11 @@ class _ChatsListPageState extends ConsumerState // Refresh conversations list ref.invalidate(conversationsProvider); - if (mounted) { - ScaffoldMessenger.of(context).showSnackBar( - SnackBar( - content: Text( - newPinnedState ? 'Chat pinned' : 'Chat unpinned', - style: AppTypography.bodyMediumStyle.copyWith( - color: context.conduitTheme.textInverse, - ), - ), - backgroundColor: context.conduitTheme.success, - ), - ); - } + if (mounted) {} } } catch (e) { DebugLogger.error('Error toggling pin', e); - if (mounted) { - ScaffoldMessenger.of(context).showSnackBar( - SnackBar( - content: Text( - 'Failed to ${conversation.pinned == true ? 'unpin' : 'pin'} chat', - style: AppTypography.bodyMediumStyle.copyWith( - color: context.conduitTheme.textInverse, - ), - ), - backgroundColor: context.conduitTheme.error, - ), - ); - } + if (mounted) {} } } @@ -1393,35 +1340,11 @@ class _ChatsListPageState extends ConsumerState // Refresh conversations list ref.invalidate(conversationsProvider); - if (mounted) { - ScaffoldMessenger.of(context).showSnackBar( - SnackBar( - content: Text( - 'Chat archived', - style: AppTypography.bodyMediumStyle.copyWith( - color: context.conduitTheme.textInverse, - ), - ), - backgroundColor: context.conduitTheme.success, - ), - ); - } + if (mounted) {} } } catch (e) { DebugLogger.error('Error archiving conversation', e); - if (mounted) { - ScaffoldMessenger.of(context).showSnackBar( - SnackBar( - content: Text( - 'Failed to archive chat', - style: AppTypography.bodyMediumStyle.copyWith( - color: context.conduitTheme.textInverse, - ), - ), - backgroundColor: context.conduitTheme.error, - ), - ); - } + if (mounted) {} } } @@ -1446,35 +1369,11 @@ class _ChatsListPageState extends ConsumerState // Refresh conversations list ref.invalidate(conversationsProvider); - if (mounted) { - ScaffoldMessenger.of(context).showSnackBar( - SnackBar( - content: Text( - 'Chat deleted', - style: AppTypography.bodyMediumStyle.copyWith( - color: context.conduitTheme.textInverse, - ), - ), - backgroundColor: context.conduitTheme.success, - ), - ); - } + if (mounted) {} } } catch (e) { DebugLogger.error('Error deleting conversation', e); - if (mounted) { - ScaffoldMessenger.of(context).showSnackBar( - SnackBar( - content: Text( - 'Failed to delete chat', - style: AppTypography.bodyMediumStyle.copyWith( - color: context.conduitTheme.textInverse, - ), - ), - backgroundColor: context.conduitTheme.error, - ), - ); - } + if (mounted) {} } } }