From 4ef60dfdc32f5effe700949e9d1ca4ec4339aa74 Mon Sep 17 00:00:00 2001 From: ruben beck Date: Wed, 11 Oct 2023 22:02:28 +0200 Subject: [PATCH] build using streambuilder --- lib/routes/account_required_actions.dart | 14 +++++++----- lib/routes/funds_over_limit_dialog.dart | 29 +++++++----------------- 2 files changed, 16 insertions(+), 27 deletions(-) diff --git a/lib/routes/account_required_actions.dart b/lib/routes/account_required_actions.dart index 2bfa193a6..2a9c940d6 100644 --- a/lib/routes/account_required_actions.dart +++ b/lib/routes/account_required_actions.dart @@ -266,12 +266,14 @@ class AccountRequiredActionsIndicatorState if (swapStatus != null && swapStatus.waitingRefundAddresses.isNotEmpty) { warnings.add( WarningAction( - () => showDialog( - useRootNavigator: false, - barrierDismissible: false, - context: context, - builder: (_) => const SwapRefundDialog(), - ), + () async { + showDialog( + useRootNavigator: false, + barrierDismissible: false, + context: context, + builder: (_) => const SwapRefundDialog(), + ); + }, ), ); } diff --git a/lib/routes/funds_over_limit_dialog.dart b/lib/routes/funds_over_limit_dialog.dart index 8a10d5b43..d526c76bb 100644 --- a/lib/routes/funds_over_limit_dialog.dart +++ b/lib/routes/funds_over_limit_dialog.dart @@ -1,4 +1,3 @@ -import 'package:auto_size_text/auto_size_text.dart'; import 'package:breez/bloc/account/account_actions.dart'; import 'package:breez/bloc/account/account_bloc.dart'; import 'package:breez/bloc/account/account_model.dart'; @@ -21,8 +20,6 @@ class SwapRefundDialog extends StatefulWidget { } class SwapRefundDialogState extends State { - Future _fetchFuture; - @override void initState() { super.initState(); @@ -34,7 +31,7 @@ class SwapRefundDialogState extends State { void _fetchSwapFundStatus() { final accountBloc = AppBlocsProvider.of(context); var fetchAction = FetchSwapFundStatus(); - _fetchFuture = fetchAction.future; + accountBloc.userActionsSink.add(fetchAction); } @@ -47,31 +44,21 @@ class SwapRefundDialogState extends State { return AlertDialog( titlePadding: const EdgeInsets.fromLTRB(24.0, 22.0, 24.0, 16.0), - title: AutoSizeText( + title: Text( texts.funds_over_limit_dialog_on_chain_transaction, style: themeData.dialogTheme.titleTextStyle, maxLines: 1, ), contentPadding: const EdgeInsets.fromLTRB(24.0, 8.0, 24.0, 24.0), - content: FutureBuilder( - future: _fetchFuture, - initialData: "loading", - builder: (ctx, loadingSnapshot) { - if (loadingSnapshot.data == "loading") { + content: StreamBuilder( + stream: accountBloc.accountStream, + builder: (ctx, snapshot) { + final swapStatus = snapshot?.data?.swapFundsStatus; + if (swapStatus == null) { return const Loader(); } - return StreamBuilder( - stream: accountBloc.accountStream, - builder: (ctx, snapshot) { - final swapStatus = snapshot?.data?.swapFundsStatus; - if (swapStatus == null) { - return const Loader(); - } - - return _build(swapStatus); - }, - ); + return _build(swapStatus); }, ), actions: [