add extra info to spark transaction generating dialog and some linter clean up

This commit is contained in:
julian 2024-05-09 16:12:22 -06:00
parent 51807ac8e6
commit 9f4df0368a
7 changed files with 620 additions and 407 deletions

View file

@ -225,6 +225,7 @@ class _Step4ViewState extends ConsumerState<Step4View> {
builder: (context) {
return BuildingTransactionDialog(
coin: wallet.info.coin,
isSpark: wallet is FiroWallet && !firoPublicSend,
onCancel: () {
wasCancelled = true;
},
@ -249,7 +250,7 @@ class _Step4ViewState extends ConsumerState<Step4View> {
address: address,
amount: amount,
isChange: false,
)
),
],
note: "${model.trade!.payInCurrency.toUpperCase()}/"
"${model.trade!.payOutCurrency.toUpperCase()} exchange",
@ -472,10 +473,10 @@ class _Step4ViewState extends ConsumerState<Step4View> {
GestureDetector(
onTap: () async {
final data = ClipboardData(
text:
model.sendAmount.toString());
text: model.sendAmount.toString(),
);
await clipboard.setData(data);
if (mounted) {
if (context.mounted) {
unawaited(
showFloatingFlushBar(
type: FlushBarType.info,
@ -535,9 +536,10 @@ class _Step4ViewState extends ConsumerState<Step4View> {
GestureDetector(
onTap: () async {
final data = ClipboardData(
text: model.trade!.payInAddress);
text: model.trade!.payInAddress,
);
await clipboard.setData(data);
if (mounted) {
if (context.mounted) {
unawaited(
showFloatingFlushBar(
type: FlushBarType.info,
@ -598,10 +600,10 @@ class _Step4ViewState extends ConsumerState<Step4View> {
GestureDetector(
onTap: () async {
final data = ClipboardData(
text:
model.trade!.payInExtraId);
text: model.trade!.payInExtraId,
);
await clipboard.setData(data);
if (mounted) {
if (context.mounted) {
unawaited(
showFloatingFlushBar(
type: FlushBarType.info,
@ -670,9 +672,10 @@ class _Step4ViewState extends ConsumerState<Step4View> {
GestureDetector(
onTap: () async {
final data = ClipboardData(
text: model.trade!.tradeId);
text: model.trade!.tradeId,
);
await clipboard.setData(data);
if (mounted) {
if (context.mounted) {
unawaited(
showFloatingFlushBar(
type: FlushBarType.info,
@ -689,9 +692,9 @@ class _Step4ViewState extends ConsumerState<Step4View> {
.infoItemIcons,
width: 12,
),
)
),
],
)
),
],
),
),
@ -739,7 +742,8 @@ class _Step4ViewState extends ConsumerState<Step4View> {
child: Text(
"Send ${model.sendTicker} to this address",
style: STextStyles.pageTitleH2(
context),
context,
),
),
),
const SizedBox(
@ -773,12 +777,13 @@ class _Step4ViewState extends ConsumerState<Step4View> {
style: Theme.of(context)
.extension<StackColors>()!
.getSecondaryEnabledButtonStyle(
context),
context,
),
child: Text(
"Cancel",
style: STextStyles.button(
context)
.copyWith(
context,
).copyWith(
color: Theme.of(context)
.extension<
StackColors>()!
@ -788,7 +793,7 @@ class _Step4ViewState extends ConsumerState<Step4View> {
),
),
],
)
),
],
),
);
@ -814,8 +819,9 @@ class _Step4ViewState extends ConsumerState<Step4View> {
final tuple = ref
.read(
exchangeSendFromWalletIdStateProvider
.state)
exchangeSendFromWalletIdStateProvider
.state,
)
.state;
if (tuple != null &&
model.sendTicker.toLowerCase() ==
@ -845,8 +851,8 @@ class _Step4ViewState extends ConsumerState<Step4View> {
(BuildContext context) {
final coin =
coinFromTickerCaseInsensitive(
model.trade!
.payInCurrency);
model.trade!.payInCurrency,
);
return SendFromView(
coin: coin,
amount: model.sendAmount
@ -868,7 +874,8 @@ class _Step4ViewState extends ConsumerState<Step4View> {
style: Theme.of(context)
.extension<StackColors>()!
.getSecondaryEnabledButtonStyle(
context),
context,
),
child: Text(
buttonTitle,
style:

View file

@ -205,13 +205,13 @@ class _SendFromViewState extends ConsumerState<SendFromView> {
class SendFromCard extends ConsumerStatefulWidget {
const SendFromCard({
Key? key,
super.key,
required this.walletId,
required this.amount,
required this.address,
required this.trade,
this.fromDesktopStep4 = false,
}) : super(key: key);
});
final String walletId;
final Amount amount;
@ -235,6 +235,8 @@ class _SendFromCardState extends ConsumerState<SendFromCard> {
try {
bool wasCancelled = false;
final wallet = ref.read(pWallets).getWallet(walletId);
unawaited(
showDialog<dynamic>(
context: context,
@ -253,6 +255,8 @@ class _SendFromCardState extends ConsumerState<SendFromCard> {
),
child: BuildingTransactionDialog(
coin: coin,
isSpark:
wallet is FiroWallet && shouldSendPublicFiroFunds != true,
onCancel: () {
wasCancelled = true;
@ -273,8 +277,6 @@ class _SendFromCardState extends ConsumerState<SendFromCard> {
TxData txData;
Future<TxData> txDataFuture;
final wallet = ref.read(pWallets).getWallet(walletId);
// if not firo then do normal send
if (shouldSendPublicFiroFunds == null) {
final memo = coin == Coin.stellar || coin == Coin.stellarTestnet
@ -371,38 +373,38 @@ class _SendFromCardState extends ConsumerState<SendFromCard> {
}
}
} catch (e) {
// if (mounted) {
// pop building dialog
Navigator.of(context).pop();
if (mounted) {
// pop building dialog
Navigator.of(context).pop();
await showDialog<dynamic>(
context: context,
useSafeArea: false,
barrierDismissible: true,
builder: (context) {
return StackDialog(
title: "Transaction failed",
message: e.toString(),
rightButton: TextButton(
style: Theme.of(context)
.extension<StackColors>()!
.getSecondaryEnabledButtonStyle(context),
child: Text(
"Ok",
style: STextStyles.button(context).copyWith(
color: Theme.of(context)
.extension<StackColors>()!
.buttonTextSecondary,
await showDialog<dynamic>(
context: context,
useSafeArea: false,
barrierDismissible: true,
builder: (context) {
return StackDialog(
title: "Transaction failed",
message: e.toString(),
rightButton: TextButton(
style: Theme.of(context)
.extension<StackColors>()!
.getSecondaryEnabledButtonStyle(context),
child: Text(
"Ok",
style: STextStyles.button(context).copyWith(
color: Theme.of(context)
.extension<StackColors>()!
.buttonTextSecondary,
),
),
onPressed: () {
Navigator.of(context).pop();
},
),
onPressed: () {
Navigator.of(context).pop();
},
),
);
},
);
// }
);
},
);
}
}
}
@ -420,7 +422,8 @@ class _SendFromCardState extends ConsumerState<SendFromCard> {
final wallet = ref.watch(pWallets).getWallet(walletId);
final locale = ref.watch(
localeServiceChangeNotifierProvider.select((value) => value.locale));
localeServiceChangeNotifierProvider.select((value) => value.locale),
);
final coin = ref.watch(pWalletCoin(walletId));
@ -483,9 +486,11 @@ class _SendFromCardState extends ConsumerState<SendFromCard> {
style: STextStyles.itemSubtitle(context),
),
Text(
ref.watch(pAmountFormatter(coin)).format(ref
.watch(pWalletBalanceTertiary(walletId))
.spendable),
ref.watch(pAmountFormatter(coin)).format(
ref
.watch(pWalletBalanceTertiary(walletId))
.spendable,
),
style: STextStyles.itemSubtitle(context),
),
],
@ -637,7 +642,8 @@ class _SendFromCardState extends ConsumerState<SendFromCard> {
if (!isFiro)
Text(
ref.watch(pAmountFormatter(coin)).format(
ref.watch(pWalletBalance(walletId)).spendable),
ref.watch(pWalletBalance(walletId)).spendable,
),
style: STextStyles.itemSubtitle(context),
),
],

View file

@ -154,8 +154,10 @@ class _SendViewState extends ConsumerState<SendView> {
// .state = true,
// );
Logging.instance.log("qrResult content: ${qrResult.rawContent}",
level: LogLevel.Info);
Logging.instance.log(
"qrResult content: ${qrResult.rawContent}",
level: LogLevel.Info,
);
final results = AddressUtils.parseUri(qrResult.rawContent);
@ -213,8 +215,9 @@ class _SendViewState extends ConsumerState<SendView> {
// here we ignore the exception caused by not giving permission
// to use the camera to scan a qr code
Logging.instance.log(
"Failed to get camera permissions while trying to scan qr code in SendView: $e\n$s",
level: LogLevel.Warning);
"Failed to get camera permissions while trying to scan qr code in SendView: $e\n$s",
level: LogLevel.Warning,
);
}
}
@ -280,8 +283,10 @@ class _SendViewState extends ConsumerState<SendView> {
return;
}
_cachedAmountToSend = amount;
Logging.instance.log("it changed $amount $_cachedAmountToSend",
level: LogLevel.Info);
Logging.instance.log(
"it changed $amount $_cachedAmountToSend",
level: LogLevel.Info,
);
final price =
ref.read(priceAnd24hChangeNotifierProvider).getPrice(coin).item1;
@ -572,9 +577,10 @@ class _SendViewState extends ConsumerState<SendView> {
child: Text(
"Cancel",
style: STextStyles.button(context).copyWith(
color: Theme.of(context)
.extension<StackColors>()!
.accentColorDark),
color: Theme.of(context)
.extension<StackColors>()!
.accentColorDark,
),
),
onPressed: () {
Navigator.of(context).pop(false);
@ -616,6 +622,9 @@ class _SendViewState extends ConsumerState<SendView> {
builder: (context) {
return BuildingTransactionDialog(
coin: wallet.info.coin,
isSpark: wallet is FiroWallet &&
ref.read(publicPrivateBalanceStateProvider.state).state ==
FiroType.spark,
onCancel: () {
wasCancelled = true;
@ -645,7 +654,7 @@ class _SendViewState extends ConsumerState<SendView> {
address: widget.accountLite!.code,
amount: amount,
isChange: false,
)
),
],
satsPerVByte: isCustomFee ? customFeeRate : null,
feeRateType: feeRate,
@ -668,7 +677,7 @@ class _SendViewState extends ConsumerState<SendView> {
amount: amount,
memo: memoController.text,
isChange: false,
)
),
],
feeRateType: ref.read(feeRateTypeStateProvider),
satsPerVByte: isCustomFee ? customFeeRate : null,
@ -687,7 +696,7 @@ class _SendViewState extends ConsumerState<SendView> {
address: _address!,
amount: amount,
isChange: false,
)
),
],
feeRateType: ref.read(feeRateTypeStateProvider),
satsPerVByte: isCustomFee ? customFeeRate : null,
@ -709,7 +718,7 @@ class _SendViewState extends ConsumerState<SendView> {
address: _address!,
amount: amount,
isChange: false,
)
),
],
),
);
@ -725,7 +734,7 @@ class _SendViewState extends ConsumerState<SendView> {
address: _address!,
amount: amount,
isChange: false,
)
),
],
sparkRecipients: ref.read(pValidSparkSendToAddress)
? [
@ -734,7 +743,7 @@ class _SendViewState extends ConsumerState<SendView> {
amount: amount,
memo: memoController.text,
isChange: false,
)
),
]
: null,
),
@ -752,7 +761,7 @@ class _SendViewState extends ConsumerState<SendView> {
address: _address!,
amount: amount,
isChange: false,
)
),
],
memo: memo,
feeRateType: ref.read(feeRateTypeStateProvider),
@ -827,9 +836,10 @@ class _SendViewState extends ConsumerState<SendView> {
child: Text(
"Ok",
style: STextStyles.button(context).copyWith(
color: Theme.of(context)
.extension<StackColors>()!
.accentColorDark),
color: Theme.of(context)
.extension<StackColors>()!
.accentColorDark,
),
),
onPressed: () {
Navigator.of(context).pop();
@ -981,7 +991,8 @@ class _SendViewState extends ConsumerState<SendView> {
debugPrint("BUILD: $runtimeType");
final wallet = ref.watch(pWallets).getWallet(walletId);
final String locale = ref.watch(
localeServiceChangeNotifierProvider.select((value) => value.locale));
localeServiceChangeNotifierProvider.select((value) => value.locale),
);
final showCoinControl = wallet is CoinControlInterface &&
ref.watch(
@ -1033,7 +1044,7 @@ class _SendViewState extends ConsumerState<SendView> {
FocusScope.of(context).unfocus();
await Future<void>.delayed(const Duration(milliseconds: 50));
}
if (mounted) {
if (context.mounted) {
Navigator.of(context).pop();
}
},
@ -1118,82 +1129,93 @@ class _SendViewState extends ConsumerState<SendView> {
],
),
const Spacer(),
Builder(builder: (context) {
final Amount amount;
if (isFiro) {
switch (ref
.watch(
Builder(
builder: (context) {
final Amount amount;
if (isFiro) {
switch (ref
.watch(
publicPrivateBalanceStateProvider
.state)
.state) {
case FiroType.public:
amount = ref
.read(pWalletBalance(walletId))
.spendable;
break;
case FiroType.lelantus:
amount = ref
.read(pWalletBalanceSecondary(
walletId))
.spendable;
break;
case FiroType.spark:
amount = ref
.read(pWalletBalanceTertiary(
walletId))
.spendable;
break;
}
} else {
amount = ref
.read(pWalletBalance(walletId))
.spendable;
}
return GestureDetector(
onTap: () {
cryptoAmountController.text = ref
.read(pAmountFormatter(coin))
.format(
amount,
withUnitName: false,
);
},
child: Container(
color: Colors.transparent,
child: Column(
crossAxisAlignment:
CrossAxisAlignment.end,
children: [
Text(
ref
.watch(pAmountFormatter(coin))
.format(amount),
style: STextStyles.titleBold12(
context)
.copyWith(
fontSize: 10,
),
textAlign: TextAlign.right,
),
Text(
"${(amount.decimal * ref.watch(priceAnd24hChangeNotifierProvider.select((value) => value.getPrice(coin).item1))).toAmount(
fractionDigits: 2,
).fiatString(
locale: locale,
)} ${ref.watch(prefsChangeNotifierProvider.select((value) => value.currency))}",
style:
STextStyles.subtitle(context)
.copyWith(
fontSize: 8,
),
textAlign: TextAlign.right,
.state,
)
],
.state) {
case FiroType.public:
amount = ref
.read(pWalletBalance(walletId))
.spendable;
break;
case FiroType.lelantus:
amount = ref
.read(
pWalletBalanceSecondary(
walletId,
),
)
.spendable;
break;
case FiroType.spark:
amount = ref
.read(
pWalletBalanceTertiary(
walletId,
),
)
.spendable;
break;
}
} else {
amount = ref
.read(pWalletBalance(walletId))
.spendable;
}
return GestureDetector(
onTap: () {
cryptoAmountController.text = ref
.read(pAmountFormatter(coin))
.format(
amount,
withUnitName: false,
);
},
child: Container(
color: Colors.transparent,
child: Column(
crossAxisAlignment:
CrossAxisAlignment.end,
children: [
Text(
ref
.watch(
pAmountFormatter(coin),
)
.format(amount),
style: STextStyles.titleBold12(
context,
).copyWith(
fontSize: 10,
),
textAlign: TextAlign.right,
),
Text(
"${(amount.decimal * ref.watch(priceAnd24hChangeNotifierProvider.select((value) => value.getPrice(coin).item1))).toAmount(
fractionDigits: 2,
).fiatString(
locale: locale,
)} ${ref.watch(prefsChangeNotifierProvider.select((value) => value.currency))}",
style: STextStyles.subtitle(
context,
).copyWith(
fontSize: 8,
),
textAlign: TextAlign.right,
),
],
),
),
),
);
}),
);
},
),
],
),
),
@ -1295,12 +1317,14 @@ class _SendViewState extends ConsumerState<SendView> {
semanticsLabel:
"Clear Button. Clears The Address Field Input.",
key: const Key(
"sendViewClearAddressFieldButtonKey"),
"sendViewClearAddressFieldButtonKey",
),
onTap: () {
sendToController.text = "";
_address = "";
_setValidAddressProviders(
_address);
_address,
);
setState(() {
_addressToggleFlag =
false;
@ -1312,12 +1336,13 @@ class _SendViewState extends ConsumerState<SendView> {
semanticsLabel:
"Paste Button. Pastes From Clipboard To Address Field Input.",
key: const Key(
"sendViewPasteAddressFieldButtonKey"),
"sendViewPasteAddressFieldButtonKey",
),
onTap: () async {
final ClipboardData? data =
await clipboard.getData(
Clipboard
.kTextPlain);
Clipboard.kTextPlain,
);
if (data?.text != null &&
data!
.text!.isNotEmpty) {
@ -1327,23 +1352,27 @@ class _SendViewState extends ConsumerState<SendView> {
.contains("\n")) {
content =
content.substring(
0,
content.indexOf(
"\n"));
0,
content.indexOf(
"\n",
),
);
}
if (coin ==
Coin.epicCash) {
// strip http:// and https:// if content contains @
content = formatAddress(
content);
content,
);
}
sendToController.text =
content.trim();
_address = content.trim();
_setValidAddressProviders(
_address);
_address,
);
setState(() {
_addressToggleFlag =
sendToController
@ -1362,7 +1391,8 @@ class _SendViewState extends ConsumerState<SendView> {
semanticsLabel:
"Address Book Button. Opens Address Book For Address Field.",
key: const Key(
"sendViewAddressBookButtonKey"),
"sendViewAddressBookButtonKey",
),
onTap: () {
Navigator.of(context).pushNamed(
AddressBookView.routeName,
@ -1376,7 +1406,8 @@ class _SendViewState extends ConsumerState<SendView> {
semanticsLabel:
"Scan QR Button. Opens Camera For Scanning QR Code.",
key: const Key(
"sendViewScanQrButtonKey"),
"sendViewScanQrButtonKey",
),
onTap: _scanQr,
child: const QrCodeIcon(),
),
@ -1393,7 +1424,8 @@ class _SendViewState extends ConsumerState<SendView> {
if (isStellar ||
(ref.watch(pValidSparkSendToAddress) &&
ref.watch(
publicPrivateBalanceStateProvider) !=
publicPrivateBalanceStateProvider,
) !=
FiroType.lelantus))
ClipRRect(
borderRadius: BorderRadius.circular(
@ -1440,7 +1472,8 @@ class _SendViewState extends ConsumerState<SendView> {
semanticsLabel:
"Clear Button. Clears The Memo Field Input.",
key: const Key(
"sendViewClearMemoFieldButtonKey"),
"sendViewClearMemoFieldButtonKey",
),
onTap: () {
memoController.text = "";
setState(() {});
@ -1451,16 +1484,17 @@ class _SendViewState extends ConsumerState<SendView> {
semanticsLabel:
"Paste Button. Pastes From Clipboard To Memo Field Input.",
key: const Key(
"sendViewPasteMemoFieldButtonKey"),
"sendViewPasteMemoFieldButtonKey",
),
onTap: () async {
final ClipboardData? data =
await clipboard.getData(
Clipboard
.kTextPlain);
Clipboard.kTextPlain,
);
if (data?.text != null &&
data!
.text!.isNotEmpty) {
String content =
final String content =
data.text!.trim();
memoController.text =
@ -1486,13 +1520,15 @@ class _SendViewState extends ConsumerState<SendView> {
error = null;
} else if (isFiro) {
if (ref.watch(
publicPrivateBalanceStateProvider) ==
publicPrivateBalanceStateProvider,
) ==
FiroType.lelantus) {
if (_data != null &&
_data!.contactLabel == _address) {
error = SparkInterface.validateSparkAddress(
address: _data!.address,
isTestNet: coin.isTestNet)
address: _data!.address,
isTestNet: coin.isTestNet,
)
? "Unsupported"
: null;
} else if (ref
@ -1611,51 +1647,65 @@ class _SendViewState extends ConsumerState<SendView> {
Text(
"${ref.watch(publicPrivateBalanceStateProvider.state).state.name.capitalize()} balance",
style: STextStyles.itemSubtitle12(
context),
context,
),
),
const SizedBox(
width: 10,
),
Builder(builder: (_) {
final Amount amount;
switch (ref
.read(
Builder(
builder: (_) {
final Amount amount;
switch (ref
.read(
publicPrivateBalanceStateProvider
.state)
.state) {
case FiroType.public:
amount = ref
.watch(pWalletBalance(
walletId))
.spendable;
break;
case FiroType.lelantus:
amount = ref
.watch(
.state,
)
.state) {
case FiroType.public:
amount = ref
.watch(
pWalletBalance(
walletId,
),
)
.spendable;
break;
case FiroType.lelantus:
amount = ref
.watch(
pWalletBalanceSecondary(
walletId))
.spendable;
break;
case FiroType.spark:
amount = ref
.watch(
walletId,
),
)
.spendable;
break;
case FiroType.spark:
amount = ref
.watch(
pWalletBalanceTertiary(
walletId))
.spendable;
break;
}
walletId,
),
)
.spendable;
break;
}
return Text(
ref
.watch(
pAmountFormatter(coin))
.format(
amount,
),
style: STextStyles.itemSubtitle(
context),
);
}),
return Text(
ref
.watch(
pAmountFormatter(coin),
)
.format(
amount,
),
style:
STextStyles.itemSubtitle(
context,
),
);
},
),
],
),
SvgPicture.asset(
@ -1669,7 +1719,7 @@ class _SendViewState extends ConsumerState<SendView> {
],
),
),
)
),
],
),
const SizedBox(
@ -1691,8 +1741,9 @@ class _SendViewState extends ConsumerState<SendView> {
final Amount amount;
switch (ref
.read(
publicPrivateBalanceStateProvider
.state)
publicPrivateBalanceStateProvider
.state,
)
.state) {
case FiroType.public:
amount = ref
@ -1701,14 +1752,20 @@ class _SendViewState extends ConsumerState<SendView> {
break;
case FiroType.lelantus:
amount = ref
.read(pWalletBalanceSecondary(
walletId))
.read(
pWalletBalanceSecondary(
walletId,
),
)
.spendable;
break;
case FiroType.spark:
amount = ref
.read(pWalletBalanceTertiary(
walletId))
.read(
pWalletBalanceTertiary(
walletId,
),
)
.spendable;
break;
}
@ -1793,9 +1850,10 @@ class _SendViewState extends ConsumerState<SendView> {
.unitForCoin(coin),
style: STextStyles.smallMed14(context)
.copyWith(
color: Theme.of(context)
.extension<StackColors>()!
.accentColorDark),
color: Theme.of(context)
.extension<StackColors>()!
.accentColorDark,
),
),
),
),
@ -1855,13 +1913,16 @@ class _SendViewState extends ConsumerState<SendView> {
child: Padding(
padding: const EdgeInsets.all(12),
child: Text(
ref.watch(prefsChangeNotifierProvider
.select((value) => value.currency)),
ref.watch(
prefsChangeNotifierProvider
.select((value) => value.currency),
),
style: STextStyles.smallMed14(context)
.copyWith(
color: Theme.of(context)
.extension<StackColors>()!
.accentColorDark),
color: Theme.of(context)
.extension<StackColors>()!
.accentColorDark,
),
),
),
),
@ -1898,7 +1959,7 @@ class _SendViewState extends ConsumerState<SendView> {
);
}
if (mounted) {
if (context.mounted) {
final spendable = ref
.read(pWalletBalance(walletId))
.spendable;
@ -2096,8 +2157,9 @@ class _SendViewState extends ConsumerState<SendView> {
onPressed: isFiro &&
ref
.watch(
publicPrivateBalanceStateProvider
.state)
publicPrivateBalanceStateProvider
.state,
)
.state !=
FiroType.public
? null
@ -2117,8 +2179,9 @@ class _SendViewState extends ConsumerState<SendView> {
TransactionFeeSelectionSheet(
walletId: walletId,
amount: (Decimal.tryParse(
cryptoAmountController
.text) ??
cryptoAmountController
.text,
) ??
ref
.watch(pSendAmount)
?.decimal ??
@ -2154,8 +2217,9 @@ class _SendViewState extends ConsumerState<SendView> {
child: (isFiro &&
ref
.watch(
publicPrivateBalanceStateProvider
.state)
publicPrivateBalanceStateProvider
.state,
)
.state !=
FiroType.public)
? Row(
@ -2175,7 +2239,8 @@ class _SendViewState extends ConsumerState<SendView> {
"~${snapshot.data!}",
style: STextStyles
.itemSubtitle(
context),
context,
),
);
} else {
return AnimatedText(
@ -2187,7 +2252,8 @@ class _SendViewState extends ConsumerState<SendView> {
],
style: STextStyles
.itemSubtitle(
context),
context,
),
);
}
},
@ -2203,13 +2269,15 @@ class _SendViewState extends ConsumerState<SendView> {
Text(
ref
.watch(
feeRateTypeStateProvider
.state)
feeRateTypeStateProvider
.state,
)
.state
.prettyName,
style: STextStyles
.itemSubtitle12(
context),
context,
),
),
const SizedBox(
width: 10,
@ -2233,7 +2301,8 @@ class _SendViewState extends ConsumerState<SendView> {
: "~${snapshot.data!}",
style: STextStyles
.itemSubtitle(
context),
context,
),
);
} else {
return AnimatedText(
@ -2245,7 +2314,8 @@ class _SendViewState extends ConsumerState<SendView> {
],
style: STextStyles
.itemSubtitle(
context),
context,
),
);
}
},
@ -2263,7 +2333,7 @@ class _SendViewState extends ConsumerState<SendView> {
],
),
),
)
),
],
),
if (isCustomFee)

