Skip to content

Commit

Permalink
build using streambuilder
Browse files Browse the repository at this point in the history
  • Loading branch information
ubbabeck committed Oct 11, 2023
1 parent 100160f commit 4ef60df
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 27 deletions.
14 changes: 8 additions & 6 deletions lib/routes/account_required_actions.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
);
},
),
);
}
Expand Down
29 changes: 8 additions & 21 deletions lib/routes/funds_over_limit_dialog.dart
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -21,8 +20,6 @@ class SwapRefundDialog extends StatefulWidget {
}

class SwapRefundDialogState extends State<SwapRefundDialog> {
Future _fetchFuture;

@override
void initState() {
super.initState();
Expand All @@ -34,7 +31,7 @@ class SwapRefundDialogState extends State<SwapRefundDialog> {
void _fetchSwapFundStatus() {
final accountBloc = AppBlocsProvider.of<AccountBloc>(context);
var fetchAction = FetchSwapFundStatus();
_fetchFuture = fetchAction.future;

accountBloc.userActionsSink.add(fetchAction);
}

Expand All @@ -47,31 +44,21 @@ class SwapRefundDialogState extends State<SwapRefundDialog> {

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<AccountModel>(
stream: accountBloc.accountStream,
builder: (ctx, snapshot) {
final swapStatus = snapshot?.data?.swapFundsStatus;
if (swapStatus == null) {
return const Loader();
}

return StreamBuilder<AccountModel>(
stream: accountBloc.accountStream,
builder: (ctx, snapshot) {
final swapStatus = snapshot?.data?.swapFundsStatus;
if (swapStatus == null) {
return const Loader();
}

return _build(swapStatus);
},
);
return _build(swapStatus);
},
),
actions: [
Expand Down

0 comments on commit 4ef60df

Please sign in to comment.