Skip to content

Commit e138338

Browse files
committed
Add error message when amounts are not sufficient in coin selection
1 parent 07dfc4d commit e138338

5 files changed

Lines changed: 33 additions & 11 deletions

File tree

lib/features/send/ui/widgets/coin_selection_bottom_sheet.dart

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -34,17 +34,15 @@ class CoinSelectionBottomSheet extends StatelessWidget {
3434
0,
3535
(previousValue, element) => previousValue + element.amountSat.toInt(),
3636
);
37-
final selectedUtxoTotal =
38-
bitcoinUnit == BitcoinUnit.btc
39-
? FormatAmount.btc(ConvertAmount.satsToBtc(selectedUtxoTotalSat))
40-
: FormatAmount.sats(selectedUtxoTotalSat);
37+
final selectedUtxoTotal = bitcoinUnit == BitcoinUnit.btc
38+
? FormatAmount.btc(ConvertAmount.satsToBtc(selectedUtxoTotalSat))
39+
: FormatAmount.sats(selectedUtxoTotalSat);
4140
final amountToSendSat = context.select(
4241
(SendCubit send) => send.state.confirmedAmountSat ?? 0,
4342
);
44-
final amountToSend =
45-
bitcoinUnit == BitcoinUnit.btc
46-
? FormatAmount.btc(ConvertAmount.satsToBtc(amountToSendSat))
47-
: FormatAmount.sats(amountToSendSat);
43+
final amountToSend = bitcoinUnit == BitcoinUnit.btc
44+
? FormatAmount.btc(ConvertAmount.satsToBtc(amountToSendSat))
45+
: FormatAmount.sats(amountToSendSat);
4846
final isAmountSufficient = selectedUtxoTotalSat > amountToSendSat;
4947

5048
return SingleChildScrollView(
@@ -78,6 +76,15 @@ class CoinSelectionBottomSheet extends StatelessWidget {
7876
'${context.loc.sendAmountRequested}$amountToSend',
7977
style: context.font.bodySmall,
8078
),
79+
if (!isAmountSufficient) ...[
80+
const Gap(8),
81+
BBText(
82+
context.loc.sendSelectedUtxosInsufficient,
83+
style: context.font.bodySmall?.copyWith(
84+
color: context.appColors.error,
85+
),
86+
),
87+
],
8188
const Gap(24),
8289
ListView.separated(
8390
physics: const NeverScrollableScrollPhysics(),
@@ -86,9 +93,8 @@ class CoinSelectionBottomSheet extends StatelessWidget {
8693
return CoinSelectTile(
8794
utxo: utxo,
8895
selected: selectedUtxos.contains(utxo),
89-
onTap:
90-
() async =>
91-
await context.read<SendCubit>().utxoSelected(utxo),
96+
onTap: () async =>
97+
await context.read<SendCubit>().utxoSelected(utxo),
9298
exchangeRate: exchangeRate,
9399
bitcoinUnit: bitcoinUnit!,
94100
fiatCurrency: fiatCurrency,

localization/app_en.arb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -832,6 +832,10 @@
832832
"@sendDone": {
833833
"description": "Button label for completing the send flow"
834834
},
835+
"sendSelectedUtxosInsufficient": "Selected utxos does not cover required amount",
836+
"@sendSelectedUtxosInsufficient": {
837+
"description": "Error message when selected UTXOs don't cover the required amount"
838+
},
835839
"sendAdvancedOptions": "Advanced Options",
836840
"@sendAdvancedOptions": {
837841
"description": "Section header for advanced sending features"

localization/app_es.arb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -832,6 +832,10 @@
832832
"@sendDone": {
833833
"description": "Button label for completing the send flow"
834834
},
835+
"sendSelectedUtxosInsufficient": "Los UTXO seleccionados no cubren el monto requerido",
836+
"@sendSelectedUtxosInsufficient": {
837+
"description": "Error message when selected UTXOs don't cover the required amount"
838+
},
835839
"sendAdvancedOptions": "Opciones Avanzadas",
836840
"@sendAdvancedOptions": {
837841
"description": "Section header for advanced sending features"

localization/app_fi.arb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -680,6 +680,10 @@
680680
"@sendDone": {
681681
"description": "Button label for completing the send flow"
682682
},
683+
"sendSelectedUtxosInsufficient": "Valitut UTXO:t eivät kata vaadittua määrää",
684+
"@sendSelectedUtxosInsufficient": {
685+
"description": "Error message when selected UTXOs don't cover the required amount"
686+
},
683687
"sendAdvancedOptions": "Lisäasetukset",
684688
"@sendAdvancedOptions": {
685689
"description": "Section header for advanced sending features"

localization/app_fr.arb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -832,6 +832,10 @@
832832
"@sendDone": {
833833
"description": "Libellé du bouton pour terminer le flux d'envoi"
834834
},
835+
"sendSelectedUtxosInsufficient": "Les UTXO sélectionnés ne couvrent pas le montant requis",
836+
"@sendSelectedUtxosInsufficient": {
837+
"description": "Message d'erreur lorsque les UTXO sélectionnés ne couvrent pas le montant requis"
838+
},
835839
"sendAdvancedOptions": "Options avancées",
836840
"@sendAdvancedOptions": {
837841
"description": "Section header for advanced sending features"

0 commit comments

Comments
 (0)