mirror of
https://github.com/Such-Software/hash-wallet.git
synced 2026-10-23 06:38:35 +02:00
Pay Anything RC Fixes (#2511)
* 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 * fixes: Pay anything related RC fixes - Recieve fiat amount showing as 0.0 - ID overlapping when there's enough space - receive amount changing even in fixed rate mode - Invalid double error for setReceiveFiatAmount
This commit is contained in:
@@ -127,16 +127,16 @@ abstract class ExchangeTradeViewModelBase with Store {
|
||||
@computed
|
||||
bool get isFiatDisabled => feesViewModel.isFiatDisabled;
|
||||
|
||||
@computed
|
||||
String get receiveAmountFiatFormatted {
|
||||
@action
|
||||
String getReceiveAmountFiatFormatted(String receiveAmount) {
|
||||
var amount = '0.00';
|
||||
try {
|
||||
if (trade.receiveAmount?.isNotEmpty ?? false) {
|
||||
if (receiveAmount.isNotEmpty) {
|
||||
if (fiatConversionStore.prices[trade.to] == null) return '';
|
||||
|
||||
amount = calculateFiatAmount(
|
||||
price: fiatConversionStore.prices[trade.to]!,
|
||||
cryptoAmount: trade.receiveAmount,
|
||||
cryptoAmount: receiveAmount,
|
||||
);
|
||||
}
|
||||
} catch (_) {
|
||||
|
||||
@@ -24,7 +24,6 @@ import 'package:cake_wallet/exchange/provider/chainflip_exchange_provider.dart';
|
||||
import 'package:cake_wallet/exchange/provider/changenow_exchange_provider.dart';
|
||||
import 'package:cake_wallet/exchange/provider/exchange_provider.dart';
|
||||
import 'package:cake_wallet/exchange/provider/exolix_exchange_provider.dart';
|
||||
import 'package:cake_wallet/exchange/provider/letsexchange_exchange_provider.dart';
|
||||
import 'package:cake_wallet/exchange/provider/sideshift_exchange_provider.dart';
|
||||
import 'package:cake_wallet/exchange/provider/stealth_ex_exchange_provider.dart';
|
||||
import 'package:cake_wallet/exchange/provider/swaptrade_exchange_provider.dart';
|
||||
@@ -449,8 +448,8 @@ abstract class ExchangeViewModelBase extends WalletChangeListenerViewModel with
|
||||
|
||||
@action
|
||||
void setReceiveAmountFromFiat({required String fiatAmount}) {
|
||||
final crypto = double.parse(fiatAmount.replaceAll(',', '.')) /
|
||||
fiatConversionStore.prices[receiveCurrency]!;
|
||||
final _enteredAmount = double.tryParse(fiatAmount.replaceAll(',', '.')) ?? 0.0;
|
||||
final crypto = _enteredAmount / fiatConversionStore.prices[receiveCurrency]!;
|
||||
final receiveAmountTmp = _cryptoNumberFormat.format(crypto);
|
||||
if (receiveAmount != receiveAmountTmp) {
|
||||
changeReceiveAmount(amount: receiveAmountTmp);
|
||||
@@ -467,6 +466,10 @@ abstract class ExchangeViewModelBase extends WalletChangeListenerViewModel with
|
||||
return;
|
||||
}
|
||||
|
||||
/// For fixed-rate transactions, we don't want to recalculate receive amount
|
||||
/// as it should remain exactly what the user set
|
||||
if (isFixedRateMode) return;
|
||||
|
||||
final _enteredAmount = double.tryParse(amount.replaceAll(',', '.')) ?? 0;
|
||||
|
||||
/// in case the best rate was not calculated yet
|
||||
@@ -475,6 +478,7 @@ abstract class ExchangeViewModelBase extends WalletChangeListenerViewModel with
|
||||
|
||||
await calculateBestRate();
|
||||
}
|
||||
|
||||
_cryptoNumberFormat.maximumFractionDigits = receiveMaxDigits;
|
||||
|
||||
receiveAmount = _cryptoNumberFormat
|
||||
|
||||
Reference in New Issue
Block a user