Skip to content

Commit ec65540

Browse files
fix: show failures on the initial screen and the send step
1 parent b9dda18 commit ec65540

27 files changed

Lines changed: 66 additions & 1 deletion

lib/features/sell/domain/sell_failure.dart

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,10 @@ final class SellPrepareTransactionFailure extends SellFailure {
3636
const SellPrepareTransactionFailure([super.logMessage]);
3737
}
3838

39+
final class SellSendPaymentFailure extends SellFailure {
40+
const SellSendPaymentFailure([super.logMessage]);
41+
}
42+
3943
final class SellLoadUtxosFailure extends SellFailure {
4044
const SellLoadUtxosFailure([super.logMessage]);
4145
}

lib/features/sell/presentation/bloc/sell_bloc.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -443,7 +443,7 @@ class SellBloc extends Bloc<SellEvent, SellState> {
443443
log.severe(message: 'send payment confirmation failed', error: e, trace: st);
444444
emit(
445445
sellPaymentState.copyWith(
446-
error: SellPrepareTransactionFailure(e.toString()),
446+
error: SellSendPaymentFailure(e.toString()),
447447
isConfirmingPayment: false,
448448
),
449449
);

lib/features/sell/presentation/sell_failure_l10n.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ extension SellFailureL10n on SellFailure {
1616
),
1717
SellPrepareTransactionFailure() =>
1818
context.loc.sellErrorFeesNotCalculated,
19+
SellSendPaymentFailure() => context.loc.sellErrorSendPayment,
1920
SellLoadUtxosFailure() => context.loc.sellErrorLoadUtxos,
2021
SellUnexpectedFailure() => context.loc.oopsSomethingWentWrong,
2122
};

lib/features/sell/ui/screens/sell_screen.dart

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
11
import 'package:bb_mobile/core/exchange/domain/entity/order.dart';
2+
import 'package:bb_mobile/core/themes/app_theme.dart';
23
import 'package:bb_mobile/core/utils/build_context_x.dart';
34
import 'package:bb_mobile/core/widgets/inputs/bb_keyboard_actions.dart';
45
import 'package:bb_mobile/core/widgets/scrollable_column.dart';
6+
import 'package:bb_mobile/features/sell/presentation/bloc/sell_bloc.dart';
7+
import 'package:bb_mobile/features/sell/presentation/sell_failure_l10n.dart';
58
import 'package:bb_mobile/features/sell/ui/widgets/sell_amount_currency_dropdown.dart';
69
import 'package:bb_mobile/features/sell/ui/widgets/sell_amount_input_bottom_buttons.dart';
710
import 'package:bb_mobile/features/sell/ui/widgets/sell_amount_input_field.dart';
811
import 'package:flutter/material.dart';
12+
import 'package:flutter_bloc/flutter_bloc.dart';
913
import 'package:gap/gap.dart';
1014
import 'package:go_router/go_router.dart';
1115

@@ -68,6 +72,8 @@ class _SellScreenState extends State<SellScreen> {
6872
});
6973
},
7074
),
75+
const Gap(16.0),
76+
const _SellError(),
7177
const Spacer(),
7278
SellAmountInputBottomButtons(
7379
formKey: _formKey,
@@ -91,3 +97,31 @@ class _SellScreenState extends State<SellScreen> {
9197
super.dispose();
9298
}
9399
}
100+
101+
class _SellError extends StatelessWidget {
102+
const _SellError();
103+
104+
@override
105+
Widget build(BuildContext context) {
106+
final failure = context.select(
107+
(SellBloc bloc) => bloc.state is SellInitialState
108+
? (bloc.state as SellInitialState).failure
109+
: null,
110+
);
111+
112+
if (failure == null) return const SizedBox.shrink();
113+
114+
return Center(
115+
child: Padding(
116+
padding: const EdgeInsets.symmetric(horizontal: 16.0),
117+
child: Text(
118+
failure.toTranslated(context),
119+
style: context.font.bodyMedium?.copyWith(
120+
color: context.appColors.error,
121+
),
122+
textAlign: TextAlign.center,
123+
),
124+
),
125+
);
126+
}
127+
}

