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)))
ConditionalParent(
condition: coin.isElectrumXCoin,
condition: coin.isElectrumXCoin &&
!(((coin == Coin.firo || coin == Coin.firoTestNet) &&
ref.read(publicPrivateBalanceStateProvider.state).state ==
"Private")),
builder: (child) => Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
@ -1421,72 +1424,117 @@ class _DesktopSendState extends ConsumerState<DesktopSend> {
),
if (!([Coin.nano, Coin.banano, Coin.epicCash].contains(coin)))
if (!isCustomFee)
(feeSelectionResult?.$2 == null)
? FutureBuilder(
future: ref.watch(
walletsChangeNotifierProvider.select(
(value) => value.getManager(walletId).fees,
Padding(
padding: const EdgeInsets.all(10),
child: (feeSelectionResult?.$2 == null)
? FutureBuilder(
future: ref.watch(
walletsChangeNotifierProvider.select(
(value) => value.getManager(walletId).fees,
),
),
),
builder: (context, snapshot) {
if (snapshot.connectionState == ConnectionState.done &&
snapshot.hasData) {
return DesktopFeeItem(
feeObject: snapshot.data,
feeRateType: FeeRateType.average,
walletId: walletId,
feeFor: ({
required Amount amount,
required FeeRateType feeRateType,
required int feeRate,
required Coin coin,
}) async {
if (ref
.read(feeSheetSessionCacheProvider)
.average[amount] ==
null) {
final manager = ref
.read(walletsChangeNotifierProvider)
.getManager(walletId);
builder: (context, snapshot) {
if (snapshot.connectionState == ConnectionState.done &&
snapshot.hasData) {
return DesktopFeeItem(
feeObject: snapshot.data,
feeRateType: FeeRateType.average,
walletId: walletId,
isButton: false,
feeFor: ({
required Amount amount,
required FeeRateType feeRateType,
required int feeRate,
required Coin coin,
}) async {
if (ref
.read(feeSheetSessionCacheProvider)
.average[amount] ==
null) {
final manager = ref
.read(walletsChangeNotifierProvider)
.getManager(walletId);
if (coin == Coin.monero || coin == Coin.wownero) {
final fee = await manager.estimateFeeFor(amount,
MoneroTransactionPriority.regular.raw!);
ref
.read(feeSheetSessionCacheProvider)
.average[amount] = fee;
} else if ((coin == Coin.firo ||
coin == Coin.firoTestNet) &&
if (coin == Coin.monero ||
coin == Coin.wownero) {
final fee = await manager.estimateFeeFor(
amount,
MoneroTransactionPriority.regular.raw!);
ref
.read(
publicPrivateBalanceStateProvider
.state)
.state !=
"Private") {
ref
.read(feeSheetSessionCacheProvider)
.average[amount] =
await (manager.wallet as FiroWallet)
.estimateFeeForPublic(amount, feeRate);
} else {
ref
.read(feeSheetSessionCacheProvider)
.average[amount] =
await manager.estimateFeeFor(
amount, feeRate);
.read(feeSheetSessionCacheProvider)
.average[amount] = fee;
} else if ((coin == Coin.firo ||
coin == Coin.firoTestNet) &&
ref
.read(
publicPrivateBalanceStateProvider
.state)
.state !=
"Private") {
ref
.read(feeSheetSessionCacheProvider)
.average[amount] = await (manager.wallet
as FiroWallet)
.estimateFeeForPublic(amount, feeRate);
} else {
ref
.read(feeSheetSessionCacheProvider)
.average[amount] =
await manager.estimateFeeFor(
amount, feeRate);
}
}
}
return ref
.read(feeSheetSessionCacheProvider)
.average[amount]!;
},
isSelected: true,
);
} else {
return Row(
return ref
.read(feeSheetSessionCacheProvider)
.average[amount]!;
},
isSelected: true,
);
} else {
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: [
AnimatedText(
stringsToLoopThrough: stringsToLoopThrough,
Text(
feeSelectionResult?.$2 ?? "",
style: STextStyles.desktopTextExtraExtraSmall(
context)
.copyWith(
@ -1494,36 +1542,21 @@ class _DesktopSendState extends ConsumerState<DesktopSend> {
.extension<StackColors>()!
.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)
Padding(
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/text_styles.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_close_button.dart';
@ -234,6 +235,7 @@ class DesktopFeeItem extends ConsumerStatefulWidget {
required this.walletId,
required this.feeFor,
required this.isSelected,
this.isButton = true,
}) : super(key: key);
final FeeObject? feeObject;
@ -246,6 +248,7 @@ class DesktopFeeItem extends ConsumerStatefulWidget {
required Coin coin,
}) feeFor;
final bool isSelected;
final bool isButton;
@override
ConsumerState<DesktopFeeItem> createState() => _DesktopFeeItemState();
@ -291,19 +294,50 @@ class _DesktopFeeItemState extends ConsumerState<DesktopFeeItem> {
Widget build(BuildContext context) {
debugPrint("BUILD: $runtimeType : ${widget.feeRateType}");
return MaterialButton(
materialTapTargetSize: MaterialTapTargetSize.shrinkWrap,
onPressed: () {
Navigator.of(context).pop(
(
widget.feeRateType,
feeString,
timeString,
),
);
},
return ConditionalParent(
condition: widget.isButton,
builder: (child) => MaterialButton(
materialTapTargetSize: MaterialTapTargetSize.shrinkWrap,
onPressed: () {
Navigator.of(context).pop(
(
widget.feeRateType,
feeString,
timeString,
),
);
},
child: child,
),
child: 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) {
return Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,