View file

@ -12,8 +12,8 @@ import 'dart:io';
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:stackwallet/themes/stack_colors.dart';
import 'package:stackwallet/themes/coin_image_provider.dart';
import 'package:stackwallet/themes/stack_colors.dart';
import 'package:stackwallet/utilities/enums/coin_enum.dart';
import 'package:stackwallet/utilities/text_styles.dart';
import 'package:stackwallet/utilities/util.dart';
@ -23,13 +23,15 @@ import 'package:stackwallet/widgets/stack_dialog.dart';
class BuildingTransactionDialog extends ConsumerStatefulWidget {
const BuildingTransactionDialog({
Key? key,
super.key,
required this.onCancel,
required this.coin,
}) : super(key: key);
required this.isSpark,
});
final VoidCallback onCancel;
final Coin coin;
final bool isSpark;
@override
ConsumerState<BuildingTransactionDialog> createState() =>
@ -62,13 +64,24 @@ class _RestoringDialogState extends ConsumerState<BuildingTransactionDialog> {
"Generating transaction",
style: STextStyles.desktopH3(context),
),
if (widget.isSpark)
const SizedBox(
height: 16,
),
if (widget.isSpark)
Text(
"This may take a few minutes...",
style: STextStyles.desktopSubtitleH2(context),
),
const SizedBox(
height: 40,
),
assetPath.endsWith(".gif")
? Image.file(File(
assetPath,
))
? Image.file(
File(
assetPath,
),
)
: const RotatingArrows(
width: 40,
height: 40,
@ -82,7 +95,7 @@ class _RestoringDialogState extends ConsumerState<BuildingTransactionDialog> {
onPressed: () {
onCancel.call();
},
)
),
],
);
} else {
@ -96,14 +109,26 @@ class _RestoringDialogState extends ConsumerState<BuildingTransactionDialog> {
crossAxisAlignment: CrossAxisAlignment.stretch,
mainAxisSize: MainAxisSize.min,
children: [
Image.file(File(
assetPath,
)),
Image.file(
File(
assetPath,
),
),
Text(
"Generating transaction",
textAlign: TextAlign.center,
style: STextStyles.pageTitleH2(context),
),
if (widget.isSpark)
const SizedBox(
height: 12,
),
if (widget.isSpark)
Text(
"This may take a few minutes...",
textAlign: TextAlign.center,
style: STextStyles.w500_16(context),
),
const SizedBox(
height: 32,
),
@ -124,7 +149,7 @@ class _RestoringDialogState extends ConsumerState<BuildingTransactionDialog> {
onCancel.call();
},
),
)
),
],
),
],
@ -132,6 +157,8 @@ class _RestoringDialogState extends ConsumerState<BuildingTransactionDialog> {
)
: StackDialog(
title: "Generating transaction",
message:
widget.isSpark ? "This may take a few minutes..." : null,
icon: const RotatingArrows(
width: 24,
height: 24,

View file

@ -58,14 +58,14 @@ import 'package:stackwallet/widgets/textfield_icon_button.dart';
class TokenSendView extends ConsumerStatefulWidget {
const TokenSendView({
Key? key,
super.key,
required this.walletId,
required this.coin,
required this.tokenContract,
this.autoFillData,
this.clipboard = const ClipboardWrapper(),
this.barcodeScanner = const BarcodeScannerWrapper(),
}) : super(key: key);
});
static const String routeName = "/tokenSendView";
@ -156,8 +156,10 @@ class _TokenSendViewState extends ConsumerState<TokenSendView> {
// .state = true,
// );
Logging.instance.log("qrResult content: ${qrResult.rawContent}",
level: LogLevel.Info);
Logging.instance.log(
"qrResult content: ${qrResult.rawContent}",
level: LogLevel.Info,
);
final results = AddressUtils.parseUri(qrResult.rawContent);
@ -216,8 +218,9 @@ class _TokenSendViewState extends ConsumerState<TokenSendView> {
// here we ignore the exception caused by not giving permission
// to use the camera to scan a qr code
Logging.instance.log(
"Failed to get camera permissions while trying to scan qr code in SendView: $e\n$s",
level: LogLevel.Warning);
"Failed to get camera permissions while trying to scan qr code in SendView: $e\n$s",
level: LogLevel.Warning,
);
}
}
@ -239,15 +242,19 @@ class _TokenSendViewState extends ConsumerState<TokenSendView> {
? Amount.zero
: Amount.fromDecimal(
(baseAmount.decimal / _price).toDecimal(
scaleOnInfinitePrecision: tokenContract.decimals),
fractionDigits: tokenContract.decimals);
scaleOnInfinitePrecision: tokenContract.decimals,
),
fractionDigits: tokenContract.decimals,
);
}
if (_cachedAmountToSend != null && _cachedAmountToSend == _amountToSend) {
return;
}
_cachedAmountToSend = _amountToSend;
Logging.instance.log("it changed $_amountToSend $_cachedAmountToSend",
level: LogLevel.Info);
Logging.instance.log(
"it changed $_amountToSend $_cachedAmountToSend",
level: LogLevel.Info,
);
_cryptoAmountChangeLock = true;
cryptoAmountController.text = ref.read(pAmountFormatter(coin)).format(
@ -282,8 +289,10 @@ class _TokenSendViewState extends ConsumerState<TokenSendView> {
return;
}
_cachedAmountToSend = _amountToSend;
Logging.instance.log("it changed $_amountToSend $_cachedAmountToSend",
level: LogLevel.Info);
Logging.instance.log(
"it changed $_amountToSend $_cachedAmountToSend",
level: LogLevel.Info,
);
final price = ref
.read(priceAnd24hChangeNotifierProvider)
@ -457,6 +466,7 @@ class _TokenSendViewState extends ConsumerState<TokenSendView> {
builder: (context) {
return BuildingTransactionDialog(
coin: wallet.info.coin,
isSpark: false,
onCancel: () {
wasCancelled = true;
@ -484,7 +494,7 @@ class _TokenSendViewState extends ConsumerState<TokenSendView> {
address: _address!,
amount: amount,
isChange: false,
)
),
],
feeRateType: ref.read(feeRateTypeStateProvider),
note: noteController.text,
@ -502,20 +512,22 @@ class _TokenSendViewState extends ConsumerState<TokenSendView> {
// pop building dialog
Navigator.of(context).pop();
unawaited(Navigator.of(context).push(
RouteGenerator.getRoute(
shouldUseMaterialRoute: RouteGenerator.useMaterialPageRoute,
builder: (_) => ConfirmTransactionView(
txData: txData,
walletId: walletId,
isTokenTx: true,
onSuccess: clearSendForm,
),
settings: const RouteSettings(
name: ConfirmTransactionView.routeName,
unawaited(
Navigator.of(context).push(
RouteGenerator.getRoute(
shouldUseMaterialRoute: RouteGenerator.useMaterialPageRoute,
builder: (_) => ConfirmTransactionView(
txData: txData,
walletId: walletId,
isTokenTx: true,
onSuccess: clearSendForm,
),
settings: const RouteSettings(
name: ConfirmTransactionView.routeName,
),
),
),
));
);
}
} catch (e) {
if (mounted) {
@ -538,9 +550,10 @@ class _TokenSendViewState extends ConsumerState<TokenSendView> {
child: Text(
"Ok",
style: STextStyles.button(context).copyWith(
color: Theme.of(context)
.extension<StackColors>()!
.accentColorDark),
color: Theme.of(context)
.extension<StackColors>()!
.accentColorDark,
),
),
onPressed: () {
Navigator.of(context).pop();
@ -626,7 +639,8 @@ class _TokenSendViewState extends ConsumerState<TokenSendView> {
Widget build(BuildContext context) {
debugPrint("BUILD: $runtimeType");
final String locale = ref.watch(
localeServiceChangeNotifierProvider.select((value) => value.locale));
localeServiceChangeNotifierProvider.select((value) => value.locale),
);
return Background(
child: Scaffold(
@ -638,7 +652,7 @@ class _TokenSendViewState extends ConsumerState<TokenSendView> {
FocusScope.of(context).unfocus();
await Future<void>.delayed(const Duration(milliseconds: 50));
}
if (mounted) {
if (context.mounted) {
Navigator.of(context).pop();
}
},
@ -712,11 +726,15 @@ class _TokenSendViewState extends ConsumerState<TokenSendView> {
.watch(pAmountFormatter(coin))
.format(
ref
.read(pTokenBalance((
walletId: widget.walletId,
contractAddress:
tokenContract.address,
)))
.read(
pTokenBalance(
(
walletId: widget.walletId,
contractAddress:
tokenContract.address,
),
),
)
.spendable,
ethContract: tokenContract,
withUnitName: false,
@ -734,13 +752,17 @@ class _TokenSendViewState extends ConsumerState<TokenSendView> {
.watch(pAmountFormatter(coin))
.format(
ref
.watch(pTokenBalance((
walletId:
widget.walletId,
contractAddress:
tokenContract
.address,
)))
.watch(
pTokenBalance(
(
walletId:
widget.walletId,
contractAddress:
tokenContract
.address,
),
),
)
.spendable,
ethContract: tokenContract,
),
@ -752,13 +774,17 @@ class _TokenSendViewState extends ConsumerState<TokenSendView> {
textAlign: TextAlign.right,
),
Text(
"${(ref.watch(pTokenBalance((
"${(ref.watch(
pTokenBalance(
(
walletId:
widget.walletId,
contractAddress:
tokenContract
.address,
))).spendable.decimal * ref.watch(priceAnd24hChangeNotifierProvider.select((value) => value.getTokenPrice(tokenContract.address).item1))).toAmount(
),
),
).spendable.decimal * ref.watch(priceAnd24hChangeNotifierProvider.select((value) => value.getTokenPrice(tokenContract.address).item1))).toAmount(
fractionDigits: 2,
).fiatString(
locale: locale,
@ -768,7 +794,7 @@ class _TokenSendViewState extends ConsumerState<TokenSendView> {
fontSize: 8,
),
textAlign: TextAlign.right,
)
),
],
),
),
@ -807,7 +833,9 @@ class _TokenSendViewState extends ConsumerState<TokenSendView> {
onChanged: (newValue) {
_address = newValue.trim();
_updatePreviewButtonState(
_address, _amountToSend);
_address,
_amountToSend,
);
setState(() {
_addressToggleFlag = newValue.isNotEmpty;
@ -838,12 +866,15 @@ class _TokenSendViewState extends ConsumerState<TokenSendView> {
_addressToggleFlag
? TextFieldIconButton(
key: const Key(
"tokenSendViewClearAddressFieldButtonKey"),
"tokenSendViewClearAddressFieldButtonKey",
),
onTap: () {
sendToController.text = "";
_address = "";
_updatePreviewButtonState(
_address, _amountToSend);
_address,
_amountToSend,
);
setState(() {
_addressToggleFlag = false;
});
@ -852,7 +883,8 @@ class _TokenSendViewState extends ConsumerState<TokenSendView> {
)
: TextFieldIconButton(
key: const Key(
"tokenSendViewPasteAddressFieldButtonKey"),
"tokenSendViewPasteAddressFieldButtonKey",
),
onTap:
_onTokenSendViewPasteAddressFieldButtonPressed,
child: sendToController
@ -863,7 +895,8 @@ class _TokenSendViewState extends ConsumerState<TokenSendView> {
if (sendToController.text.isEmpty)
TextFieldIconButton(
key: const Key(
"sendViewAddressBookButtonKey"),
"sendViewAddressBookButtonKey",
),
onTap: () {
Navigator.of(context).pushNamed(
AddressBookView.routeName,
@ -875,11 +908,12 @@ class _TokenSendViewState extends ConsumerState<TokenSendView> {
if (sendToController.text.isEmpty)
TextFieldIconButton(
key: const Key(
"sendViewScanQrButtonKey"),
"sendViewScanQrButtonKey",
),
onTap:
_onTokenSendViewScanQrButtonPressed,
child: const QrCodeIcon(),
)
),
],
),
),
@ -997,9 +1031,10 @@ class _TokenSendViewState extends ConsumerState<TokenSendView> {
tokenContract.symbol,
style: STextStyles.smallMed14(context)
.copyWith(
color: Theme.of(context)
.extension<StackColors>()!
.accentColorDark),
color: Theme.of(context)
.extension<StackColors>()!
.accentColorDark,
),
),
),
),
@ -1058,13 +1093,16 @@ class _TokenSendViewState extends ConsumerState<TokenSendView> {
child: Padding(
padding: const EdgeInsets.all(12),
child: Text(
ref.watch(prefsChangeNotifierProvider
.select((value) => value.currency)),
ref.watch(
prefsChangeNotifierProvider
.select((value) => value.currency),
),
style: STextStyles.smallMed14(context)
.copyWith(
color: Theme.of(context)
.extension<StackColors>()!
.accentColorDark),
color: Theme.of(context)
.extension<StackColors>()!
.accentColorDark,
),
),
),
),
@ -1169,8 +1207,8 @@ class _TokenSendViewState extends ConsumerState<TokenSendView> {
walletId: walletId,
isToken: true,
amount: (Decimal.tryParse(
cryptoAmountController
.text) ??
cryptoAmountController.text,
) ??
Decimal.zero)
.toAmount(
fractionDigits:
@ -1193,12 +1231,15 @@ class _TokenSendViewState extends ConsumerState<TokenSendView> {
children: [
Text(
ref
.watch(feeRateTypeStateProvider
.state)
.watch(
feeRateTypeStateProvider
.state,
)
.state
.prettyName,
style: STextStyles.itemSubtitle12(
context),
context,
),
),
const SizedBox(
width: 10,
@ -1213,7 +1254,8 @@ class _TokenSendViewState extends ConsumerState<TokenSendView> {
"~${snapshot.data!}",
style:
STextStyles.itemSubtitle(
context),
context,
),
);
} else {
return AnimatedText(
@ -1225,7 +1267,8 @@ class _TokenSendViewState extends ConsumerState<TokenSendView> {
],
style:
STextStyles.itemSubtitle(
context),
context,
),
);
}
},
@ -1243,7 +1286,7 @@ class _TokenSendViewState extends ConsumerState<TokenSendView> {
],
),
),
)
),
],
),
const Spacer(),
@ -1253,13 +1296,15 @@ class _TokenSendViewState extends ConsumerState<TokenSendView> {
TextButton(
onPressed: ref
.watch(
previewTokenTxButtonStateProvider.state)
previewTokenTxButtonStateProvider.state,
)
.state
? _previewTransaction
: null,
style: ref
.watch(
previewTokenTxButtonStateProvider.state)
previewTokenTxButtonStateProvider.state,
)
.state
? Theme.of(context)
.extension<StackColors>()!

