changed color theme to be black and added the ability to enter the amount in the recipient’s currency
This commit is contained in:
@@ -0,0 +1,57 @@
|
||||
import 'package:pshared/models/payment/methods/card.dart';
|
||||
import 'package:pshared/models/payment/methods/crypto_address.dart';
|
||||
import 'package:pshared/models/payment/methods/data.dart';
|
||||
import 'package:pshared/models/payment/methods/iban.dart';
|
||||
import 'package:pshared/models/payment/methods/russian_bank.dart';
|
||||
import 'package:pshared/models/payment/quote/quote.dart';
|
||||
|
||||
|
||||
class PaymentQuotationCurrencyResolver {
|
||||
static String? resolveQuoteCurrency({
|
||||
PaymentQuote? quote,
|
||||
PaymentMethodData? paymentData,
|
||||
}) {
|
||||
final quoteCurrency = _normalizeCurrency(
|
||||
quote?.amounts?.destinationSettlement?.currency,
|
||||
);
|
||||
if (quoteCurrency != null) return quoteCurrency;
|
||||
|
||||
if (paymentData == null) return null;
|
||||
|
||||
final metadataCurrency = _normalizeCurrency(
|
||||
paymentData.metadata?['currency'],
|
||||
);
|
||||
if (metadataCurrency != null) return metadataCurrency;
|
||||
|
||||
if (paymentData is CryptoAddressPaymentMethod) {
|
||||
return _normalizeCurrency(paymentData.asset?.tokenSymbol);
|
||||
}
|
||||
|
||||
if (paymentData is RussianBankAccountPaymentMethod ||
|
||||
paymentData is CardPaymentMethod) {
|
||||
return 'RUB';
|
||||
}
|
||||
|
||||
if (paymentData is IbanPaymentMethod) {
|
||||
return 'EUR';
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
static bool isFxEnabled({
|
||||
required String? sourceCurrency,
|
||||
required String? quoteCurrency,
|
||||
}) {
|
||||
final normalizedSource = _normalizeCurrency(sourceCurrency);
|
||||
final normalizedQuote = _normalizeCurrency(quoteCurrency);
|
||||
if (normalizedSource == null || normalizedQuote == null) return false;
|
||||
return normalizedSource != normalizedQuote;
|
||||
}
|
||||
|
||||
static String? _normalizeCurrency(String? value) {
|
||||
final normalized = value?.trim().toUpperCase();
|
||||
if (normalized == null || normalized.isEmpty) return null;
|
||||
return normalized;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user