From 02a92351291c23d5e601b10acfe1e62aadfdebc3 Mon Sep 17 00:00:00 2001 From: Victor Eronmosele Date: Mon, 7 Oct 2024 19:14:43 +0100 Subject: [PATCH] chore: remove 'verifying dap...' loading message from sendpage (#305) --- lib/features/dap/dap_form.dart | 72 ++++++++++++++++++------------ lib/features/send/send_page.dart | 76 +++++++++++++++----------------- 2 files changed, 80 insertions(+), 68 deletions(-) diff --git a/lib/features/dap/dap_form.dart b/lib/features/dap/dap_form.dart index 72af98a..e90bc34 100644 --- a/lib/features/dap/dap_form.dart +++ b/lib/features/dap/dap_form.dart @@ -53,35 +53,51 @@ class DapForm extends HookConsumerWidget { child: Column( crossAxisAlignment: CrossAxisAlignment.stretch, children: [ - TextFormField( - focusNode: focusNode, - controller: textController, - onTap: () => errorText.value = null, - onTapOutside: (_) { - if (textController.text.isNotEmpty) { - _parseDap( - textController.text, - errorMessage, - errorText, - ); - } + Row( + crossAxisAlignment: CrossAxisAlignment.end, + children: [ + Expanded( + child: TextFormField( + focusNode: focusNode, + controller: textController, + onTap: () => errorText.value = null, + onTapOutside: (_) { + if (textController.text.isNotEmpty) { + _parseDap( + textController.text, + errorMessage, + errorText, + ); + } - focusNode.unfocus(); - }, - onFieldSubmitted: (_) => _parseDap( - textController.text, - errorMessage, - errorText, - ), - enableSuggestions: false, - autocorrect: false, - decoration: InputDecoration( - labelText: Loc.of(context).dapHint, - errorText: errorText.value, - ), - validator: (value) => value == null || value.isEmpty - ? Loc.of(context).thisFieldCannotBeEmpty - : null, + focusNode.unfocus(); + }, + onFieldSubmitted: (_) => _parseDap( + textController.text, + errorMessage, + errorText, + ), + enableSuggestions: false, + autocorrect: false, + decoration: InputDecoration( + labelText: Loc.of(context).dapHint, + errorText: errorText.value, + ), + validator: (value) => value == null || value.isEmpty + ? Loc.of(context).thisFieldCannotBeEmpty + : null, + ), + ), + const SizedBox(width: Grid.xs), + if (dap.value?.isLoading ?? false) + const Padding( + padding: EdgeInsets.all(Grid.xxs), + child: SizedBox.square( + dimension: Grid.sm, + child: CircularProgressIndicator(), + ), + ), + ], ), ], ), diff --git a/lib/features/send/send_page.dart b/lib/features/send/send_page.dart index f9f8154..9ff39c5 100644 --- a/lib/features/send/send_page.dart +++ b/lib/features/send/send_page.dart @@ -29,52 +29,48 @@ class SendPage extends HookConsumerWidget { return Scaffold( appBar: _buildAppBar(context, featureFlags), body: SafeArea( - child: dap.value != null - ? dap.value!.when( - data: (_) => Container(), - loading: () => - LoadingMessage(message: Loc.of(context).verifyingDap), - error: (error, _) => ErrorMessage( - message: error.toString(), - onRetry: () => dap.value = null, + child: switch (dap.value) { + AsyncError(:final error) => ErrorMessage( + message: error.toString(), + onRetry: () => dap.value = null, + ), + _ => Column( + crossAxisAlignment: CrossAxisAlignment.stretch, + children: [ + Header( + title: Loc.of(context).whoDoYouWantToPay, + subtitle: Loc.of(context).enterADap, ), - ) - : Column( - crossAxisAlignment: CrossAxisAlignment.stretch, - children: [ - Header( - title: Loc.of(context).whoDoYouWantToPay, - subtitle: Loc.of(context).enterADap, - ), - Expanded( - child: DapForm( - buttonTitle: Loc.of(context).next, - dapText: dapText, - dap: dap, - onSubmit: (recipientDap, moneyAddresses) async { - await Navigator.of(context).push( - MaterialPageRoute( - builder: (_) => PaymentAmountPage( - paymentState: PaymentState( - transactionType: TransactionType.send, - paymentDetailsState: PaymentDetailsState( - paymentName: recipientDap.dap, - ), - ), - dapState: DapState( - moneyAddresses: moneyAddresses, + Expanded( + child: DapForm( + buttonTitle: Loc.of(context).next, + dapText: dapText, + dap: dap, + onSubmit: (recipientDap, moneyAddresses) async { + await Navigator.of(context).push( + MaterialPageRoute( + builder: (_) => PaymentAmountPage( + paymentState: PaymentState( + transactionType: TransactionType.send, + paymentDetailsState: PaymentDetailsState( + paymentName: recipientDap.dap, ), ), - fullscreenDialog: true, + dapState: DapState( + moneyAddresses: moneyAddresses, + ), ), - ); + fullscreenDialog: true, + ), + ); - if (context.mounted) dap.value = null; - }, - ), + if (context.mounted) dap.value = null; + }, ), - ], - ), + ), + ], + ), + }, ), ); }