mirror of
https://github.com/Such-Software/hash-wallet.git
synced 2026-10-17 05:41:29 +02:00
Pay Anything Swap Flow (#2503)
* feat: Swap flow for Pay Anything. [WIP] * feat: Pay Anything Swap Flow [WIP] * feat: Pay anything swap flow [WIP] - Add fiat values for send and receive amounts to swap details confirmation bottomsheet * feat: Pay anything swap flow [WIP] - Switch exchangeviewmodel back to factory - Expand address box to fill width * Handle second swipe to swap cta * Add fiat for receive amount * Scope Observers for bottomsheets and add validator * fix: Repeated instances issue for exchangeVM * fix: Estimated fee and balance not correctly updating after wallet switching occurs * fix: Available balance not updating properly after wallet switching * fix: Available balance and fee rate not displaying after wallet is switched in pay anything flow
This commit is contained in:
@@ -3,10 +3,10 @@ import 'dart:async';
|
||||
import 'package:cake_wallet/core/open_crypto_pay/open_cryptopay_service.dart';
|
||||
import 'package:cake_wallet/entities/priority_for_wallet_type.dart';
|
||||
import 'package:cake_wallet/src/screens/receive/widgets/currency_input_field.dart';
|
||||
import 'package:cake_wallet/src/widgets/bottom_sheet/info_bottom_sheet_widget.dart';
|
||||
import 'package:cake_wallet/src/widgets/bottom_sheet/payment_confirmation_bottom_sheet.dart';
|
||||
import 'package:cake_wallet/src/widgets/bottom_sheet/wallet_switcher_bottom_sheet.dart';
|
||||
import 'package:cake_wallet/src/widgets/bottom_sheet/swap_confirmation_bottom_sheet.dart';
|
||||
import 'package:cake_wallet/src/widgets/bottom_sheet/info_bottom_sheet_widget.dart';
|
||||
import 'package:cake_wallet/src/widgets/picker.dart';
|
||||
import 'package:cake_wallet/src/widgets/standard_checkbox.dart';
|
||||
import 'package:cake_wallet/src/screens/exchange/widgets/currency_picker.dart';
|
||||
@@ -776,6 +776,12 @@ class SendCardState extends State<SendCard> with AutomaticKeepAliveClientMixin<S
|
||||
noteController.text = initialPaymentRequest!.note;
|
||||
}
|
||||
|
||||
reaction((_) => sendViewModel.isReadyForSend, (bool isReadyForSend) {
|
||||
if (isReadyForSend) {
|
||||
sendViewModel.updateSendingBalance();
|
||||
}
|
||||
});
|
||||
|
||||
_effectsInstalled = true;
|
||||
}
|
||||
|
||||
|
||||
@@ -118,7 +118,8 @@ abstract class OutputBase with Store {
|
||||
_amount = wownero!.formatterWowneroParseAmount(amount: _cryptoAmount);
|
||||
break;
|
||||
case WalletType.zano:
|
||||
_amount = zano!.formatterParseAmount(amount: _cryptoAmount, currency: cryptoCurrencyHandler());
|
||||
_amount = zano!
|
||||
.formatterParseAmount(amount: _cryptoAmount, currency: cryptoCurrencyHandler());
|
||||
break;
|
||||
case WalletType.none:
|
||||
case WalletType.haven:
|
||||
@@ -143,6 +144,9 @@ abstract class OutputBase with Store {
|
||||
@computed
|
||||
double get estimatedFee {
|
||||
try {
|
||||
// forces mobx to rebuild the computed value
|
||||
final _ = _wallet.syncStatus;
|
||||
|
||||
if (_wallet.type == WalletType.tron) {
|
||||
if (cryptoCurrencyHandler() == CryptoCurrency.trx) {
|
||||
final nativeEstimatedFee = tron!.getTronNativeEstimatedFee(_wallet) ?? 0;
|
||||
@@ -170,7 +174,8 @@ abstract class OutputBase with Store {
|
||||
return bitcoin!.formatterBitcoinAmountToDouble(amount: fee);
|
||||
}
|
||||
|
||||
if (_wallet.type == WalletType.litecoin || _wallet.type == WalletType.bitcoinCash ||
|
||||
if (_wallet.type == WalletType.litecoin ||
|
||||
_wallet.type == WalletType.bitcoinCash ||
|
||||
_wallet.type == WalletType.dogecoin) {
|
||||
return bitcoin!.formatterBitcoinAmountToDouble(amount: fee);
|
||||
}
|
||||
@@ -192,7 +197,8 @@ abstract class OutputBase with Store {
|
||||
}
|
||||
|
||||
if (_wallet.type == WalletType.zano) {
|
||||
return zano!.formatterIntAmountToDouble(amount: fee, currency: cryptoCurrencyHandler(), forFee: true);
|
||||
return zano!.formatterIntAmountToDouble(
|
||||
amount: fee, currency: cryptoCurrencyHandler(), forFee: true);
|
||||
}
|
||||
|
||||
if (_wallet.type == WalletType.decred) {
|
||||
@@ -207,6 +213,9 @@ abstract class OutputBase with Store {
|
||||
|
||||
@computed
|
||||
String get estimatedFeeFiatAmount {
|
||||
// forces mobx to rebuild the computed value
|
||||
final _ = _wallet.syncStatus;
|
||||
|
||||
try {
|
||||
final currency = (isEVMCompatibleChain(_wallet.type) ||
|
||||
_wallet.type == WalletType.solana ||
|
||||
@@ -235,7 +244,8 @@ abstract class OutputBase with Store {
|
||||
}
|
||||
|
||||
@action
|
||||
void updateWallet(WalletBase<Balance, TransactionHistoryBase<TransactionInfo>, TransactionInfo> newWallet) {
|
||||
void updateWallet(
|
||||
WalletBase<Balance, TransactionHistoryBase<TransactionInfo>, TransactionInfo> newWallet) {
|
||||
_wallet = newWallet;
|
||||
_setCryptoNumMaximumFractionDigits();
|
||||
}
|
||||
@@ -371,15 +381,15 @@ extension OutputCopyWith on Output {
|
||||
);
|
||||
|
||||
clone
|
||||
..cryptoAmount = cryptoAmount
|
||||
..cryptoAmount = cryptoAmount
|
||||
..cryptoFullBalance = cryptoFullBalance
|
||||
..note = note
|
||||
..sendAll = sendAll
|
||||
..memo = memo
|
||||
..stealthAddress = stealthAddress
|
||||
..parsedAddress = parsedAddress ?? this.parsedAddress
|
||||
..fiatAmount = fiatAmount ?? this.fiatAmount;
|
||||
..note = note
|
||||
..sendAll = sendAll
|
||||
..memo = memo
|
||||
..stealthAddress = stealthAddress
|
||||
..parsedAddress = parsedAddress ?? this.parsedAddress
|
||||
..fiatAmount = fiatAmount ?? this.fiatAmount;
|
||||
|
||||
return clone;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user