fix ui bug where chosen fee field doesnt show the updated user fee

This commit is contained in:
Marco 2022-10-12 18:09:17 -06:00
parent 2f7585a5e0
commit 764c66ee08
3 changed files with 63 additions and 1 deletions
lib
pages/send_view
services/coins/wownero

View file

@ -1319,6 +1319,12 @@ class _SendViewState extends ConsumerState<SendView> {
cryptoAmountController
.text) ??
Decimal.zero,
updateChosen: (String fee) {
setState(() {
_calculateFeesFuture =
Future(() => fee);
});
},
),
);
},

View file

@ -32,10 +32,12 @@ class TransactionFeeSelectionSheet extends ConsumerStatefulWidget {
Key? key,
required this.walletId,
required this.amount,
required this.updateChosen,
}) : super(key: key);
final String walletId;
final Decimal amount;
final Function updateChosen;
@override
ConsumerState<TransactionFeeSelectionSheet> createState() =>
@ -223,6 +225,10 @@ class _TransactionFeeSelectionSheetState
ref.read(feeRateTypeStateProvider.state).state =
FeeRateType.fast;
}
String? fee = getAmount(FeeRateType.fast);
if (fee != null) {
widget.updateChosen(fee);
}
Navigator.of(context).pop();
},
child: Container(
@ -352,6 +358,10 @@ class _TransactionFeeSelectionSheetState
ref.read(feeRateTypeStateProvider.state).state =
FeeRateType.average;
}
String? fee = getAmount(FeeRateType.average);
if (fee != null) {
widget.updateChosen(fee);
}
Navigator.of(context).pop();
},
child: Container(
@ -479,6 +489,11 @@ class _TransactionFeeSelectionSheetState
ref.read(feeRateTypeStateProvider.state).state =
FeeRateType.slow;
}
String? fee = getAmount(FeeRateType.slow);
print("fee $fee");
if (fee != null) {
widget.updateChosen(fee);
}
Navigator.of(context).pop();
},
child: Container(
@ -608,4 +623,45 @@ class _TransactionFeeSelectionSheetState
),
);
}
String? getAmount(FeeRateType feeRateType) {
try {
print(feeRateType);
var amount = Format.decimalAmountToSatoshis(this.amount);
print(amount);
print(ref.read(feeSheetSessionCacheProvider).fast);
print(ref.read(feeSheetSessionCacheProvider).average);
print(ref.read(feeSheetSessionCacheProvider).slow);
switch (feeRateType) {
case FeeRateType.fast:
if (ref.read(feeSheetSessionCacheProvider).fast[amount] != null) {
return (ref.read(feeSheetSessionCacheProvider).fast[amount]
as Decimal)
.toString();
}
return null;
case FeeRateType.average:
if (ref.read(feeSheetSessionCacheProvider).average[amount] != null) {
return (ref.read(feeSheetSessionCacheProvider).average[amount]
as Decimal)
.toString();
}
return null;
case FeeRateType.slow:
print(ref.read(feeSheetSessionCacheProvider).slow);
print(ref.read(feeSheetSessionCacheProvider).slow[amount]);
if (ref.read(feeSheetSessionCacheProvider).slow[amount] != null) {
return (ref.read(feeSheetSessionCacheProvider).slow[amount]
as Decimal)
.toString();
}
return null;
}
} catch (e, s) {
print("$e $s");
return null;
}
}
}

View file

@ -1558,7 +1558,7 @@ class WowneroWallet extends CoinServiceAPI {
"WW3iVcnoAY6K9zNdU4qmdvZELefx6xZz4PMpTwUifRkvMQckyadhSPYMVPJhBdYE8P9c27fg9RPmVaWNFx1cDaj61HnetqBiy",
satoshiAmount: satoshiAmount,
args: {"feeRate": feeRateType}))['fee'];
await Future.delayed(const Duration(milliseconds: 100));
await Future.delayed(const Duration(milliseconds: 500));
} catch (e, s) {
aprox = -9999999999999999;
}