Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions lib/core/deep_link_handler.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import 'package:logger/logger.dart';
import 'package:mostro_mobile/generated/l10n.dart';
import 'package:mostro_mobile/services/deep_link_service.dart';
import 'package:mostro_mobile/shared/providers/nostr_service_provider.dart';
import 'package:mostro_mobile/shared/utils/snack_bar_helper.dart';

class DeepLinkHandler {
final Ref _ref;
Expand Down Expand Up @@ -149,12 +150,11 @@ class DeepLinkHandler {
void _showErrorSnackBar(BuildContext? context, String message) {
if (context == null) return;

ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: Text(message),
backgroundColor: Colors.red,
duration: const Duration(seconds: 3),
),
SnackBarHelper.showTopSnackBar(
context,
message,
duration: const Duration(seconds: 3),
backgroundColor: Colors.red,
);
}

Expand Down
6 changes: 4 additions & 2 deletions lib/features/auth/screens/login_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import 'package:mostro_mobile/features/auth/notifiers/auth_state.dart';
import 'package:mostro_mobile/features/auth/providers/auth_notifier_provider.dart';
import 'package:mostro_mobile/shared/widgets/custom_button.dart';
import 'package:mostro_mobile/generated/l10n.dart';
import 'package:mostro_mobile/shared/utils/snack_bar_helper.dart';

class LoginScreen extends HookConsumerWidget {
const LoginScreen({super.key});
Expand All @@ -20,8 +21,9 @@ class LoginScreen extends HookConsumerWidget {
if (state is AuthAuthenticated) {
context.go('/');
} else if (state is AuthFailure) {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(content: Text(state.error)),
SnackBarHelper.showTopSnackBar(
context,
state.error,
);
}
});
Expand Down
6 changes: 4 additions & 2 deletions lib/features/auth/screens/register_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import 'package:mostro_mobile/features/notifications/providers/backup_reminder_p
import 'package:mostro_mobile/shared/widgets/custom_button.dart';
import 'package:mostro_mobile/shared/utils/nostr_utils.dart';
import 'package:mostro_mobile/generated/l10n.dart';
import 'package:mostro_mobile/shared/utils/snack_bar_helper.dart';

class RegisterScreen extends HookConsumerWidget {
const RegisterScreen({super.key});
Expand Down Expand Up @@ -39,8 +40,9 @@ class RegisterScreen extends HookConsumerWidget {
// Navigate to home after successful registration
context.go('/');
} else if (state is AuthFailure) {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(content: Text(state.error)),
SnackBarHelper.showTopSnackBar(
context,
state.error,
);
}
});
Expand Down
21 changes: 10 additions & 11 deletions lib/features/chat/widgets/encrypted_file_message.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import 'package:mostro_mobile/features/chat/providers/chat_room_providers.dart';
import 'package:mostro_mobile/services/encrypted_file_upload_service.dart';
import 'package:mostro_mobile/services/file_validation_service.dart';
import 'package:mostro_mobile/generated/l10n.dart';
import 'package:mostro_mobile/shared/utils/snack_bar_helper.dart';

class EncryptedFileMessage extends ConsumerStatefulWidget {
final NostrEvent message;
Expand Down Expand Up @@ -494,22 +495,20 @@ class _EncryptedFileMessageState extends ConsumerState<EncryptedFileMessage> {

if (mounted) {
if (result.type != ResultType.done) {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: Text('Could not open file: ${result.message}'),
backgroundColor: Colors.orange,
duration: const Duration(seconds: 3),
),
SnackBarHelper.showTopSnackBar(
context,
'Could not open file: ${result.message}',
duration: const Duration(seconds: 3),
backgroundColor: Colors.orange,
);
}
}
} catch (e) {
if (mounted) {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: Text('Error opening file: $e'),
backgroundColor: Colors.red,
),
SnackBarHelper.showTopSnackBar(
context,
'Error opening file: $e',
backgroundColor: Colors.red,
);
}
}
Expand Down
21 changes: 10 additions & 11 deletions lib/features/chat/widgets/encrypted_image_message.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import 'package:mostro_mobile/core/app_theme.dart';
import 'package:mostro_mobile/features/chat/providers/chat_room_providers.dart';
import 'package:mostro_mobile/services/encrypted_image_upload_service.dart';
import 'package:mostro_mobile/generated/l10n.dart';
import 'package:mostro_mobile/shared/utils/snack_bar_helper.dart';

