fix: disable fee selection for firo private send on desktop

This commit is contained in:
julian 2023-06-23 13:35:19 -06:00
parent 3a9f567150
commit c784d2cf04
2 changed files with 167 additions and 100 deletions

View file

@ -1369,7 +1369,10 @@ class _DesktopSendState extends ConsumerState<DesktopSend> {
), ),
if (!([Coin.nano, Coin.banano, Coin.epicCash].contains(coin))) if (!([Coin.nano, Coin.banano, Coin.epicCash].contains(coin)))
ConditionalParent( ConditionalParent(
condition: coin.isElectrumXCoin, condition: coin.isElectrumXCoin &&
!(((coin == Coin.firo || coin == Coin.firoTestNet) &&
ref.read(publicPrivateBalanceStateProvider.state).state ==
"Private")),
builder: (child) => Row( builder: (child) => Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween, mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [ children: [
@ -1421,72 +1424,117 @@ class _DesktopSendState extends ConsumerState<DesktopSend> {
), ),
if (!([Coin.nano, Coin.banano, Coin.epicCash].contains(coin))) if (!([Coin.nano, Coin.banano, Coin.epicCash].contains(coin)))
if (!isCustomFee) if (!isCustomFee)
(feeSelectionResult?.$2 == null) Padding(
? FutureBuilder( padding: const EdgeInsets.all(10),
future: ref.watch( child: (feeSelectionResult?.$2 == null)
walletsChangeNotifierProvider.select( ? FutureBuilder(
(value) => value.getManager(walletId).fees, future: ref.watch(
walletsChangeNotifierProvider.select(
(value) => value.getManager(walletId).fees,
),
), ),
), builder: (context, snapshot) {
builder: (context, snapshot) { if (snapshot.connectionState == ConnectionState.done &&
if (snapshot.connectionState == ConnectionState.done && snapshot.hasData) {
snapshot.hasData) { return DesktopFeeItem(
return DesktopFeeItem( feeObject: snapshot.data,
feeObject: snapshot.data, feeRateType: FeeRateType.average,
feeRateType: FeeRateType.average, walletId: walletId,
walletId: walletId, isButton: false,
feeFor: ({ feeFor: ({
required Amount amount, required Amount amount,
required FeeRateType feeRateType, required FeeRateType feeRateType,
required int feeRate, required int feeRate,
required Coin coin, required Coin coin,
}) async { }) async {
if (ref if (ref
.read(feeSheetSessionCacheProvider) .read(feeSheetSessionCacheProvider)
.average[amount] == .average[amount] ==
null) { null) {
final manager = ref final manager = ref
.read(walletsChangeNotifierProvider) .read(walletsChangeNotifierProvider)
.getManager(walletId); .getManager(walletId);
if (coin == Coin.monero || coin == Coin.wownero) { if (coin == Coin.monero ||
final fee = await manager.estimateFeeFor(amount, coin == Coin.wownero) {
MoneroTransactionPriority.regular.raw!); final fee = await manager.estimateFeeFor(
ref amount,
.read(feeSheetSessionCacheProvider) MoneroTransactionPriority.regular.raw!);
.average[amount] = fee;
} else if ((coin == Coin.firo ||
coin == Coin.firoTestNet) &&
ref ref
.read( .read(feeSheetSessionCacheProvider)
publicPrivateBalanceStateProvider .average[amount] = fee;
.state) } else if ((coin == Coin.firo ||
.state != coin == Coin.firoTestNet) &&
"Private") { ref
ref .read(
.read(feeSheetSessionCacheProvider) publicPrivateBalanceStateProvider
.average[amount] = .state)
await (manager.wallet as FiroWallet) .state !=
.estimateFeeForPublic(amount, feeRate); "Private") {
} else { ref
ref .read(feeSheetSessionCacheProvider)
.read(feeSheetSessionCacheProvider) .average[amount] = await (manager.wallet
.average[amount] = as FiroWallet)
await manager.estimateFeeFor( .estimateFeeForPublic(amount, feeRate);
amount, feeRate); } else {
ref
.read(feeSheetSessionCacheProvider)
.average[amount] =
await manager.estimateFeeFor(
amount, feeRate);
}
} }
} return ref
return ref .read(feeSheetSessionCacheProvider)
.read(feeSheetSessionCacheProvider) .average[amount]!;
.average[amount]!; },
}, isSelected: true,
isSelected: true, );
); } else {
} else { return Row(
return Row( children: [
AnimatedText(
stringsToLoopThrough: stringsToLoopThrough,
style: STextStyles.desktopTextExtraExtraSmall(
context)
.copyWith(
color: Theme.of(context)
.extension<StackColors>()!
.textFieldActiveText,
),
),
],
);
}
},
)
: (coin == Coin.firo || coin == Coin.firoTestNet) &&
ref
.watch(
publicPrivateBalanceStateProvider.state)
.state ==
"Private"
? Text(
"~${ref.watch(pAmountFormatter(coin)).format(
Amount(
rawValue: BigInt.parse("3794"),
fractionDigits: coin.decimals,
),
indicatePrecisionLoss: false,
)}",
style: STextStyles.desktopTextExtraExtraSmall(context)
.copyWith(
color: Theme.of(context)
.extension<StackColors>()!
.textFieldActiveText,
),
textAlign: TextAlign.left,
)
: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [ children: [
AnimatedText( Text(
stringsToLoopThrough: stringsToLoopThrough, feeSelectionResult?.$2 ?? "",
style: STextStyles.desktopTextExtraExtraSmall( style: STextStyles.desktopTextExtraExtraSmall(
context) context)
.copyWith( .copyWith(
@ -1494,36 +1542,21 @@ class _DesktopSendState extends ConsumerState<DesktopSend> {
.extension<StackColors>()! .extension<StackColors>()!
.textFieldActiveText, .textFieldActiveText,
), ),
textAlign: TextAlign.left,
),
Text(
feeSelectionResult?.$3 ?? "",
style: STextStyles.desktopTextExtraExtraSmall(
context)
.copyWith(
color: Theme.of(context)
.extension<StackColors>()!
.textFieldActiveSearchIconRight,
),
), ),
], ],
);
}
},
)
: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
feeSelectionResult?.$2 ?? "",
style: STextStyles.desktopTextExtraExtraSmall(context)
.copyWith(
color: Theme.of(context)
.extension<StackColors>()!
.textFieldActiveText,
), ),
textAlign: TextAlign.left, ),
),
Text(
feeSelectionResult?.$3 ?? "",
style: STextStyles.desktopTextExtraExtraSmall(context)
.copyWith(
color: Theme.of(context)
.extension<StackColors>()!
.textFieldActiveSearchIconRight,
),
),
],
),
if (isCustomFee) if (isCustomFee)
Padding( Padding(
padding: const EdgeInsets.only( padding: const EdgeInsets.only(

View file

@ -16,6 +16,7 @@ import 'package:stackwallet/utilities/enums/coin_enum.dart';
import 'package:stackwallet/utilities/enums/fee_rate_type_enum.dart'; import 'package:stackwallet/utilities/enums/fee_rate_type_enum.dart';
import 'package:stackwallet/utilities/text_styles.dart'; import 'package:stackwallet/utilities/text_styles.dart';
import 'package:stackwallet/widgets/animated_text.dart'; import 'package:stackwallet/widgets/animated_text.dart';
import 'package:stackwallet/widgets/conditional_parent.dart';
import 'package:stackwallet/widgets/desktop/desktop_dialog.dart'; import 'package:stackwallet/widgets/desktop/desktop_dialog.dart';
import 'package:stackwallet/widgets/desktop/desktop_dialog_close_button.dart'; import 'package:stackwallet/widgets/desktop/desktop_dialog_close_button.dart';
@ -234,6 +235,7 @@ class DesktopFeeItem extends ConsumerStatefulWidget {
required this.walletId, required this.walletId,
required this.feeFor, required this.feeFor,
required this.isSelected, required this.isSelected,
this.isButton = true,
}) : super(key: key); }) : super(key: key);
final FeeObject? feeObject; final FeeObject? feeObject;
@ -246,6 +248,7 @@ class DesktopFeeItem extends ConsumerStatefulWidget {
required Coin coin, required Coin coin,
}) feeFor; }) feeFor;
final bool isSelected; final bool isSelected;
final bool isButton;
@override @override
ConsumerState<DesktopFeeItem> createState() => _DesktopFeeItemState(); ConsumerState<DesktopFeeItem> createState() => _DesktopFeeItemState();
@ -291,19 +294,50 @@ class _DesktopFeeItemState extends ConsumerState<DesktopFeeItem> {
Widget build(BuildContext context) { Widget build(BuildContext context) {
debugPrint("BUILD: $runtimeType : ${widget.feeRateType}"); debugPrint("BUILD: $runtimeType : ${widget.feeRateType}");
return MaterialButton( return ConditionalParent(
materialTapTargetSize: MaterialTapTargetSize.shrinkWrap, condition: widget.isButton,
onPressed: () { builder: (child) => MaterialButton(
Navigator.of(context).pop( materialTapTargetSize: MaterialTapTargetSize.shrinkWrap,
( onPressed: () {
widget.feeRateType, Navigator.of(context).pop(
feeString, (
timeString, widget.feeRateType,
), feeString,
); timeString,
}, ),
);
},
child: child,
),
child: Builder( child: Builder(
builder: (_) { builder: (_) {
if (!widget.isButton) {
final coin = ref.watch(
walletsChangeNotifierProvider.select(
(value) => value.getManager(widget.walletId).coin,
),
);
if ((coin == Coin.firo || coin == Coin.firoTestNet) &&
ref.watch(publicPrivateBalanceStateProvider.state).state ==
"Private") {
return Text(
"~${ref.watch(pAmountFormatter(coin)).format(
Amount(
rawValue: BigInt.parse("3794"),
fractionDigits: coin.decimals,
),
indicatePrecisionLoss: false,
)}",
style: STextStyles.desktopTextExtraExtraSmall(context).copyWith(
color: Theme.of(context)
.extension<StackColors>()!
.textFieldActiveText,
),
textAlign: TextAlign.left,
);
}
}
if (widget.feeRateType == FeeRateType.custom) { if (widget.feeRateType == FeeRateType.custom) {
return Row( return Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween, mainAxisAlignment: MainAxisAlignment.spaceBetween,