View file

@ -272,6 +272,11 @@ class _DesktopSendState extends ConsumerState<DesktopSend> {
padding: const EdgeInsets.all(32),
child: BuildingTransactionDialog(
coin: wallet.info.coin,
isSpark: wallet is FiroWallet &&
ref
.read(publicPrivateBalanceStateProvider.state)
.state ==
FiroType.spark,
onCancel: () {
wasCancelled = true;
@ -306,7 +311,7 @@ class _DesktopSendState extends ConsumerState<DesktopSend> {
address: widget.accountLite!.code,
amount: amount,
isChange: false,
)
),
],
satsPerVByte: isCustomFee ? customFeeRate : null,
feeRateType: feeRate,
@ -329,7 +334,7 @@ class _DesktopSendState extends ConsumerState<DesktopSend> {
amount: amount,
memo: memoController.text,
isChange: false,
)
),
],
feeRateType: ref.read(feeRateTypeStateProvider),
satsPerVByte: isCustomFee ? customFeeRate : null,
@ -348,7 +353,7 @@ class _DesktopSendState extends ConsumerState<DesktopSend> {
address: _address!,
amount: amount,
isChange: false,
)
),
],
feeRateType: ref.read(feeRateTypeStateProvider),
satsPerVByte: isCustomFee ? customFeeRate : null,
@ -370,7 +375,7 @@ class _DesktopSendState extends ConsumerState<DesktopSend> {
address: _address!,
amount: amount,
isChange: false,
)
),
],
),
);
@ -386,7 +391,7 @@ class _DesktopSendState extends ConsumerState<DesktopSend> {
address: _address!,
amount: amount,
isChange: false,
)
),
],
sparkRecipients: ref.read(pValidSparkSendToAddress)
? [
@ -395,7 +400,7 @@ class _DesktopSendState extends ConsumerState<DesktopSend> {
amount: amount,
memo: memoController.text,
isChange: false,
)
),
]
: null,
),
@ -411,7 +416,7 @@ class _DesktopSendState extends ConsumerState<DesktopSend> {
address: _address!,
amount: amount,
isChange: false,
)
),
],
memo: memo,
feeRateType: ref.read(feeRateTypeStateProvider),
@ -577,8 +582,10 @@ class _DesktopSendState extends ConsumerState<DesktopSend> {
if (_cachedAmountToSend != null && _cachedAmountToSend == amount) {
return;
}
Logging.instance.log("it changed $amount $_cachedAmountToSend",
level: LogLevel.Info);
Logging.instance.log(
"it changed $amount $_cachedAmountToSend",
level: LogLevel.Info,
);
_cachedAmountToSend = amount;
final price =
@ -627,8 +634,10 @@ class _DesktopSendState extends ConsumerState<DesktopSend> {
final qrResult = await scanner.scan();
Logging.instance.log("qrResult content: ${qrResult.rawContent}",
level: LogLevel.Info);
Logging.instance.log(
"qrResult content: ${qrResult.rawContent}",
level: LogLevel.Info,
);
final results = AddressUtils.parseUri(qrResult.rawContent);
@ -679,8 +688,9 @@ class _DesktopSendState extends ConsumerState<DesktopSend> {
// here we ignore the exception caused by not giving permission
// to use the camera to scan a qr code
Logging.instance.log(
"Failed to get camera permissions while trying to scan qr code in SendView: $e\n$s",
level: LogLevel.Warning);
"Failed to get camera permissions while trying to scan qr code in SendView: $e\n$s",
level: LogLevel.Warning,
);
}
}
@ -734,7 +744,7 @@ class _DesktopSendState extends ConsumerState<DesktopSend> {
} else {
final ClipboardData? data = await clipboard.getData(Clipboard.kTextPlain);
if (data?.text != null && data!.text!.isNotEmpty) {
String content = data.text!.trim();
final String content = data.text!.trim();
setState(() {
memoController.text = content;
@ -865,7 +875,8 @@ class _DesktopSendState extends ConsumerState<DesktopSend> {
if (isPaynymSend) {
sendToController.text = widget.accountLite!.nymName;
WidgetsBinding.instance.addPostFrameCallback(
(_) => _setValidAddressProviders(sendToController.text));
(_) => _setValidAddressProviders(sendToController.text),
);
}
_cryptoFocus.addListener(() {
@ -912,7 +923,8 @@ class _DesktopSendState extends ConsumerState<DesktopSend> {
Widget build(BuildContext context) {
debugPrint("BUILD: $runtimeType");
final String locale = ref.watch(
localeServiceChangeNotifierProvider.select((value) => value.locale));
localeServiceChangeNotifierProvider.select((value) => value.locale),
);
// add listener for epic cash to strip http:// and https:// prefixes if the address also ocntains an @ symbol (indicating an epicbox address)
if (coin == Coin.epicCash) {
@ -975,9 +987,11 @@ class _DesktopSendState extends ConsumerState<DesktopSend> {
width: 10,
),
Text(
ref.watch(pAmountFormatter(coin)).format(ref
.watch(pWalletBalanceTertiary(walletId))
.spendable),
ref.watch(pAmountFormatter(coin)).format(
ref
.watch(pWalletBalanceTertiary(walletId))
.spendable,
),
style: STextStyles.itemSubtitle(context),
),
],
@ -995,9 +1009,11 @@ class _DesktopSendState extends ConsumerState<DesktopSend> {
width: 10,
),
Text(
ref.watch(pAmountFormatter(coin)).format(ref
.watch(pWalletBalanceSecondary(walletId))
.spendable),
ref.watch(pAmountFormatter(coin)).format(
ref
.watch(pWalletBalanceSecondary(walletId))
.spendable,
),
style: STextStyles.itemSubtitle(context),
),
],
@ -1016,7 +1032,8 @@ class _DesktopSendState extends ConsumerState<DesktopSend> {
),
Text(
ref.watch(pAmountFormatter(coin)).format(
ref.watch(pWalletBalance(walletId)).spendable),
ref.watch(pWalletBalance(walletId)).spendable,
),
style: STextStyles.itemSubtitle(context),
),
],
@ -1164,9 +1181,10 @@ class _DesktopSendState extends ConsumerState<DesktopSend> {
child: Text(
ref.watch(pAmountUnit(coin)).unitForCoin(coin),
style: STextStyles.smallMed14(context).copyWith(
color: Theme.of(context)
.extension<StackColors>()!
.accentColorDark),
color: Theme.of(context)
.extension<StackColors>()!
.accentColorDark,
),
),
),
),
@ -1223,12 +1241,15 @@ class _DesktopSendState extends ConsumerState<DesktopSend> {
child: Padding(
padding: const EdgeInsets.all(12),
child: Text(
ref.watch(prefsChangeNotifierProvider
.select((value) => value.currency)),
ref.watch(
prefsChangeNotifierProvider
.select((value) => value.currency),
),
style: STextStyles.smallMed14(context).copyWith(
color: Theme.of(context)
.extension<StackColors>()!
.accentColorDark),
color: Theme.of(context)
.extension<StackColors>()!
.accentColorDark,
),
),
),
),
@ -1337,7 +1358,8 @@ class _DesktopSendState extends ConsumerState<DesktopSend> {
_addressToggleFlag
? TextFieldIconButton(
key: const Key(
"sendViewClearAddressFieldButtonKey"),
"sendViewClearAddressFieldButtonKey",
),
onTap: () {
sendToController.text = "";
_address = "";
@ -1350,7 +1372,8 @@ class _DesktopSendState extends ConsumerState<DesktopSend> {
)
: TextFieldIconButton(
key: const Key(
"sendViewPasteAddressFieldButtonKey"),
"sendViewPasteAddressFieldButtonKey",
),
onTap: pasteAddress,
child: sendToController.text.isEmpty
? const ClipboardIcon()
@ -1380,7 +1403,8 @@ class _DesktopSendState extends ConsumerState<DesktopSend> {
child: Text(
"Address book",
style: STextStyles.desktopH3(
context),
context,
),
),
),
const DesktopDialogCloseButton(),
@ -1436,7 +1460,9 @@ class _DesktopSendState extends ConsumerState<DesktopSend> {
FiroType.lelantus) {
if (_data != null && _data!.contactLabel == _address) {
error = SparkInterface.validateSparkAddress(
address: _data!.address, isTestNet: coin.isTestNet)
address: _data!.address,
isTestNet: coin.isTestNet,
)
? "Lelantus to Spark not supported"
: null;
} else if (ref.watch(pValidSparkSendToAddress)) {
@ -1662,8 +1688,9 @@ class _DesktopSendState extends ConsumerState<DesktopSend> {
if (coin == Coin.monero ||
coin == Coin.wownero) {
final fee = await wallet.estimateFeeFor(
amount,
MoneroTransactionPriority.regular.raw!);
amount,
MoneroTransactionPriority.regular.raw!,
);
ref
.read(feeSheetSessionCacheProvider)
.average[amount] = fee;
@ -1671,16 +1698,18 @@ class _DesktopSendState extends ConsumerState<DesktopSend> {
coin == Coin.firoTestNet) &&
ref
.read(
publicPrivateBalanceStateProvider
.state)
publicPrivateBalanceStateProvider
.state,
)
.state !=
FiroType.public) {
final firoWallet = wallet as FiroWallet;
if (ref
.read(
publicPrivateBalanceStateProvider
.state)
publicPrivateBalanceStateProvider
.state,
)
.state ==
FiroType.lelantus) {
ref
@ -1690,8 +1719,9 @@ class _DesktopSendState extends ConsumerState<DesktopSend> {
.estimateFeeForLelantus(amount);
} else if (ref
.read(
publicPrivateBalanceStateProvider
.state)
publicPrivateBalanceStateProvider
.state,
)
.state ==
FiroType.spark) {
ref
@ -1705,7 +1735,9 @@ class _DesktopSendState extends ConsumerState<DesktopSend> {
.read(feeSheetSessionCacheProvider)
.average[amount] =
await wallet.estimateFeeFor(
amount, feeRate);
amount,
feeRate,
);
}
}
return ref
@ -1720,8 +1752,8 @@ class _DesktopSendState extends ConsumerState<DesktopSend> {
AnimatedText(
stringsToLoopThrough: stringsToLoopThrough,
style: STextStyles.desktopTextExtraExtraSmall(
context)
.copyWith(
context,
).copyWith(
color: Theme.of(context)
.extension<StackColors>()!
.textFieldActiveText,
@ -1735,7 +1767,8 @@ class _DesktopSendState extends ConsumerState<DesktopSend> {
: (coin == Coin.firo || coin == Coin.firoTestNet) &&
ref
.watch(
publicPrivateBalanceStateProvider.state)
publicPrivateBalanceStateProvider.state,
)
.state ==
FiroType.lelantus
? Text(
@ -1760,8 +1793,8 @@ class _DesktopSendState extends ConsumerState<DesktopSend> {
Text(
feeSelectionResult?.$2 ?? "",
style: STextStyles.desktopTextExtraExtraSmall(
context)
.copyWith(
context,
).copyWith(
color: Theme.of(context)
.extension<StackColors>()!
.textFieldActiveText,
@ -1771,8 +1804,8 @@ class _DesktopSendState extends ConsumerState<DesktopSend> {
Text(
feeSelectionResult?.$3 ?? "",
style: STextStyles.desktopTextExtraExtraSmall(
context)
.copyWith(
context,
).copyWith(
color: Theme.of(context)
.extension<StackColors>()!
.textFieldActiveSearchIconRight,
@ -1803,7 +1836,7 @@ class _DesktopSendState extends ConsumerState<DesktopSend> {
enabled: ref.watch(pPreviewTxButtonEnabled(coin)),
onPressed:
ref.watch(pPreviewTxButtonEnabled(coin)) ? previewSend : null,
)
),
],
);
}

View file

@ -56,13 +56,13 @@ import 'package:stackwallet/widgets/textfield_icon_button.dart';
class DesktopTokenSend extends ConsumerStatefulWidget {
const DesktopTokenSend({
Key? key,
super.key,
required this.walletId,
this.autoFillData,
this.clipboard = const ClipboardWrapper(),
this.barcodeScanner = const BarcodeScannerWrapper(),
this.accountLite,
}) : super(key: key);
});
final String walletId;
final SendViewAutoFillData? autoFillData;
@ -108,10 +108,14 @@ class _DesktopTokenSendState extends ConsumerState<DesktopTokenSend> {
final Amount amount = _amountToSend!;
final Amount availableBalance = ref
.read(pTokenBalance((
walletId: walletId,
contractAddress: tokenWallet.tokenContract.address
)))
.read(
pTokenBalance(
(
walletId: walletId,
contractAddress: tokenWallet.tokenContract.address
),
),
)
.spendable;
// confirm send all
@ -221,6 +225,7 @@ class _DesktopTokenSendState extends ConsumerState<DesktopTokenSend> {
padding: const EdgeInsets.all(32),
child: BuildingTransactionDialog(
coin: tokenWallet.cryptoCurrency.coin,
isSpark: false,
onCancel: () {
wasCancelled = true;
@ -250,7 +255,7 @@ class _DesktopTokenSendState extends ConsumerState<DesktopTokenSend> {
address: _address!,
amount: amount,
isChange: false,
)
),
],
feeRateType: ref.read(feeRateTypeStateProvider),
nonce: int.tryParse(nonceController.text),
@ -405,8 +410,10 @@ class _DesktopTokenSendState extends ConsumerState<DesktopTokenSend> {
_cachedAmountToSend == _amountToSend) {
return;
}
Logging.instance.log("it changed $_amountToSend $_cachedAmountToSend",
level: LogLevel.Info);
Logging.instance.log(
"it changed $_amountToSend $_cachedAmountToSend",
level: LogLevel.Info,
);
_cachedAmountToSend = _amountToSend;
final price = ref
@ -468,8 +475,10 @@ class _DesktopTokenSendState extends ConsumerState<DesktopTokenSend> {
final qrResult = await scanner.scan();
Logging.instance.log("qrResult content: ${qrResult.rawContent}",
level: LogLevel.Info);
Logging.instance.log(
"qrResult content: ${qrResult.rawContent}",
level: LogLevel.Info,
);
final results = AddressUtils.parseUri(qrResult.rawContent);
@ -524,8 +533,9 @@ class _DesktopTokenSendState extends ConsumerState<DesktopTokenSend> {
// here we ignore the exception caused by not giving permission
// to use the camera to scan a qr code
Logging.instance.log(
"Failed to get camera permissions while trying to scan qr code in SendView: $e\n$s",
level: LogLevel.Warning);
"Failed to get camera permissions while trying to scan qr code in SendView: $e\n$s",
level: LogLevel.Warning,
);
}
}
@ -579,8 +589,10 @@ class _DesktopTokenSendState extends ConsumerState<DesktopTokenSend> {
return;
}
_cachedAmountToSend = _amountToSend;
Logging.instance.log("it changed $_amountToSend $_cachedAmountToSend",
level: LogLevel.Info);
Logging.instance.log(
"it changed $_amountToSend $_cachedAmountToSend",
level: LogLevel.Info,
);
final amountString = ref.read(pAmountFormatter(coin)).format(
_amountToSend!,
@ -603,10 +615,15 @@ class _DesktopTokenSendState extends ConsumerState<DesktopTokenSend> {
Future<void> sendAllTapped() async {
cryptoAmountController.text = ref
.read(pTokenBalance((
walletId: walletId,
contractAddress: ref.read(pCurrentTokenWallet)!.tokenContract.address
)))
.read(
pTokenBalance(
(
walletId: walletId,
contractAddress:
ref.read(pCurrentTokenWallet)!.tokenContract.address
),
),
)
.spendable
.decimal
.toStringAsFixed(
@ -788,9 +805,10 @@ class _DesktopTokenSendState extends ConsumerState<DesktopTokenSend> {
child: Text(
tokenContract.symbol,
style: STextStyles.smallMed14(context).copyWith(
color: Theme.of(context)
.extension<StackColors>()!
.accentColorDark),
color: Theme.of(context)
.extension<StackColors>()!
.accentColorDark,
),
),
),
),
@ -850,12 +868,15 @@ class _DesktopTokenSendState extends ConsumerState<DesktopTokenSend> {
child: Padding(
padding: const EdgeInsets.all(12),
child: Text(
ref.watch(prefsChangeNotifierProvider
.select((value) => value.currency)),
ref.watch(
prefsChangeNotifierProvider
.select((value) => value.currency),
),
style: STextStyles.smallMed14(context).copyWith(
color: Theme.of(context)
.extension<StackColors>()!
.accentColorDark),
color: Theme.of(context)
.extension<StackColors>()!
.accentColorDark,
),
),
),
),
@ -936,12 +957,15 @@ class _DesktopTokenSendState extends ConsumerState<DesktopTokenSend> {
_addressToggleFlag
? TextFieldIconButton(
key: const Key(
"sendTokenViewClearAddressFieldButtonKey"),
"sendTokenViewClearAddressFieldButtonKey",
),
onTap: () {
sendToController.text = "";
_address = "";
_updatePreviewButtonState(
_address, _amountToSend);
_address,
_amountToSend,
);
setState(() {
_addressToggleFlag = false;
});
@ -950,7 +974,8 @@ class _DesktopTokenSendState extends ConsumerState<DesktopTokenSend> {
)
: TextFieldIconButton(
key: const Key(
"sendTokenViewPasteAddressFieldButtonKey"),
"sendTokenViewPasteAddressFieldButtonKey",
),
onTap: pasteAddress,
child: sendToController.text.isEmpty
? const ClipboardIcon()
@ -1129,7 +1154,7 @@ class _DesktopTokenSendState extends ConsumerState<DesktopTokenSend> {
onPressed: ref.watch(previewTokenTxButtonStateProvider.state).state
? previewSend
: null,
)
),
],
);
}