Skip to content

Commit

Permalink
feat: 💄 Show snackbar during RPC signTransactions command processing.
Browse files Browse the repository at this point in the history
  • Loading branch information
Chralu committed Nov 5, 2024
1 parent 0489006 commit 8f999b7
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 2 deletions.
3 changes: 2 additions & 1 deletion lib/l10n/intl_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -746,5 +746,6 @@
"logsDialogTitle": "Logs",
"logsDesc": "If you encounter any problems, you can copy and send the information below to the Archethic support team.\nEnsure that no sensitive or private information that could affect the security of your funds is shared.",
"logsCopied": "Logs copied",
"getSomeHelp": "Get some help"
"getSomeHelp": "Get some help",
"rpcSignTransactionsProcessing": "Processing transactions signature request"
}
3 changes: 2 additions & 1 deletion lib/l10n/intl_fr.arb
Original file line number Diff line number Diff line change
Expand Up @@ -726,5 +726,6 @@
"logsDialogTitle": "Journal",
"logsDesc": "Si vous rencontrez des problèmes, vous pouvez copier et envoyer les informations ci-dessous à l'équipe support d'Archethic.\nVeillez à ce qu'aucune information sensible ou privée qui pourrait affecter la sécurité de vos fonds ne soit partagée.",
"logsCopied": "Informations copiées",
"getSomeHelp": "Contactez nous"
"getSomeHelp": "Contactez nous",
"rpcSignTransactionsProcessing": "Traitement de la demande de signature"
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@ import 'package:aewallet/ui/themes/archethic_theme.dart';
import 'package:aewallet/ui/util/window_util_desktop.dart'
if (dart.library.js) 'package:aewallet/ui/util/window_util_web.dart';
import 'package:aewallet/ui/views/rpc_command_receiver/sign_transactions/layouts/sign_transactions_confirmation_form.dart';
import 'package:aewallet/ui/views/rpc_command_receiver/util/processing_indicator.dart';
import 'package:archethic_lib_dart/archethic_lib_dart.dart' as archethic;
import 'package:archethic_wallet_client/archethic_wallet_client.dart' as awc;
import 'package:flutter/material.dart';
import 'package:flutter_gen/gen_l10n/localizations.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';

const slippage = 1.01;
Expand All @@ -22,8 +24,13 @@ class SignTransactionsCommandHandler extends CommandHandler {
canHandle: (command) =>
command is RPCCommand<awc.SignTransactionRequest>,
handle: (command) async {
final localizations = AppLocalizations.of(context)!;
command as RPCCommand<awc.SignTransactionRequest>;

CommandHandlerLoadingSnackbar(
message: localizations.rpcSignTransactionsProcessing,
).show(context);

final signedTransactionList = <awc.SignTransactionsResultDetail>[];
final serviceName = command.data.serviceName;
final pathSuffix = command.data.pathSuffix;
Expand Down Expand Up @@ -84,6 +91,8 @@ class SignTransactionsCommandHandler extends CommandHandler {
addresses.add(signedTransaction.address?.address);
}

CommandHandlerLoadingSnackbar.hide(context);

await WindowUtil().showFirst();

final confirmation = await showDialog<bool>(
Expand All @@ -109,6 +118,10 @@ class SignTransactionsCommandHandler extends CommandHandler {
);
}

CommandHandlerLoadingSnackbar(
message: localizations.rpcSignTransactionsProcessing,
).show(context);

for (final rpcSignTransactionCommandData
in command.data.transactions) {
final transaction = archethic.Transaction(
Expand Down Expand Up @@ -139,6 +152,8 @@ class SignTransactionsCommandHandler extends CommandHandler {
index++;
}

CommandHandlerLoadingSnackbar.hide(context);

return Result.success(
awc.SignTransactionsResult(signedTxs: signedTransactionList),
);
Expand Down
30 changes: 30 additions & 0 deletions lib/ui/views/rpc_command_receiver/util/processing_indicator.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import 'package:flutter/material.dart';

class CommandHandlerLoadingSnackbar extends SnackBar {
CommandHandlerLoadingSnackbar({super.key, required String message})
: super(
duration: const Duration(days: 1),
behavior: SnackBarBehavior.floating,
content: Row(
children: [
const CircularProgressIndicator(
strokeWidth: 2,
),
const SizedBox(
width: 21,
),
Text(message),
],
),
);

void show(BuildContext context) {
if (!context.mounted) return;
ScaffoldMessenger.of(context).showSnackBar(this);
}

static void hide(BuildContext context) {
if (!context.mounted) return;
ScaffoldMessenger.of(context).hideCurrentSnackBar();
}
}

0 comments on commit 8f999b7

Please sign in to comment.