Skip to content

Commit d9c0411

Browse files
authored
Merge pull request #1668 from SatoshiPortal/enable-disable-coinselection
Coinselection continue button
2 parents d0a6675 + e138338 commit d9c0411

5 files changed

Lines changed: 35 additions & 11 deletions

File tree

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

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -34,17 +34,16 @@ 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);
46+
final isAmountSufficient = selectedUtxoTotalSat > amountToSendSat;
4847

4948
return SingleChildScrollView(
5049
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 24),
@@ -77,6 +76,15 @@ class CoinSelectionBottomSheet extends StatelessWidget {
7776
'${context.loc.sendAmountRequested}$amountToSend',
7877
style: context.font.bodySmall,
7978
),
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+
],
8088
const Gap(24),
8189
ListView.separated(
8290
physics: const NeverScrollableScrollPhysics(),
@@ -85,9 +93,8 @@ class CoinSelectionBottomSheet extends StatelessWidget {
8593
return CoinSelectTile(
8694
utxo: utxo,
8795
selected: selectedUtxos.contains(utxo),
88-
onTap:
89-
() async =>
90-
await context.read<SendCubit>().utxoSelected(utxo),
96+
onTap: () async =>
97+
await context.read<SendCubit>().utxoSelected(utxo),
9198
exchangeRate: exchangeRate,
9299
bitcoinUnit: bitcoinUnit!,
93100
fiatCurrency: fiatCurrency,
@@ -103,6 +110,7 @@ class CoinSelectionBottomSheet extends StatelessWidget {
103110
onPressed: context.pop,
104111
bgColor: context.appColors.secondary,
105112
textColor: context.appColors.onSecondary,
113+
disabled: !isAmountSufficient,
106114
),
107115
const Gap(24),
108116
],

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)