class EncryptedImageMessage extends ConsumerStatefulWidget {
final NostrEvent message;
Expand Down Expand Up @@ -373,22 +374,20 @@ class _EncryptedImageMessageState extends ConsumerState<EncryptedImageMessage> {

if (mounted) {
if (result.type != ResultType.done) {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: Text('$couldNotOpenMsg: ${result.message}'),
backgroundColor: Colors.orange,
duration: const Duration(seconds: 3),
),
SnackBarHelper.showTopSnackBar(
context,
'$couldNotOpenMsg: ${result.message}',
duration: const Duration(seconds: 3),
backgroundColor: Colors.orange,
);
}
}
} catch (e) {
if (mounted) {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: Text('$errorOpeningMsg: $e'),
backgroundColor: Colors.red,
),
SnackBarHelper.showTopSnackBar(
context,
'$errorOpeningMsg: $e',
backgroundColor: Colors.red,
);
}
}
Expand Down
17 changes: 6 additions & 11 deletions lib/features/chat/widgets/message_bubble.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import 'package:mostro_mobile/shared/providers/avatar_provider.dart';
import 'package:mostro_mobile/features/chat/widgets/encrypted_image_message.dart';
import 'package:mostro_mobile/features/chat/widgets/encrypted_file_message.dart';
import 'package:mostro_mobile/features/chat/utils/message_type_helpers.dart';
import 'package:mostro_mobile/shared/utils/snack_bar_helper.dart';

class MessageBubble extends ConsumerWidget {
final NostrEvent message;
Expand Down Expand Up @@ -154,17 +155,11 @@ class MessageBubble extends ConsumerWidget {
// Only copy if text is not empty
if (text.isNotEmpty) {
Clipboard.setData(ClipboardData(text: text));
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: Text(S.of(context)!.messageCopiedToClipboard),
duration: const Duration(seconds: 2),
backgroundColor: AppTheme.backgroundCard,
behavior: SnackBarBehavior.floating,
margin: const EdgeInsets.all(16),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(8),
),
),
SnackBarHelper.showTopSnackBar(
context,
S.of(context)!.messageCopiedToClipboard,
duration: const Duration(seconds: 2),
backgroundColor: AppTheme.backgroundCard,
);
}
}
Expand Down
10 changes: 5 additions & 5 deletions lib/features/chat/widgets/message_input.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import 'package:mostro_mobile/services/encrypted_file_upload_service.dart';
import 'package:mostro_mobile/services/encrypted_image_upload_service.dart';
import 'package:mostro_mobile/services/file_validation_service.dart';
import 'package:mostro_mobile/services/media_validation_service.dart';
import 'package:mostro_mobile/shared/utils/snack_bar_helper.dart';