localization/app_ar.arb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10067,6 +10067,7 @@
1006710067
"description": "Status while hardware wallet signs"
1006810068
},
1006910069
"sellErrorFeesNotCalculated": "رسوم المعاملات غير محسوبة أرجوك حاول مرة أخرى.",
10070+
"sellErrorSendPayment": "فشل إرسال الدفعة. يرجى المحاولة مرة أخرى.",
1007010071
"@sellErrorFeesNotCalculated": {
1007110072
"description": "Error message when transaction fees calculation failed"
1007210073
},

localization/app_as.arb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9062,6 +9062,7 @@
90629062
"description": "Description explaining user must complete KYC before proceeding"
90639063
},
90649064
"sellErrorFeesNotCalculated": "লেনদেনৰ মাচুল গণনা কৰা হোৱা নাই। অনুগ্ৰহ কৰি পুনৰ চেষ্টা কৰক।",
9065+
"sellErrorSendPayment": "পেমেণ্ট পঠাবলৈ ব্যৰ্থ হ'ল। অনুগ্ৰহ কৰি পুনৰ চেষ্টা কৰক।",
90659066
"@sellErrorFeesNotCalculated": {
90669067
"description": "Error message when transaction fees calculation failed"
90679068
},

localization/app_bg.arb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10066,5 +10066,6 @@
1006610066
"logsExportedMessage": "Журналите са експортирани успешно",
1006710067
"logsExportFailedMessage": "Неуспешно експортиране на журналите",
1006810068
"sellErrorFeesNotCalculated": "Транзакционните такси не са изчислени. Моля, опитайте отново.",
10069+
"sellErrorSendPayment": "Плащането не бе изпратено. Моля, опитайте отново.",
1006910070
"sellErrorLoadUtxos": "Неуспешно зареждане на монети. Моля, опитайте отново."
1007010071
}

localization/app_bn.arb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10487,6 +10487,7 @@
1048710487
"description": "Status while hardware wallet signs"
1048810488
},
1048910489
"sellErrorFeesNotCalculated": "লেনদেনের ফি নির্ধারণ করা হয়নি। অনুগ্রহ করে আবার চেষ্টা করুন।",
10490+
"sellErrorSendPayment": "পেমেন্ট পাঠাতে ব্যর্থ হয়েছে। অনুগ্রহ করে আবার চেষ্টা করুন।",
1049010491
"@sellErrorFeesNotCalculated": {
1049110492
"description": "Error message when transaction fees calculation failed"
1049210493
},

localization/app_cs.arb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10489,6 +10489,7 @@
1048910489
"description": "Status while hardware wallet signs"
1049010490
},
1049110491
"sellErrorFeesNotCalculated": "Transakční poplatky nejsou vypočítány. Prosím, zkuste to znovu.",
10492+
"sellErrorSendPayment": "Odeslání platby se nezdařilo. Zkuste to prosím znovu.",
1049210493
"@sellErrorFeesNotCalculated": {
1049310494
"description": "Error message when transaction fees calculation failed"
1049410495
},

localization/app_de.arb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3509,6 +3509,7 @@
35093509
"payAdvancedOptions": "Erweiterte Optionen",
35103510
"sendSigningTransaction": "Transaktion wird signiert…",
35113511
"sellErrorFeesNotCalculated": "Transaktionsgebühren konnten nicht berechnet werden. Bitte versuchen Sie es erneut.",
3512+
"sellErrorSendPayment": "Zahlung konnte nicht gesendet werden. Bitte versuchen Sie es erneut.",
35123513
"dcaAddressLiquid": "Liquid-Adresse",
35133514
"buyVerificationInProgress": "Verifizierung läuft…",
35143515
"transactionSwapDescChainPaid": "Ihre Transaktion wurde gesendet. Wir warten auf die Bestätigung der Sperrtransaktion",

0 commit comments

Comments
 (0)