diff --git a/lib/routes/home/widgets/bottom_actions_bar/send_options_bottom_sheet.dart b/lib/routes/home/widgets/bottom_actions_bar/send_options_bottom_sheet.dart index 97f0d5eb5..b2d93665a 100644 --- a/lib/routes/home/widgets/bottom_actions_bar/send_options_bottom_sheet.dart +++ b/lib/routes/home/widgets/bottom_actions_bar/send_options_bottom_sheet.dart @@ -1,16 +1,12 @@ -import 'package:breez_sdk/bridge_generated.dart'; import 'package:breez_translations/breez_translations_locales.dart'; import 'package:c_breez/bloc/account/account_bloc.dart'; import 'package:c_breez/bloc/account/account_state.dart'; -import 'package:c_breez/bloc/input/input_bloc.dart'; import 'package:c_breez/routes/home/widgets/bottom_actions_bar/bottom_action_item_image.dart'; import 'package:c_breez/routes/home/widgets/bottom_actions_bar/enter_payment_info_dialog.dart'; import 'package:c_breez/routes/withdraw_funds/withdraw_funds_address_page.dart'; import 'package:c_breez/theme/theme_provider.dart' as theme; -import 'package:c_breez/widgets/loader.dart'; import 'package:fimber/fimber.dart'; import 'package:flutter/material.dart'; -import 'package:flutter/services.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; final _log = FimberLog("SendOptionsBottomSheet"); @@ -28,8 +24,6 @@ class SendOptionsBottomSheet extends StatefulWidget { } class _SendOptionsBottomSheetState extends State { - ModalRoute? _loaderRoute; - @override Widget build(BuildContext context) { final texts = context.texts(); @@ -46,7 +40,7 @@ class _SendOptionsBottomSheetState extends State { texts.bottom_action_bar_paste_invoice, style: theme.bottomSheetTextStyle, ), - onTap: () => _pasteFromClipboard(context), + onTap: () => _showEnterPaymentInfoDialog(context, widget.firstPaymentItemKey), ), Divider( height: 0.0, @@ -73,57 +67,6 @@ class _SendOptionsBottomSheetState extends State { ); } - // TODO: Improve error handling flow to reduce open Enter Payment Info Dialog calls - Future _pasteFromClipboard(BuildContext context) async { - try { - final inputBloc = context.read(); - _setLoading(true); - // Get clipboard data - await Clipboard.getData("text/plain").then( - (clipboardData) async { - // Close bottom sheet - Navigator.of(context).pop(); - final clipboardText = clipboardData?.text; - _log.v("Clipboard text: $clipboardText"); - if (clipboardText != null) { - // Parse clipboard text - await inputBloc.parseInput(input: clipboardText).then( - (inputType) { - // Handle parsed input - if (!(inputType is InputType_Bolt11 || - inputType is InputType_LnUrlPay || - inputType is InputType_LnUrlWithdraw || - inputType is InputType_LnUrlAuth || - inputType is InputType_LnUrlError || - inputType is InputType_NodeId)) { - _showEnterPaymentInfoDialog(context, widget.firstPaymentItemKey); - } else { - inputBloc.addIncomingInput(clipboardText); - } - }, - ); - } else { - _setLoading(false); - // If clipboard data is empty, display EnterPaymentInfoDialog - _showEnterPaymentInfoDialog( - context, - widget.firstPaymentItemKey, - ); - } - }, - ); - } catch (e) { - _setLoading(false); - // If there's an error getting the clipboard data, display EnterPaymentInfoDialog - _showEnterPaymentInfoDialog( - context, - widget.firstPaymentItemKey, - ); - } finally { - _setLoading(false); - } - } - Future _showEnterPaymentInfoDialog( BuildContext context, GlobalKey> firstPaymentItemKey, @@ -152,17 +95,4 @@ class _SendOptionsBottomSheetState extends State { ), ); } - - void _setLoading(bool visible) { - if (visible && _loaderRoute == null) { - _loaderRoute = createLoaderRoute(context); - Navigator.of(context).push(_loaderRoute!); - return; - } - - if (!visible && (_loaderRoute != null && _loaderRoute!.isActive)) { - _loaderRoute!.navigator?.removeRoute(_loaderRoute!); - _loaderRoute = null; - } - } }