class MessageInput extends ConsumerStatefulWidget {
final String orderId;
Expand Down Expand Up @@ -127,11 +128,10 @@ class _MessageInputState extends ConsumerState<MessageInput> {
} catch (e) {
// Show error to user
if (mounted) {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: Text('Error uploading file: $e'),
backgroundColor: Colors.red,
),
SnackBarHelper.showTopSnackBar(
context,
'Error uploading file: $e',
backgroundColor: Colors.red,
);
}
} finally {
Expand Down
19 changes: 9 additions & 10 deletions lib/features/disputes/widgets/dispute_input_section.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import 'package:flutter/material.dart';
import 'package:mostro_mobile/core/app_theme.dart';
import 'package:mostro_mobile/generated/l10n.dart';
import 'package:mostro_mobile/shared/utils/snack_bar_helper.dart';

class DisputeInputSection extends StatefulWidget {
final String disputeId;
Expand Down Expand Up @@ -127,20 +128,18 @@ class _DisputeInputSectionState extends State<DisputeInputSection> {
await Future.delayed(const Duration(milliseconds: 500));

if (mounted) {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: Text('Message sent: $message'),
backgroundColor: Colors.green,
),
SnackBarHelper.showTopSnackBar(
context,
'Message sent: $message',
backgroundColor: Colors.green,
);
}
} catch (error) {
if (mounted) {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: Text('Failed to send message: $error'),
backgroundColor: Colors.red,
),
SnackBarHelper.showTopSnackBar(
context,
'Failed to send message: $error',
backgroundColor: Colors.red,
);
}
} finally {
Expand Down
12 changes: 6 additions & 6 deletions lib/features/disputes/widgets/dispute_message_bubble.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:mostro_mobile/core/app_theme.dart';
import 'package:mostro_mobile/generated/l10n.dart';
import 'package:mostro_mobile/shared/utils/snack_bar_helper.dart';

class DisputeMessageBubble extends StatelessWidget {
final String message;
Expand Down Expand Up @@ -88,12 +89,11 @@ class DisputeMessageBubble extends StatelessWidget {

void _copyToClipboard(BuildContext context, String text) {
Clipboard.setData(ClipboardData(text: text));
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: Text(S.of(context)?.messageCopiedToClipboard ?? 'Message copied to clipboard'),
duration: const Duration(seconds: 1),
backgroundColor: Colors.green,
),
SnackBarHelper.showTopSnackBar(
context,
S.of(context)?.messageCopiedToClipboard ?? 'Message copied to clipboard',
duration: const Duration(seconds: 1),
backgroundColor: Colors.green,
);
}

Expand Down
11 changes: 7 additions & 4 deletions lib/features/key_manager/key_management_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import 'package:mostro_mobile/features/notifications/providers/backup_reminder_p
import 'package:mostro_mobile/shared/providers.dart';
import 'package:mostro_mobile/generated/l10n.dart';
import 'package:mostro_mobile/shared/providers/notifications_history_repository_provider.dart';
import 'package:mostro_mobile/shared/utils/snack_bar_helper.dart';

class KeyManagementScreen extends ConsumerStatefulWidget {
const KeyManagementScreen({super.key});
Expand Down Expand Up @@ -90,14 +91,16 @@ class _KeyManagementScreenState extends ConsumerState<KeyManagementScreen> {
await keyManager.importMnemonic(importValue);
await _loadKeys();
if (mounted) {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(content: Text(S.of(context)!.keyImportedSuccessfully)),
SnackBarHelper.showTopSnackBar(
context,
S.of(context)!.keyImportedSuccessfully,
);
}
} catch (e) {
if (mounted) {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(content: Text(S.of(context)!.importFailed(e.toString()))),
SnackBarHelper.showTopSnackBar(
context,
S.of(context)!.importFailed(e.toString()),
);
}
}
Expand Down
6 changes: 4 additions & 2 deletions lib/features/logs/screens/logs_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import 'package:mostro_mobile/features/settings/settings_provider.dart';
import 'package:mostro_mobile/generated/l10n.dart';
import 'package:mostro_mobile/services/logger_service.dart';
import 'package:mostro_mobile/shared/utils/datetime_extensions_utils.dart';
import 'package:mostro_mobile/shared/utils/snack_bar_helper.dart';

class LogsScreen extends ConsumerStatefulWidget {
const LogsScreen({super.key});
Expand Down Expand Up @@ -142,8 +143,9 @@ class _LogsScreenState extends ConsumerState<LogsScreen> {
ref.read(logsProvider.notifier).clearLogs();
WidgetsBinding.instance.addPostFrameCallback((_) {
if (mounted) {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(content: Text(S.of(context)!.logsCleared)),
SnackBarHelper.showTopSnackBar(
context,
S.of(context)!.logsCleared,
);
}
});
Expand Down
19 changes: 9 additions & 10 deletions lib/features/notifications/widgets/notifications_actions_menu.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import 'package:heroicons/heroicons.dart';
import 'package:mostro_mobile/core/app_theme.dart';
import 'package:mostro_mobile/features/notifications/providers/notifications_provider.dart';
import 'package:mostro_mobile/generated/l10n.dart';
import 'package:mostro_mobile/shared/utils/snack_bar_helper.dart';

class NotificationsActionsMenu extends ConsumerWidget {
const NotificationsActionsMenu({super.key});
Expand Down Expand Up @@ -74,11 +75,10 @@ class NotificationsActionsMenu extends ConsumerWidget {
switch (action) {
case 'mark_all_read':
repository.markAllAsRead();
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: Text(S.of(context)!.markAllAsRead),
backgroundColor: AppTheme.statusSuccess,
),
SnackBarHelper.showTopSnackBar(
context,
S.of(context)!.markAllAsRead,
backgroundColor: AppTheme.statusSuccess,
);
break;
case 'clear_all':
Expand Down Expand Up @@ -112,11 +112,10 @@ class NotificationsActionsMenu extends ConsumerWidget {
onPressed: () {
ref.read(notificationsDatabaseProvider).clearAll();
Navigator.of(context).pop();
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: Text(S.of(context)!.clearAll),
backgroundColor: AppTheme.statusError,
),
SnackBarHelper.showTopSnackBar(
context,
S.of(context)!.clearAll,
backgroundColor: AppTheme.statusError,
);
},
child: Text(
Expand Down
17 changes: 7 additions & 10 deletions lib/features/order/screens/add_lightning_invoice_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import 'package:mostro_mobile/shared/providers/mostro_storage_provider.dart';
import 'package:mostro_mobile/data/models/order.dart';
import 'package:mostro_mobile/shared/widgets/add_lightning_invoice_widget.dart';
import 'package:mostro_mobile/generated/l10n.dart';
import 'package:mostro_mobile/shared/utils/snack_bar_helper.dart';

class AddLightningInvoiceScreen extends ConsumerStatefulWidget {
final String orderId;
Expand Down Expand Up @@ -63,11 +64,9 @@ class _AddLightningInvoiceScreenState
if (context.mounted) context.go('/');
} catch (e) {
if (context.mounted) {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: Text(
'Failed to update invoice: ${e.toString()}'),
),
SnackBarHelper.showTopSnackBar(
context,
'Failed to update invoice: ${e.toString()}',
);
}
}
Expand All @@ -81,11 +80,9 @@ class _AddLightningInvoiceScreenState
if (context.mounted) context.go('/');
} catch (e) {
if (context.mounted) {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: Text(
'Failed to cancel order: ${e.toString()}'),
),
SnackBarHelper.showTopSnackBar(
context,
'Failed to cancel order: ${e.toString()}',
);
}
}
Expand Down
Loading
Loading